@domainkit/react 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["Root","mergeMessages","leafPart","Value","Priority","Root","State","Command","useModel","LifecycleEvent","useController","Root","Outcome","Dialog","BaseAlertDialog","Operations.List","Flow","State","Command","useModel","LifecycleEvent","useController","Root","Status","BaseDialog","Provider.Mark","Dialog","Flow","RetryAction","Card","BaseAlertDialog","Status","Root","State","Command","useModel","LifecycleEvent","useController","Root","Outcome","Dialog","BaseDialog","Operations.List","Flow","Records.Table","_exhaustive","RecordStatus","BasePopover","Connection.useController","Connection.Root","Records.Table","Verification.Status","Connection.Card","Connection.CardIdentity","Provider.Mark","Connection.Status","Connection.CardActions","Connection.RetryAction","BaseDialog","Connection.ConnectTrigger","Connection.Dialog","Provisioning.Flow","Cleanup.useController","BaseMenu","Cleanup.Dialog","Connection.DisconnectDialog"],"sources":["../src/atom.ts","../src/composition.tsx","../src/icons.tsx","../src/messages.ts","../src/theme.ts","../src/domain-kit.tsx","../src/lifecycle.ts","../src/operations.tsx","../src/cleanup.tsx","../src/provider.tsx","../src/connection.tsx","../src/records.tsx","../src/provisioning.tsx","../src/verification.tsx","../src/domain.tsx","../src/testing.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport type * as Atom from \"effect/unstable/reactivity/Atom\";\nimport { Transport } from \"domainkit\";\n\nexport type Runtime = Atom.AtomRuntime<Transport.Service>;\n\nexport type Failure = Data.TaggedEnum<{\n Failure: {\n readonly message: string;\n readonly operation: string;\n readonly retry: Transport.Failure[\"retry\"];\n };\n}>;\nexport const Failure = Data.taggedEnum<Failure>();\n\nexport const failureFromError = (error: Transport.Failure): Failure =>\n Failure.Failure({\n message: error.message,\n operation: error.operation,\n retry: error.retry,\n });\n\nexport const failureFromDefect = (operation: string, message: string): Failure =>\n Failure.Failure({ message, operation, retry: \"safe\" });\n\nexport const recordsIdentity = (records: ReadonlyArray<Transport.DnsRecord>): string =>\n JSON.stringify(\n records.map(({ id, name, priority, type, value }) => ({ id, name, priority, type, value })),\n );\n","import { useRender } from \"@base-ui/react/use-render\";\nimport type { CSSProperties, ElementType, ReactElement } from \"react\";\n\nexport type ClassName<State> = string | ((state: State) => string | undefined);\nexport type Style<State> = CSSProperties | ((state: State) => CSSProperties | undefined);\n\nexport type PartProps<Tag extends ElementType, State extends Record<string, unknown>> = Omit<\n useRender.ElementProps<Tag>,\n \"className\" | \"style\"\n> & {\n readonly className?: ClassName<State>;\n readonly render?: useRender.RenderProp<State>;\n readonly style?: Style<State>;\n};\n\nexport function usePart<\n Tag extends keyof React.JSX.IntrinsicElements,\n State extends Record<string, unknown>,\n>(\n defaultTagName: Tag,\n componentProps: PartProps<Tag, State>,\n state: State,\n internalProps: Record<string, unknown>,\n): ReactElement {\n const { className, render, style, ...externalProps } = componentProps;\n const parameters: useRender.Parameters<State, Element, undefined> & {\n readonly className?: ClassName<State>;\n readonly style?: Style<State>;\n } = {\n ...(className === undefined ? {} : { className }),\n defaultTagName,\n props: [internalProps, externalProps] as unknown as Record<string, unknown>,\n ...(render === undefined ? {} : { render }),\n state,\n ...(style === undefined ? {} : { style }),\n };\n return useRender(parameters);\n}\n","import { createContext, useContext, useMemo, type ReactNode } from \"react\";\n\nexport type Icons = {\n readonly copied: ReactNode;\n readonly copy: ReactNode;\n readonly download: ReactNode;\n};\n\nfunction Glyph({ children }: { readonly children: ReactNode }) {\n return (\n <svg\n aria-hidden=\"true\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n viewBox=\"0 0 24 24\"\n >\n {children}\n </svg>\n );\n}\n\nexport const defaultIcons = {\n copied: (\n <Glyph>\n <path d=\"M20 6 9 17l-5-5\" />\n </Glyph>\n ),\n copy: (\n <Glyph>\n <rect height=\"14\" rx=\"2\" width=\"14\" x=\"8\" y=\"8\" />\n <path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />\n </Glyph>\n ),\n download: (\n <Glyph>\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\" />\n <path d=\"m7 10 5 5 5-5\" />\n <path d=\"M12 15V3\" />\n </Glyph>\n ),\n} as const satisfies Icons;\n\nconst IconsContext = createContext<Icons>(defaultIcons);\n\nexport function IconsProvider({\n children,\n icons,\n}: {\n readonly children: ReactNode;\n readonly icons?: Partial<Icons>;\n}) {\n const value = useMemo<Icons>(\n () => ({\n copied: icons?.copied ?? defaultIcons.copied,\n copy: icons?.copy ?? defaultIcons.copy,\n download: icons?.download ?? defaultIcons.download,\n }),\n [icons],\n );\n return <IconsContext.Provider value={value}>{children}</IconsContext.Provider>;\n}\n\nexport function useIcons(): Icons {\n return useContext(IconsContext);\n}\n","export interface Catalog {\n readonly applyCleanup: string;\n readonly applyDns: string;\n readonly applyingDns: string;\n readonly authenticationAlternative: string;\n readonly automaticUnavailable: string;\n readonly cancel: string;\n readonly checkAgain: string;\n readonly checkingDns: string;\n readonly checkDns: string;\n readonly cleanupConsent: string;\n readonly cleanupPartial: string;\n readonly cleaningDns: string;\n readonly connectProvider: (provider: string) => string;\n readonly connected: (provider: string) => string;\n readonly providerAvailable: (provider: string) => string;\n readonly connecting: string;\n readonly close: string;\n readonly detectingProvider: string;\n readonly disconnectDomain: string;\n readonly disconnectConsent: string;\n readonly disconnecting: string;\n readonly detaching: string;\n readonly disconnectTitle: (provider: string) => string;\n readonly domainDisconnected: string;\n readonly dialogDescription: (domain: string) => string;\n readonly dialogTitle: (provider: string) => string;\n readonly openingAuthorization: string;\n readonly moreActions: string;\n readonly noChanges: string;\n readonly planConsent: string;\n readonly planningCleanup: string;\n readonly planningDns: string;\n readonly recordsPartiallyApplied: string;\n readonly reviewCleanup: string;\n readonly reviewDns: string;\n readonly retry: string;\n readonly existingConnection: string;\n readonly targetUnavailable: string;\n readonly attachTarget: (target: string) => string;\n readonly tokenLabel: string;\n}\n\nexport const english: Catalog = {\n applyCleanup: \"Remove records\",\n applyDns: \"Add records\",\n applyingDns: \"Adding records…\",\n authenticationAlternative: \"or\",\n automaticUnavailable: \"Automatic connection is not available for this domain\",\n cancel: \"Cancel\",\n checkAgain: \"Check again\",\n checkingDns: \"Checking DNS…\",\n checkDns: \"Check DNS\",\n cleanupConsent: \"Only records proven by the apply receipt will be deleted.\",\n cleanupPartial: \"Some DNS records could not be deleted. Review and retry safely.\",\n cleaningDns: \"Removing records…\",\n connectProvider: () => \"Connect\",\n connected: (provider) => `${provider} connected`,\n providerAvailable: (provider) => `${provider} manages DNS for this domain`,\n connecting: \"Connecting…\",\n close: \"Close\",\n detectingProvider: \"Detecting DNS provider…\",\n disconnectDomain: \"Disconnect\",\n disconnectConsent:\n \"This domain will be detached from the provider. Existing DNS records will be preserved.\",\n disconnecting: \"Disconnecting…\",\n detaching: \"Detaching domain…\",\n disconnectTitle: (provider) => `Detach ${provider}?`,\n domainDisconnected: \"Domain detached. DNS records were preserved.\",\n dialogDescription: (domain) => `Authorize DNS changes for ${domain}.`,\n dialogTitle: (provider) => `Connect ${provider}`,\n openingAuthorization: \"Opening provider authorization…\",\n moreActions: \"More connection actions\",\n noChanges: \"No changes needed\",\n planConsent: \"Review the exact DNS operations before approving this plan.\",\n planningCleanup: \"Preparing cleanup…\",\n planningDns: \"Preparing DNS changes…\",\n recordsPartiallyApplied: \"Some DNS changes failed. Review and retry safely.\",\n reviewCleanup: \"Remove records\",\n reviewDns: \"Review changes\",\n retry: \"Try again\",\n existingConnection: \"Existing provider connection\",\n targetUnavailable: \"No provider targets are available for this connection.\",\n attachTarget: (target) => `Use ${target}`,\n tokenLabel: \"API token\",\n};\n\nexport const merge = (overrides: Partial<Catalog> = {}): Catalog => ({\n ...english,\n ...overrides,\n});\n","import type { CSSProperties } from \"react\";\n\nexport interface Theme {\n readonly accent?: string;\n readonly accentContrast?: string;\n readonly backdrop?: string;\n readonly background?: string;\n readonly border?: string;\n readonly danger?: string;\n readonly dangerContrast?: string;\n readonly fill?: string;\n readonly fontFamily?: string;\n readonly muted?: string;\n readonly radius?: string;\n readonly shadow?: string;\n readonly success?: string;\n readonly text?: string;\n}\n\nconst variables = {\n accent: \"--domainkit-accent\",\n accentContrast: \"--domainkit-accent-contrast\",\n backdrop: \"--domainkit-backdrop\",\n background: \"--domainkit-background\",\n border: \"--domainkit-border\",\n danger: \"--domainkit-danger\",\n dangerContrast: \"--domainkit-danger-contrast\",\n fill: \"--domainkit-fill\",\n fontFamily: \"--domainkit-font-family\",\n muted: \"--domainkit-muted\",\n radius: \"--domainkit-radius\",\n shadow: \"--domainkit-shadow\",\n success: \"--domainkit-success\",\n text: \"--domainkit-text\",\n} as const satisfies Record<keyof Theme, string>;\n\nexport function toStyle(theme: Theme = {}): CSSProperties {\n return Object.fromEntries(\n Object.entries(theme).flatMap(([key, value]) =>\n value === undefined ? [] : [[variables[key as keyof Theme], value]],\n ),\n ) as CSSProperties;\n}\n","import { RegistryProvider } from \"@effect/atom-react\";\nimport { Transport } from \"domainkit\";\nimport type * as Layer from \"effect/Layer\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport {\n createContext,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n type ReactNode,\n type RefObject,\n} from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport type { Icons } from \"./icons.tsx\";\nimport { IconsProvider } from \"./icons.tsx\";\nimport type * as Lifecycle from \"./lifecycle.ts\";\nimport type { Catalog } from \"./messages.ts\";\nimport { merge as mergeMessages } from \"./messages.ts\";\nimport type { Marks } from \"./provider.tsx\";\nimport type { Theme } from \"./theme.ts\";\nimport { toStyle } from \"./theme.ts\";\nimport type { Runtime } from \"./atom.ts\";\n\nexport interface RootState extends Record<string, unknown> {\n readonly colorScheme: \"dark\" | \"inherit\" | \"light\";\n}\n\nexport interface RootProps extends Omit<PartProps<\"div\", RootState>, \"children\"> {\n readonly children: ReactNode;\n readonly colorScheme?: RootState[\"colorScheme\"];\n readonly icons?: Partial<Icons>;\n readonly messages?: Partial<Catalog>;\n readonly marks?: Marks;\n readonly navigate?: (url: string) => void;\n readonly onEvent?: Lifecycle.Listener;\n readonly portalContainer?: HTMLElement | null;\n readonly theme?: Theme;\n readonly transport: Layer.Layer<Transport.Service>;\n}\n\ninterface ContextValue {\n readonly colorScheme: RootState[\"colorScheme\"];\n readonly navigate: (url: string) => void;\n readonly marks: Marks;\n readonly messages: Catalog;\n readonly emit: Lifecycle.Listener;\n readonly portalContainer: RefObject<HTMLElement | null>;\n readonly themeStyle: ReturnType<typeof toStyle>;\n readonly runtime: Runtime;\n}\n\nconst Context = createContext<ContextValue | null>(null);\n\nconst navigateInBrowser = (url: string): void => {\n if (typeof window === \"undefined\") {\n throw new Error(\"DomainKit OAuth navigation requires a browser or a custom navigate function\");\n }\n window.location.assign(url);\n};\n\nconst resolvePortalContainer = (\n container: HTMLElement | null,\n ownerDocument: Document | null,\n): HTMLElement | null => {\n if (container === null || ownerDocument === null) return null;\n return container.ownerDocument === ownerDocument && container.getRootNode() === ownerDocument\n ? container\n : null;\n};\n\nconst usePortalContainer = (container: HTMLElement | null): HTMLElement | null => {\n const ownerDocument = useMemo(() => container?.ownerDocument ?? null, [container]);\n const subscribe = useCallback(\n (notify: () => void) => {\n if (ownerDocument === null || typeof MutationObserver === \"undefined\") return () => {};\n const observer = new MutationObserver(notify);\n observer.observe(ownerDocument, { childList: true, subtree: true });\n return () => observer.disconnect();\n },\n [ownerDocument],\n );\n const getSnapshot = useCallback(\n () => resolvePortalContainer(container, ownerDocument),\n [container, ownerDocument],\n );\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n\nexport function Root({\n children,\n colorScheme = \"inherit\",\n icons,\n marks = {},\n messages,\n navigate = navigateInBrowser,\n onEvent,\n portalContainer = null,\n theme,\n transport,\n ...props\n}: RootProps) {\n const runtime = useMemo(() => Atom.runtime(transport), [transport]);\n const onEventRef = useRef(onEvent);\n useLayoutEffect(() => {\n onEventRef.current = onEvent;\n }, [onEvent]);\n const emit = useCallback<Lifecycle.Listener>((event) => {\n try {\n onEventRef.current?.(event);\n } catch {\n // Host observers are best-effort and cannot change a completed mutation's outcome.\n }\n }, []);\n const themeStyle = toStyle(theme);\n const resolvedPortalContainer = usePortalContainer(portalContainer);\n const portalContainerRef = useMemo<RefObject<HTMLElement | null>>(\n () => ({ current: resolvedPortalContainer }),\n [resolvedPortalContainer],\n );\n const content = usePart(\n \"div\",\n props,\n { colorScheme },\n {\n children,\n \"data-color-scheme\": colorScheme,\n \"data-domainkit-root\": \"\",\n style: themeStyle,\n },\n );\n return (\n <RegistryProvider>\n <Context.Provider\n value={{\n colorScheme,\n emit,\n marks,\n messages: mergeMessages(messages),\n navigate,\n portalContainer: portalContainerRef,\n runtime,\n themeStyle,\n }}\n >\n <IconsProvider {...(icons === undefined ? {} : { icons })}>{content}</IconsProvider>\n </Context.Provider>\n </RegistryProvider>\n );\n}\n\nexport function useDomainKit(): ContextValue {\n const value = useContext(Context);\n if (value === null)\n throw new Error(\"DomainKit components must be rendered inside DomainKit.Root\");\n return value;\n}\n","import type { Transport } from \"domainkit\";\nimport * as Data from \"effect/Data\";\n\n/** User-action lifecycle events suitable for host notifications and telemetry. */\nexport type Event = Data.TaggedEnum<{\n ConnectionEstablished: {\n readonly connection: Transport.Connected;\n readonly source: \"attach\" | \"connect\";\n };\n DomainDetached: {\n readonly connection: Transport.Connected;\n readonly result: Transport.DetachResult;\n };\n RecordsApplied: {\n readonly connection: Transport.Connected;\n readonly result: Extract<Transport.ApplyResult, { readonly _tag: \"Applied\" }>;\n };\n RecordsCleaned: {\n readonly connection: Transport.Connected;\n readonly result: Extract<Transport.CleanupResult, { readonly _tag: \"Cleaned\" }>;\n };\n RecordsPartiallyApplied: {\n readonly connection: Transport.Connected;\n readonly result: Extract<Transport.ApplyResult, { readonly _tag: \"Partial\" }>;\n };\n RecordsPartiallyCleaned: {\n readonly connection: Transport.Connected;\n readonly result: Extract<Transport.CleanupResult, { readonly _tag: \"Partial\" }>;\n };\n}>;\n\nexport const Event = Data.taggedEnum<Event>();\n\nexport type Listener = (event: Event) => void;\n","import type { Transport } from \"domainkit\";\nimport type { ReactElement } from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\n\nexport type Operation =\n | Transport.ProvisioningPlan[\"operations\"][number]\n | Transport.CleanupPlan[\"operations\"][number];\n\ntype LeafState = Record<string, unknown>;\n\nfunction leafPart<Tag extends keyof React.JSX.IntrinsicElements>(\n defaultTagName: Tag,\n part: string,\n) {\n return function Leaf(props: PartProps<Tag, LeafState>): ReactElement {\n return usePart(defaultTagName, props, {}, { \"data-domainkit-part\": part });\n };\n}\n\nexport const Kind = leafPart(\"span\", \"operation-kind\");\nexport const Type = leafPart(\"strong\", \"operation-type\");\nexport const Record = leafPart(\"span\", \"operation-record\");\nexport const Name = leafPart(\"span\", \"operation-name\");\nexport const Value = leafPart(\"code\", \"operation-value\");\nexport const Priority = leafPart(\"span\", \"operation-priority\");\nexport const Reason = leafPart(\"span\", \"operation-reason\");\n\nexport interface ItemProps extends PartProps<\"li\", { readonly operation: Operation[\"_tag\"] }> {\n readonly operation: Operation;\n}\n\nexport function Item({ operation, ...props }: ItemProps) {\n return usePart(\n \"li\",\n props,\n { operation: operation._tag },\n {\n children: (\n <>\n <Kind>{operation._tag}</Kind> <Type>{operation.record.type}</Type>{\" \"}\n <Record>\n <Name>{operation.record.name}</Name>\n <Value>{operation.record.value}</Value>\n {operation.record.priority === undefined ? null : (\n <Priority>Priority {operation.record.priority}</Priority>\n )}\n {\"reason\" in operation ? <Reason>{operation.reason}</Reason> : null}\n </Record>\n </>\n ),\n \"data-domainkit-part\": \"operation-item\",\n \"data-operation\": operation._tag,\n },\n );\n}\n\nexport interface RootProps extends PartProps<\n \"ul\",\n { readonly count: number; readonly lifecycle: Lifecycle }\n> {\n readonly count?: number;\n readonly lifecycle: Lifecycle;\n}\n\nexport type Lifecycle = \"cleanup\" | \"provisioning\";\n\nexport function Root({ count = 0, lifecycle, ...props }: RootProps) {\n return usePart(\n \"ul\",\n props,\n { count, lifecycle },\n {\n \"data-domainkit-part\":\n lifecycle === \"provisioning\" ? \"plan-operations\" : \"cleanup-operations\",\n \"data-lifecycle\": lifecycle,\n },\n );\n}\n\nexport interface ListProps extends Omit<RootProps, \"children\" | \"count\"> {\n readonly operations: ReadonlyArray<Operation>;\n}\n\nexport function List({ lifecycle, operations, ...props }: ListProps) {\n return (\n <Root count={operations.length} lifecycle={lifecycle} {...props}>\n {operations.map((operation) => (\n <Item key={operation.id} operation={operation} />\n ))}\n </Root>\n );\n}\n","import { AlertDialog as BaseAlertDialog } from \"@base-ui/react/alert-dialog\";\nimport { useAtomSet, useAtomValue } from \"@effect/atom-react\";\nimport { Transport } from \"domainkit\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport { useMemo, useRef, type ReactElement } from \"react\";\n\nimport { failureFromError, type Failure } from \"./atom.ts\";\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { Event as LifecycleEvent } from \"./lifecycle.ts\";\nimport * as Operations from \"./operations.tsx\";\n\ntype LocalState = Data.TaggedEnum<{\n Cleaned: { readonly result: Extract<Transport.CleanupResult, { readonly _tag: \"Cleaned\" }> };\n Cleaning: { readonly plan: Transport.CleanupPlan };\n Idle: {};\n Partial: { readonly result: Extract<Transport.CleanupResult, { readonly _tag: \"Partial\" }> };\n Planning: {};\n Review: { readonly plan: Transport.CleanupPlan };\n}>;\nexport const State = Data.taggedEnum<LocalState>();\nexport type State =\n | LocalState\n | Extract<Transport.CleanupResult, { readonly _tag: \"Stale\" }>\n | Failure;\n\nexport type Command = Data.TaggedEnum<{\n Apply: {};\n Dismiss: {};\n Plan: {};\n}>;\nexport const Command = Data.taggedEnum<Command>();\n\nexport interface Model {\n readonly command: Atom.AtomResultFn<Command, void>;\n readonly state: Atom.Atom<State>;\n}\n\nexport interface Controller {\n readonly apply: () => void;\n readonly dismiss: () => void;\n readonly plan: () => void;\n readonly retry: () => void;\n readonly state: State;\n}\n\nexport type Completion = Extract<Transport.CleanupResult, { readonly _tag: \"Cleaned\" | \"Partial\" }>;\n\nexport function useModel(\n connection: Transport.Connected,\n receiptId: string,\n onCleaned?: (result: Completion) => void,\n): Model {\n const { emit, runtime } = useDomainKit();\n const onCleanedRef = useRef(onCleaned);\n onCleanedRef.current = onCleaned;\n return useMemo(() => {\n const state = Atom.make<State>(State.Idle());\n const execute = runtime.fn<Command>()((command, get) => {\n const current = get(state);\n if (command._tag === \"Dismiss\") {\n if (current._tag === \"Planning\" || current._tag === \"Cleaning\") return Effect.void;\n get.set(state, State.Idle());\n return Effect.void;\n }\n if (command._tag === \"Plan\") {\n if (current._tag === \"Planning\" || current._tag === \"Cleaning\") return Effect.void;\n get.set(state, State.Planning());\n return Effect.flatMap(Transport.Service, (transport) =>\n transport.cleanup.plan({\n attachmentId: connection.attachment.id,\n domain: connection.attachment.domain,\n receiptId,\n }),\n ).pipe(\n Effect.tap((plan) => Effect.sync(() => get.set(state, State.Review({ plan })))),\n Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))),\n Effect.asVoid,\n );\n }\n if (\n current._tag !== \"Review\" ||\n current.plan.operations.some((operation) => operation._tag === \"Blocked\")\n )\n return Effect.void;\n const plan = current.plan;\n get.set(state, State.Cleaning({ plan }));\n return Effect.flatMap(Transport.Service, (transport) =>\n transport.cleanup.apply({\n attachmentId: connection.attachment.id,\n domain: connection.attachment.domain,\n planDigest: plan.digest,\n receiptId,\n }),\n ).pipe(\n Effect.tap((result) =>\n Effect.sync(() => {\n if (result._tag === \"Cleaned\") {\n get.set(state, State.Cleaned({ result }));\n onCleanedRef.current?.(result);\n emit(LifecycleEvent.RecordsCleaned({ connection, result }));\n } else if (result._tag === \"Partial\") {\n get.set(state, State.Partial({ result }));\n onCleanedRef.current?.(result);\n emit(LifecycleEvent.RecordsPartiallyCleaned({ connection, result }));\n } else {\n get.set(state, result);\n }\n }),\n ),\n Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))),\n Effect.asVoid,\n );\n });\n return { command: execute, state };\n }, [connection.attachment.domain, connection.attachment.id, emit, receiptId, runtime]);\n}\n\nexport function useController(\n connection: Transport.Connected,\n receiptId: string,\n onCleaned?: (result: Completion) => void,\n): Controller {\n const model = useModel(connection, receiptId, onCleaned);\n const state = useAtomValue(model.state);\n const execute = useAtomSet(model.command);\n\n return {\n apply: () => execute(Command.Apply()),\n dismiss: () => execute(Command.Dismiss()),\n plan: () => execute(Command.Plan()),\n retry: () => execute(Command.Plan()),\n state,\n } as const;\n}\n\nexport interface RootProps extends PartProps<\"div\", { readonly status: State[\"_tag\"] }> {\n readonly status: State[\"_tag\"];\n}\n\nexport function Root({ status, ...props }: RootProps) {\n return usePart(\n \"div\",\n props,\n { status },\n { \"data-domainkit-part\": \"cleanup-flow\", \"data-state\": status },\n );\n}\n\nexport function Outcome({ state }: { readonly state: State }) {\n const { messages } = useDomainKit();\n if (state._tag === \"Partial\" || state._tag === \"Failure\" || state._tag === \"Stale\") {\n return (\n <p data-domainkit-part=\"flow-outcome\" data-tone=\"danger\" role=\"alert\">\n {state._tag === \"Partial\" ? messages.cleanupPartial : state.message}\n </p>\n );\n }\n return null;\n}\n\nexport interface DialogProps {\n readonly controller: Controller;\n readonly onOpenChange?: (open: boolean) => void;\n readonly onOpenChangeComplete?: (open: boolean) => void;\n readonly trigger?: ReactElement | null;\n}\n\nexport function Dialog({ controller, onOpenChange, onOpenChangeComplete, trigger }: DialogProps) {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const state = controller.state;\n const planRef = useRef<Transport.CleanupPlan | undefined>(undefined);\n if (state._tag === \"Idle\") planRef.current = undefined;\n if (state._tag === \"Review\" || state._tag === \"Cleaning\") planRef.current = state.plan;\n const plan = planRef.current;\n const busy = state._tag === \"Planning\" || state._tag === \"Cleaning\";\n const open = state._tag !== \"Idle\" && state._tag !== \"Cleaned\";\n return (\n <BaseAlertDialog.Root\n onOpenChange={(nextOpen, eventDetails) => {\n if (!nextOpen && busy) {\n eventDetails.cancel();\n return;\n }\n if (!nextOpen) {\n controller.dismiss();\n }\n onOpenChange?.(nextOpen);\n }}\n onOpenChangeComplete={onOpenChangeComplete}\n open={open}\n >\n {trigger === null ? null : (\n <BaseAlertDialog.Trigger\n data-domainkit-part=\"cleanup-trigger\"\n disabled={state._tag !== \"Idle\"}\n onClick={() => controller.plan()}\n {...(trigger === undefined ? {} : { render: trigger })}\n >\n {messages.reviewCleanup}\n </BaseAlertDialog.Trigger>\n )}\n <BaseAlertDialog.Portal container={portalContainer}>\n <BaseAlertDialog.Backdrop\n data-color-scheme={colorScheme}\n data-domainkit-part=\"dialog-backdrop\"\n data-domainkit-root=\"\"\n style={themeStyle}\n />\n <BaseAlertDialog.Popup\n data-color-scheme={colorScheme}\n data-domainkit-part=\"cleanup-dialog\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <div data-domainkit-part=\"dialog-header\">\n <div data-domainkit-part=\"dialog-heading\">\n <BaseAlertDialog.Title data-domainkit-part=\"dialog-title\">\n {messages.reviewCleanup}\n </BaseAlertDialog.Title>\n <BaseAlertDialog.Description data-domainkit-part=\"dialog-description\">\n {messages.cleanupConsent}\n </BaseAlertDialog.Description>\n </div>\n {busy ? null : (\n <BaseAlertDialog.Close aria-label={messages.close} data-domainkit-part=\"dialog-close\">\n ×\n </BaseAlertDialog.Close>\n )}\n </div>\n <div data-domainkit-part=\"dialog-body\">\n {plan === undefined ? (\n <p data-domainkit-part=\"dialog-progress\" role=\"status\">\n {messages.planningCleanup}\n </p>\n ) : (\n <Operations.List lifecycle=\"cleanup\" operations={plan.operations} />\n )}\n <Outcome state={state} />\n </div>\n <div data-domainkit-part=\"dialog-footer\">\n {busy ? (\n <button data-domainkit-part=\"cleanup-apply\" disabled type=\"button\">\n {state._tag === \"Cleaning\" ? messages.cleaningDns : messages.planningCleanup}\n </button>\n ) : state._tag === \"Review\" && plan !== undefined ? (\n <>\n <BaseAlertDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.cancel}\n </BaseAlertDialog.Close>\n <button\n data-domainkit-part=\"cleanup-apply\"\n disabled={plan.operations.some((operation) => operation._tag === \"Blocked\")}\n onClick={() => controller.apply()}\n type=\"button\"\n >\n {messages.applyCleanup}\n </button>\n </>\n ) : (\n <>\n <BaseAlertDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.close}\n </BaseAlertDialog.Close>\n <button\n data-domainkit-part=\"cleanup-retry\"\n onClick={() => controller.retry()}\n type=\"button\"\n >\n {messages.retry}\n </button>\n </>\n )}\n </div>\n </BaseAlertDialog.Popup>\n </BaseAlertDialog.Portal>\n </BaseAlertDialog.Root>\n );\n}\n\nexport interface FlowProps extends Omit<RootProps, \"status\"> {\n readonly connection: Transport.Connected;\n readonly onCleaned?: (result: Completion) => void;\n readonly receiptId: string;\n readonly trigger?: ReactElement;\n}\n\nexport function Flow({ connection, onCleaned, receiptId, trigger, ...props }: FlowProps) {\n const controller = useController(connection, receiptId, onCleaned);\n const state = controller.state;\n return (\n <Root status={state._tag} {...props}>\n <Dialog controller={controller} {...(trigger === undefined ? {} : { trigger })} />\n </Root>\n );\n}\n","import { useState, type ComponentPropsWithoutRef, type ReactNode } from \"react\";\nimport type { Transport } from \"domainkit\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\n\ntype ProviderDescriptor = Transport.Provider;\n\nexport type Marks = Readonly<\n Record<string, ReactNode | ((provider: ProviderDescriptor) => ReactNode)>\n>;\n\nexport interface MarkState extends Record<string, unknown> {\n readonly providerId: string;\n}\n\nexport interface MarkProps extends PartProps<\"span\", MarkState> {\n readonly provider: ProviderDescriptor;\n}\n\nconst logoHosts: Readonly<Record<string, string>> = {\n amazonroute53: \"route53.com\",\n aws: \"amazonaws.com\",\n bluehost: \"bluehost.com\",\n cloudflare: \"cloudflare.com\",\n digitalocean: \"digitalocean.com\",\n dnsimple: \"dnsimple.com\",\n dreamhost: \"dreamhost.com\",\n dynadot: \"dynadot.com\",\n gandi: \"gandi.net\",\n godaddy: \"godaddy.com\",\n google: \"cloud.google.com\",\n googlecloud: \"cloud.google.com\",\n googleclouddns: \"cloud.google.com\",\n hostgator: \"hostgator.com\",\n hostinger: \"hostinger.com\",\n hover: \"hover.com\",\n ionos: \"ionos.com\",\n namecheap: \"namecheap.com\",\n namecom: \"name.com\",\n netlify: \"netlify.com\",\n ns1: \"ns1.com\",\n ovh: \"ovh.com\",\n porkbun: \"porkbun.com\",\n route53: \"route53.com\",\n spaceship: \"spaceship.com\",\n squarespace: \"squarespace.com\",\n vercel: \"vercel.com\",\n};\n\nconst logoKey = (providerId: string): string =>\n providerId\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"\");\n\nconst logoHost = (providerId: string): string | undefined => logoHosts[logoKey(providerId)];\n\nconst letterMark = (provider: ProviderDescriptor): string =>\n provider.name.trim().charAt(0).toUpperCase() || \"?\";\n\nfunction DefaultMark({ provider }: { readonly provider: ProviderDescriptor }) {\n const host = logoHost(provider.id);\n const [failed, setFailed] = useState(false);\n if (host === undefined || failed) return letterMark(provider);\n return (\n <img\n alt=\"\"\n height={32}\n onError={() => setFailed(true)}\n referrerPolicy=\"no-referrer\"\n src={`https://integrations.sh/logo/${host}?sz=64`}\n width={32}\n />\n );\n}\n\nexport function Mark({ provider, ...props }: MarkProps) {\n const { marks } = useDomainKit();\n const replacement = marks[provider.id];\n const content =\n typeof replacement === \"function\"\n ? replacement(provider)\n : (replacement ?? <DefaultMark key={provider.id} provider={provider} />);\n return usePart(\n \"span\",\n props,\n { providerId: provider.id },\n {\n \"aria-label\": provider.name,\n children: content,\n \"data-domainkit-part\": \"provider-mark\",\n \"data-domainkit-provider\": logoKey(provider.id),\n role: \"img\",\n },\n );\n}\n\nexport type { ProviderDescriptor as Provider };\nexport type MarkElementProps = ComponentPropsWithoutRef<\"span\">;\n","import { AlertDialog as BaseAlertDialog } from \"@base-ui/react/alert-dialog\";\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { useAtomSet, useAtomValue } from \"@effect/atom-react\";\nimport { Transport } from \"domainkit\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\nimport {\n useMemo,\n useState,\n type ComponentPropsWithoutRef,\n type FormEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport * as Provider from \"./provider.tsx\";\nimport { Event as LifecycleEvent } from \"./lifecycle.ts\";\nimport { failureFromDefect, failureFromError, type Failure } from \"./atom.ts\";\n\ntype LocalState = Data.TaggedEnum<{\n Detaching: { readonly snapshot: Transport.Connected };\n Loading: {};\n Redirecting: { readonly snapshot: Disconnected };\n Submitting: { readonly snapshot: Disconnected };\n}>;\nexport const State = Data.taggedEnum<LocalState>();\nexport type State = LocalState | Transport.ConnectionSnapshot | Failure;\n\ntype Disconnected = Extract<Transport.ConnectionSnapshot, { readonly _tag: \"Disconnected\" }>;\n\nconst sameTarget = (left: Transport.ProviderTarget, right: Transport.ProviderTarget): boolean =>\n left.accountId === right.accountId &&\n left.accountKind === right.accountKind &&\n left.zoneId === right.zoneId &&\n left.zoneName === right.zoneName;\n\nexport interface Controller {\n readonly attach: (\n connection: Transport.ReusableConnection,\n target: Transport.ProviderTarget,\n ) => void;\n readonly connect: (method: Transport.Method) => void;\n readonly detach: () => void;\n readonly retry: () => void;\n readonly state: State;\n}\n\nexport type Command = Data.TaggedEnum<{\n Attach: { readonly connectionId: string; readonly target: Transport.ProviderTarget };\n Connect: { readonly method: Transport.Method };\n Detach: {};\n Retry: {};\n}>;\nexport const Command = Data.taggedEnum<Command>();\n\nexport interface Model {\n readonly command: Atom.AtomResultFn<Command, void>;\n readonly state: Atom.Atom<State>;\n}\n\nexport function useModel(domain: string): Model {\n const { emit, navigate, runtime } = useDomainKit();\n return useMemo(() => {\n const actionState = Atom.make<State | undefined>(undefined);\n const inspect = runtime.atom(\n Effect.flatMap(Transport.Service, (transport) => transport.connection.inspect({ domain })),\n );\n const state = Atom.make((get): State => {\n const action = get(actionState);\n if (action !== undefined) return action;\n const inspection = get(inspect);\n return AsyncResult.matchWithError(inspection, {\n onDefect: () => failureFromDefect(\"connection.inspect\", \"Provider detection failed\"),\n onError: failureFromError,\n onInitial: () => State.Loading(),\n onSuccess: ({ value }) => value,\n });\n });\n const command = runtime.fn<Command>()((input, get) => {\n if (input._tag === \"Retry\") {\n get.set(actionState, undefined);\n get.refresh(inspect);\n return Effect.void;\n }\n const snapshot = get(state);\n if (input._tag === \"Detach\") {\n if (snapshot._tag !== \"Connected\") return Effect.void;\n get.set(actionState, State.Detaching({ snapshot }));\n return Effect.flatMap(Transport.Service, (transport) =>\n Effect.flatMap(\n transport.connection.detach({\n attachmentId: snapshot.attachment.id,\n preserveDns: true,\n }),\n (result) => {\n const detached: Disconnected = Transport.Disconnected({\n domain: snapshot.attachment.domain,\n provider: snapshot.provider,\n reusableConnections: [],\n });\n return Effect.flatMap(\n Effect.sync(() => {\n get.set(actionState, detached);\n emit(\n LifecycleEvent.DomainDetached({\n connection: snapshot,\n result,\n }),\n );\n }),\n () =>\n transport.connection.inspect({ domain }).pipe(\n Effect.catch(() => Effect.succeed(detached)),\n Effect.tap((refreshed) => Effect.sync(() => get.set(actionState, refreshed))),\n ),\n );\n },\n ),\n ).pipe(\n Effect.catch((error) => Effect.sync(() => get.set(actionState, failureFromError(error)))),\n Effect.asVoid,\n );\n }\n if (snapshot._tag !== \"Disconnected\") return Effect.void;\n const complete = (\n request: Effect.Effect<Transport.ConnectionResult, Transport.Failure, Transport.Service>,\n source: \"connect\" | \"attach\",\n ) =>\n request.pipe(\n Effect.tap((result) =>\n Effect.sync(() => {\n if (result._tag === \"Redirect\") {\n get.set(actionState, State.Redirecting({ snapshot }));\n navigate(result.authorizationUrl);\n } else {\n get.set(actionState, result);\n emit(\n LifecycleEvent.ConnectionEstablished({\n connection: result,\n source,\n }),\n );\n }\n }),\n ),\n Effect.catch((error) => Effect.sync(() => get.set(actionState, failureFromError(error)))),\n Effect.asVoid,\n );\n if (input._tag === \"Attach\") {\n const reusableConnection = snapshot.reusableConnections.find(\n ({ connection }) => connection.id === input.connectionId,\n );\n if (reusableConnection === undefined) return Effect.void;\n const target = reusableConnection.targets.find((candidate) =>\n sameTarget(candidate, input.target),\n );\n if (target === undefined) return Effect.void;\n get.set(actionState, State.Submitting({ snapshot }));\n return complete(\n Effect.flatMap(Transport.Service, (transport) =>\n transport.connection.attach({\n connectionId: input.connectionId,\n domain,\n target,\n }),\n ),\n \"attach\",\n );\n }\n get.set(actionState, State.Submitting({ snapshot }));\n if (input._tag === \"Connect\") {\n return complete(\n Effect.flatMap(Transport.Service, (transport) =>\n transport.connection.connect({\n domain,\n method: input.method,\n providerId: snapshot.provider.id,\n }),\n ),\n \"connect\",\n );\n }\n return Effect.void;\n });\n return { command, state };\n }, [domain, emit, navigate, runtime]);\n}\n\nexport function useController(domain: string): Controller {\n const model = useModel(domain);\n const state = useAtomValue(model.state);\n const execute = useAtomSet(model.command);\n\n return {\n attach: (connection, target) =>\n execute(Command.Attach({ connectionId: connection.connection.id, target })),\n connect: (method) => execute(Command.Connect({ method })),\n detach: () => execute(Command.Detach()),\n retry: () => execute(Command.Retry()),\n state,\n };\n}\n\nexport interface RootState extends Record<string, unknown> {\n readonly status: State[\"_tag\"];\n}\n\nexport interface RootProps extends PartProps<\"div\", RootState> {\n readonly status?: State[\"_tag\"];\n}\n\nexport function Root({ children, status = \"Loading\", ...props }: RootProps) {\n return usePart(\n \"div\",\n props,\n { status },\n {\n children,\n \"data-domainkit-part\": \"connection-root\",\n },\n );\n}\n\nexport interface StatusState extends Record<string, unknown> {\n readonly status: State[\"_tag\"];\n}\n\nexport interface StatusProps extends PartProps<\"div\", StatusState> {\n readonly state: State;\n}\n\nexport function Status({ children, state, ...props }: StatusProps) {\n const { messages } = useDomainKit();\n const text =\n state._tag === \"Loading\"\n ? messages.detectingProvider\n : state._tag === \"Connected\"\n ? messages.connected(state.provider.name)\n : state._tag === \"Detaching\"\n ? messages.detaching\n : state._tag === \"Unsupported\"\n ? messages.automaticUnavailable\n : state._tag === \"Failure\"\n ? state.message\n : state._tag === \"Redirecting\"\n ? messages.openingAuthorization\n : state._tag === \"Submitting\"\n ? messages.connecting\n : messages.providerAvailable(state.provider.name);\n return usePart(\n \"div\",\n props,\n { status: state._tag },\n {\n children: children ?? text,\n \"data-domainkit-part\": \"connection-status\",\n \"data-state\": state._tag,\n },\n );\n}\n\nexport interface TriggerProps extends Omit<\n ComponentPropsWithoutRef<typeof BaseDialog.Trigger>,\n \"children\"\n> {\n readonly children: ReactNode;\n}\n\nexport interface ConnectTriggerProps extends Omit<TriggerProps, \"children\"> {\n readonly children?: ReactNode;\n readonly provider: Provider.Provider;\n}\n\nexport function Trigger({ children, ...props }: TriggerProps) {\n return (\n <BaseDialog.Trigger data-domainkit-part=\"connection-trigger\" {...props}>\n {children}\n </BaseDialog.Trigger>\n );\n}\n\nexport function ConnectTrigger({ children, provider, ...props }: ConnectTriggerProps) {\n const { messages } = useDomainKit();\n return (\n <Trigger {...props} data-domainkit-recipe=\"connect\">\n {children ?? (\n <>\n <Provider.Mark aria-hidden=\"true\" provider={provider} />\n {messages.connectProvider(provider.name)}\n </>\n )}\n </Trigger>\n );\n}\n\nexport interface ActionState extends Record<string, unknown> {\n readonly authentication: \"attach\" | \"integration\" | \"oauth\" | \"token\";\n}\n\nexport interface OAuthActionProps extends PartProps<\"button\", ActionState> {\n readonly controller: Controller;\n readonly label: string;\n}\n\nexport function OAuthAction({ controller, label, ...props }: OAuthActionProps) {\n const pending = controller.state._tag === \"Submitting\" || controller.state._tag === \"Redirecting\";\n return usePart(\n \"button\",\n props,\n { authentication: \"oauth\" },\n {\n children: label,\n \"data-domainkit-part\": \"oauth-connect\",\n disabled: pending,\n onClick: () => controller.connect(Transport.Method.OAuth()),\n type: \"button\",\n },\n );\n}\n\nexport interface IntegrationActionProps extends PartProps<\"button\", ActionState> {\n readonly controller: Controller;\n readonly label: string;\n}\n\nexport function IntegrationAction({ controller, label, ...props }: IntegrationActionProps) {\n const pending = controller.state._tag === \"Submitting\" || controller.state._tag === \"Redirecting\";\n return usePart(\n \"button\",\n props,\n { authentication: \"integration\" },\n {\n children: label,\n \"data-domainkit-part\": \"integration-connect\",\n disabled: pending,\n onClick: () => controller.connect(Transport.Method.Integration()),\n type: \"button\",\n },\n );\n}\n\nexport interface AttachActionProps extends PartProps<\"button\", ActionState> {\n readonly connection: Transport.ReusableConnection;\n readonly controller: Controller;\n readonly label: string;\n readonly target: Transport.ProviderTarget;\n}\n\nexport function AttachAction({\n connection,\n controller,\n label,\n target,\n ...props\n}: AttachActionProps) {\n const pending = controller.state._tag === \"Submitting\" || controller.state._tag === \"Redirecting\";\n return usePart(\n \"button\",\n props,\n { authentication: \"attach\" },\n {\n children: label,\n \"data-domainkit-part\": \"attach-target\",\n disabled: pending,\n onClick: () => controller.attach(connection, target),\n type: \"button\",\n },\n );\n}\n\nexport interface TokenActionProps extends Omit<PartProps<\"form\", ActionState>, \"method\"> {\n readonly controller: Controller;\n readonly method: Extract<Transport.AuthenticationMethod, { readonly _tag: \"Token\" }>;\n}\n\nexport function TokenAction({ controller, method, ...props }: TokenActionProps) {\n const { messages } = useDomainKit();\n const pending = controller.state._tag === \"Submitting\" || controller.state._tag === \"Redirecting\";\n const [token, setToken] = useState(\"\");\n const [parameters, setParameters] = useState<Readonly<Record<string, string>>>({});\n const submit = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (token.length > 0) {\n const populated = Object.fromEntries(\n Object.entries(parameters).filter(([, value]) => value.length > 0),\n );\n controller.connect(\n Transport.Method.Token({\n token,\n ...(Object.keys(populated).length === 0 ? {} : { parameters: populated }),\n }),\n );\n }\n };\n const missingRequiredParameter = method.parameters?.some(\n (parameter) => parameter.required === true && !parameters[parameter.key],\n );\n return usePart(\n \"form\",\n props,\n { authentication: \"token\" },\n {\n children: (\n <>\n {method.parameters?.map((parameter) => (\n <label key={parameter.key}>\n {parameter.label}\n <input\n name={parameter.key}\n disabled={pending}\n onChange={(event) => {\n const value = event.currentTarget.value;\n setParameters((current) => ({\n ...current,\n [parameter.key]: value,\n }));\n }}\n placeholder={parameter.placeholder}\n required={parameter.required}\n type=\"text\"\n value={parameters[parameter.key] ?? \"\"}\n />\n {parameter.description === undefined ? null : <small>{parameter.description}</small>}\n </label>\n ))}\n <label>\n {messages.tokenLabel}\n <input\n autoComplete=\"off\"\n disabled={pending}\n name=\"token\"\n onChange={(event) => setToken(event.currentTarget.value)}\n placeholder={method.placeholder}\n type=\"password\"\n value={token}\n />\n </label>\n <button\n disabled={pending || token.length === 0 || missingRequiredParameter === true}\n type=\"submit\"\n >\n {method.label}\n </button>\n </>\n ),\n \"data-domainkit-part\": \"token-connect\",\n onSubmit: submit,\n },\n );\n}\n\nexport interface DialogProps {\n readonly controller: Controller;\n readonly snapshot: Disconnected;\n}\n\nexport const targetLabel = (target: Transport.ProviderTarget): string =>\n `${target.evidence?.accountName ?? target.accountId} · ${target.zoneName}`;\n\nexport function Dialog({ controller, snapshot }: DialogProps) {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const pending = controller.state._tag === \"Submitting\" || controller.state._tag === \"Redirecting\";\n const integrationMethods = snapshot.provider.authentication.filter(\n (method): method is Extract<Transport.AuthenticationMethod, { readonly _tag: \"Integration\" }> =>\n method._tag === \"Integration\",\n );\n const oauthMethods = snapshot.provider.authentication.filter(\n (method): method is Extract<Transport.AuthenticationMethod, { readonly _tag: \"OAuth\" }> =>\n method._tag === \"OAuth\",\n );\n const tokenMethods = snapshot.provider.authentication.filter(\n (method): method is Extract<Transport.AuthenticationMethod, { readonly _tag: \"Token\" }> =>\n method._tag === \"Token\",\n );\n const hasProviderAccountPath =\n integrationMethods.length > 0 ||\n oauthMethods.length > 0 ||\n snapshot.reusableConnections.length > 0;\n return (\n <BaseDialog.Portal container={portalContainer}>\n <BaseDialog.Backdrop\n data-color-scheme={colorScheme}\n data-domainkit-part=\"dialog-backdrop\"\n data-domainkit-root=\"\"\n style={themeStyle}\n />\n <BaseDialog.Popup\n data-domainkit-part=\"connection-dialog\"\n data-domainkit-root=\"\"\n data-color-scheme={colorScheme}\n style={themeStyle}\n >\n <div data-domainkit-part=\"dialog-header\">\n <Provider.Mark provider={snapshot.provider} />\n <div data-domainkit-part=\"dialog-heading\">\n <BaseDialog.Title data-domainkit-part=\"dialog-title\">\n {messages.dialogTitle(snapshot.provider.name)}\n </BaseDialog.Title>\n <BaseDialog.Description data-domainkit-part=\"dialog-description\">\n {messages.dialogDescription(snapshot.domain)}\n </BaseDialog.Description>\n </div>\n {pending ? null : (\n <BaseDialog.Close aria-label={messages.close} data-domainkit-part=\"dialog-close\">\n ×\n </BaseDialog.Close>\n )}\n </div>\n <div data-domainkit-part=\"dialog-body\">\n {hasProviderAccountPath ? (\n <div data-domainkit-part=\"provider-authentication\">\n {integrationMethods.map((method) => (\n <IntegrationAction controller={controller} key={method._tag} label={method.label} />\n ))}\n {oauthMethods.map((method) => (\n <OAuthAction controller={controller} key={method._tag} label={method.label} />\n ))}\n {snapshot.reusableConnections.map((connection) => (\n <section\n data-connection-id={connection.connection.id}\n data-domainkit-part=\"reusable-connection\"\n key={connection.connection.id}\n >\n <div data-domainkit-part=\"reusable-connection-heading\">\n <strong>{messages.existingConnection}</strong>\n <span>{connection.connection.providerId}</span>\n </div>\n <div\n data-domainkit-part=\"target-list\"\n data-state={\n connection.targets.length === 0\n ? \"unavailable\"\n : connection.targets.length === 1\n ? \"unique\"\n : \"ambiguous\"\n }\n >\n {connection.targets.length === 0 ? (\n <p data-domainkit-part=\"target-unavailable\">{messages.targetUnavailable}</p>\n ) : (\n connection.targets.map((target) => (\n <AttachAction\n connection={connection}\n controller={controller}\n key={`${target.accountId}:${target.zoneId}`}\n label={messages.attachTarget(targetLabel(target))}\n target={target}\n />\n ))\n )}\n </div>\n </section>\n ))}\n </div>\n ) : null}\n {hasProviderAccountPath && tokenMethods.length > 0 ? (\n <div\n aria-label={messages.authenticationAlternative}\n data-domainkit-part=\"authentication-separator\"\n role=\"separator\"\n >\n <span aria-hidden=\"true\">{messages.authenticationAlternative}</span>\n </div>\n ) : null}\n {tokenMethods.map((method) => (\n <TokenAction controller={controller} key={method._tag} method={method} />\n ))}\n </div>\n {pending ? null : (\n <div data-domainkit-part=\"dialog-footer\">\n <BaseDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.cancel}\n </BaseDialog.Close>\n </div>\n )}\n </BaseDialog.Popup>\n </BaseDialog.Portal>\n );\n}\n\nexport interface FlowProps extends Omit<RootProps, \"children\"> {\n readonly domain: string;\n}\n\nexport function Flow({ domain, ...props }: FlowProps) {\n const controller = useController(domain);\n const state = controller.state;\n const snapshot =\n state._tag === \"Disconnected\"\n ? state\n : state._tag === \"Submitting\" || state._tag === \"Redirecting\"\n ? state.snapshot\n : undefined;\n return (\n <Root {...props} status={state._tag}>\n <Status state={state} />\n {state._tag === \"Failure\" && state.retry !== \"never\" ? (\n <RetryAction\n controller={controller}\n kind={state.retry === \"after-user-action\" ? \"after-user-action\" : \"retry\"}\n />\n ) : null}\n {snapshot === undefined ? null : (\n <BaseDialog.Root\n onOpenChange={(open, eventDetails) => {\n if (!open && (state._tag === \"Submitting\" || state._tag === \"Redirecting\")) {\n eventDetails.cancel();\n }\n }}\n >\n <ConnectTrigger provider={snapshot.provider} />\n <Dialog controller={controller} snapshot={snapshot} />\n </BaseDialog.Root>\n )}\n </Root>\n );\n}\n\nexport interface RetryActionProps extends PartProps<\"button\", { readonly status: \"Failure\" }> {\n readonly controller: Controller;\n readonly kind?: \"after-user-action\" | \"retry\";\n}\n\nexport function RetryAction({ controller, kind = \"retry\", ...props }: RetryActionProps) {\n const { messages } = useDomainKit();\n return usePart(\n \"button\",\n props,\n { status: \"Failure\" },\n {\n children: kind === \"after-user-action\" ? messages.checkAgain : messages.retry,\n \"data-domainkit-part\": \"connection-retry\",\n onClick: controller.retry,\n type: \"button\",\n },\n );\n}\n\nexport interface CardProps extends PartProps<\"div\", { readonly status: State[\"_tag\"] }> {\n readonly status: State[\"_tag\"];\n}\n\nexport function Card({ status, ...props }: CardProps) {\n return usePart(\n \"div\",\n props,\n { status },\n { \"data-domainkit-part\": \"connected-card\", \"data-state\": status },\n );\n}\n\nexport interface CardIdentityProps extends PartProps<\"div\", { readonly status: State[\"_tag\"] }> {\n readonly status: State[\"_tag\"];\n}\n\nexport function CardIdentity({ status, ...props }: CardIdentityProps) {\n return usePart(\n \"div\",\n props,\n { status },\n { \"data-domainkit-part\": \"connected-identity\", \"data-state\": status },\n );\n}\n\nexport interface CardActionsProps extends PartProps<\"div\", { readonly status: State[\"_tag\"] }> {\n readonly status: State[\"_tag\"];\n}\n\nexport function CardActions({ status, ...props }: CardActionsProps) {\n return usePart(\n \"div\",\n props,\n { status },\n { \"data-domainkit-part\": \"connected-actions\", \"data-state\": status },\n );\n}\n\nexport interface DisconnectDialogProps {\n readonly connection: Transport.Connected;\n readonly controller: Controller;\n readonly onOpenChange?: (open: boolean) => void;\n readonly open?: boolean;\n readonly trigger?: ReactElement | null;\n}\n\nexport function DisconnectDialog({\n connection,\n controller,\n onOpenChange,\n open: openProp,\n trigger,\n}: DisconnectDialogProps) {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const [internalOpen, setInternalOpen] = useState(false);\n const open = openProp ?? internalOpen;\n const setOpen = (nextOpen: boolean) => {\n if (openProp === undefined) setInternalOpen(nextOpen);\n onOpenChange?.(nextOpen);\n };\n const detaching = controller.state._tag === \"Detaching\";\n return (\n <BaseAlertDialog.Root\n onOpenChange={(nextOpen, eventDetails) => {\n if (!nextOpen && detaching) {\n eventDetails.cancel();\n return;\n }\n setOpen(nextOpen);\n }}\n open={open}\n >\n {trigger === null ? null : (\n <BaseAlertDialog.Trigger\n data-domainkit-part=\"disconnect-trigger\"\n {...(trigger === undefined ? {} : { render: trigger })}\n >\n {messages.disconnectDomain}\n </BaseAlertDialog.Trigger>\n )}\n <BaseAlertDialog.Portal container={portalContainer}>\n <BaseAlertDialog.Backdrop\n data-color-scheme={colorScheme}\n data-domainkit-part=\"dialog-backdrop\"\n data-domainkit-root=\"\"\n style={themeStyle}\n />\n <BaseAlertDialog.Popup\n data-color-scheme={colorScheme}\n data-domainkit-part=\"disconnect-dialog\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <div data-domainkit-part=\"dialog-header\">\n <div data-domainkit-part=\"dialog-heading\">\n <BaseAlertDialog.Title data-domainkit-part=\"dialog-title\">\n {messages.disconnectTitle(connection.provider.name)}\n </BaseAlertDialog.Title>\n <BaseAlertDialog.Description data-domainkit-part=\"dialog-description\">\n {messages.disconnectConsent}\n </BaseAlertDialog.Description>\n </div>\n {detaching ? null : (\n <BaseAlertDialog.Close aria-label={messages.close} data-domainkit-part=\"dialog-close\">\n ×\n </BaseAlertDialog.Close>\n )}\n </div>\n <div data-domainkit-part=\"dialog-footer\">\n {detaching ? null : (\n <BaseAlertDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.cancel}\n </BaseAlertDialog.Close>\n )}\n <button\n data-domainkit-part=\"disconnect-action\"\n disabled={detaching}\n onClick={() => controller.detach()}\n type=\"button\"\n >\n {detaching ? messages.detaching : messages.disconnectDomain}\n </button>\n </div>\n </BaseAlertDialog.Popup>\n </BaseAlertDialog.Portal>\n </BaseAlertDialog.Root>\n );\n}\n\nexport type Connected = Transport.Connected;\n","import { useEffect, useRef, useState, type ReactElement, type ReactNode } from \"react\";\nimport type { Transport } from \"domainkit\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useIcons } from \"./icons.tsx\";\n\nexport const copyText = (value: string): Promise<boolean> => {\n if (typeof navigator === \"undefined\" || navigator.clipboard === undefined) {\n return Promise.resolve(false);\n }\n return navigator.clipboard.writeText(value).then(\n () => true,\n () => false,\n );\n};\n\nconst downloadText = (filename: string, contents: string): void => {\n if (typeof document === \"undefined\") return;\n const blob = new Blob([contents], { type: \"text/plain;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const anchor = document.createElement(\"a\");\n anchor.download = filename;\n anchor.href = url;\n document.body.append(anchor);\n anchor.click();\n anchor.remove();\n URL.revokeObjectURL(url);\n};\n\nconst absoluteDomainName = (value: string): string => (value.endsWith(\".\") ? value : `${value}.`);\n\nconst textEncoder = new TextEncoder();\n\nconst escapeTxtCharacter = (character: string): string => {\n if (character === '\"' || character === \"\\\\\") return `\\\\${character}`;\n const codePoint = character.codePointAt(0);\n if (codePoint !== undefined && (codePoint < 32 || codePoint === 127)) {\n return `\\\\${codePoint.toString().padStart(3, \"0\")}`;\n }\n return character;\n};\n\nconst txtValue = (value: string): string => {\n const chunks: Array<string> = [];\n let chunk = \"\";\n let byteLength = 0;\n for (const character of value) {\n const characterByteLength = textEncoder.encode(character).byteLength;\n if (byteLength + characterByteLength > 255) {\n chunks.push(chunk);\n chunk = \"\";\n byteLength = 0;\n }\n chunk += escapeTxtCharacter(character);\n byteLength += characterByteLength;\n }\n chunks.push(chunk);\n return chunks.map((part) => `\"${part}\"`).join(\" \");\n};\n\nconst srvValue = (value: string): string => {\n const fields = value.trim().split(/\\s+/);\n if (fields.length !== 3) throw new Error(`Invalid SRV value: ${value}`);\n const [weight, port, target] = fields;\n if (weight === undefined || port === undefined || target === undefined) {\n throw new Error(`Invalid SRV value: ${value}`);\n }\n return `${weight} ${port} ${absoluteDomainName(target)}`;\n};\n\nconst zoneValue = (record: Transport.DnsRecord): string => {\n switch (record.type.toUpperCase()) {\n case \"CNAME\":\n case \"MX\":\n case \"NS\":\n case \"PTR\":\n return absoluteDomainName(record.value);\n case \"SRV\":\n return srvValue(record.value);\n case \"TXT\":\n return txtValue(record.value);\n default:\n return record.value;\n }\n};\n\ntype LeafState = Record<string, unknown>;\n\nfunction leafPart<Tag extends keyof React.JSX.IntrinsicElements>(\n defaultTagName: Tag,\n part: string,\n) {\n return function Leaf(props: PartProps<Tag, LeafState>): ReactElement {\n return usePart(defaultTagName, props, {}, { \"data-domainkit-part\": part });\n };\n}\n\nexport interface CopyController {\n readonly copied: boolean;\n readonly copy: () => void;\n}\n\nexport function useCopy(value: string, resetAfter = 2000): CopyController {\n const [copied, setCopied] = useState(false);\n const reset = useRef<ReturnType<typeof setTimeout>>(undefined);\n useEffect(() => () => clearTimeout(reset.current), []);\n return {\n copied,\n copy: () => {\n void copyText(value).then((ok) => {\n if (!ok) return;\n setCopied(true);\n clearTimeout(reset.current);\n reset.current = setTimeout(() => setCopied(false), resetAfter);\n });\n },\n };\n}\n\nexport interface CopyValueProps extends PartProps<\"span\", { readonly copied: boolean }> {\n readonly copiedIcon?: ReactNode;\n readonly copiedLabel?: string;\n readonly copyIcon?: ReactNode;\n readonly copyLabel?: string;\n readonly value: string;\n}\n\nexport function CopyValue({\n copiedIcon,\n copiedLabel = \"Copied\",\n copyIcon,\n copyLabel = \"Copy\",\n value,\n ...props\n}: CopyValueProps) {\n const icons = useIcons();\n const controller = useCopy(value);\n const copied = controller.copied;\n return usePart(\n \"span\",\n props,\n { copied },\n {\n children: (\n <>\n <code>{value}</code>\n <button\n aria-label={`${copied ? copiedLabel : copyLabel} ${value}`}\n data-domainkit-part=\"copy-action\"\n onClick={controller.copy}\n type=\"button\"\n >\n <span\n aria-hidden=\"true\"\n data-domainkit-part=\"copy-glyph\"\n data-icon=\"\"\n data-state=\"idle\"\n >\n {copyIcon ?? icons.copy}\n </span>\n <span\n aria-hidden=\"true\"\n data-domainkit-part=\"copy-glyph\"\n data-icon=\"\"\n data-state=\"done\"\n >\n {copiedIcon ?? icons.copied}\n </span>\n </button>\n </>\n ),\n \"data-copied\": copied ? \"\" : undefined,\n \"data-domainkit-part\": \"copy-value\",\n },\n );\n}\n\nexport interface ZoneFileProps extends PartProps<\"div\", { readonly count: number }> {\n readonly copiedIcon?: ReactNode;\n readonly copiedLabel?: string;\n readonly copyIcon?: ReactNode;\n readonly copyLabel?: string;\n readonly domain: string;\n readonly downloadIcon?: ReactNode;\n readonly downloadLabel?: string;\n readonly records: ReadonlyArray<Transport.DnsRecord>;\n}\n\nexport function ZoneFile({\n copiedIcon,\n copiedLabel = \"Copied\",\n copyIcon,\n copyLabel = \"Copy zone\",\n domain,\n downloadIcon,\n downloadLabel = \"Download\",\n records,\n ...props\n}: ZoneFileProps) {\n const icons = useIcons();\n const zone = toZoneFile(records);\n const controller = useCopy(zone);\n const copied = controller.copied;\n return usePart(\n \"div\",\n props,\n { count: records.length },\n {\n children: (\n <>\n <button\n aria-label={copied ? copiedLabel : copyLabel}\n data-domainkit-part=\"zone-copy\"\n onClick={controller.copy}\n type=\"button\"\n >\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {copied ? (copiedIcon ?? icons.copied) : (copyIcon ?? icons.copy)}\n </span>\n {copied ? copiedLabel : copyLabel}\n </button>\n <button\n aria-label={downloadLabel}\n data-domainkit-part=\"zone-download\"\n onClick={() => downloadZoneFile(domain, records)}\n type=\"button\"\n >\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {downloadIcon ?? icons.download}\n </span>\n {downloadLabel}\n </button>\n </>\n ),\n \"data-domainkit-part\": \"zone-file\",\n },\n );\n}\n\nexport interface StatusProps extends PartProps<\n \"span\",\n { readonly status: Transport.ObservationEvidence[\"_tag\"] }\n> {\n readonly evidence: Transport.ObservationEvidence;\n}\n\nexport function Status({ evidence, ...props }: StatusProps) {\n return usePart(\n \"span\",\n props,\n { status: evidence._tag },\n {\n children: evidence._tag,\n \"data-domainkit-part\": \"record-status\",\n \"data-status\": evidence._tag,\n },\n );\n}\n\nexport interface PriorityProps extends PartProps<\"span\", { readonly priority: number }> {\n readonly priority?: number;\n}\n\nexport function Priority({ children, priority = 0, ...props }: PriorityProps) {\n return usePart(\n \"span\",\n props,\n { priority },\n {\n children: children ?? `Priority ${priority}`,\n \"data-domainkit-part\": \"record-priority\",\n },\n );\n}\n\nexport const Header = leafPart(\"thead\", \"records-header\");\nexport const Body = leafPart(\"tbody\", \"records-body\");\nexport const Footer = leafPart(\"tfoot\", \"records-footer\");\nexport const Row = leafPart(\"tr\", \"records-row\");\nexport const Head = leafPart(\"th\", \"records-head\");\nexport const Cell = leafPart(\"td\", \"records-cell\");\nexport const Caption = leafPart(\"caption\", \"records-caption\");\nexport const Value = leafPart(\"span\", \"record-value\");\nexport const CardHeader = leafPart(\"div\", \"record-card-head\");\nexport const CardTitle = leafPart(\"strong\", \"record-card-title\");\nexport const CardContent = leafPart(\"dl\", \"record-card-content\");\n\nexport interface RootProps extends PartProps<\"table\", { readonly count: number }> {\n readonly count?: number;\n}\n\nexport function Root({ count = 0, ...props }: RootProps) {\n return (\n <div data-domainkit-part=\"records-panel\">\n {usePart(\"table\", props, { count }, { \"data-domainkit-part\": \"records-table\" })}\n </div>\n );\n}\n\nexport interface CardProps extends PartProps<\"section\", { readonly recordId: string }> {\n readonly copiedIcon?: ReactNode;\n readonly copyIcon?: ReactNode;\n readonly evidence?: ReadonlyArray<Transport.ObservationEvidence>;\n readonly record: Transport.DnsRecord;\n}\n\nexport function Card({ copiedIcon, copyIcon, evidence, record, ...props }: CardProps) {\n const matching =\n evidence === undefined ? [] : evidence.filter((item) => item.recordId === record.id);\n return usePart(\n \"section\",\n props,\n { recordId: record.id },\n {\n children: (\n <>\n <CardHeader>\n <CardTitle>{record.type}</CardTitle>\n {matching.map((item, index) => (\n <Status evidence={item} key={`${item._tag}-${index}`} />\n ))}\n </CardHeader>\n <CardContent>\n <div>\n <dt>Name</dt>\n <dd>\n <CopyValue copiedIcon={copiedIcon} copyIcon={copyIcon} value={record.name} />\n </dd>\n </div>\n <div>\n <dt>Value</dt>\n <dd>\n <CopyValue copiedIcon={copiedIcon} copyIcon={copyIcon} value={record.value} />\n {record.priority === undefined ? null : <Priority priority={record.priority} />}\n </dd>\n </div>\n </CardContent>\n </>\n ),\n \"data-domainkit-part\": \"record-card\",\n },\n );\n}\n\nexport interface TableProps extends PartProps<\"table\", { readonly count: number }> {\n readonly copiedIcon?: ReactNode;\n readonly copyIcon?: ReactNode;\n readonly evidence?: ReadonlyArray<Transport.ObservationEvidence>;\n readonly records: ReadonlyArray<Transport.DnsRecord>;\n}\n\nexport function Table({ copiedIcon, copyIcon, evidence, records, ...props }: TableProps) {\n const status = evidence !== undefined;\n return (\n <Root count={records.length} {...props}>\n <Header>\n <Row>\n <Head scope=\"col\">Type</Head>\n <Head scope=\"col\">Name</Head>\n <Head scope=\"col\">Value</Head>\n {status ? (\n <Head data-column=\"status\" scope=\"col\">\n Status\n </Head>\n ) : null}\n </Row>\n </Header>\n <Body>\n {records.map((record) => (\n <Row key={record.id}>\n <Cell>{record.type}</Cell>\n <Cell>\n <CopyValue copiedIcon={copiedIcon} copyIcon={copyIcon} value={record.name} />\n </Cell>\n <Cell>\n <Value>\n <CopyValue copiedIcon={copiedIcon} copyIcon={copyIcon} value={record.value} />\n {record.priority === undefined ? null : <Priority priority={record.priority} />}\n </Value>\n </Cell>\n {status ? (\n <Cell data-column=\"status\">\n {evidence\n .filter((item) => item.recordId === record.id)\n .map((item, index) => (\n <Status evidence={item} key={`${item._tag}-${index}`} />\n ))}\n </Cell>\n ) : null}\n </Row>\n ))}\n </Body>\n </Root>\n );\n}\n\nexport const toZoneFile = (records: ReadonlyArray<Transport.DnsRecord>): string =>\n `${records\n .map(\n (record) =>\n `${absoluteDomainName(record.name)} IN ${record.type} ${record.priority === undefined ? \"\" : `${record.priority} `}${zoneValue(record)}`,\n )\n .join(\"\\n\")}\\n`;\n\nexport const downloadZoneFile = (\n domain: string,\n records: ReadonlyArray<Transport.DnsRecord>,\n): void => downloadText(`${domain}.txt`, toZoneFile(records));\n\nexport type DnsRecord = Transport.DnsRecord;\nexport type ObservationEvidence = Transport.ObservationEvidence;\n","import { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { useAtomSet, useAtomValue } from \"@effect/atom-react\";\nimport { Transport } from \"domainkit\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport { useMemo, useRef, type ReactElement } from \"react\";\n\nimport { failureFromError, recordsIdentity, type Failure } from \"./atom.ts\";\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { Event as LifecycleEvent } from \"./lifecycle.ts\";\nimport * as Operations from \"./operations.tsx\";\nimport * as Records from \"./records.tsx\";\n\ntype LocalState = Data.TaggedEnum<{\n Applying: { readonly plan: Transport.ProvisioningPlan };\n Complete: { readonly result: Extract<Transport.ApplyResult, { readonly _tag: \"Applied\" }> };\n Idle: {};\n Partial: { readonly result: Extract<Transport.ApplyResult, { readonly _tag: \"Partial\" }> };\n Planning: {};\n Review: { readonly plan: Transport.ProvisioningPlan };\n}>;\nexport const State = Data.taggedEnum<LocalState>();\nexport type State =\n | LocalState\n | Extract<Transport.ApplyResult, { readonly _tag: \"Stale\" }>\n | Failure;\n\nexport interface Controller {\n readonly apply: () => void;\n readonly dismiss: () => void;\n readonly plan: () => void;\n readonly retry: () => void;\n readonly state: State;\n}\n\nexport type Command = Data.TaggedEnum<{\n Apply: {};\n Dismiss: {};\n Plan: {};\n}>;\nexport const Command = Data.taggedEnum<Command>();\n\nexport interface Model {\n readonly command: Atom.AtomResultFn<Command, void>;\n readonly state: Atom.Atom<State>;\n}\n\nexport function useModel(\n connection: Transport.Connected,\n records: ReadonlyArray<Transport.DnsRecord>,\n onApplied?: (\n result: Extract<Transport.ApplyResult, { readonly _tag: \"Applied\" | \"Partial\" }>,\n ) => void,\n): Model {\n const { emit, runtime } = useDomainKit();\n const recordKey = recordsIdentity(records);\n const onAppliedRef = useRef(onApplied);\n onAppliedRef.current = onApplied;\n return useMemo(() => {\n const state = Atom.make<State>(State.Idle());\n const execute = runtime.fn<Command>()((command, get) => {\n const current = get(state);\n if (command._tag === \"Dismiss\") {\n if (current._tag === \"Planning\" || current._tag === \"Applying\") return Effect.void;\n get.set(state, State.Idle());\n return Effect.void;\n }\n if (command._tag === \"Plan\") {\n if (current._tag === \"Planning\" || current._tag === \"Applying\") return Effect.void;\n get.set(state, State.Planning());\n return Effect.flatMap(Transport.Service, (transport) =>\n transport.provisioning.plan({\n attachmentId: connection.attachment.id,\n domain: connection.attachment.domain,\n records,\n }),\n ).pipe(\n Effect.tap((plan) => Effect.sync(() => get.set(state, State.Review({ plan })))),\n Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))),\n Effect.asVoid,\n );\n }\n if (\n current._tag !== \"Review\" ||\n current.plan.operations.some((operation) => operation._tag === \"Conflict\")\n )\n return Effect.void;\n const plan = current.plan;\n get.set(state, State.Applying({ plan }));\n return Effect.flatMap(Transport.Service, (transport) =>\n transport.provisioning.apply({\n attachmentId: connection.attachment.id,\n domain: connection.attachment.domain,\n planDigest: plan.digest,\n }),\n ).pipe(\n Effect.tap((result) =>\n Effect.sync(() => {\n if (result._tag === \"Applied\") {\n get.set(state, State.Complete({ result }));\n emit(LifecycleEvent.RecordsApplied({ connection, result }));\n onAppliedRef.current?.(result);\n } else if (result._tag === \"Partial\") {\n get.set(state, State.Partial({ result }));\n emit(LifecycleEvent.RecordsPartiallyApplied({ connection, result }));\n onAppliedRef.current?.(result);\n } else {\n get.set(state, result);\n }\n }),\n ),\n Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))),\n Effect.asVoid,\n );\n });\n return { command: execute, state };\n }, [connection.attachment.domain, connection.attachment.id, emit, recordKey, runtime]);\n}\n\nexport function useController(\n connection: Transport.Connected,\n records: ReadonlyArray<Transport.DnsRecord>,\n onApplied?: (\n result: Extract<Transport.ApplyResult, { readonly _tag: \"Applied\" | \"Partial\" }>,\n ) => void,\n): Controller {\n const model = useModel(connection, records, onApplied);\n const state = useAtomValue(model.state);\n const execute = useAtomSet(model.command);\n\n return {\n apply: () => execute(Command.Apply()),\n dismiss: () => execute(Command.Dismiss()),\n plan: () => execute(Command.Plan()),\n retry: () => execute(Command.Plan()),\n state,\n };\n}\n\nexport interface RootProps extends PartProps<\"div\", { readonly status: State[\"_tag\"] }> {\n readonly status: State[\"_tag\"];\n}\n\nexport function Root({ status, ...props }: RootProps) {\n return usePart(\n \"div\",\n props,\n { status },\n { \"data-domainkit-part\": \"provisioning-flow\", \"data-state\": status },\n );\n}\n\nexport function Outcome({ state }: { readonly state: State }) {\n const { messages } = useDomainKit();\n if (state._tag === \"Partial\" || state._tag === \"Failure\" || state._tag === \"Stale\") {\n return (\n <p data-domainkit-part=\"flow-outcome\" data-tone=\"danger\" role=\"alert\">\n {state._tag === \"Partial\" ? messages.recordsPartiallyApplied : state.message}\n </p>\n );\n }\n return null;\n}\n\nexport interface DialogProps {\n readonly controller: Controller;\n readonly trigger?: ReactElement;\n}\n\nexport function Dialog({ controller, trigger }: DialogProps) {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const state = controller.state;\n const planRef = useRef<Transport.ProvisioningPlan | undefined>(undefined);\n if (state._tag === \"Idle\") planRef.current = undefined;\n if (state._tag === \"Review\" || state._tag === \"Applying\") planRef.current = state.plan;\n const plan = planRef.current;\n const busy = state._tag === \"Planning\" || state._tag === \"Applying\";\n const open = state._tag !== \"Idle\" && state._tag !== \"Complete\";\n const isNoopOnly =\n plan !== undefined && plan.operations.every((operation) => operation._tag === \"Noop\");\n return (\n <BaseDialog.Root\n onOpenChange={(nextOpen, eventDetails) => {\n if (!nextOpen && busy) {\n eventDetails.cancel();\n return;\n }\n if (!nextOpen) controller.dismiss();\n }}\n open={open}\n >\n <BaseDialog.Trigger\n data-domainkit-part=\"plan-trigger\"\n disabled={state._tag !== \"Idle\"}\n onClick={() => controller.plan()}\n {...(trigger === undefined ? {} : { render: trigger })}\n >\n {messages.reviewDns}\n </BaseDialog.Trigger>\n <BaseDialog.Portal container={portalContainer}>\n <BaseDialog.Backdrop\n data-color-scheme={colorScheme}\n data-domainkit-part=\"dialog-backdrop\"\n data-domainkit-root=\"\"\n style={themeStyle}\n />\n <BaseDialog.Popup\n data-color-scheme={colorScheme}\n data-domainkit-part=\"plan-dialog\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <div data-domainkit-part=\"dialog-header\">\n <div data-domainkit-part=\"dialog-heading\">\n <BaseDialog.Title data-domainkit-part=\"dialog-title\">\n {messages.reviewDns}\n </BaseDialog.Title>\n <BaseDialog.Description data-domainkit-part=\"dialog-description\">\n {messages.planConsent}\n </BaseDialog.Description>\n </div>\n {busy ? null : (\n <BaseDialog.Close aria-label={messages.close} data-domainkit-part=\"dialog-close\">\n ×\n </BaseDialog.Close>\n )}\n </div>\n <div data-domainkit-part=\"dialog-body\">\n {plan === undefined ? (\n <p data-domainkit-part=\"dialog-progress\" role=\"status\">\n {messages.planningDns}\n </p>\n ) : (\n <Operations.List lifecycle=\"provisioning\" operations={plan.operations} />\n )}\n <Outcome state={state} />\n </div>\n <div data-domainkit-part=\"dialog-footer\">\n {busy ? (\n <button data-domainkit-part=\"plan-apply\" disabled type=\"button\">\n {state._tag === \"Applying\" ? messages.applyingDns : messages.planningDns}\n </button>\n ) : state._tag === \"Review\" && plan !== undefined ? (\n <>\n <BaseDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.cancel}\n </BaseDialog.Close>\n <button\n data-domainkit-part=\"plan-apply\"\n disabled={\n isNoopOnly || plan.operations.some((operation) => operation._tag === \"Conflict\")\n }\n onClick={() => controller.apply()}\n type=\"button\"\n >\n {isNoopOnly ? messages.noChanges : messages.applyDns}\n </button>\n </>\n ) : (\n <>\n <BaseDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.close}\n </BaseDialog.Close>\n <button\n data-domainkit-part=\"provisioning-retry\"\n onClick={() => controller.retry()}\n type=\"button\"\n >\n {messages.retry}\n </button>\n </>\n )}\n </div>\n </BaseDialog.Popup>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n );\n}\n\nexport function RetryAction({ controller }: { readonly controller: Controller }) {\n const { messages } = useDomainKit();\n const state = controller.state;\n if (state._tag !== \"Failure\" && state._tag !== \"Stale\" && state._tag !== \"Partial\") return null;\n return (\n <button\n data-domainkit-part=\"provisioning-retry\"\n onClick={() => controller.retry()}\n type=\"button\"\n >\n {messages.retry}\n </button>\n );\n}\n\nexport interface FlowProps extends Omit<RootProps, \"status\"> {\n readonly connection: Transport.Connected;\n readonly onApplied?: (\n result: Extract<Transport.ApplyResult, { readonly _tag: \"Applied\" | \"Partial\" }>,\n ) => void;\n readonly records: ReadonlyArray<Transport.DnsRecord>;\n readonly showRecords?: boolean;\n readonly trigger?: ReactElement;\n}\n\nexport function Flow({\n connection,\n onApplied,\n records,\n showRecords = true,\n trigger,\n ...props\n}: FlowProps) {\n const controller = useController(connection, records, onApplied);\n const state = controller.state;\n return (\n <Root status={state._tag} {...props}>\n {showRecords ? <Records.Table records={records} /> : null}\n <Dialog controller={controller} {...(trigger === undefined ? {} : { trigger })} />\n </Root>\n );\n}\n","import { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { useAtomSet, useAtomValue } from \"@effect/atom-react\";\nimport { Transport } from \"domainkit\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport { useMemo } from \"react\";\n\nimport { failureFromError, recordsIdentity, type Failure } from \"./atom.ts\";\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { Status as RecordStatus } from \"./records.tsx\";\n\ntype LocalState = Data.TaggedEnum<{\n Failed: { readonly failure: Failure; readonly previous?: Transport.Observation };\n Idle: {};\n Observing: { readonly previous?: Transport.Observation };\n}>;\nexport const State = Data.taggedEnum<LocalState>();\nexport type State = LocalState | Transport.Observation;\n\nexport interface ObserveConfig {\n readonly connection?: Transport.Connected;\n readonly domain: string;\n readonly records: ReadonlyArray<Transport.DnsRecord>;\n readonly sources?: {\n readonly provider?: boolean;\n readonly publicDns?: boolean;\n };\n}\n\nexport type Command = Data.TaggedEnum<{\n Observe: {};\n Reset: {};\n}>;\nexport const Command = Data.taggedEnum<Command>();\n\nexport interface Model {\n readonly command: Atom.AtomResultFn<Command, void>;\n readonly state: Atom.Atom<State>;\n}\n\nexport interface Controller {\n readonly observe: () => void;\n readonly reset: () => void;\n readonly state: State;\n}\n\nexport function useModel(config: ObserveConfig): Model {\n const { runtime } = useDomainKit();\n const provider = config.sources?.provider ?? config.connection !== undefined;\n const publicDns = config.sources?.publicDns ?? true;\n const recordKey = recordsIdentity(config.records);\n return useMemo(() => {\n const state = Atom.make<State>(State.Idle());\n const observe = runtime.fn<Command>()((command, get) => {\n if (command._tag === \"Reset\") {\n get.set(state, State.Idle());\n return Effect.void;\n }\n const current = get(state);\n if (current._tag === \"Observing\") return Effect.void;\n const previous =\n current._tag === \"Observation\"\n ? current\n : current._tag === \"Failed\"\n ? current.previous\n : undefined;\n get.set(state, State.Observing({ ...(previous === undefined ? {} : { previous }) }));\n return Effect.flatMap(Transport.Service, (transport) =>\n transport.verification.observe({\n ...(config.connection === undefined\n ? {}\n : { attachmentId: config.connection.attachment.id }),\n domain: config.domain,\n records: config.records,\n sources: { provider, publicDns },\n }),\n ).pipe(\n Effect.tap((observation) => Effect.sync(() => get.set(state, observation))),\n Effect.catch((error) =>\n Effect.sync(() =>\n get.set(\n state,\n State.Failed({\n failure: failureFromError(error),\n ...(previous === undefined ? {} : { previous }),\n }),\n ),\n ),\n ),\n Effect.asVoid,\n );\n });\n return { command: observe, state };\n }, [config.connection?.attachment.id, config.domain, provider, publicDns, recordKey, runtime]);\n}\n\nexport function useController(config: ObserveConfig): Controller {\n const model = useModel(config);\n const state = useAtomValue(model.state);\n const dispatch = useAtomSet(model.command);\n const observe = () => dispatch(Command.Observe());\n const reset = () => dispatch(Command.Reset());\n return { observe, reset, state };\n}\n\nconst evidenceNote = (evidence: Transport.ObservationEvidence): string | undefined => {\n switch (evidence._tag) {\n case \"Mismatch\":\n case \"Unavailable\":\n return evidence.message;\n case \"Found\":\n case \"Missing\":\n return undefined;\n default: {\n const _exhaustive: never = evidence;\n return _exhaustive;\n }\n }\n};\n\nconst observationGroups = (\n observation: Transport.Observation,\n): ReadonlyArray<{\n readonly evidence: ReadonlyArray<Transport.ObservationEvidence>;\n readonly label: string;\n}> =>\n [\n { evidence: observation.provider, label: \"Provider\" },\n { evidence: observation.publicDns, label: \"Public DNS\" },\n ].filter((group) => group.evidence.length > 0);\n\nexport interface RootProps extends PartProps<\"div\", { readonly status: State[\"_tag\"] }> {\n readonly status: State[\"_tag\"];\n}\n\nexport function Root({ status, ...props }: RootProps) {\n return usePart(\n \"div\",\n props,\n { status },\n { \"data-domainkit-part\": \"verification-status\", \"data-state\": status },\n );\n}\n\nexport function Evidence({ observation }: { readonly observation: Transport.Observation }) {\n return (\n <div data-domainkit-part=\"observation-list\">\n {observationGroups(observation).map((group) => (\n <section data-domainkit-part=\"observation-group\" key={group.label}>\n <h3 data-domainkit-part=\"observation-source\">{group.label}</h3>\n <ul>\n {group.evidence.map((evidence, index) => {\n const note = evidenceNote(evidence);\n return (\n <li key={`${evidence._tag}-${evidence.recordId}-${index}`}>\n <div data-domainkit-part=\"observation-row\">\n <span data-domainkit-part=\"observation-record\">{evidence.recordId}</span>\n <RecordStatus evidence={evidence} />\n </div>\n {note === undefined ? null : <p data-domainkit-part=\"observation-note\">{note}</p>}\n </li>\n );\n })}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n\nexport function Outcome({ state }: { readonly state: State }) {\n if (state._tag !== \"Failed\") return null;\n return (\n <p data-domainkit-part=\"flow-outcome\" data-tone=\"danger\" role=\"alert\">\n {state.failure.message}\n </p>\n );\n}\n\nexport interface ObserveActionProps extends PartProps<\n \"button\",\n { readonly status: State[\"_tag\"] }\n> {\n readonly controller: Controller;\n}\n\nexport function ObserveAction({ controller, ...props }: ObserveActionProps) {\n const { messages } = useDomainKit();\n const observing = controller.state._tag === \"Observing\";\n return usePart(\n \"button\",\n props,\n { status: controller.state._tag },\n {\n \"aria-busy\": observing,\n children: messages.checkDns,\n \"data-domainkit-part\": \"observe-action\",\n \"data-loading\": observing ? \"\" : undefined,\n disabled: observing,\n onClick: () => controller.observe(),\n type: \"button\",\n },\n );\n}\n\nexport interface StatusProps extends Omit<RootProps, \"status\"> {\n readonly config: ObserveConfig;\n}\n\nexport function Status({ config, ...props }: StatusProps) {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const controller = useController(config);\n const state = controller.state;\n const observation =\n state._tag === \"Observation\"\n ? state\n : state._tag === \"Observing\" || state._tag === \"Failed\"\n ? state.previous\n : undefined;\n return (\n <Root status={state._tag} {...props}>\n <BasePopover.Root>\n <BasePopover.Trigger render={<ObserveAction controller={controller} />} />\n <BasePopover.Portal container={portalContainer}>\n <BasePopover.Positioner\n align=\"end\"\n data-domainkit-part=\"verification-positioner\"\n sideOffset={6}\n >\n <BasePopover.Popup\n aria-label={messages.checkDns}\n aria-busy={state._tag === \"Observing\"}\n data-color-scheme={colorScheme}\n data-domainkit-part=\"verification-popover\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <BasePopover.Arrow data-domainkit-part=\"verification-arrow\" />\n {state._tag === \"Observing\" ? (\n <p data-domainkit-part=\"verification-progress\" role=\"status\">\n {messages.checkingDns}\n </p>\n ) : null}\n {observation === undefined ? null : <Evidence observation={observation} />}\n <Outcome state={state} />\n </BasePopover.Popup>\n </BasePopover.Positioner>\n </BasePopover.Portal>\n </BasePopover.Root>\n </Root>\n );\n}\n\nexport type Observation = Transport.Observation;\n","import { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { Menu as BaseMenu } from \"@base-ui/react/menu\";\nimport type { Transport } from \"domainkit\";\nimport { useRef, useState, type RefObject } from \"react\";\n\nimport * as Cleanup from \"./cleanup.tsx\";\nimport * as Connection from \"./connection.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport * as Provider from \"./provider.tsx\";\nimport * as Provisioning from \"./provisioning.tsx\";\nimport * as Records from \"./records.tsx\";\nimport * as Verification from \"./verification.tsx\";\n\nexport interface FlowProps {\n readonly domain: string;\n readonly receiptId?: string;\n readonly records: ReadonlyArray<Transport.DnsRecord>;\n}\n\nexport function Flow({ domain, receiptId, records }: FlowProps) {\n const controller = Connection.useController(domain);\n const state = controller.state;\n const connected =\n state._tag === \"Connected\" ? state : state._tag === \"Detaching\" ? state.snapshot : undefined;\n return (\n <Connection.Root status={state._tag}>\n {state._tag === \"Connected\" || state._tag === \"Detaching\" ? (\n <ConnectedCard\n connection={state._tag === \"Connected\" ? state : state.snapshot}\n controller={controller}\n {...(receiptId === undefined ? {} : { initialReceiptId: receiptId })}\n records={records}\n status={state._tag}\n />\n ) : (\n <AvailableCard controller={controller} state={state} />\n )}\n <Records.Table records={records} />\n <Verification.Status\n config={{\n ...(connected === undefined ? {} : { connection: connected }),\n domain,\n records,\n }}\n />\n </Connection.Root>\n );\n}\n\nfunction AvailableCard({\n controller,\n state,\n}: {\n readonly controller: Connection.Controller;\n readonly state: Exclude<Connection.State, Transport.Connected>;\n}) {\n const { messages } = useDomainKit();\n const snapshot =\n state._tag === \"Disconnected\"\n ? state\n : state._tag === \"Submitting\" || state._tag === \"Redirecting\"\n ? state.snapshot\n : undefined;\n return (\n <Connection.Card status={state._tag}>\n <Connection.CardIdentity status={state._tag}>\n {snapshot === undefined ? null : <Provider.Mark provider={snapshot.provider} />}\n <Connection.Status state={state} />\n </Connection.CardIdentity>\n <Connection.CardActions status={state._tag}>\n {state._tag === \"Failure\" && state.retry !== \"never\" ? (\n <Connection.RetryAction\n controller={controller}\n kind={state.retry === \"after-user-action\" ? \"after-user-action\" : \"retry\"}\n />\n ) : null}\n {snapshot === undefined ? null : (\n <BaseDialog.Root\n onOpenChange={(open, eventDetails) => {\n if (!open && (state._tag === \"Submitting\" || state._tag === \"Redirecting\")) {\n eventDetails.cancel();\n }\n }}\n >\n <Connection.ConnectTrigger\n disabled={state._tag === \"Submitting\" || state._tag === \"Redirecting\"}\n provider={snapshot.provider}\n >\n {messages.connectProvider(snapshot.provider.name)}\n </Connection.ConnectTrigger>\n <Connection.Dialog controller={controller} snapshot={snapshot} />\n </BaseDialog.Root>\n )}\n </Connection.CardActions>\n </Connection.Card>\n );\n}\n\nfunction ConnectedCard({\n connection,\n controller,\n initialReceiptId,\n records,\n status,\n}: {\n readonly connection: Transport.Connected;\n readonly controller: Connection.Controller;\n readonly initialReceiptId?: string;\n readonly records: ReadonlyArray<Transport.DnsRecord>;\n readonly status: \"Connected\" | \"Detaching\";\n}) {\n const [receipt, setReceipt] = useState({\n host: initialReceiptId,\n value: initialReceiptId,\n });\n if (receipt.host !== initialReceiptId) {\n setReceipt({ host: initialReceiptId, value: initialReceiptId });\n }\n const receiptId = receipt.host === initialReceiptId ? receipt.value : initialReceiptId;\n const disabled = status === \"Detaching\";\n const actionsTriggerRef = useRef<HTMLButtonElement>(null);\n return (\n <Connection.Card status={status}>\n <Connection.CardIdentity status={status}>\n <Provider.Mark provider={connection.provider} />\n <Connection.Status state={status === \"Connected\" ? connection : controller.state} />\n </Connection.CardIdentity>\n <Connection.CardActions status={status}>\n <Provisioning.Flow\n connection={connection}\n onApplied={(result) => setReceipt({ host: initialReceiptId, value: result.receiptId })}\n records={records}\n showRecords={false}\n />\n {receiptId === undefined ? (\n <ProviderActions\n actionsTriggerRef={actionsTriggerRef}\n connection={connection}\n controller={controller}\n disabled={disabled}\n />\n ) : (\n <ProviderActionsWithCleanup\n actionsTriggerRef={actionsTriggerRef}\n connection={connection}\n controller={controller}\n disabled={disabled}\n key={receiptId}\n onCleaned={() => setReceipt({ host: initialReceiptId, value: undefined })}\n receiptId={receiptId}\n />\n )}\n </Connection.CardActions>\n </Connection.Card>\n );\n}\n\nfunction ProviderActionsWithCleanup({\n actionsTriggerRef,\n connection,\n controller,\n disabled,\n onCleaned,\n receiptId,\n}: {\n readonly actionsTriggerRef: RefObject<HTMLButtonElement | null>;\n readonly connection: Transport.Connected;\n readonly controller: Connection.Controller;\n readonly disabled: boolean;\n readonly onCleaned: () => void;\n readonly receiptId: string;\n}) {\n const [cleaned, setCleaned] = useState(false);\n const cleanup = Cleanup.useController(connection, receiptId, (result) => {\n if (result._tag === \"Cleaned\") setCleaned(true);\n });\n return (\n <ProviderActions\n actionsTriggerRef={actionsTriggerRef}\n cleanup={cleanup}\n connection={connection}\n controller={controller}\n disabled={disabled}\n onCleanupCloseComplete={() => {\n if (cleaned) onCleaned();\n }}\n />\n );\n}\n\nfunction ProviderActions({\n actionsTriggerRef: actionsTriggerRefProp,\n cleanup,\n connection,\n controller,\n disabled,\n onCleanupCloseComplete,\n}: {\n readonly actionsTriggerRef?: RefObject<HTMLButtonElement | null>;\n readonly cleanup?: Cleanup.Controller;\n readonly connection: Transport.Connected;\n readonly controller: Connection.Controller;\n readonly disabled: boolean;\n readonly onCleanupCloseComplete?: () => void;\n}) {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const fallbackActionsTriggerRef = useRef<HTMLButtonElement>(null);\n const actionsTriggerRef = actionsTriggerRefProp ?? fallbackActionsTriggerRef;\n const [menuOpen, setMenuOpen] = useState(false);\n const [disconnectOpen, setDisconnectOpen] = useState(false);\n return (\n <>\n <BaseMenu.Root disabled={disabled} modal={false} onOpenChange={setMenuOpen} open={menuOpen}>\n <BaseMenu.Trigger\n aria-label={messages.moreActions}\n data-domainkit-part=\"actions-trigger\"\n ref={actionsTriggerRef}\n >\n <span aria-hidden=\"true\">⋯</span>\n </BaseMenu.Trigger>\n <BaseMenu.Portal container={portalContainer} keepMounted>\n <BaseMenu.Positioner align=\"end\" sideOffset={6}>\n <BaseMenu.Popup\n data-color-scheme={colorScheme}\n data-domainkit-part=\"actions-menu\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n {cleanup === undefined ? null : (\n <>\n <BaseMenu.Item\n closeOnClick={false}\n data-domainkit-part=\"actions-item\"\n nativeButton\n onClickCapture={() => {\n setMenuOpen(false);\n queueMicrotask(() => cleanup.plan());\n }}\n render={<button type=\"button\" />}\n >\n {messages.reviewCleanup}\n </BaseMenu.Item>\n <BaseMenu.Separator data-domainkit-part=\"actions-separator\" />\n </>\n )}\n <BaseMenu.Item\n closeOnClick={false}\n data-domainkit-part=\"actions-item\"\n data-tone=\"danger\"\n nativeButton\n onClickCapture={() => {\n setMenuOpen(false);\n queueMicrotask(() => setDisconnectOpen(true));\n }}\n render={<button type=\"button\" />}\n >\n {messages.disconnectDomain}\n </BaseMenu.Item>\n </BaseMenu.Popup>\n </BaseMenu.Positioner>\n </BaseMenu.Portal>\n </BaseMenu.Root>\n {cleanup === undefined ? null : (\n <Cleanup.Dialog\n controller={cleanup}\n onOpenChangeComplete={(open) => {\n if (!open) {\n onCleanupCloseComplete?.();\n queueMicrotask(() => actionsTriggerRef.current?.focus());\n }\n }}\n trigger={null}\n />\n )}\n <Connection.DisconnectDialog\n connection={connection}\n controller={controller}\n onOpenChange={(open) => {\n setDisconnectOpen(open);\n if (!open) queueMicrotask(() => actionsTriggerRef.current?.focus());\n }}\n open={disconnectOpen}\n trigger={null}\n />\n </>\n );\n}\n","import { DomainName, Transport } from \"domainkit\";\nimport type * as Layer from \"effect/Layer\";\n\nexport interface FakeOptions {\n readonly connect?: Transport.ConnectionResult;\n readonly inspect:\n | Transport.ConnectionSnapshot\n | FakeFailure\n | ReadonlyArray<Transport.ConnectionSnapshot | FakeFailure>;\n readonly attach?: Transport.Connected;\n readonly detach?: Transport.DetachResult;\n readonly plan?: Transport.ProvisioningPlan;\n readonly apply?: Transport.ApplyResult;\n readonly observe?: Transport.Observation;\n readonly cleanupPlan?: Transport.CleanupPlan;\n readonly cleanupApply?: Transport.CleanupResult;\n}\n\ninterface FakeFailure {\n readonly _tag: \"Failure\";\n readonly message: string;\n readonly operation?: string;\n readonly retry: Transport.Failure[\"retry\"];\n}\n\nexport interface FakeTransport extends Transport.AsyncInterface, Layer.Layer<Transport.Service> {\n readonly calls: {\n readonly attach: Array<Transport.AttachInput>;\n readonly connect: Array<Transport.ConnectInput>;\n readonly detach: Array<Transport.DetachInput>;\n readonly inspect: Array<Transport.InspectInput>;\n readonly plan: Array<Transport.ProvisioningPlanInput>;\n readonly apply: Array<Transport.ProvisioningApplyInput>;\n readonly observe: Array<Transport.ObserveInput>;\n readonly cleanupPlan: Array<Transport.CleanupPlanInput>;\n readonly cleanupApply: Array<Transport.CleanupApplyInput>;\n };\n}\n\nexport const provider = (overrides: Partial<Transport.Provider> = {}): Transport.Provider => ({\n authentication: [\n Transport.AuthenticationMethod.OAuth({ label: \"Continue with OAuth\" }),\n Transport.AuthenticationMethod.Token({\n label: \"Connect with token\",\n placeholder: \"Paste API token\",\n }),\n ],\n id: \"cloudflare\",\n name: \"Cloudflare\",\n ...overrides,\n});\n\nexport const target = (\n overrides: Partial<Transport.ProviderTarget> = {},\n): Transport.ProviderTarget => ({\n accountId: \"account-1\",\n accountKind: \"account\",\n zoneId: \"zone-1\",\n zoneName: DomainName.parse(\"example.com\"),\n ...overrides,\n});\n\nexport const connection = (\n overrides: Partial<Transport.ProviderConnection> = {},\n): Transport.ProviderConnection => ({\n createdAt: new Date(\"2026-08-30T00:00:00.000Z\"),\n id: \"connection-1\",\n method: \"oauth2\",\n ownerId: \"organization-1\",\n providerId: \"cloudflare\",\n status: \"active\",\n ...overrides,\n});\n\nexport const attachment = (\n overrides: Partial<Transport.DomainAttachment> = {},\n): Transport.DomainAttachment => ({\n connectionId: \"connection-1\",\n createdAt: new Date(\"2026-08-30T00:00:00.000Z\"),\n domain: DomainName.parse(\"mail.example.com\"),\n id: \"attachment-1\",\n target: target(),\n ...overrides,\n});\n\nexport const connected = (overrides: Partial<Transport.Connected> = {}): Transport.Connected =>\n Transport.Connected({\n attachment: attachment(),\n connection: connection(),\n provider: provider(),\n ...overrides,\n });\n\nexport function makeFakeTransport(options: FakeOptions): FakeTransport {\n const calls: FakeTransport[\"calls\"] = {\n apply: [],\n attach: [],\n cleanupApply: [],\n cleanupPlan: [],\n connect: [],\n detach: [],\n inspect: [],\n observe: [],\n plan: [],\n };\n const inspections = Array.isArray(options.inspect) ? [...options.inspect] : [options.inspect];\n const transport: Transport.AsyncInterface = {\n cleanup: {\n apply: async (input) => {\n calls.cleanupApply.push(input);\n return (\n options.cleanupApply ??\n Transport.CleanupResult.Cleaned({\n operationId: \"cleanup-operation-1\",\n results: [],\n })\n );\n },\n plan: async (input) => {\n calls.cleanupPlan.push(input);\n return (\n options.cleanupPlan ??\n Transport.CleanupPlan({\n digest: \"cleanup-digest-1\",\n expiresAt: \"2099-01-01T00:00:00.000Z\",\n operations: [],\n })\n );\n },\n },\n connection: {\n connect: async (input) => {\n calls.connect.push(input);\n return (\n options.connect ??\n Transport.Connected({\n attachment: attachment({ domain: DomainName.parse(input.domain) }),\n connection: connection(),\n provider: provider(),\n })\n );\n },\n inspect: async (input) => {\n calls.inspect.push(input);\n const snapshot = inspections.shift() ?? inspections.at(-1) ?? options.inspect;\n if (Array.isArray(snapshot)) throw new Error(\"Fake inspection sequence is empty\");\n if (snapshot._tag === \"Failure\")\n throw new Transport.Failure({\n message: snapshot.message,\n operation: snapshot.operation ?? \"connection.inspect\",\n retry: snapshot.retry,\n });\n return snapshot;\n },\n attach: async (input) => {\n calls.attach.push(input);\n return (\n options.attach ??\n Transport.Connected({\n attachment: attachment({\n connectionId: input.connectionId,\n domain: DomainName.parse(input.domain),\n target: input.target,\n }),\n connection: connection({ id: input.connectionId }),\n provider: provider(),\n })\n );\n },\n detach: async (input) => {\n calls.detach.push(input);\n return (\n options.detach ??\n Transport.DetachResult({\n attachment: attachment(),\n connection: connection(),\n remainingAttachments: 0,\n })\n );\n },\n },\n provisioning: {\n apply: async (input) => {\n calls.apply.push(input);\n return (\n options.apply ??\n Transport.ApplyResult.Applied({\n operationId: \"apply-operation-1\",\n receiptId: \"receipt-1\",\n results: [],\n })\n );\n },\n plan: async (input) => {\n calls.plan.push(input);\n return (\n options.plan ??\n Transport.ProvisioningPlan({\n digest: \"plan-digest-1\",\n expiresAt: \"2099-01-01T00:00:00.000Z\",\n operations: input.records.map((record) =>\n Transport.PlanOperation.Create({\n id: `create-${record.id}`,\n record,\n }),\n ),\n })\n );\n },\n },\n verification: {\n observe: async (input) => {\n calls.observe.push(input);\n return (\n options.observe ??\n Transport.Observation({\n provider: input.sources.provider\n ? input.records.map((record) =>\n Transport.ObservationEvidence.Found({ recordId: record.id }),\n )\n : [],\n publicDns: input.sources.publicDns\n ? input.records.map((record) =>\n Transport.ObservationEvidence.Found({ recordId: record.id }),\n )\n : [],\n })\n );\n },\n },\n };\n return Object.assign(Transport.layerFromAsync(transport), transport, { calls });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAa,UAAU,KAAK,WAAoB;AAEhD,MAAa,oBAAoB,UAC/B,QAAQ,QAAQ;CACd,SAAS,MAAM;CACf,WAAW,MAAM;CACjB,OAAO,MAAM;AACf,CAAC;AAEH,MAAa,qBAAqB,WAAmB,YACnD,QAAQ,QAAQ;CAAE;CAAS;CAAW,OAAO;AAAO,CAAC;AAEvD,MAAa,mBAAmB,YAC9B,KAAK,UACH,QAAQ,KAAK,EAAE,IAAI,MAAM,UAAU,MAAM,aAAa;CAAE;CAAI;CAAM;CAAU;CAAM;AAAM,EAAE,CAC5F;;;ACbF,SAAgB,QAId,gBACA,gBACA,OACA,eACc;CACd,MAAM,EAAE,WAAW,QAAQ,OAAO,GAAG,kBAAkB;CACvD,MAAM,aAGF;EACF,GAAI,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,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,KAAK,KAAK;IACtB,OACE,QAAQ,SACR,UAAU,YAAY,QAAQ;KAC5B,aAAa;KACb,WAAW;KACX,SAAS,CAAC;IACZ,CAAC;GAEL;GACA,MAAM,OAAO,UAAU;IACrB,MAAM,KAAK,KAAK,KAAK;IACrB,OACE,QAAQ,QACR,UAAU,iBAAiB;KACzB,QAAQ;KACR,WAAW;KACX,YAAY,MAAM,QAAQ,KAAK,WAC7B,UAAU,cAAc,OAAO;MAC7B,IAAI,UAAU,OAAO;MACrB;KACF,CAAC,CACH;IACF,CAAC;GAEL;EACF;EACA,cAAc,EACZ,SAAS,OAAO,UAAU;GACxB,MAAM,QAAQ,KAAK,KAAK;GACxB,OACE,QAAQ,WACR,UAAU,YAAY;IACpB,UAAU,MAAM,QAAQ,WACpB,MAAM,QAAQ,KAAK,WACjB,UAAU,oBAAoB,MAAM,EAAE,UAAU,OAAO,GAAG,CAAC,CAC7D,IACA,CAAC;IACL,WAAW,MAAM,QAAQ,YACrB,MAAM,QAAQ,KAAK,WACjB,UAAU,oBAAoB,MAAM,EAAE,UAAU,OAAO,GAAG,CAAC,CAC7D,IACA,CAAC;GACP,CAAC;EAEL,EACF;CACF;CACA,OAAO,OAAO,OAAO,UAAU,eAAe,SAAS,GAAG,WAAW,EAAE,MAAM,CAAC;AAChF"}
1
+ {"version":3,"file":"index.mjs","names":["Root","mergeMessages","State","Status","Body","Root","Card","Reason","Root","Status","Outcome","describeFailure","Actions","Operations.List","Dialog","BaseDialog","useController","Root","Dialog","Review.Dialog","Actions","Review.Actions","Outcome","Review.Outcome","Status","Review.Status","Flow","State","useController","Root","Outcome","describeFailure","Status","Provider.Mark","Dialog","BaseDialog","Flow","Records.requirementsKey","useController","Root","Dialog","Review.Dialog","Review.Actions","Outcome","Review.Outcome","Status","Review.Status","Flow","RecordStatus","describeFailure","BasePopover","Connect.Card","Connect.Status","Connect.Dialog","Connect.Outcome","Provision.Status","Provision.Actions","Provision.Outcome","Cleanup.Status","Cleanup.Actions","Cleanup.Outcome","Connect.useController","Provision.useController","Cleanup.useController","Verify.useController","Records.Table","Verify.Status"],"sources":["../src/composition.tsx","../src/icons.tsx","../src/messages.ts","../src/theme.ts","../src/domain-kit.tsx","../src/events.ts","../src/task.ts","../src/attempt.ts","../src/records.tsx","../src/operations.tsx","../src/review.tsx","../src/cleanup.tsx","../src/provider.tsx","../src/connect.tsx","../src/provision.tsx","../src/verify.tsx","../src/domain.tsx","../src/testing.ts","../src/failure.ts"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\";\nimport type { CSSProperties, ElementType, ReactElement } from \"react\";\n\nexport type ClassName<State> = string | ((state: State) => string | undefined);\nexport type Style<State> = CSSProperties | ((state: State) => CSSProperties | undefined);\n\n/**\n * What every rendered part accepts: the element's own props, a state-aware `className` and\n * `style`, and Base UI's `render` for replacing the element outright.\n */\nexport type PartProps<\n Tag extends ElementType = \"div\",\n State extends Record<string, unknown> = Record<string, unknown>,\n> = Omit<useRender.ElementProps<Tag>, \"className\" | \"style\"> & {\n readonly className?: ClassName<State>;\n readonly render?: useRender.RenderProp<State>;\n readonly style?: Style<State>;\n};\n\nexport function usePart<\n Tag extends keyof React.JSX.IntrinsicElements,\n State extends Record<string, unknown>,\n>(\n defaultTagName: Tag,\n componentProps: PartProps<Tag, State>,\n state: State,\n internalProps: Record<string, unknown>,\n): ReactElement {\n const { className, render, style, ...externalProps } = componentProps;\n const parameters: useRender.Parameters<State, Element, undefined> & {\n readonly className?: ClassName<State>;\n readonly style?: Style<State>;\n } = {\n ...(className === undefined ? {} : { className }),\n defaultTagName,\n props: [internalProps, externalProps] as unknown as Record<string, unknown>,\n ...(render === undefined ? {} : { render }),\n state,\n ...(style === undefined ? {} : { style }),\n };\n return useRender(parameters);\n}\n\n/** A part with no state of its own: one tag, one `data-domainkit-part`, host props on top. */\nexport function leafPart<Tag extends keyof React.JSX.IntrinsicElements>(\n defaultTagName: Tag,\n part: string,\n) {\n return function Leaf(props: PartProps<Tag, Record<string, unknown>>): ReactElement {\n return usePart(defaultTagName, props, {}, { \"data-domainkit-part\": part });\n };\n}\n","import { createContext, useContext, useMemo, type ReactNode } from \"react\";\n\n/**\n * Every glyph the package draws, in one place. Parts read them from context; none of them takes\n * an icon prop of its own, so a host swaps the whole set once on `DomainKit.Root`.\n */\nexport interface Icons {\n readonly close: ReactNode;\n readonly copied: ReactNode;\n readonly copy: ReactNode;\n readonly download: ReactNode;\n readonly external: ReactNode;\n readonly failure: ReactNode;\n readonly pending: ReactNode;\n readonly success: ReactNode;\n}\n\nfunction Glyph({ children }: { readonly children: ReactNode }) {\n return (\n <svg\n aria-hidden=\"true\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n viewBox=\"0 0 24 24\"\n >\n {children}\n </svg>\n );\n}\n\nexport const defaultIcons = {\n close: (\n <Glyph>\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </Glyph>\n ),\n copied: (\n <Glyph>\n <path d=\"M20 6 9 17l-5-5\" />\n </Glyph>\n ),\n copy: (\n <Glyph>\n <rect height=\"14\" rx=\"2\" width=\"14\" x=\"8\" y=\"8\" />\n <path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />\n </Glyph>\n ),\n download: (\n <Glyph>\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\" />\n <path d=\"m7 10 5 5 5-5\" />\n <path d=\"M12 15V3\" />\n </Glyph>\n ),\n external: (\n <Glyph>\n <path d=\"M15 3h6v6\" />\n <path d=\"M10 14 21 3\" />\n <path d=\"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5\" />\n </Glyph>\n ),\n failure: (\n <Glyph>\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"M15 9 9 15\" />\n <path d=\"m9 9 6 6\" />\n </Glyph>\n ),\n pending: (\n <Glyph>\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"M12 7v5l3 2\" />\n </Glyph>\n ),\n success: (\n <Glyph>\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"m8.5 12.5 2.5 2.5 4.5-5\" />\n </Glyph>\n ),\n} as const satisfies Icons;\n\nconst IconsContext = createContext<Icons>(defaultIcons);\n\nexport function IconsProvider({\n children,\n icons,\n}: {\n readonly children: ReactNode;\n readonly icons?: Partial<Icons>;\n}) {\n const value = useMemo<Icons>(() => ({ ...defaultIcons, ...icons }), [icons]);\n return <IconsContext.Provider value={value}>{children}</IconsContext.Provider>;\n}\n\nexport function useIcons(): Icons {\n return useContext(IconsContext);\n}\n","/**\n * Every string the package can put on screen. Nothing renders a `_tag`, a reason name, or a\n * status literal directly: each one arrives here first, so a host translates the whole surface by\n * passing `messages` to `DomainKit.Root`.\n */\nimport type { DnsRecord, DomainKit, Plan, Reason, Receipt, Storage } from \"domainkit\";\n\nexport interface Catalog {\n // Actions\n readonly connect: string;\n readonly connectWith: (method: string) => string;\n readonly disconnect: string;\n readonly detach: string;\n readonly cancel: string;\n readonly close: string;\n readonly retry: string;\n readonly approve: string;\n readonly decline: string;\n readonly reviewChanges: string;\n readonly cleanUp: string;\n readonly checkDns: string;\n readonly checkAgain: string;\n readonly moreActions: string;\n readonly copy: string;\n readonly copied: string;\n readonly copyZone: string;\n readonly download: string;\n readonly useConnection: (label: string) => string;\n readonly chooseZone: string;\n readonly getToken: string;\n\n // Progress\n readonly loading: string;\n readonly connecting: string;\n readonly redirecting: string;\n readonly detaching: string;\n readonly disconnecting: string;\n readonly planning: string;\n readonly approving: string;\n readonly applying: string;\n readonly rejecting: string;\n readonly planningCleanup: string;\n readonly cleaning: string;\n readonly observing: string;\n\n // Connection\n readonly connectTitle: (provider: string) => string;\n /** The dialog heading before a provider is chosen. */\n readonly connectAnyTitle: string;\n readonly connectDescription: (domain: string) => string;\n readonly connectedTo: (provider: string) => string;\n /** Shown where a connect control would be when the customer may not connect. */\n readonly notConnected: string;\n readonly reconnectRequired: (provider: string) => string;\n readonly disconnectTitle: (provider: string) => string;\n readonly disconnectConsent: string;\n readonly detachConsent: string;\n readonly detached: string;\n readonly reusableConnections: string;\n readonly authenticationAlternative: string;\n readonly discoveredConnection: (label: string) => string;\n readonly discoveryAmbiguous: string;\n readonly discoveryNotFound: (nameservers: ReadonlyArray<string>) => string;\n readonly noProviders: string;\n readonly fieldLabel: (name: string) => string;\n readonly optionalField: string;\n\n // Plan review\n readonly planTitle: string;\n readonly planConsent: string;\n readonly cleanupTitle: string;\n readonly cleanupConsent: string;\n readonly noChanges: string;\n readonly planExpires: (at: string) => string;\n readonly declinedBy: (actor: string) => string;\n readonly declineReason: (reason: string) => string;\n readonly operation: (operation: Plan.Operation) => string;\n readonly conflictReason: (reason: Plan.Conflict[\"reason\"]) => string;\n readonly attemptStatus: (status: Storage.AttemptStatus) => string;\n\n // Records\n readonly recordsCaption: (domain: string) => string;\n readonly headingType: string;\n readonly headingName: string;\n readonly headingValue: string;\n readonly headingStatus: string;\n readonly headingPurpose: string;\n readonly priority: (priority: number) => string;\n readonly ttl: (seconds: number) => string;\n readonly recordType: (record: DnsRecord.Observed) => string;\n\n // Receipts\n readonly applied: (receipt: Receipt.Model) => string;\n readonly cleaned: (receipt: Receipt.Model) => string;\n readonly partiallyApplied: string;\n readonly partiallyCleaned: string;\n readonly outcome: (outcome: Receipt.Outcome) => string;\n readonly skippedReason: (reason: Receipt.Skipped[\"reason\"]) => string;\n\n // Verification\n readonly requirementStatus: (status: Storage.RequirementStatus) => string;\n readonly overall: (overall: Storage.Overall) => string;\n readonly evidenceSource: (evidence: EvidenceLike) => string;\n readonly hostEvidenceStatus: (status: \"failed\" | \"ok\" | \"pending\") => string;\n /** What the requirement asks for, shown when an observation disagrees with it. */\n readonly expectedValue: (value: string) => string;\n /** What one observer actually read back for that name. */\n readonly observedValues: (values: ReadonlyArray<string>) => string;\n readonly observedNothing: string;\n readonly checkedAt: (at: string) => string;\n readonly nextCheckAt: (at: string) => string;\n readonly hostEvidence: string;\n readonly noEvidence: string;\n\n // Failures, rendered from the error's reason\n readonly invalidInput: (reason: Reason.InvalidInput) => string;\n readonly unauthenticated: (reason: Reason.Unauthenticated) => string;\n readonly forbidden: (reason: Reason.Forbidden) => string;\n readonly notFound: (reason: Reason.NotFound) => string;\n readonly conflict: (reason: Reason.Conflict) => string;\n readonly stale: (reason: Reason.Stale) => string;\n readonly expired: (reason: Reason.Expired) => string;\n readonly busy: (reason: Reason.Busy) => string;\n readonly providerRejected: (reason: Reason.ProviderRejected) => string;\n readonly providerUnavailable: (reason: Reason.ProviderUnavailable) => string;\n readonly providerConflict: (reason: Reason.ProviderConflict) => string;\n readonly unsupported: (reason: Reason.Unsupported) => string;\n readonly reconnect: (reason: Reason.Reconnect) => string;\n readonly storageFailed: (reason: Reason.StorageFailed) => string;\n readonly cryptoFailed: (reason: Reason.CryptoFailed) => string;\n readonly resolverFailed: (reason: Reason.ResolverFailed) => string;\n}\n\n/** The evidence shapes `Verify` produces, structurally, so the catalog needs no service import. */\nexport type EvidenceLike =\n | { readonly _tag: \"Host\"; readonly source: string; readonly label: string }\n | { readonly _tag: \"Provider\"; readonly provider: string }\n | { readonly _tag: \"PublicDns\"; readonly resolver: string };\n\nconst entity: Readonly<Record<Reason.NotFound[\"entity\"], string>> = {\n approval: \"approval\",\n attachment: \"domain attachment\",\n authorization: \"provider authorization\",\n connection: \"provider connection\",\n continuation: \"sign-in attempt\",\n plan: \"plan\",\n provider: \"provider\",\n receipt: \"receipt\",\n record: \"DNS record\",\n zone: \"DNS zone\",\n};\n\nconst expiredEntity: Readonly<Record<Reason.Expired[\"entity\"], string>> = {\n approval: \"approval\",\n continuation: \"sign-in attempt\",\n credential: \"provider credential\",\n plan: \"plan\",\n};\n\nconst recordTypes: Readonly<Record<Exclude<DnsRecord.Observed[\"_tag\"], \"Opaque\">, string>> = {\n A: \"A\",\n AAAA: \"AAAA\",\n CAA: \"CAA\",\n CNAME: \"CNAME\",\n MX: \"MX\",\n NS: \"NS\",\n SRV: \"SRV\",\n TXT: \"TXT\",\n};\n\n/** `accountId` reads as \"Account id\" until a host names the field itself. */\nconst humanize = (name: string): string => {\n const spaced = name\n .replaceAll(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replaceAll(/[_-]+/g, \" \")\n .trim();\n return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();\n};\n\nexport const english: Catalog = {\n connect: \"Connect\",\n connectWith: (method) => method,\n disconnect: \"Disconnect\",\n detach: \"Detach domain\",\n cancel: \"Cancel\",\n close: \"Close\",\n retry: \"Try again\",\n approve: \"Approve\",\n decline: \"Decline\",\n reviewChanges: \"Review changes\",\n cleanUp: \"Remove records\",\n checkDns: \"Check DNS\",\n checkAgain: \"Check again\",\n moreActions: \"More actions\",\n copy: \"Copy\",\n copied: \"Copied\",\n copyZone: \"Copy zone file\",\n download: \"Download\",\n useConnection: (label) => `Use ${label}`,\n chooseZone: \"Choose the zone that serves this domain\",\n getToken: \"Where do I find this?\",\n\n loading: \"Loading…\",\n connecting: \"Connecting…\",\n redirecting: \"Opening the provider…\",\n detaching: \"Detaching…\",\n disconnecting: \"Disconnecting…\",\n planning: \"Preparing DNS changes…\",\n approving: \"Approving…\",\n applying: \"Adding records…\",\n rejecting: \"Declining…\",\n planningCleanup: \"Preparing cleanup…\",\n cleaning: \"Removing records…\",\n observing: \"Checking DNS…\",\n\n connectTitle: (provider) => `Connect ${provider}`,\n connectAnyTitle: \"Connect your DNS provider\",\n connectDescription: (domain) => `Authorize DNS changes for ${domain}.`,\n connectedTo: (provider) => `${provider} connected`,\n notConnected: \"No DNS provider is connected.\",\n reconnectRequired: (provider) => `${provider} needs to be reconnected`,\n disconnectTitle: (provider) => `Disconnect ${provider}?`,\n disconnectConsent: \"The provider connection is removed. Existing DNS records are preserved.\",\n detachConsent: \"This domain is detached from the provider. Existing DNS records are preserved.\",\n detached: \"Domain detached. DNS records were preserved.\",\n reusableConnections: \"Connections you already have\",\n authenticationAlternative: \"or\",\n discoveredConnection: (label) => `${label} already serves this domain`,\n discoveryAmbiguous: \"More than one connection can serve this domain. Pick one.\",\n discoveryNotFound: (nameservers) =>\n nameservers.length === 0\n ? \"No connected provider serves this domain yet.\"\n : `No connected provider serves this domain. Its nameservers are ${nameservers.join(\", \")}.`,\n noProviders: \"No DNS providers are available.\",\n fieldLabel: humanize,\n optionalField: \"optional\",\n\n planTitle: \"Review DNS changes\",\n planConsent: \"Review the exact DNS operations before approving this plan.\",\n cleanupTitle: \"Review the records to remove\",\n cleanupConsent: \"Only records the apply receipt proves DomainKit created will be deleted.\",\n noChanges: \"No changes needed\",\n planExpires: (at) => `This plan expires at ${at}.`,\n declinedBy: (actor) => `Declined by ${actor}. Build a new plan to continue.`,\n declineReason: (reason) => `Reason: ${reason}`,\n operation: (operation) => {\n switch (operation._tag) {\n case \"Create\":\n return \"Add\";\n case \"Noop\":\n return \"Already in place\";\n case \"Delete\":\n return \"Remove\";\n case \"Conflict\":\n return \"Blocked\";\n }\n },\n conflictReason: (reason) => {\n switch (reason) {\n case \"exclusive-name\":\n return \"Another record already owns this name.\";\n case \"cname-collision\":\n return \"A CNAME cannot share a name with other records.\";\n case \"value-mismatch\":\n return \"A record with this name holds a different value.\";\n case \"opaque\":\n return \"A record here uses a form DomainKit will not overwrite.\";\n case \"missing\":\n return \"The record this plan expected is gone.\";\n }\n },\n attemptStatus: (status) => {\n switch (status) {\n case \"planned\":\n return \"Awaiting review\";\n case \"approved\":\n return \"Approved\";\n case \"applying\":\n return \"Applying\";\n case \"complete\":\n return \"Applied\";\n case \"partial\":\n return \"Partly applied\";\n case \"failed\":\n return \"Failed\";\n case \"expired\":\n return \"Expired\";\n case \"rejected\":\n return \"Declined\";\n }\n },\n\n recordsCaption: (domain) => `DNS records for ${domain}`,\n headingType: \"Type\",\n headingName: \"Name\",\n headingValue: \"Value\",\n headingStatus: \"Status\",\n headingPurpose: \"Purpose\",\n priority: (priority) => `Priority ${priority}`,\n ttl: (seconds) => `TTL ${seconds}s`,\n recordType: (record) => (record._tag === \"Opaque\" ? record.type : recordTypes[record._tag]),\n\n applied: (receipt) =>\n receipt.status === \"complete\" ? \"DNS records added.\" : \"Some DNS records were not added.\",\n cleaned: (receipt) =>\n receipt.status === \"complete\" ? \"DNS records removed.\" : \"Some DNS records were not removed.\",\n partiallyApplied: \"Some DNS changes failed. Review and retry safely.\",\n partiallyCleaned: \"Some DNS records could not be deleted. Review and retry safely.\",\n outcome: (outcome) => {\n switch (outcome._tag) {\n case \"Applied\":\n return \"Done\";\n case \"Skipped\":\n return \"Skipped\";\n case \"Failed\":\n return outcome.message;\n }\n },\n skippedReason: (reason) => {\n switch (reason) {\n case \"noop\":\n return \"The record was already in place.\";\n case \"not-approved\":\n return \"The approval left this operation out.\";\n case \"not-attempted\":\n return \"An earlier operation failed before this one ran.\";\n }\n },\n\n requirementStatus: (status) => {\n switch (status) {\n case \"satisfied\":\n return \"Found\";\n case \"missing\":\n return \"Missing\";\n case \"mismatch\":\n return \"Different value\";\n case \"unknown\":\n return \"Not checked\";\n }\n },\n overall: (overall) => {\n switch (overall) {\n case \"ready\":\n return \"Ready\";\n case \"pending\":\n return \"Pending\";\n case \"failed\":\n return \"Failed\";\n }\n },\n evidenceSource: (evidence) => {\n switch (evidence._tag) {\n case \"Host\":\n return evidence.label;\n case \"Provider\":\n return `${evidence.provider} records`;\n case \"PublicDns\":\n return `Public DNS via ${evidence.resolver}`;\n }\n },\n hostEvidenceStatus: (status) => {\n switch (status) {\n case \"ok\":\n return \"Ready\";\n case \"pending\":\n return \"Pending\";\n case \"failed\":\n return \"Failed\";\n }\n },\n expectedValue: (value) => `Expected ${value}`,\n observedValues: (values) => `Found ${values.join(\", \")}`,\n observedNothing: \"Found nothing\",\n checkedAt: (at) => `Checked ${at}`,\n nextCheckAt: (at) => `Next check ${at}`,\n hostEvidence: \"Other checks\",\n noEvidence: \"Nothing has been checked yet.\",\n\n invalidInput: (reason) =>\n reason.field === undefined ? reason.message : `${humanize(reason.field)}: ${reason.message}`,\n unauthenticated: () => \"The provider rejected these credentials.\",\n forbidden: () => \"You do not have access to this domain.\",\n notFound: (reason) => `That ${entity[reason.entity]} no longer exists.`,\n conflict: (reason) =>\n reason.operations.length === 1\n ? \"One DNS record conflicts with what is already in the zone.\"\n : `${reason.operations.length} DNS records conflict with what is already in the zone.`,\n stale: () => \"The zone changed while you were reviewing. Build a new plan.\",\n expired: (reason) => `That ${expiredEntity[reason.entity]} expired. Start again.`,\n busy: () => \"Another change is running. Try again in a moment.\",\n providerRejected: (reason) => `${reason.provider} refused the change: ${reason.message}`,\n providerUnavailable: (reason) => `${reason.provider} is unreachable right now.`,\n providerConflict: (reason) => `${reason.provider} already holds a conflicting record.`,\n unsupported: (reason) => `${reason.provider} cannot ${reason.operation}.`,\n reconnect: (reason) => `Reconnect ${reason.provider} to continue.`,\n storageFailed: () => \"The change could not be saved. Try again.\",\n cryptoFailed: () => \"A stored credential could not be read.\",\n resolverFailed: (reason) => `DNS lookups through ${reason.resolver} failed.`,\n};\n\nexport const merge = (overrides: Partial<Catalog> = {}): Catalog => ({ ...english, ...overrides });\n\n/** The user-facing sentence for a failure, chosen by the error's reason. */\nexport const failure = (error: DomainKit.Error, catalog: Catalog): string => {\n const reason = error.reason;\n switch (reason._tag) {\n case \"InvalidInput\":\n return catalog.invalidInput(reason);\n case \"Unauthenticated\":\n return catalog.unauthenticated(reason);\n case \"Forbidden\":\n return catalog.forbidden(reason);\n case \"NotFound\":\n return catalog.notFound(reason);\n case \"Conflict\":\n return catalog.conflict(reason);\n case \"Stale\":\n return catalog.stale(reason);\n case \"Expired\":\n return catalog.expired(reason);\n case \"Busy\":\n return catalog.busy(reason);\n case \"ProviderRejected\":\n return catalog.providerRejected(reason);\n case \"ProviderUnavailable\":\n return catalog.providerUnavailable(reason);\n case \"ProviderConflict\":\n return catalog.providerConflict(reason);\n case \"Unsupported\":\n return catalog.unsupported(reason);\n case \"Reconnect\":\n return catalog.reconnect(reason);\n case \"StorageFailed\":\n return catalog.storageFailed(reason);\n case \"CryptoFailed\":\n return catalog.cryptoFailed(reason);\n case \"ResolverFailed\":\n return catalog.resolverFailed(reason);\n }\n};\n","import type { CSSProperties } from \"react\";\n\nexport interface Theme {\n readonly accent?: string;\n readonly accentContrast?: string;\n readonly backdrop?: string;\n readonly background?: string;\n readonly border?: string;\n readonly danger?: string;\n readonly dangerContrast?: string;\n readonly fill?: string;\n readonly fontFamily?: string;\n readonly muted?: string;\n readonly radius?: string;\n readonly shadow?: string;\n readonly success?: string;\n readonly text?: string;\n}\n\nconst variables = {\n accent: \"--domainkit-accent\",\n accentContrast: \"--domainkit-accent-contrast\",\n backdrop: \"--domainkit-backdrop\",\n background: \"--domainkit-background\",\n border: \"--domainkit-border\",\n danger: \"--domainkit-danger\",\n dangerContrast: \"--domainkit-danger-contrast\",\n fill: \"--domainkit-fill\",\n fontFamily: \"--domainkit-font-family\",\n muted: \"--domainkit-muted\",\n radius: \"--domainkit-radius\",\n shadow: \"--domainkit-shadow\",\n success: \"--domainkit-success\",\n text: \"--domainkit-text\",\n} as const satisfies Record<keyof Theme, string>;\n\nexport function toStyle(theme: Theme = {}): CSSProperties {\n return Object.fromEntries(\n Object.entries(theme).flatMap(([key, value]) =>\n value === undefined ? [] : [[variables[key as keyof Theme], value]],\n ),\n ) as CSSProperties;\n}\n","import { Transport } from \"domainkit/client\";\nimport * as Effect from \"effect/Effect\";\nimport {\n createContext,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n type ReactNode,\n type RefObject,\n} from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport type { Listener } from \"./events.ts\";\nimport type { Icons } from \"./icons.tsx\";\nimport { IconsProvider } from \"./icons.tsx\";\nimport type { Catalog } from \"./messages.ts\";\nimport { merge as mergeMessages } from \"./messages.ts\";\nimport type { Marks } from \"./provider.tsx\";\nimport type { Theme } from \"./theme.ts\";\nimport { toStyle } from \"./theme.ts\";\n\nexport interface RootState extends Record<string, unknown> {\n readonly colorScheme: \"dark\" | \"inherit\" | \"light\";\n}\n\nexport interface RootProps extends Omit<PartProps<\"div\", RootState>, \"children\"> {\n readonly children: ReactNode;\n readonly colorScheme?: RootState[\"colorScheme\"];\n readonly icons?: Partial<Icons>;\n readonly marks?: Marks;\n readonly messages?: Partial<Catalog>;\n /** Where an interactive provider flow sends the customer. Defaults to `window.location`. */\n readonly navigate?: (url: string) => void;\n readonly onEvent?: Listener;\n readonly portalContainer?: HTMLElement | null;\n /**\n * Render the state without the controls that change it, for a customer who may read the domain\n * but not write to it. Capability gating already hides a group the transport does not declare;\n * this covers authorization the transport cannot express, such as a member of an organisation.\n */\n readonly readOnly?: boolean;\n /** Bump to re-inspect every mounted domain after a change the UI did not make. */\n readonly revision?: number;\n readonly theme?: Theme;\n /** The transport, by value. Rebuilding it inline on every render does not restart controllers. */\n readonly transport: Transport.Interface;\n}\n\ninterface ContextValue {\n readonly capabilities: ReadonlyArray<Transport.Capability>;\n readonly colorScheme: RootState[\"colorScheme\"];\n readonly emit: Listener;\n readonly marks: Marks;\n readonly messages: Catalog;\n readonly navigate: (url: string) => void;\n readonly portalContainer: RefObject<HTMLElement | null>;\n readonly readOnly: boolean;\n readonly revision: number;\n readonly themeStyle: ReturnType<typeof toStyle>;\n readonly transport: Transport.Interface;\n}\n\nconst Context = createContext<ContextValue | null>(null);\n\nconst navigateInBrowser = (url: string): void => {\n if (typeof window === \"undefined\") {\n throw new Error(\"DomainKit provider authorization requires a browser or a `navigate` prop\");\n }\n window.location.assign(url);\n};\n\nexport interface StableTransport {\n readonly transport: Transport.Interface;\n readonly capabilities: ReadonlyArray<Transport.Capability>;\n}\n\ntype Method = (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown>;\n\n/**\n * A transport whose identity survives re-renders. Each method reads the newest transport when it\n * runs, so a host may write `<DomainKit.Root transport={Transport.fromFetch(\"/api/domainkit\")}>`\n * inline and controllers still see one transport for the whole mount. Swapping in a transport\n * that declares different capability groups rebuilds it, and every controller re-runs.\n */\nconst useStableTransport = (transport: Transport.Interface): StableTransport => {\n const latest = useRef(transport);\n useLayoutEffect(() => {\n latest.current = transport;\n });\n const signature = Transport.capabilities(transport).join(\",\");\n return useMemo(() => {\n const capabilities = Transport.capabilities(latest.current);\n const stable = Object.fromEntries(\n capabilities.map((capability) => {\n const group = latest.current[capability] as unknown as Record<string, Method>;\n return [\n capability,\n Object.fromEntries(\n Object.keys(group).map((name) => [\n name,\n (...args: ReadonlyArray<never>) =>\n Effect.suspend(() => {\n const live = latest.current[capability] as unknown as Record<string, Method>;\n const method = live[name];\n if (method === undefined) {\n throw new Error(`The transport no longer declares ${capability}.${name}`);\n }\n return method(...args);\n }),\n ]),\n ),\n ];\n }),\n ) as Transport.Interface;\n return { capabilities, transport: stable };\n }, [signature]);\n};\n\nconst resolvePortalContainer = (\n container: HTMLElement | null,\n ownerDocument: Document | null,\n): HTMLElement | null => {\n if (container === null || ownerDocument === null) return null;\n return container.ownerDocument === ownerDocument && container.getRootNode() === ownerDocument\n ? container\n : null;\n};\n\nconst usePortalContainer = (container: HTMLElement | null): HTMLElement | null => {\n const ownerDocument = useMemo(() => container?.ownerDocument ?? null, [container]);\n const subscribe = useCallback(\n (notify: () => void) => {\n if (ownerDocument === null || typeof MutationObserver === \"undefined\") return () => {};\n const observer = new MutationObserver(notify);\n observer.observe(ownerDocument, { childList: true, subtree: true });\n return () => observer.disconnect();\n },\n [ownerDocument],\n );\n const getSnapshot = useCallback(\n () => resolvePortalContainer(container, ownerDocument),\n [container, ownerDocument],\n );\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n\nexport function Root({\n children,\n colorScheme = \"inherit\",\n icons,\n marks = {},\n messages,\n navigate = navigateInBrowser,\n onEvent,\n portalContainer = null,\n readOnly = false,\n revision = 0,\n theme,\n transport,\n ...props\n}: RootProps) {\n const { capabilities, transport: stable } = useStableTransport(transport);\n const onEventRef = useRef(onEvent);\n useLayoutEffect(() => {\n onEventRef.current = onEvent;\n }, [onEvent]);\n const emit = useCallback<Listener>((event) => {\n try {\n onEventRef.current?.(event);\n } catch {\n // Host observers are best-effort and cannot change a completed operation's outcome.\n }\n }, []);\n const themeStyle = toStyle(theme);\n const resolvedPortalContainer = usePortalContainer(portalContainer);\n const portalContainerRef = useMemo<RefObject<HTMLElement | null>>(\n () => ({ current: resolvedPortalContainer }),\n [resolvedPortalContainer],\n );\n const value: ContextValue = {\n capabilities,\n colorScheme,\n emit,\n marks,\n messages: mergeMessages(messages),\n navigate,\n portalContainer: portalContainerRef,\n readOnly,\n revision,\n themeStyle,\n transport: stable,\n };\n const content = usePart(\n \"div\",\n props,\n { colorScheme },\n {\n children,\n \"data-color-scheme\": colorScheme,\n \"data-domainkit-root\": \"\",\n style: themeStyle,\n },\n );\n return (\n <Context.Provider value={value}>\n <IconsProvider {...(icons === undefined ? {} : { icons })}>{content}</IconsProvider>\n </Context.Provider>\n );\n}\n\nexport function useDomainKit(): ContextValue {\n const value = useContext(Context);\n if (value === null) {\n throw new Error(\"DomainKit components must be rendered inside DomainKit.Root\");\n }\n return value;\n}\n\n/** The transport `DomainKit.Root` holds, with the identity it keeps for the whole mount. */\nexport function useTransport(): Transport.Interface {\n return useDomainKit().transport;\n}\n\nconst ReadOnlyContext = createContext<boolean | null>(null);\n\n/** Narrow one subtree to read-only without touching the rest of the page. */\nexport function ReadOnly({\n children,\n value,\n}: {\n readonly children: ReactNode;\n readonly value: boolean;\n}) {\n return <ReadOnlyContext.Provider value={value}>{children}</ReadOnlyContext.Provider>;\n}\n\n/** Whether this part may offer controls that change the domain. */\nexport function useReadOnly(): boolean {\n const scoped = useContext(ReadOnlyContext);\n const root = useDomainKit().readOnly;\n return scoped ?? root;\n}\n\n/** Which capability groups the host's transport declares, for gating a custom part. */\nexport function useCapabilities(): ReadonlyArray<Transport.Capability> {\n return useDomainKit().capabilities;\n}\n","import type { DomainKit, Receipt } from \"domainkit\";\nimport type { Transport } from \"domainkit/client\";\nimport * as Data from \"effect/Data\";\n\n/** What a customer finished doing, for host notifications, analytics, and audit trails. */\nexport type Event = Data.TaggedEnum<{\n Connected: {\n readonly domain: string;\n readonly connectionId: string;\n readonly snapshot: Transport.Snapshot;\n };\n Detached: { readonly domain: string };\n Disconnected: { readonly domain: string; readonly connectionId: string };\n Applied: { readonly domain: string; readonly receipt: Receipt.Model };\n Cleaned: { readonly domain: string; readonly receipt: Receipt.Model };\n Declined: { readonly domain: string; readonly attempt: Transport.Attempt };\n Failed: { readonly domain: string; readonly error: DomainKit.Error };\n}>;\nexport const Event = Data.taggedEnum<Event>();\n\nexport type Listener = (event: Event) => void;\n","/**\n * The one place the package leaves Effect. Every controller runs its transport calls through\n * `useRunner`, which interrupts the call in flight when a newer one starts or the component\n * unmounts, and drops results that arrive after either.\n */\nimport { DomainKit, Reason } from \"domainkit\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as Option from \"effect/Option\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nexport interface Runner {\n /**\n * Run `effect`, replacing whatever this runner had in flight. `onSuccess` and `onFailure` fire\n * only while this call is still the newest and the component is mounted.\n */\n readonly run: <A>(\n effect: Effect.Effect<A, DomainKit.Error>,\n handlers: {\n readonly onSuccess: (value: A) => void;\n readonly onFailure: (error: DomainKit.Error) => void;\n },\n ) => void;\n /** Stop the call in flight without starting another. */\n readonly cancel: () => void;\n}\n\n/** A defect is not a lifecycle failure; report it in the shape the UI already renders. */\nconst defect = (cause: unknown): DomainKit.Error =>\n new DomainKit.Error({\n reason: new Reason.ProviderUnavailable({\n provider: \"domainkit\",\n message: `The transport failed: ${String(cause)}`,\n }),\n });\n\ninterface Live {\n readonly id: number;\n interrupt: (() => void) | null;\n}\n\nexport function useRunner(): Runner {\n const state = useRef<{ mounted: boolean; next: number; live: Live | null }>({\n live: null,\n mounted: true,\n next: 0,\n });\n useEffect(() => {\n const current = state.current;\n current.mounted = true;\n return () => {\n current.mounted = false;\n current.live?.interrupt?.();\n current.live = null;\n };\n }, []);\n return useMemo<Runner>(() => {\n const stop = () => {\n state.current.live?.interrupt?.();\n state.current.live = null;\n };\n return {\n cancel: stop,\n run: (effect, handlers) => {\n stop();\n const live: Live = { id: (state.current.next += 1), interrupt: null };\n state.current.live = live;\n const interrupt = Effect.runCallback(effect, {\n onExit: (exit) => {\n if (state.current.live?.id !== live.id || !state.current.mounted) return;\n state.current.live = null;\n if (Exit.isSuccess(exit)) {\n handlers.onSuccess(exit.value);\n return;\n }\n // Read both before the interrupt guard: it narrows `exit` to the success side.\n const cause = exit.cause;\n const error = Exit.findErrorOption(exit);\n if (Exit.hasInterrupts(exit)) return;\n handlers.onFailure(Option.isSome(error) ? error.value : defect(cause));\n },\n });\n // A synchronous effect already ran `onExit` and cleared `live`; only a call still in\n // flight needs an interrupt handle.\n if (state.current.live?.id === live.id) live.interrupt = () => interrupt();\n },\n };\n }, []);\n}\n","/**\n * The plan -> approve -> apply machine both `Provision` and `Cleanup` run. They differ only in\n * which plan they build and which event they emit when the receipt lands, so the machine lives\n * here once and each namespace exports its own controller over it.\n */\nimport type { Approval, DomainKit, Plan, Receipt } from \"domainkit\";\nimport type { Transport } from \"domainkit/client\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useDomainKit, useReadOnly } from \"./domain-kit.tsx\";\nimport { Event } from \"./events.ts\";\nimport { useRunner } from \"./task.ts\";\n\nexport type State = Data.TaggedEnum<{\n Idle: {};\n Planning: {};\n Planned: { readonly plan: Plan.Model };\n Approving: { readonly plan: Plan.Model };\n Applying: { readonly plan: Plan.Model; readonly approval: Approval.Model };\n Applied: { readonly plan: Plan.Model | null; readonly receipt: Receipt.Model };\n Rejecting: { readonly plan: Plan.Model };\n Rejected: { readonly plan: Plan.Model; readonly attempt: Transport.Attempt };\n Failure: { readonly error: DomainKit.Error };\n}>;\nexport const State = Data.taggedEnum<State>();\n\n/** The verbs `Provision` and `Cleanup` share on the wire. */\nexport interface Group {\n readonly approve: (input: {\n readonly planId: Plan.PlanId;\n readonly operationIds?: ReadonlyArray<Plan.OperationId>;\n }) => Effect.Effect<Approval.Model, DomainKit.Error>;\n readonly reject: (input: {\n readonly planId: Plan.PlanId;\n readonly reason?: string;\n }) => Effect.Effect<Transport.Attempt, DomainKit.Error>;\n readonly apply: (\n approvalId: Approval.ApprovalId,\n ) => Effect.Effect<Receipt.Model, DomainKit.Error>;\n}\n\nexport interface Controller {\n readonly state: State;\n /** Build a plan. The plan itself rides on the state, from `Planned` through `Applied`. */\n readonly plan: () => void;\n /** Authorize the digest and apply it. Pass `operationIds` to approve part of the plan. */\n readonly approve: (operationIds?: ReadonlyArray<Plan.OperationId>) => void;\n /** Decline the plan. Terminal: approving it afterwards fails `Stale`. */\n readonly reject: (reason?: string) => void;\n /** Apply the approval this controller already holds. */\n readonly apply: () => void;\n /** Re-plan when the zone moved under the plan, otherwise re-run the step that failed. */\n readonly retry: () => void;\n readonly reset: () => void;\n}\n\nexport interface Options {\n readonly domain: string;\n /**\n * Identifies the inputs this attempt is for. When it changes the attempt is abandoned, because a\n * plan, approval, and receipt only mean anything for the inputs that produced them.\n */\n readonly key: string;\n readonly group: Group | undefined;\n /** The plan call, or `null` when this flow has nothing to plan yet. */\n readonly plan: () => Effect.Effect<Plan.Model, DomainKit.Error> | null;\n readonly done: (receipt: Receipt.Model) => Event;\n readonly onDone: ((receipt: Receipt.Model) => void) | undefined;\n}\n\n/** Reasons that mean the plan itself is gone: retrying the same step would fail the same way. */\nconst needsNewPlan = (error: DomainKit.Error): boolean =>\n error.reason._tag === \"Stale\" ||\n error.reason._tag === \"Expired\" ||\n error.reason._tag === \"Conflict\";\n\nexport function useAttempt(options: Options): Controller {\n const { domain, done, group, key, onDone } = options;\n const { emit } = useDomainKit();\n const readOnly = useReadOnly();\n const runner = useRunner();\n const [state, setState] = useState<State>(State.Idle());\n // The key travels with what it produced, so a command raised before the reset commits still\n // refuses to run: a plan built for one domain must never be approved for another.\n const held = useRef<{\n key: string;\n plan: Plan.Model | null;\n approval: Approval.Model | null;\n }>({ approval: null, key, plan: null });\n const lastCommand = useRef<{ key: string; run: () => void } | null>(null);\n const build = useRef(options.plan);\n useEffect(() => {\n build.current = options.plan;\n });\n\n // Abandoning while rendering, not one effect later, is what makes the guards below sound: a\n // reply that lands in between finds the new key already recorded and drops itself.\n const [current, setCurrent] = useState(key);\n if (current !== key) {\n setCurrent(key);\n runner.cancel();\n held.current = { approval: null, key, plan: null };\n lastCommand.current = null;\n setState(State.Idle());\n }\n\n const onFailure = useCallback(\n (error: DomainKit.Error) => {\n setState(State.Failure({ error }));\n emit(Event.Failed({ domain, error }));\n },\n [domain, emit],\n );\n\n const applyWith = useCallback(\n (plan: Plan.Model, approval: Approval.Model) => {\n if (group === undefined || held.current.key !== key) return;\n const command = () => {\n setState(State.Applying({ approval, plan }));\n runner.run(group.apply(approval.id), {\n onFailure,\n onSuccess: (receipt) => {\n setState(State.Applied({ plan, receipt }));\n emit(done(receipt));\n onDone?.(receipt);\n },\n });\n };\n lastCommand.current = { key, run: command };\n command();\n },\n [done, emit, group, key, onDone, onFailure, runner],\n );\n\n const buildPlan = useCallback(() => {\n const effect = build.current();\n if (effect === null) return;\n const command = () => {\n setState(State.Planning());\n runner.run(effect, {\n onFailure,\n onSuccess: (plan) => {\n if (held.current.key !== key) return;\n held.current = { approval: null, key, plan };\n setState(State.Planned({ plan }));\n },\n });\n };\n lastCommand.current = { key, run: command };\n command();\n }, [key, onFailure, runner]);\n\n const approve = useCallback(\n (operationIds?: ReadonlyArray<Plan.OperationId>) => {\n const plan = held.current.plan;\n if (group === undefined || plan === null || held.current.key !== key) return;\n const command = () => {\n setState(State.Approving({ plan }));\n runner.run(\n group.approve({\n planId: plan.id,\n ...(operationIds === undefined ? {} : { operationIds }),\n }),\n {\n onFailure,\n onSuccess: (approval) => {\n if (held.current.key !== key) return;\n held.current = { approval, key, plan };\n applyWith(plan, approval);\n },\n },\n );\n };\n lastCommand.current = { key, run: command };\n command();\n },\n [applyWith, group, key, onFailure, runner],\n );\n\n const reject = useCallback(\n (reason?: string) => {\n const plan = held.current.plan;\n if (group === undefined || plan === null || held.current.key !== key) return;\n const command = () => {\n setState(State.Rejecting({ plan }));\n runner.run(group.reject({ planId: plan.id, ...(reason === undefined ? {} : { reason }) }), {\n onFailure,\n onSuccess: (attempt) => {\n setState(State.Rejected({ attempt, plan }));\n emit(Event.Declined({ attempt, domain }));\n },\n });\n };\n lastCommand.current = { key, run: command };\n command();\n },\n [domain, emit, group, key, onFailure, runner],\n );\n\n const apply = useCallback(() => {\n const { approval, plan } = held.current;\n if (approval === null || plan === null) return;\n applyWith(plan, approval);\n }, [applyWith]);\n\n const retry = useCallback(() => {\n // Every step of an attempt is a write, so read-only has nothing to retry.\n if (readOnly) return;\n if (state._tag === \"Failure\" && needsNewPlan(state.error)) {\n held.current = { approval: null, key, plan: null };\n buildPlan();\n return;\n }\n const command = lastCommand.current;\n if (command === null || command.key !== key) buildPlan();\n else command.run();\n }, [buildPlan, key, readOnly, state]);\n\n const reset = useCallback(() => {\n runner.cancel();\n held.current = { approval: null, key, plan: null };\n lastCommand.current = null;\n setState(State.Idle());\n }, [key, runner]);\n\n return { apply, approve, plan: buildPlan, reject, reset, retry, state };\n}\n","import { DnsRecord } from \"domainkit\";\nimport type { Transport } from \"domainkit/client\";\nimport { useEffect, useRef, useState, type ReactElement } from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { leafPart, usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { useIcons } from \"./icons.tsx\";\n\nexport type Readiness = Transport.Readiness;\nexport type RequirementStatus = Readiness[\"requirements\"][number][\"status\"];\n\n// ---------------------------------------------------------------------------------------------\n// Zone file\n// ---------------------------------------------------------------------------------------------\n\nconst absolute = (value: string): string => (value.endsWith(\".\") ? value : `${value}.`);\n\nconst textEncoder = new TextEncoder();\n\nconst escapeTxtCharacter = (character: string): string => {\n if (character === '\"' || character === \"\\\\\") return `\\\\${character}`;\n const codePoint = character.codePointAt(0);\n if (codePoint !== undefined && (codePoint < 32 || codePoint === 127)) {\n return `\\\\${codePoint.toString().padStart(3, \"0\")}`;\n }\n return character;\n};\n\n/** TXT strings are capped at 255 bytes each, so long values are split and quoted per chunk. */\nconst txtValue = (value: string): string => {\n const chunks: Array<string> = [];\n let chunk = \"\";\n let byteLength = 0;\n for (const character of value) {\n const characterByteLength = textEncoder.encode(character).byteLength;\n if (byteLength + characterByteLength > 255) {\n chunks.push(chunk);\n chunk = \"\";\n byteLength = 0;\n }\n chunk += escapeTxtCharacter(character);\n byteLength += characterByteLength;\n }\n chunks.push(chunk);\n return chunks.map((part) => `\"${part}\"`).join(\" \");\n};\n\n/** The RR type as a zone file spells it. The tag and the type name are the same string. */\nconst rrType = (record: DnsRecord.Model): string => record._tag;\n\nconst zoneData = (record: DnsRecord.Model): string => {\n switch (record._tag) {\n case \"A\":\n case \"AAAA\":\n return record.address;\n case \"CNAME\":\n return absolute(record.target);\n case \"NS\":\n return absolute(record.nameserver);\n case \"TXT\":\n return txtValue(record.value);\n case \"MX\":\n return `${record.priority} ${absolute(record.exchange)}`;\n case \"CAA\":\n return `${record.flags} ${record.tag} \"${record.value}\"`;\n case \"SRV\":\n return `${record.priority} ${record.weight} ${record.port} ${absolute(record.target)}`;\n }\n};\n\nexport const toZoneFile = (records: ReadonlyArray<DnsRecord.Model>): string =>\n `${records\n .map(\n (record) =>\n `${absolute(record.name)}${record.ttl === null ? \"\" : ` ${record.ttl}`} IN ${rrType(record)} ${zoneData(record)}`,\n )\n .join(\"\\n\")}\\n`;\n\nconst downloadText = (filename: string, contents: string): void => {\n if (typeof document === \"undefined\") return;\n const blob = new Blob([contents], { type: \"text/plain;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const anchor = document.createElement(\"a\");\n anchor.download = filename;\n anchor.href = url;\n document.body.append(anchor);\n anchor.click();\n anchor.remove();\n URL.revokeObjectURL(url);\n};\n\nexport const downloadZoneFile = (domain: string, records: ReadonlyArray<DnsRecord.Model>): void =>\n downloadText(`${domain}.txt`, toZoneFile(records));\n\n// ---------------------------------------------------------------------------------------------\n// Copy\n// ---------------------------------------------------------------------------------------------\n\nexport const copyText = (value: string): Promise<boolean> => {\n if (typeof navigator === \"undefined\" || navigator.clipboard === undefined) {\n return Promise.resolve(false);\n }\n return navigator.clipboard.writeText(value).then(\n () => true,\n () => false,\n );\n};\n\nexport interface CopyController {\n readonly copied: boolean;\n readonly copy: () => void;\n}\n\nexport function useCopy(value: string, resetAfter = 2000): CopyController {\n const [copied, setCopied] = useState(false);\n const reset = useRef<ReturnType<typeof setTimeout>>(undefined);\n useEffect(() => () => clearTimeout(reset.current), []);\n return {\n copied,\n copy: () => {\n void copyText(value).then((ok) => {\n if (!ok) return;\n setCopied(true);\n clearTimeout(reset.current);\n reset.current = setTimeout(() => setCopied(false), resetAfter);\n });\n },\n };\n}\n\nexport interface CopyValueProps extends PartProps<\"span\", { readonly copied: boolean }> {\n readonly value: string;\n}\n\nexport function CopyValue({ value, ...props }: CopyValueProps) {\n const { messages } = useDomainKit();\n const icons = useIcons();\n const { copied, copy } = useCopy(value);\n return usePart(\n \"span\",\n props,\n { copied },\n {\n children: (\n <>\n <code>{value}</code>\n <button\n aria-label={`${copied ? messages.copied : messages.copy} ${value}`}\n data-domainkit-part=\"copy-action\"\n onClick={copy}\n type=\"button\"\n >\n <span\n aria-hidden=\"true\"\n data-domainkit-part=\"copy-glyph\"\n data-icon=\"\"\n data-state=\"idle\"\n >\n {icons.copy}\n </span>\n <span\n aria-hidden=\"true\"\n data-domainkit-part=\"copy-glyph\"\n data-icon=\"\"\n data-state=\"done\"\n >\n {icons.copied}\n </span>\n </button>\n </>\n ),\n \"data-copied\": copied ? \"\" : undefined,\n \"data-domainkit-part\": \"copy-value\",\n },\n );\n}\n\nexport interface ZoneFileProps extends PartProps<\"div\", { readonly count: number }> {\n readonly domain: string;\n readonly records: ReadonlyArray<DnsRecord.Model>;\n}\n\nexport function ZoneFile({ domain, records, ...props }: ZoneFileProps) {\n const { messages } = useDomainKit();\n const icons = useIcons();\n const zone = toZoneFile(records);\n const { copied, copy } = useCopy(zone);\n return usePart(\n \"div\",\n props,\n { count: records.length },\n {\n children: (\n <>\n <button\n aria-label={copied ? messages.copied : messages.copyZone}\n data-domainkit-part=\"zone-copy\"\n onClick={copy}\n type=\"button\"\n >\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {copied ? icons.copied : icons.copy}\n </span>\n {copied ? messages.copied : messages.copyZone}\n </button>\n <button\n aria-label={messages.download}\n data-domainkit-part=\"zone-download\"\n onClick={() => downloadZoneFile(domain, records)}\n type=\"button\"\n >\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {icons.download}\n </span>\n {messages.download}\n </button>\n </>\n ),\n \"data-domainkit-part\": \"zone-file\",\n },\n );\n}\n\n// ---------------------------------------------------------------------------------------------\n// Status\n// ---------------------------------------------------------------------------------------------\n\n/** The readiness this record reached, or `null` when nothing has observed it. */\nexport const statusOf = (\n record: DnsRecord.Model,\n readiness: Readiness | null | undefined,\n): RequirementStatus | null =>\n readiness?.requirements.find((requirement) => DnsRecord.equals(requirement.record, record))\n ?.status ?? null;\n\nexport interface StatusProps extends PartProps<\"span\", { readonly status: RequirementStatus }> {\n readonly status: RequirementStatus;\n}\n\nexport function Status({ status, ...props }: StatusProps) {\n const { messages } = useDomainKit();\n const icons = useIcons();\n const glyph =\n status === \"satisfied\" ? icons.success : status === \"unknown\" ? icons.pending : icons.failure;\n return usePart(\n \"span\",\n props,\n { status },\n {\n children: (\n <>\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {glyph}\n </span>\n {messages.requirementStatus(status)}\n </>\n ),\n \"data-domainkit-part\": \"record-status\",\n \"data-status\": status,\n },\n );\n}\n\n// ---------------------------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------------------------\n\nexport const Header = leafPart(\"thead\", \"records-header\");\nexport const Body = leafPart(\"tbody\", \"records-body\");\nexport const Footer = leafPart(\"tfoot\", \"records-footer\");\nexport const Row = leafPart(\"tr\", \"records-row\");\nexport const Head = leafPart(\"th\", \"records-head\");\nexport const Cell = leafPart(\"td\", \"records-cell\");\nexport const Caption = leafPart(\"caption\", \"records-caption\");\nexport const Value = leafPart(\"span\", \"record-value\");\nexport const Purpose = leafPart(\"span\", \"record-purpose\");\nexport const CardHeader = leafPart(\"div\", \"record-card-head\");\nexport const CardTitle = leafPart(\"strong\", \"record-card-title\");\nexport const CardContent = leafPart(\"dl\", \"record-card-content\");\n\nexport interface RootProps extends PartProps<\"table\", { readonly count: number }> {\n readonly count?: number;\n}\n\nexport function Root({ count = 0, ...props }: RootProps) {\n return (\n <div data-domainkit-part=\"records-panel\">\n {usePart(\"table\", props, { count }, { \"data-domainkit-part\": \"records-table\" })}\n </div>\n );\n}\n\n/** A stable React key for a requirement: type, name, and data identify a record. */\nexport const identity = (record: DnsRecord.Model): string =>\n [rrType(record), record.name, DnsRecord.data(record)].join(\":\");\n\n/**\n * A requirement set keyed by everything it carries, for memos that decide whether to re-send it.\n * `identity` is deliberately narrower: it answers \"is this the same record\" for a React key, while\n * a plan and an observation are built from `ttl`, `policy`, and `purpose` as well. `policy` in\n * particular decides whether a name may hold anything else, so readiness turns on it.\n */\nexport const requirementsKey = (records: ReadonlyArray<DnsRecord.Model>): string =>\n JSON.stringify(records);\n\nexport interface CardProps extends PartProps<\"section\", { readonly record: string }> {\n readonly readiness?: Readiness | null;\n readonly record: DnsRecord.Model;\n}\n\nexport function Card({ readiness, record, ...props }: CardProps): ReactElement {\n const { messages } = useDomainKit();\n const status = statusOf(record, readiness);\n return usePart(\n \"section\",\n props,\n { record: identity(record) },\n {\n children: (\n <>\n <CardHeader>\n <CardTitle>{messages.recordType(record)}</CardTitle>\n {status === null ? null : <Status status={status} />}\n </CardHeader>\n <CardContent>\n <div>\n <dt>{messages.headingName}</dt>\n <dd>\n <CopyValue value={record.name} />\n </dd>\n </div>\n <div>\n <dt>{messages.headingValue}</dt>\n <dd>\n <CopyValue value={DnsRecord.data(record)} />\n </dd>\n </div>\n {record.purpose === undefined ? null : (\n <div>\n <dt>{messages.headingPurpose}</dt>\n <dd>\n <Purpose>{record.purpose}</Purpose>\n </dd>\n </div>\n )}\n </CardContent>\n </>\n ),\n \"data-domainkit-part\": \"record-card\",\n },\n );\n}\n\nexport interface TableProps extends PartProps<\"table\", { readonly count: number }> {\n readonly caption?: string;\n readonly readiness?: Readiness | null;\n readonly records: ReadonlyArray<DnsRecord.Model>;\n}\n\n/** The default records presentation: one row per requirement, with readiness when there is any. */\nexport function Table({ caption, readiness, records, ...props }: TableProps): ReactElement {\n const { messages } = useDomainKit();\n const withStatus = readiness !== null && readiness !== undefined;\n return (\n <Root count={records.length} {...props}>\n {caption === undefined ? null : <Caption>{caption}</Caption>}\n <Header>\n <Row>\n <Head scope=\"col\">{messages.headingType}</Head>\n <Head scope=\"col\">{messages.headingName}</Head>\n <Head scope=\"col\">{messages.headingValue}</Head>\n {withStatus ? (\n <Head data-column=\"status\" scope=\"col\">\n {messages.headingStatus}\n </Head>\n ) : null}\n </Row>\n </Header>\n <Body>\n {records.map((record) => {\n const status = statusOf(record, readiness);\n return (\n <Row key={identity(record)}>\n <Cell>{messages.recordType(record)}</Cell>\n <Cell>\n <CopyValue value={record.name} />\n </Cell>\n <Cell>\n <Value>\n <CopyValue value={DnsRecord.data(record)} />\n {record.purpose === undefined ? null : <Purpose>{record.purpose}</Purpose>}\n </Value>\n </Cell>\n {withStatus ? (\n <Cell data-column=\"status\">\n {status === null ? null : <Status status={status} />}\n </Cell>\n ) : null}\n </Row>\n );\n })}\n </Body>\n </Root>\n );\n}\n","import { DnsRecord, type Plan } from \"domainkit\";\nimport type { ReactElement } from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { leafPart, usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { CopyValue } from \"./records.tsx\";\n\nexport const Kind = leafPart(\"span\", \"operation-kind\");\nexport const Type = leafPart(\"strong\", \"operation-type\");\nexport const Record = leafPart(\"span\", \"operation-record\");\nexport const Name = leafPart(\"span\", \"operation-name\");\nexport const Reason = leafPart(\"span\", \"operation-reason\");\n\nexport interface ItemProps extends PartProps<\"li\", { readonly operation: Plan.Operation[\"_tag\"] }> {\n readonly operation: Plan.Operation;\n}\n\nexport function Item({ operation, ...props }: ItemProps): ReactElement {\n const { messages } = useDomainKit();\n return usePart(\n \"li\",\n props,\n { operation: operation._tag },\n {\n children: (\n <>\n <Kind>{messages.operation(operation)}</Kind>{\" \"}\n <Type>{messages.recordType(operation.record)}</Type>{\" \"}\n <Record>\n <Name>{operation.record.name}</Name>\n <CopyValue value={DnsRecord.data(operation.record)} />\n </Record>\n {operation._tag === \"Conflict\" ? (\n <Reason>{messages.conflictReason(operation.reason)}</Reason>\n ) : null}\n </>\n ),\n \"data-domainkit-part\": \"operation-item\",\n \"data-operation\": operation._tag,\n },\n );\n}\n\nexport interface RootProps extends PartProps<\n \"ul\",\n { readonly count: number; readonly kind: Plan.Kind }\n> {\n readonly count?: number;\n readonly kind: Plan.Kind;\n}\n\nexport function Root({ count = 0, kind, ...props }: RootProps): ReactElement {\n return usePart(\n \"ul\",\n props,\n { count, kind },\n {\n \"data-domainkit-part\": kind === \"provisioning\" ? \"plan-operations\" : \"cleanup-operations\",\n \"data-kind\": kind,\n },\n );\n}\n\nexport interface ListProps extends Omit<RootProps, \"children\" | \"count\" | \"kind\"> {\n readonly plan: Plan.Model;\n}\n\n/** Every operation the plan holds, in plan order, so a customer reviews exactly what will run. */\nexport function List({ plan, ...props }: ListProps): ReactElement {\n return (\n <Root count={plan.operations.length} kind={plan.kind} {...props}>\n {plan.operations.map((operation) => (\n <Item key={operation.id} operation={operation} />\n ))}\n </Root>\n );\n}\n","/**\n * The review surface both `Provision` and `Cleanup` render: what the plan will do, the Approve\n * and Decline actions D35 defines, and the outcome. `kind` picks the wording; nothing else about\n * the two flows differs on screen.\n */\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport type { Plan } from \"domainkit\";\nimport { useState, type ReactElement, type ReactNode } from \"react\";\n\nimport type { Controller } from \"./attempt.ts\";\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit, useReadOnly } from \"./domain-kit.tsx\";\nimport { failure as describeFailure } from \"./messages.ts\";\nimport * as Operations from \"./operations.tsx\";\n\nexport interface ReviewState extends Record<string, unknown> {\n readonly status: Controller[\"state\"][\"_tag\"];\n}\n\nexport interface KindProps {\n readonly controller: Controller;\n readonly kind: Plan.Kind;\n}\n\nconst busy = (status: Controller[\"state\"][\"_tag\"]): boolean =>\n status === \"Planning\" ||\n status === \"Approving\" ||\n status === \"Applying\" ||\n status === \"Rejecting\";\n\nexport interface StatusProps extends PartProps<\"p\", ReviewState>, KindProps {}\n\n/** What the flow is doing right now, or what it finished doing. */\nexport function Status({ controller, kind, ...props }: StatusProps): ReactElement {\n const { messages } = useDomainKit();\n const state = controller.state;\n const text = (): string => {\n switch (state._tag) {\n case \"Idle\":\n return \"\";\n case \"Planning\":\n return kind === \"provisioning\" ? messages.planning : messages.planningCleanup;\n case \"Planned\":\n return kind === \"provisioning\" ? messages.planConsent : messages.cleanupConsent;\n case \"Approving\":\n return messages.approving;\n case \"Applying\":\n return kind === \"provisioning\" ? messages.applying : messages.cleaning;\n case \"Rejecting\":\n return messages.rejecting;\n case \"Rejected\":\n return messages.declinedBy(state.attempt.rejection?.actorId ?? \"\");\n case \"Applied\":\n return kind === \"provisioning\"\n ? messages.applied(state.receipt)\n : messages.cleaned(state.receipt);\n case \"Failure\":\n return \"\";\n }\n };\n return usePart(\n \"p\",\n props,\n { status: state._tag },\n {\n children: text(),\n \"data-domainkit-part\": kind === \"provisioning\" ? \"provisioning-status\" : \"cleanup-status\",\n \"data-state\": state._tag,\n role: busy(state._tag) ? \"status\" : undefined,\n },\n );\n}\n\nexport interface OutcomeProps extends PartProps<\"p\", ReviewState>, KindProps {}\n\n/** The failure sentence from the error's reason, with the retry the flow allows. */\nexport function Outcome({ controller, kind, ...props }: OutcomeProps): ReactElement | null {\n const { messages } = useDomainKit();\n const readOnly = useReadOnly();\n const state = controller.state;\n const partial = state._tag === \"Applied\" && state.receipt.status === \"partial\";\n const element = usePart(\n \"p\",\n props,\n { status: state._tag },\n {\n children:\n state._tag === \"Failure\" ? (\n <>\n {describeFailure(state.error, messages)}\n {readOnly ? null : (\n <>\n {\" \"}\n <button\n data-domainkit-part={\n kind === \"provisioning\" ? \"provisioning-retry\" : \"cleanup-retry\"\n }\n onClick={controller.retry}\n type=\"button\"\n >\n {messages.retry}\n </button>\n </>\n )}\n </>\n ) : partial ? (\n kind === \"provisioning\" ? (\n messages.partiallyApplied\n ) : (\n messages.partiallyCleaned\n )\n ) : null,\n \"data-domainkit-part\": \"flow-outcome\",\n \"data-tone\": \"danger\",\n role: \"alert\",\n },\n );\n return state._tag === \"Failure\" || partial ? element : null;\n}\n\nexport interface ActionsProps extends PartProps<\"div\", ReviewState>, KindProps {}\n\n/**\n * Approve and Decline. Approve authorizes the digest and applies it; Decline records the refusal\n * and ends the attempt. Neither renders until there is a plan to act on.\n */\nexport function Actions({ controller, kind, ...props }: ActionsProps): ReactElement | null {\n const { messages } = useDomainKit();\n const readOnly = useReadOnly();\n const state = controller.state;\n const plan = state._tag === \"Planned\" ? state.plan : null;\n const running = busy(state._tag);\n const element = usePart(\n \"div\",\n props,\n { status: state._tag },\n {\n children: (\n <>\n <button\n data-domainkit-part={kind === \"provisioning\" ? \"plan-apply\" : \"cleanup-apply\"}\n disabled={running || plan === null || plan.operations.length === 0}\n onClick={() => controller.approve()}\n type=\"button\"\n >\n {messages.approve}\n </button>\n <button\n data-domainkit-part=\"plan-decline\"\n disabled={running || plan === null}\n onClick={() => controller.reject()}\n type=\"button\"\n >\n {messages.decline}\n </button>\n </>\n ),\n \"data-domainkit-part\": \"review-actions\",\n },\n );\n if (readOnly) return null;\n return plan === null && !running ? null : element;\n}\n\nexport interface BodyProps extends KindProps {}\n\n/** The operations under review, or the reason there is nothing to review. */\nexport function Body({ controller, kind }: BodyProps): ReactElement {\n const { messages } = useDomainKit();\n const state = controller.state;\n const plan =\n state._tag === \"Planned\" ||\n state._tag === \"Approving\" ||\n state._tag === \"Applying\" ||\n state._tag === \"Rejecting\" ||\n state._tag === \"Rejected\"\n ? state.plan\n : state._tag === \"Applied\"\n ? state.plan\n : null;\n return (\n <div data-domainkit-part=\"dialog-body\">\n <Status controller={controller} kind={kind} />\n {plan === null ? null : plan.operations.length === 0 ? (\n <p data-domainkit-part=\"plan-empty\">{messages.noChanges}</p>\n ) : (\n <Operations.List plan={plan} />\n )}\n {state._tag === \"Rejected\" && state.attempt.rejection?.reason != null ? (\n <p data-domainkit-part=\"plan-decline-reason\">\n {messages.declineReason(state.attempt.rejection.reason)}\n </p>\n ) : null}\n <Outcome controller={controller} kind={kind} />\n </div>\n );\n}\n\nexport interface DialogProps extends KindProps {\n readonly children?: ReactNode;\n readonly onOpenChange?: (open: boolean) => void;\n readonly open?: boolean;\n /** Replace the dialog surface entirely: a drawer, an inline panel, a host modal. */\n readonly render?: (props: { readonly open: boolean; readonly children: ReactNode }) => ReactNode;\n readonly trigger?: ReactNode;\n}\n\n/** The review dialog. `render` swaps the surface; the contents stay the flow's. */\nexport function Dialog({\n children,\n controller,\n kind,\n onOpenChange,\n open,\n render,\n trigger,\n}: DialogProps): ReactElement {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const readOnly = useReadOnly();\n const [uncontrolled, setUncontrolled] = useState(false);\n const isOpen = open ?? uncontrolled;\n const setOpen = (next: boolean) => {\n if (open === undefined) setUncontrolled(next);\n onOpenChange?.(next);\n };\n const running = busy(controller.state._tag);\n const body = children ?? <Body controller={controller} kind={kind} />;\n const title = kind === \"provisioning\" ? messages.planTitle : messages.cleanupTitle;\n const label = trigger ?? (kind === \"provisioning\" ? messages.reviewChanges : messages.cleanUp);\n // Reviewing exists to authorize a write, so the whole surface goes rather than a dead trigger.\n if (readOnly) return <></>;\n if (render !== undefined) {\n return (\n <>\n <button\n data-domainkit-part={kind === \"provisioning\" ? \"plan-trigger\" : \"cleanup-trigger\"}\n onClick={() => {\n setOpen(true);\n controller.plan();\n }}\n type=\"button\"\n >\n {label}\n </button>\n {render({ children: body, open: isOpen })}\n </>\n );\n }\n return (\n <BaseDialog.Root\n onOpenChange={(next, details) => {\n if (!next && running) {\n details.cancel();\n return;\n }\n setOpen(next);\n }}\n open={isOpen}\n >\n <BaseDialog.Trigger\n data-domainkit-part={kind === \"provisioning\" ? \"plan-trigger\" : \"cleanup-trigger\"}\n onClick={controller.plan}\n >\n {label}\n </BaseDialog.Trigger>\n <BaseDialog.Portal container={portalContainer}>\n <BaseDialog.Backdrop\n data-color-scheme={colorScheme}\n data-domainkit-part=\"dialog-backdrop\"\n data-domainkit-root=\"\"\n style={themeStyle}\n />\n <BaseDialog.Popup\n data-color-scheme={colorScheme}\n data-domainkit-part={kind === \"provisioning\" ? \"plan-dialog\" : \"cleanup-dialog\"}\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <div data-domainkit-part=\"dialog-header\">\n <div data-domainkit-part=\"dialog-heading\">\n <BaseDialog.Title data-domainkit-part=\"dialog-title\">{title}</BaseDialog.Title>\n <BaseDialog.Description data-domainkit-part=\"dialog-description\">\n {kind === \"provisioning\" ? messages.planConsent : messages.cleanupConsent}\n </BaseDialog.Description>\n </div>\n {running ? null : (\n <BaseDialog.Close aria-label={messages.close} data-domainkit-part=\"dialog-close\">\n ×\n </BaseDialog.Close>\n )}\n </div>\n {body}\n <div data-domainkit-part=\"dialog-footer\">\n <Actions controller={controller} kind={kind} />\n {running ? null : (\n <BaseDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.cancel}\n </BaseDialog.Close>\n )}\n </div>\n </BaseDialog.Popup>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n );\n}\n","import { DomainKit, Reason, Receipt } from \"domainkit\";\nimport * as Effect from \"effect/Effect\";\nimport { useCallback, type ReactElement, type ReactNode } from \"react\";\n\nimport { State, useAttempt, type Controller } from \"./attempt.ts\";\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { Event } from \"./events.ts\";\nimport * as Review from \"./review.tsx\";\n\nexport { State };\nexport type { Controller };\n\nexport interface Options {\n readonly domain: string;\n /** Which apply to undo. Without it, the domain's latest provisioning receipt. */\n readonly receiptId?: Receipt.ReceiptId;\n readonly onCleaned?: (receipt: Receipt.Model) => void;\n}\n\n/**\n * Cleanup is bound to a receipt: it removes only what an apply proved DomainKit created. When the\n * host does not name one, the controller reads the domain's latest from the snapshot.\n */\nexport function useController({ domain, onCleaned, receiptId }: Options): Controller {\n const { transport } = useDomainKit();\n const group = transport.cleanup;\n const connection = transport.connection;\n return useAttempt({\n domain,\n key: [domain, receiptId ?? \"\"].join(\"|\"),\n done: (receipt) => Event.Cleaned({ domain, receipt }),\n group,\n onDone: onCleaned,\n plan: useCallback(() => {\n if (group === undefined) return null;\n if (receiptId !== undefined) return group.plan(receiptId);\n if (connection === undefined) return null;\n return Effect.flatMap(connection.inspect(domain), (snapshot) =>\n snapshot.lastReceiptId === null\n ? Effect.fail(\n new DomainKit.Error({\n reason: new Reason.NotFound({ entity: \"receipt\", id: snapshot.domain }),\n }),\n )\n : group.plan(Receipt.ReceiptId.make(snapshot.lastReceiptId)),\n );\n }, [connection, domain, group, receiptId]),\n });\n}\n\nexport interface RootState extends Record<string, unknown> {\n readonly status: State[\"_tag\"];\n}\n\nexport interface RootProps extends PartProps<\"div\", RootState> {\n readonly controller: Controller;\n}\n\nexport function Root({ controller, ...props }: RootProps): ReactElement {\n return usePart(\n \"div\",\n props,\n { status: controller.state._tag },\n { \"data-domainkit-part\": \"cleanup-flow\", \"data-state\": controller.state._tag },\n );\n}\n\nexport interface DialogProps extends Omit<Review.DialogProps, \"kind\"> {}\n\nexport function Dialog(props: DialogProps): ReactElement {\n return <Review.Dialog {...props} kind=\"cleanup\" />;\n}\n\nexport interface ActionsProps extends Omit<Review.ActionsProps, \"kind\"> {}\n\nexport function Actions(props: ActionsProps): ReactElement | null {\n return <Review.Actions {...props} kind=\"cleanup\" />;\n}\n\nexport interface OutcomeProps extends Omit<Review.OutcomeProps, \"kind\"> {}\n\nexport function Outcome(props: OutcomeProps): ReactElement | null {\n return <Review.Outcome {...props} kind=\"cleanup\" />;\n}\n\nexport interface StatusProps extends Omit<Review.StatusProps, \"kind\"> {}\n\nexport function Status(props: StatusProps): ReactElement {\n return <Review.Status {...props} kind=\"cleanup\" />;\n}\n\nexport interface FlowProps extends Omit<RootProps, \"controller\"> {\n readonly domain: string;\n readonly onCleaned?: (receipt: Receipt.Model) => void;\n readonly receiptId?: Receipt.ReceiptId;\n readonly trigger?: ReactNode;\n}\n\n/** Cleanup on its own: a trigger that plans the removal, then the same review dialog. */\nexport function Flow({ domain, onCleaned, receiptId, trigger, ...props }: FlowProps) {\n const controller = useController({\n domain,\n ...(onCleaned === undefined ? {} : { onCleaned }),\n ...(receiptId === undefined ? {} : { receiptId }),\n });\n return (\n <Root controller={controller} {...props}>\n <Dialog controller={controller} {...(trigger === undefined ? {} : { trigger })} />\n <Outcome controller={controller} />\n </Root>\n );\n}\n","import type { Transport } from \"domainkit/client\";\nimport type { ReactNode } from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\n\n/** A provider as the snapshot describes it: an id, a display name, and its auth methods. */\nexport type Descriptor = Transport.Snapshot[\"providers\"][number];\n\n/** Host-supplied artwork per provider id. A function receives the descriptor it renders for. */\nexport type Marks = Readonly<Record<string, ReactNode | ((provider: Descriptor) => ReactNode)>>;\n\nexport interface MarkState extends Record<string, unknown> {\n readonly providerId: string;\n}\n\nexport interface MarkProps extends PartProps<\"span\", MarkState> {\n readonly provider: Descriptor;\n}\n\nconst key = (providerId: string): string =>\n providerId\n .trim()\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/g, \"\");\n\n/** No network call: the fallback is the provider's own initial, drawn with the theme's tokens. */\nconst monogram = (provider: Descriptor): string =>\n provider.name.trim().charAt(0).toUpperCase() || \"?\";\n\n/**\n * A provider's artwork. `DomainKit.Root`'s `marks` decides what a provider looks like; without an\n * entry the mark is the provider's initial. Nothing is fetched at render time.\n */\nexport function Mark({ provider, ...props }: MarkProps) {\n const { marks } = useDomainKit();\n const replacement = marks[provider.id];\n const content =\n typeof replacement === \"function\" ? replacement(provider) : (replacement ?? monogram(provider));\n return usePart(\n \"span\",\n props,\n { providerId: provider.id },\n {\n \"aria-label\": provider.name,\n children: content,\n \"data-domainkit-part\": \"provider-mark\",\n \"data-domainkit-provider\": key(provider.id),\n role: \"img\",\n },\n );\n}\n","import { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport type { DomainKit, Storage } from \"domainkit\";\nimport { Transport } from \"domainkit/client\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport { useCallback, useEffect, useRef, useState, type ReactElement, type ReactNode } from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit, useReadOnly } from \"./domain-kit.tsx\";\nimport { Event } from \"./events.ts\";\nimport { useIcons } from \"./icons.tsx\";\nimport { failure as describeFailure } from \"./messages.ts\";\nimport * as Provider from \"./provider.tsx\";\nimport { useRunner } from \"./task.ts\";\n\nexport type Snapshot = Transport.Snapshot;\nexport type Discovery = Transport.Discovery;\nexport type Candidate = Transport.Candidate;\nexport type Descriptor = Provider.Descriptor;\nexport type MethodDescriptor = Descriptor[\"methods\"][number];\nexport type Field = NonNullable<MethodDescriptor[\"fields\"]>[number];\n\n/**\n * Where a domain stands with its DNS provider. `Disconnected` carries whatever\n * `connection.discover` found, so the UI can offer a connection the customer already has before\n * asking for another one.\n */\nexport type State = Data.TaggedEnum<{\n Loading: { readonly snapshot: Snapshot | null };\n Disconnected: { readonly snapshot: Snapshot; readonly discovery: Discovery | null };\n Connected: { readonly snapshot: Snapshot };\n Reconnect: { readonly snapshot: Snapshot };\n Submitting: { readonly snapshot: Snapshot | null };\n Redirecting: { readonly url: string };\n SelectionRequired: {\n readonly snapshot: Snapshot | null;\n readonly connectionId: string;\n readonly candidates: ReadonlyArray<Candidate>;\n };\n Failure: { readonly error: DomainKit.Error };\n}>;\nexport const State = Data.taggedEnum<State>();\n\nexport interface ConnectInput {\n readonly provider: string;\n readonly method: Storage.AuthMethod;\n /** Keyed by the descriptor's field names. Ignored by the interactive methods. */\n readonly values?: Readonly<Record<string, string>>;\n /** Where an interactive method returns the customer. */\n readonly returnTo?: string;\n}\n\nexport interface Controller {\n readonly state: State;\n readonly snapshot: Snapshot | null;\n readonly discovery: Discovery | null;\n readonly providers: ReadonlyArray<Descriptor>;\n readonly connect: (input: ConnectInput) => void;\n /** Attach the domain to a connection this owner already has. */\n readonly reuse: (input: { readonly connectionId: string; readonly zone?: string }) => void;\n /** Answer `SelectionRequired` by naming the zone that serves the domain. */\n readonly select: (zone: string) => void;\n readonly detach: () => void;\n readonly disconnect: () => void;\n /** Re-inspect the domain, discarding any failure. */\n readonly refresh: () => void;\n /** Re-run the step that failed; without one, re-inspect. */\n readonly retry: () => void;\n}\n\nexport interface Options {\n readonly domain: string;\n /**\n * Where an interactive method returns the customer. Defaults to the page they started from;\n * pass `null` to send none and let the server's `defaultReturnTo` decide.\n */\n readonly returnTo?: string | null;\n}\n\n/** Read at connect time, not at render, so it is the page the customer is actually on. */\nconst currentUrl = (): string | null =>\n typeof window === \"undefined\" ? null : window.location.href;\n\nconst snapshotOf = (state: State): Snapshot | null => {\n switch (state._tag) {\n case \"Connected\":\n case \"Reconnect\":\n case \"Disconnected\":\n return state.snapshot;\n case \"Loading\":\n case \"Submitting\":\n case \"SelectionRequired\":\n return state.snapshot;\n case \"Redirecting\":\n case \"Failure\":\n return null;\n }\n};\n\nconst settled = (snapshot: Snapshot, discovery: Discovery | null): State => {\n switch (snapshot.status) {\n case \"connected\":\n return State.Connected({ snapshot });\n case \"reconnect\":\n return State.Reconnect({ snapshot });\n case \"disconnected\":\n return State.Disconnected({ discovery, snapshot });\n }\n};\n\n/**\n * The domain's connection, and the four ways to change it. Discovery runs on mount whenever the\n * transport declares it and the domain has no connection yet; a discovery failure is not the\n * customer's problem, so the provider list still renders.\n */\nexport function useController({ domain, returnTo }: Options): Controller {\n const { emit, navigate, revision, transport } = useDomainKit();\n const readOnly = useReadOnly();\n const connection = transport.connection;\n const runner = useRunner();\n const [state, setState] = useState<State>(State.Loading({ snapshot: null }));\n\n // The snapshot and the discovery belong to the domain they were read for, so a controller\n // pointed at a new domain drops both while rendering rather than one effect later.\n // What was read travels with the domain it was read for, so a command or a reply that arrives\n // after the controller moved refuses to act: one domain's attachment must never be detached for\n // another.\n const held = useRef<{\n domain: string;\n snapshot: Snapshot | null;\n discovery: Discovery | null;\n }>({ discovery: null, domain, snapshot: null });\n const lastCommand = useRef<{ domain: string; run: () => void } | null>(null);\n\n const [inspected, setInspected] = useState(domain);\n if (inspected !== domain) {\n setInspected(domain);\n runner.cancel();\n held.current = { discovery: null, domain, snapshot: null };\n lastCommand.current = null;\n setState(State.Loading({ snapshot: null }));\n }\n\n const onFailure = useCallback(\n (error: DomainKit.Error) => {\n setState(State.Failure({ error }));\n emit(Event.Failed({ domain, error }));\n },\n [domain, emit],\n );\n\n const load = useCallback(() => {\n if (connection === undefined) return;\n lastCommand.current = null;\n held.current = { discovery: null, domain, snapshot: null };\n // A refresh keeps the snapshot on screen; a domain change already cleared it.\n setState((previous) => State.Loading({ snapshot: snapshotOf(previous) }));\n runner.run(\n Effect.flatMap(connection.inspect(domain), (snapshot) =>\n snapshot.status === \"disconnected\"\n ? Effect.map(\n connection.discover(domain).pipe(Effect.catch(() => Effect.succeed(null))),\n (discovery) => ({ discovery, snapshot }),\n )\n : Effect.succeed({ discovery: null, snapshot }),\n ),\n {\n onFailure,\n onSuccess: ({ discovery, snapshot }) => {\n if (held.current.domain !== domain) return;\n held.current = { discovery, domain, snapshot };\n setState(settled(snapshot, discovery));\n },\n },\n );\n }, [connection, domain, onFailure, runner]);\n\n useEffect(load, [load, revision]);\n\n const started = useCallback(\n (result: Transport.Started) => {\n if (held.current.domain !== domain) return;\n switch (result._tag) {\n case \"Connected\":\n held.current = { discovery: null, domain, snapshot: result.snapshot };\n setState(settled(result.snapshot, null));\n if (result.snapshot.connectionId !== null) {\n emit(\n Event.Connected({\n connectionId: result.snapshot.connectionId,\n domain,\n snapshot: result.snapshot,\n }),\n );\n }\n return;\n case \"Redirect\":\n setState(State.Redirecting({ url: result.authorizationUrl }));\n navigate(result.authorizationUrl);\n return;\n case \"SelectionRequired\":\n setState(\n State.SelectionRequired({\n candidates: result.candidates,\n connectionId: result.connectionId,\n snapshot: held.current.snapshot,\n }),\n );\n return;\n }\n },\n [domain, emit, navigate],\n );\n\n const submit = useCallback(\n (effect: Effect.Effect<Transport.Started, DomainKit.Error>) => {\n if (held.current.domain !== domain) return;\n const command = () => {\n setState(State.Submitting({ snapshot: held.current.snapshot }));\n runner.run(effect, { onFailure, onSuccess: started });\n };\n lastCommand.current = { domain, run: command };\n command();\n },\n [domain, onFailure, runner, started],\n );\n\n const connect = useCallback(\n (input: ConnectInput) => {\n if (connection === undefined) return;\n const destination = input.returnTo ?? (returnTo === undefined ? currentUrl() : returnTo);\n const interactive = destination === null ? {} : { returnTo: destination };\n const method =\n input.method === \"token\"\n ? Transport.Method.token(input.values ?? {})\n : input.method === \"oauth\"\n ? Transport.Method.oauth(interactive)\n : Transport.Method.integration(interactive);\n submit(connection.start({ domain, method, provider: input.provider }));\n },\n [connection, domain, returnTo, submit],\n );\n\n const reuse = useCallback(\n (input: { readonly connectionId: string; readonly zone?: string }) => {\n if (connection === undefined) return;\n submit(\n connection.attach({\n connectionId: input.connectionId,\n domain,\n ...(input.zone === undefined ? {} : { zone: input.zone }),\n }),\n );\n },\n [connection, domain, submit],\n );\n\n const select = useCallback(\n (zone: string) => {\n if (state._tag !== \"SelectionRequired\") return;\n reuse({ connectionId: state.connectionId, zone });\n },\n [reuse, state],\n );\n\n const release = useCallback(\n (effect: Effect.Effect<void, DomainKit.Error>, event: Event) => {\n if (held.current.domain !== domain) return;\n const command = () => {\n setState(State.Submitting({ snapshot: held.current.snapshot }));\n runner.run(effect, {\n onFailure,\n onSuccess: () => {\n emit(event);\n load();\n },\n });\n };\n lastCommand.current = { domain, run: command };\n command();\n },\n [domain, emit, load, onFailure, runner],\n );\n\n const detach = useCallback(() => {\n const attachmentId = held.current.snapshot?.attachmentId;\n if (connection === undefined || attachmentId == null || held.current.domain !== domain) return;\n release(connection.detach(attachmentId), Event.Detached({ domain }));\n }, [connection, domain, release]);\n\n const disconnect = useCallback(() => {\n const connectionId = held.current.snapshot?.connectionId;\n if (connection === undefined || connectionId == null || held.current.domain !== domain) return;\n release(connection.disconnect(connectionId), Event.Disconnected({ connectionId, domain }));\n }, [connection, domain, release]);\n\n const retry = useCallback(() => {\n const command = lastCommand.current;\n // Re-inspecting is a read, so it stays; rerunning the last write does not.\n if (readOnly || command === null || command.domain !== domain) load();\n else command.run();\n }, [domain, load, readOnly]);\n\n return {\n connect,\n detach,\n disconnect,\n discovery: state._tag === \"Disconnected\" ? state.discovery : null,\n providers: snapshotOf(state)?.providers ?? [],\n refresh: load,\n retry,\n reuse,\n select,\n snapshot: snapshotOf(state),\n state,\n };\n}\n\n// ---------------------------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------------------------\n\nexport interface RootState extends Record<string, unknown> {\n readonly status: State[\"_tag\"];\n}\n\nexport interface RootProps extends PartProps<\"div\", RootState> {\n readonly controller: Controller;\n}\n\nexport function Root({ controller, ...props }: RootProps): ReactElement {\n return usePart(\n \"div\",\n props,\n { status: controller.state._tag },\n { \"data-domainkit-part\": \"connection-root\", \"data-state\": controller.state._tag },\n );\n}\n\nexport interface OutcomeProps extends PartProps<\"p\", RootState> {\n readonly controller: Controller;\n}\n\n/** The failure sentence, chosen by the error's reason, plus the retry that reason allows. */\nexport function Outcome({ controller, ...props }: OutcomeProps): ReactElement | null {\n const { messages } = useDomainKit();\n const readOnly = useReadOnly();\n const state = controller.state;\n const element = usePart(\n \"p\",\n props,\n { status: state._tag },\n {\n children:\n state._tag === \"Failure\" ? (\n <>\n {describeFailure(state.error, messages)}\n {readOnly ? null : (\n <>\n {\" \"}\n <button\n data-domainkit-part=\"connection-retry\"\n onClick={controller.retry}\n type=\"button\"\n >\n {messages.retry}\n </button>\n </>\n )}\n </>\n ) : null,\n \"data-domainkit-part\": \"flow-outcome\",\n \"data-tone\": \"danger\",\n role: \"alert\",\n },\n );\n return state._tag === \"Failure\" ? element : null;\n}\n\nexport interface StatusProps extends PartProps<\"p\", RootState> {\n readonly controller: Controller;\n}\n\nexport function Status({ controller, ...props }: StatusProps): ReactElement {\n const { messages } = useDomainKit();\n const state = controller.state;\n const provider = controller.snapshot?.provider ?? \"\";\n const text = (): string => {\n switch (state._tag) {\n case \"Loading\":\n return messages.loading;\n case \"Submitting\":\n return messages.connecting;\n case \"Redirecting\":\n return messages.redirecting;\n case \"Connected\":\n return messages.connectedTo(provider);\n case \"Reconnect\":\n return messages.reconnectRequired(provider);\n case \"SelectionRequired\":\n return messages.chooseZone;\n case \"Disconnected\":\n return messages.notConnected;\n case \"Failure\":\n return \"\";\n }\n };\n return usePart(\n \"p\",\n props,\n { status: state._tag },\n {\n children: text(),\n \"data-domainkit-part\": \"connection-status\",\n \"data-state\": state._tag,\n role: state._tag === \"Submitting\" || state._tag === \"Loading\" ? \"status\" : undefined,\n },\n );\n}\n\ninterface MethodProps {\n readonly controller: Controller;\n readonly method: MethodDescriptor;\n readonly provider: Descriptor;\n}\n\n/**\n * One auth method, rendered from its descriptor. A token method draws an input per declared\n * field, so a provider that needs an account id alongside a token needs no code here.\n */\nfunction Method({ controller, method, provider }: MethodProps): ReactElement {\n const { messages } = useDomainKit();\n const icons = useIcons();\n const busy = controller.state._tag === \"Submitting\";\n if (method.fields === null) {\n return (\n <button\n data-domainkit-part={method.kind === \"oauth\" ? \"oauth-connect\" : \"integration-connect\"}\n data-provider={provider.id}\n disabled={busy}\n onClick={() => controller.connect({ method: method.kind, provider: provider.id })}\n type=\"button\"\n >\n {messages.connectWith(method.label)}\n </button>\n );\n }\n const fields = method.fields;\n return (\n <form\n data-domainkit-part=\"token-connect\"\n data-provider={provider.id}\n onSubmit={(event) => {\n event.preventDefault();\n const data = new FormData(event.currentTarget);\n const values: Record<string, string> = {};\n for (const field of fields) {\n const value = data.get(field.name);\n if (typeof value === \"string\" && (value !== \"\" || field.required)) {\n values[field.name] = value;\n }\n }\n controller.connect({ method: method.kind, provider: provider.id, values });\n }}\n >\n {fields.map((field) => (\n <label data-domainkit-part=\"token-field\" key={field.name}>\n <span data-domainkit-part=\"token-field-label\">\n {messages.fieldLabel(field.name)}\n {field.required ? null : (\n <span data-domainkit-part=\"token-field-optional\">{messages.optionalField}</span>\n )}\n </span>\n <input\n autoComplete=\"off\"\n data-domainkit-part=\"token-field-input\"\n name={field.name}\n required={field.required}\n type={field.secret ? \"password\" : \"text\"}\n />\n </label>\n ))}\n {method.docsUrl === null ? null : (\n <a data-domainkit-part=\"token-docs\" href={method.docsUrl} rel=\"noreferrer\" target=\"_blank\">\n {messages.getToken}\n <span aria-hidden=\"true\" data-icon=\"inline-end\">\n {icons.external}\n </span>\n </a>\n )}\n <button data-domainkit-part=\"token-submit\" disabled={busy} type=\"submit\">\n {messages.connectWith(method.label)}\n </button>\n </form>\n );\n}\n\nexport interface FormProps extends PartProps<\"div\", RootState> {\n readonly controller: Controller;\n}\n\n/**\n * Everything a disconnected domain can do: a connection discovery already found, the connections\n * this owner already has, then each provider's declared methods.\n */\nexport function Form({ controller, ...props }: FormProps): ReactElement {\n const { messages } = useDomainKit();\n const state = controller.state;\n const snapshot = controller.snapshot;\n const discovery = controller.discovery;\n const candidates =\n state._tag === \"SelectionRequired\"\n ? state.candidates.map((candidate) => ({ ...candidate, connectionId: state.connectionId }))\n : discovery !== null && discovery._tag === \"SelectionRequired\"\n ? discovery.candidates\n : [];\n const resolved = discovery !== null && discovery._tag === \"Resolved\" ? discovery : null;\n const reusable = snapshot?.reusable ?? [];\n const providers = controller.providers;\n return usePart(\n \"div\",\n props,\n { status: state._tag },\n {\n children: (\n <>\n {resolved === null ? null : (\n <section data-domainkit-part=\"discovery-resolved\">\n <p>{messages.discoveredConnection(resolved.label)}</p>\n <button\n data-domainkit-part=\"attach-target\"\n onClick={() =>\n controller.reuse({\n connectionId: resolved.connectionId,\n zone: resolved.zone,\n })\n }\n type=\"button\"\n >\n {messages.useConnection(resolved.label)}\n </button>\n </section>\n )}\n {candidates.length === 0 ? null : (\n <section data-domainkit-part=\"discovery-candidates\">\n <p>\n {state._tag === \"SelectionRequired\"\n ? messages.chooseZone\n : messages.discoveryAmbiguous}\n </p>\n <div data-domainkit-part=\"target-list\" data-state=\"ambiguous\">\n {candidates.map((candidate) => (\n <button\n data-domainkit-part=\"attach-target\"\n key={`${candidate.connectionId}:${candidate.zone}`}\n onClick={() =>\n controller.reuse({\n connectionId: candidate.connectionId,\n zone: candidate.zone,\n })\n }\n type=\"button\"\n >\n {messages.useConnection(candidate.label)}\n </button>\n ))}\n </div>\n </section>\n )}\n {reusable.length === 0 ? null : (\n <section data-domainkit-part=\"reusable-connection\">\n <div data-domainkit-part=\"reusable-connection-heading\">\n <strong>{messages.reusableConnections}</strong>\n </div>\n {reusable.map((connection) => (\n <button\n data-connection-id={connection.connectionId}\n data-domainkit-part=\"attach-target\"\n key={connection.connectionId}\n onClick={() => controller.reuse({ connectionId: connection.connectionId })}\n type=\"button\"\n >\n {messages.useConnection(connection.provider)}\n </button>\n ))}\n </section>\n )}\n {providers.length === 0 ? (\n <p data-domainkit-part=\"target-unavailable\">{messages.noProviders}</p>\n ) : (\n providers.map((provider) => (\n <section data-domainkit-part=\"provider-authentication\" key={provider.id}>\n <div data-domainkit-part=\"provider-heading\">\n <Provider.Mark provider={provider} />\n <strong>{provider.name}</strong>\n </div>\n {provider.methods.map((method) => (\n <Method\n controller={controller}\n key={`${provider.id}:${method.kind}`}\n method={method}\n provider={provider}\n />\n ))}\n </section>\n ))\n )}\n </>\n ),\n \"data-domainkit-part\": \"connection-form\",\n },\n );\n}\n\nexport interface DialogProps {\n readonly controller: Controller;\n readonly children?: ReactNode;\n /** Replace the dialog surface: a drawer, a panel, whatever the host already has. */\n readonly render?: (props: { readonly open: boolean; readonly children: ReactNode }) => ReactNode;\n readonly title?: ReactNode;\n readonly trigger?: ReactNode;\n}\n\n/** The connect surface. Without `render` it is a Base UI dialog behind `trigger`. */\nexport function Dialog({\n children,\n controller,\n render,\n title,\n trigger,\n}: DialogProps): ReactElement {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const readOnly = useReadOnly();\n const [open, setOpen] = useState(false);\n const busy = controller.state._tag === \"Submitting\";\n const snapshot = controller.snapshot;\n const provider = snapshot?.provider;\n const heading =\n title ??\n (provider === null || provider === undefined\n ? messages.connectAnyTitle\n : messages.connectTitle(provider));\n const body = children ?? <Form controller={controller} />;\n // Connecting is a write, so the whole surface goes rather than a disabled trigger.\n if (readOnly) return <></>;\n if (render !== undefined) {\n return (\n <>\n <button\n data-domainkit-part=\"connection-trigger\"\n onClick={() => setOpen(!open)}\n type=\"button\"\n >\n {trigger ?? messages.connect}\n </button>\n {render({ children: body, open })}\n </>\n );\n }\n return (\n <BaseDialog.Root\n onOpenChange={(next, details) => {\n if (!next && busy) {\n details.cancel();\n return;\n }\n setOpen(next);\n }}\n open={open}\n >\n <BaseDialog.Trigger data-domainkit-part=\"connection-trigger\">\n {trigger ?? messages.connect}\n </BaseDialog.Trigger>\n <BaseDialog.Portal container={portalContainer}>\n <BaseDialog.Backdrop\n data-color-scheme={colorScheme}\n data-domainkit-part=\"dialog-backdrop\"\n data-domainkit-root=\"\"\n style={themeStyle}\n />\n <BaseDialog.Popup\n data-color-scheme={colorScheme}\n data-domainkit-part=\"connection-dialog\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <div data-domainkit-part=\"dialog-header\">\n <div data-domainkit-part=\"dialog-heading\">\n <BaseDialog.Title data-domainkit-part=\"dialog-title\">{heading}</BaseDialog.Title>\n <BaseDialog.Description data-domainkit-part=\"dialog-description\">\n {messages.connectDescription(snapshot?.domain ?? \"\")}\n </BaseDialog.Description>\n </div>\n {busy ? null : (\n <BaseDialog.Close aria-label={messages.close} data-domainkit-part=\"dialog-close\">\n ×\n </BaseDialog.Close>\n )}\n </div>\n <div data-domainkit-part=\"dialog-body\">\n <Status controller={controller} />\n {body}\n <Outcome controller={controller} />\n </div>\n {busy ? null : (\n <div data-domainkit-part=\"dialog-footer\">\n <BaseDialog.Close data-domainkit-part=\"dialog-cancel\">\n {messages.cancel}\n </BaseDialog.Close>\n </div>\n )}\n </BaseDialog.Popup>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n );\n}\n\nexport interface CardProps extends PartProps<\"div\", RootState> {\n readonly controller: Controller;\n}\n\n/** A connected domain: which provider holds it, and how to let it go. */\nexport function Card({ controller, ...props }: CardProps): ReactElement {\n const { messages } = useDomainKit();\n const readOnly = useReadOnly();\n const state = controller.state;\n const snapshot = controller.snapshot;\n const provider = controller.providers.find((entry) => entry.id === snapshot?.provider);\n return usePart(\n \"div\",\n props,\n { status: state._tag },\n {\n children: (\n <>\n <div data-domainkit-part=\"connected-identity\">\n {provider === undefined ? null : <Provider.Mark provider={provider} />}\n <Status controller={controller} />\n </div>\n {readOnly ? null : (\n <div data-domainkit-part=\"connected-actions\">\n <button\n data-domainkit-part=\"disconnect-trigger\"\n disabled={state._tag === \"Submitting\"}\n onClick={controller.detach}\n type=\"button\"\n >\n {messages.detach}\n </button>\n <button\n data-domainkit-part=\"disconnect-action\"\n disabled={state._tag === \"Submitting\"}\n onClick={controller.disconnect}\n type=\"button\"\n >\n {messages.disconnect}\n </button>\n </div>\n )}\n <Outcome controller={controller} />\n </>\n ),\n \"data-domainkit-part\": \"connected-card\",\n },\n );\n}\n\nexport interface FlowProps extends Omit<RootProps, \"controller\"> {\n readonly domain: string;\n readonly returnTo?: string | null;\n}\n\n/** Connection on its own: the card once connected, the dialog until then. */\nexport function Flow({ domain, returnTo, ...props }: FlowProps): ReactElement {\n const controller = useController({ domain, ...(returnTo === undefined ? {} : { returnTo }) });\n const state = controller.state;\n return (\n <Root controller={controller} {...props}>\n {state._tag === \"Connected\" ? (\n <Card controller={controller} />\n ) : (\n <>\n <Dialog controller={controller} />\n <Outcome controller={controller} />\n </>\n )}\n </Root>\n );\n}\n","import { DnsRecord, type Receipt } from \"domainkit\";\nimport { useCallback, type ReactElement, type ReactNode } from \"react\";\n\nimport { State, useAttempt, type Controller } from \"./attempt.ts\";\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { Event } from \"./events.ts\";\nimport * as Records from \"./records.tsx\";\nimport * as Review from \"./review.tsx\";\n\nexport { State };\nexport type { Controller };\n\nexport interface Options {\n readonly domain: string;\n readonly requirements: ReadonlyArray<DnsRecord.Model>;\n readonly onApplied?: (receipt: Receipt.Model) => void;\n}\n\n/** Plan, approve, apply. `approve` authorizes the digest and applies it in the same action. */\n/**\n * Requirements identify themselves by content, so an inline array does not abandon the attempt.\n * Every field counts: a plan turns on `policy`, and `ttl` and `purpose` ride the wire with it.\n */\nconst keyOf = (domain: string, requirements: ReadonlyArray<DnsRecord.Model>): string =>\n [domain, Records.requirementsKey(requirements)].join(\"|\");\n\nexport function useController({ domain, onApplied, requirements }: Options): Controller {\n const { transport } = useDomainKit();\n const group = transport.provisioning;\n return useAttempt({\n domain,\n key: keyOf(domain, requirements),\n done: (receipt) => Event.Applied({ domain, receipt }),\n group,\n onDone: onApplied,\n plan: useCallback(\n () => (group === undefined ? null : group.plan({ domain, requirements })),\n [domain, group, requirements],\n ),\n });\n}\n\nexport interface RootState extends Record<string, unknown> {\n readonly status: State[\"_tag\"];\n}\n\nexport interface RootProps extends PartProps<\"div\", RootState> {\n readonly controller: Controller;\n}\n\nexport function Root({ controller, ...props }: RootProps): ReactElement {\n return usePart(\n \"div\",\n props,\n { status: controller.state._tag },\n { \"data-domainkit-part\": \"provisioning-flow\", \"data-state\": controller.state._tag },\n );\n}\n\nexport interface DialogProps extends Omit<Review.DialogProps, \"kind\"> {}\n\nexport function Dialog(props: DialogProps): ReactElement {\n return <Review.Dialog {...props} kind=\"provisioning\" />;\n}\n\nexport interface ActionsProps extends Omit<Review.ActionsProps, \"kind\"> {}\n\n/** Approve and Decline for a plan already under review. */\nexport function Actions(props: ActionsProps): ReactElement | null {\n return <Review.Actions {...props} kind=\"provisioning\" />;\n}\n\nexport interface OutcomeProps extends Omit<Review.OutcomeProps, \"kind\"> {}\n\nexport function Outcome(props: OutcomeProps): ReactElement | null {\n return <Review.Outcome {...props} kind=\"provisioning\" />;\n}\n\nexport interface StatusProps extends Omit<Review.StatusProps, \"kind\"> {}\n\nexport function Status(props: StatusProps): ReactElement {\n return <Review.Status {...props} kind=\"provisioning\" />;\n}\n\nexport interface FlowProps extends Omit<RootProps, \"controller\"> {\n readonly domain: string;\n readonly onApplied?: (receipt: Receipt.Model) => void;\n readonly requirements: ReadonlyArray<DnsRecord.Model>;\n readonly trigger?: ReactNode;\n}\n\n/** Provisioning on its own: a trigger that plans, then the review dialog. */\nexport function Flow({ domain, onApplied, requirements, trigger, ...props }: FlowProps) {\n const controller = useController({\n domain,\n requirements,\n ...(onApplied === undefined ? {} : { onApplied }),\n });\n return (\n <Root controller={controller} {...props}>\n <Dialog controller={controller} {...(trigger === undefined ? {} : { trigger })} />\n <Outcome controller={controller} />\n </Root>\n );\n}\n","import { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { DnsRecord, type DomainKit } from \"domainkit\";\nimport type { Transport } from \"domainkit/client\";\nimport * as Data from \"effect/Data\";\nimport * as DateTime from \"effect/DateTime\";\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport { useDomainKit } from \"./domain-kit.tsx\";\nimport { Event } from \"./events.ts\";\nimport { useIcons } from \"./icons.tsx\";\nimport { failure as describeFailure } from \"./messages.ts\";\nimport { identity, requirementsKey, Status as RecordStatus } from \"./records.tsx\";\nimport { useRunner } from \"./task.ts\";\n\nexport type Readiness = Transport.Readiness;\nexport type HostEvidence = Readiness[\"host\"][number];\nexport type Requirement = Readiness[\"requirements\"][number];\nexport type Evidence = Requirement[\"evidence\"][number];\n\n/**\n * What the observer read back for the requirement's name, or `null` when it read nothing back at\n * all. Host evidence reports a status the host reached rather than values read off a name, and an\n * `unknown` observation is a lookup that never answered, which is not the same as finding nothing.\n */\nconst valuesOf = (evidence: Evidence): ReadonlyArray<string> | null =>\n evidence._tag === \"Host\" || evidence.status === \"unknown\" ? null : evidence.values;\n\n/**\n * Readiness rides on the state rather than a ref, so it can never outlive the render that\n * produced it: a controller pointed at a new domain has no readiness in the very first frame.\n */\nexport type State = Data.TaggedEnum<{\n Idle: {};\n Observing: { readonly readiness: Readiness | null };\n Observed: { readonly readiness: Readiness };\n Failure: { readonly error: DomainKit.Error; readonly readiness: Readiness | null };\n}>;\nexport const State = Data.taggedEnum<State>();\n\nconst readinessOf = (state: State): Readiness | null =>\n state._tag === \"Idle\" ? null : state.readiness;\n\nexport interface Controller {\n readonly state: State;\n /** The latest readiness, kept while a new observation runs. */\n readonly readiness: Readiness | null;\n readonly observe: () => void;\n /** Observe again after a failure. */\n readonly retry: () => void;\n /** Whether this controller re-observes at `nextCheckAt` while mounted. */\n readonly polling: boolean;\n}\n\nexport interface Options {\n readonly domain: string;\n /**\n * What to look for. Supplied requirements win over the attachment's latest provisioning receipt,\n * which is what lets a domain with no attachment be verified at all.\n */\n readonly requirements?: ReadonlyArray<DnsRecord.Model>;\n /** Re-observe at each `nextCheckAt` while mounted. Default true. */\n readonly polling?: boolean;\n}\n\n/** Observe once on mount, then follow the readiness's own `nextCheckAt` while polling is on. */\nexport function useController({ domain, polling = true, requirements }: Options): Controller {\n const { emit, revision, transport } = useDomainKit();\n const verification = transport.verification;\n const runner = useRunner();\n const [state, setState] = useState<State>(State.Idle());\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n\n // Requirements identify themselves by content, so a host writing the array inline does not\n // rebuild `observe` on every render and set the mount effect observing in a loop. The key covers\n // every field, because `policy` and `ttl` ride the wire and `policy` decides readiness.\n const signature = requirements === undefined ? null : requirementsKey(requirements);\n const requested = useMemo(\n () => (requirements === undefined ? undefined : { requirements }),\n [signature],\n );\n\n // Readiness belongs to the domain that was observed. Dropping it while rendering, rather than\n // in an effect, keeps the first frame for a new domain free of the previous one's evidence.\n const [observed, setObserved] = useState(domain);\n if (observed !== domain) {\n setObserved(domain);\n setState(State.Idle());\n }\n\n const observe = useCallback(() => {\n if (verification === undefined) return;\n clearTimeout(timer.current);\n setState((previous) => State.Observing({ readiness: readinessOf(previous) }));\n runner.run(\n requested === undefined\n ? verification.observe(domain)\n : verification.observe(domain, requested),\n {\n onFailure: (error) => {\n setState((previous) => State.Failure({ error, readiness: readinessOf(previous) }));\n emit(Event.Failed({ domain, error }));\n },\n onSuccess: (readiness) => setState(State.Observed({ readiness })),\n },\n );\n }, [domain, emit, requested, runner, verification]);\n\n useEffect(() => {\n observe();\n }, [observe, revision]);\n\n useEffect(() => {\n if (!polling || state._tag !== \"Observed\") return;\n const next = state.readiness.nextCheckAt;\n if (next === null) return;\n const delay = Math.max(0, DateTime.toEpochMillis(next) - Date.now());\n timer.current = setTimeout(observe, delay);\n return () => clearTimeout(timer.current);\n }, [observe, polling, state]);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n return {\n observe,\n polling,\n readiness: readinessOf(state),\n retry: observe,\n state,\n };\n}\n\n// ---------------------------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------------------------\n\nexport interface RootState extends Record<string, unknown> {\n readonly status: State[\"_tag\"];\n}\n\nexport interface RootProps extends PartProps<\"div\", RootState> {\n readonly controller: Controller;\n}\n\nexport function Root({ controller, ...props }: RootProps): ReactElement {\n const overall = controller.readiness?.overall ?? null;\n return usePart(\n \"div\",\n props,\n { status: controller.state._tag },\n {\n \"data-domainkit-part\": \"verification-status\",\n \"data-overall\": overall ?? undefined,\n \"data-state\": controller.state._tag,\n },\n );\n}\n\nexport interface ObserveActionProps extends PartProps<\"button\", RootState> {\n readonly controller: Controller;\n}\n\nexport function ObserveAction({ controller, ...props }: ObserveActionProps): ReactElement {\n const { messages } = useDomainKit();\n const observing = controller.state._tag === \"Observing\";\n return usePart(\n \"button\",\n props,\n { status: controller.state._tag },\n {\n \"aria-busy\": observing,\n children: controller.readiness === null ? messages.checkDns : messages.checkAgain,\n \"data-domainkit-part\": \"observe-action\",\n \"data-loading\": observing ? \"\" : undefined,\n disabled: observing,\n onClick: controller.observe,\n type: \"button\",\n },\n );\n}\n\n/** Evidence carries no id; its source and position identify it within one requirement. */\nconst evidenceKey = (evidence: { readonly _tag: string }, index: number): string =>\n [evidence._tag, index].join(\"-\");\n\nexport interface EvidenceProps {\n readonly readiness: Readiness;\n}\n\n/**\n * Per-requirement readiness and, below it, the host's own evidence: an SES identity, a certificate,\n * anything DomainKit cannot observe but the host feeds in.\n */\nexport function Evidence({ readiness }: EvidenceProps): ReactElement {\n const { messages } = useDomainKit();\n const icons = useIcons();\n return (\n <div data-domainkit-part=\"observation-list\">\n {readiness.requirements.map((requirement) => {\n const settled = requirement.status === \"satisfied\";\n return (\n <section data-domainkit-part=\"observation-group\" key={identity(requirement.record)}>\n <div data-domainkit-part=\"observation-row\">\n <span data-domainkit-part=\"observation-record\">\n {messages.recordType(requirement.record)} {requirement.record.name}\n </span>\n <RecordStatus status={requirement.status} />\n </div>\n {settled ? null : (\n <p data-domainkit-part=\"observation-expected\">\n {messages.expectedValue(DnsRecord.data(requirement.record))}\n </p>\n )}\n <ul>\n {requirement.evidence.map((evidence, index) => {\n const values = settled ? null : valuesOf(evidence);\n return (\n <li data-domainkit-part=\"observation-source\" key={evidenceKey(evidence, index)}>\n {messages.evidenceSource(evidence)}\n {values === null ? null : (\n <span data-domainkit-part=\"observation-observed\">\n {values.length === 0\n ? messages.observedNothing\n : messages.observedValues(values)}\n </span>\n )}\n {evidence.detail === null ? null : (\n <p data-domainkit-part=\"observation-note\">{evidence.detail}</p>\n )}\n </li>\n );\n })}\n </ul>\n </section>\n );\n })}\n {readiness.host.length === 0 ? null : (\n <section data-domainkit-part=\"observation-group\" data-source=\"host\">\n <h3 data-domainkit-part=\"observation-source\">{messages.hostEvidence}</h3>\n <ul>\n {readiness.host.map((evidence, index) => (\n <li data-domainkit-part=\"host-evidence\" key={`${evidence.source}-${index}`}>\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {evidence.status === \"ok\"\n ? icons.success\n : evidence.status === \"pending\"\n ? icons.pending\n : icons.failure}\n </span>\n <span data-domainkit-part=\"observation-record\">{evidence.label}</span>\n <span data-domainkit-part=\"record-status\" data-status={evidence.status}>\n {messages.hostEvidenceStatus(evidence.status)}\n </span>\n {evidence.detail === null ? null : (\n <p data-domainkit-part=\"observation-note\">{evidence.detail}</p>\n )}\n </li>\n ))}\n </ul>\n </section>\n )}\n </div>\n );\n}\n\nexport interface OutcomeProps extends PartProps<\"p\", RootState> {\n readonly controller: Controller;\n}\n\nexport function Outcome({ controller, ...props }: OutcomeProps): ReactElement | null {\n const { messages } = useDomainKit();\n const state = controller.state;\n const element = usePart(\n \"p\",\n props,\n { status: state._tag },\n {\n children:\n state._tag === \"Failure\" ? (\n <>\n {describeFailure(state.error, messages)}{\" \"}\n <button\n data-domainkit-part=\"verification-retry\"\n onClick={controller.retry}\n type=\"button\"\n >\n {messages.retry}\n </button>\n </>\n ) : null,\n \"data-domainkit-part\": \"flow-outcome\",\n \"data-tone\": \"danger\",\n role: \"alert\",\n },\n );\n return state._tag === \"Failure\" ? element : null;\n}\n\nexport interface StatusProps extends Omit<RootProps, \"render\"> {\n /** Replace the popover surface with a panel of the host's own. */\n readonly render?: (props: { readonly open: boolean; readonly children: ReactNode }) => ReactNode;\n}\n\n/** The default verification slot: a button that observes, with the evidence behind it. */\nexport function Status({ controller, render, ...props }: StatusProps): ReactElement {\n const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();\n const readiness = controller.readiness;\n const body = (\n <>\n {controller.state._tag === \"Observing\" ? (\n <p data-domainkit-part=\"verification-progress\" role=\"status\">\n {messages.observing}\n </p>\n ) : null}\n {readiness === null ? (\n <p data-domainkit-part=\"verification-progress\">{messages.noEvidence}</p>\n ) : (\n <Evidence readiness={readiness} />\n )}\n <Outcome controller={controller} />\n </>\n );\n return (\n <Root controller={controller} {...props}>\n {render === undefined ? (\n <BasePopover.Root>\n <BasePopover.Trigger render={<ObserveAction controller={controller} />} />\n <BasePopover.Portal container={portalContainer}>\n <BasePopover.Positioner\n align=\"end\"\n data-domainkit-part=\"verification-positioner\"\n sideOffset={6}\n >\n <BasePopover.Popup\n aria-busy={controller.state._tag === \"Observing\"}\n aria-label={messages.checkDns}\n data-color-scheme={colorScheme}\n data-domainkit-part=\"verification-popover\"\n data-domainkit-root=\"\"\n style={themeStyle}\n >\n <BasePopover.Arrow data-domainkit-part=\"verification-arrow\" />\n {body}\n </BasePopover.Popup>\n </BasePopover.Positioner>\n </BasePopover.Portal>\n </BasePopover.Root>\n ) : (\n <>\n <ObserveAction controller={controller} />\n {render({ children: body, open: controller.state._tag !== \"Idle\" })}\n </>\n )}\n </Root>\n );\n}\n","import { Receipt, type DnsRecord } from \"domainkit\";\nimport { useCallback, type ReactElement, type ReactNode } from \"react\";\n\nimport type { PartProps } from \"./composition.tsx\";\nimport { usePart } from \"./composition.tsx\";\nimport * as Cleanup from \"./cleanup.tsx\";\nimport * as Connect from \"./connect.tsx\";\nimport { ReadOnly, useDomainKit, useReadOnly } from \"./domain-kit.tsx\";\nimport { useIcons } from \"./icons.tsx\";\nimport * as Provision from \"./provision.tsx\";\nimport * as Records from \"./records.tsx\";\nimport * as Verify from \"./verify.tsx\";\n\nexport interface RecordsSlotProps {\n readonly records: ReadonlyArray<DnsRecord.Model>;\n readonly readiness: Verify.Readiness | null;\n readonly controller: Verify.Controller;\n readonly domain: string;\n}\n\nexport interface VerificationSlotProps {\n readonly controller: Verify.Controller;\n readonly domain: string;\n}\n\nexport interface ActionsSlotProps {\n readonly connection: Connect.Controller;\n readonly provisioning: Provision.Controller;\n readonly cleanup: Cleanup.Controller;\n readonly domain: string;\n}\n\nexport interface ConnectionSlotProps {\n readonly controller: Connect.Controller;\n readonly domain: string;\n}\n\n/**\n * Each slot replaces one part of the flow and keeps the rest. Every slot has a default, so\n * `<Domain.Flow domain requirements />` is complete on its own.\n */\nexport interface Slots {\n /** The requirements table. Defaults to `Records.Table` with readiness when there is any. */\n readonly records?: (props: RecordsSlotProps) => ReactNode;\n /** Defaults to `Verify.Status`. Rendered only when the transport declares `verification`. */\n readonly verification?: (props: VerificationSlotProps) => ReactNode;\n /** Defaults to Approve and Decline, plus cleanup when the transport declares it. */\n readonly actions?: (props: ActionsSlotProps) => ReactNode;\n /** Defaults to `Connect.Card` once connected and `Connect.Dialog` until then. */\n readonly connection?: (props: ConnectionSlotProps) => ReactNode;\n}\n\nexport interface FlowState extends Record<string, unknown> {\n readonly connection: Connect.State[\"_tag\"];\n readonly provisioning: Provision.State[\"_tag\"];\n}\n\nexport interface FlowProps extends Omit<PartProps<\"div\", FlowState>, \"children\"> {\n readonly domain: string;\n readonly requirements: ReadonlyArray<DnsRecord.Model>;\n readonly slots?: Slots;\n readonly onApplied?: (receipt: Receipt.Model) => void;\n readonly onCleaned?: (receipt: Receipt.Model) => void;\n /**\n * Where an interactive provider flow returns the customer. Defaults to the page they started\n * from; pass `null` to let the server's `defaultReturnTo` decide.\n */\n readonly returnTo?: string | null;\n /** Render this domain's state without the controls that change it. Defaults to the root's. */\n readonly readOnly?: boolean;\n}\n\nfunction DefaultConnection({ controller }: ConnectionSlotProps): ReactElement {\n return controller.state._tag === \"Connected\" ? (\n <Connect.Card controller={controller} />\n ) : (\n <>\n <Connect.Status controller={controller} />\n <Connect.Dialog controller={controller} />\n <Connect.Outcome controller={controller} />\n </>\n );\n}\n\nfunction DefaultActions({\n cleanup,\n connection,\n provisioning,\n}: ActionsSlotProps): ReactElement | null {\n const { capabilities, messages } = useDomainKit();\n const readOnly = useReadOnly();\n const icons = useIcons();\n const connected = connection.state._tag === \"Connected\";\n // Every control here starts a write; the state a read-only customer may see is rendered above.\n if (readOnly) return null;\n const hasReceipt = connection.snapshot?.lastReceiptId != null;\n return (\n <>\n {capabilities.includes(\"provisioning\") && connected ? (\n <>\n <button\n data-domainkit-part=\"plan-trigger\"\n disabled={provisioning.state._tag === \"Planning\"}\n onClick={provisioning.plan}\n type=\"button\"\n >\n {messages.reviewChanges}\n </button>\n <Provision.Status controller={provisioning} />\n <Provision.Actions controller={provisioning} />\n <Provision.Outcome controller={provisioning} />\n </>\n ) : null}\n {capabilities.includes(\"cleanup\") && connected && hasReceipt ? (\n <>\n <button\n data-domainkit-part=\"cleanup-trigger\"\n disabled={cleanup.state._tag === \"Planning\"}\n onClick={cleanup.plan}\n type=\"button\"\n >\n <span aria-hidden=\"true\" data-icon=\"inline-start\">\n {icons.close}\n </span>\n {messages.cleanUp}\n </button>\n <Cleanup.Status controller={cleanup} />\n <Cleanup.Actions controller={cleanup} />\n <Cleanup.Outcome controller={cleanup} />\n </>\n ) : null}\n </>\n );\n}\n\n/**\n * The whole lifecycle for one domain: connect, review, apply, observe, clean up. The flow renders\n * only what the transport declares, and every part of it is a slot with a default. It adds no\n * layout containers of its own, so a host's grid can place the slot output directly.\n */\nexport function Flow({\n domain,\n onApplied,\n onCleaned,\n readOnly,\n requirements,\n returnTo,\n slots = {},\n ...props\n}: FlowProps): ReactElement {\n const { capabilities } = useDomainKit();\n const inherited = useReadOnly();\n const connection = Connect.useController({\n domain,\n ...(returnTo === undefined ? {} : { returnTo }),\n });\n const refresh = connection.refresh;\n const provisioning = Provision.useController({\n domain,\n onApplied: useCallback(\n (receipt: Receipt.Model) => {\n refresh();\n onApplied?.(receipt);\n },\n [onApplied, refresh],\n ),\n requirements,\n });\n const cleanup = Cleanup.useController({\n domain,\n onCleaned: useCallback(\n (receipt: Receipt.Model) => {\n refresh();\n onCleaned?.(receipt);\n },\n [onCleaned, refresh],\n ),\n ...(connection.snapshot?.lastReceiptId == null\n ? {}\n : { receiptId: Receipt.ReceiptId.make(connection.snapshot.lastReceiptId) }),\n });\n // The flow knows what it asked for, so a domain with no attachment can still be verified.\n const verification = Verify.useController({ domain, requirements });\n const readiness = verification.readiness;\n return usePart(\n \"div\",\n props,\n { connection: connection.state._tag, provisioning: provisioning.state._tag },\n {\n children: (\n <ReadOnly value={readOnly ?? inherited}>\n {!capabilities.includes(\"connection\") ? null : slots.connection === undefined ? (\n <DefaultConnection controller={connection} domain={domain} />\n ) : (\n slots.connection({ controller: connection, domain })\n )}\n {slots.records === undefined ? (\n <Records.Table readiness={readiness} records={requirements} />\n ) : (\n slots.records({ controller: verification, domain, readiness, records: requirements })\n )}\n {!capabilities.includes(\"verification\") ? null : slots.verification === undefined ? (\n <Verify.Status controller={verification} />\n ) : (\n slots.verification({ controller: verification, domain })\n )}\n {slots.actions === undefined ? (\n <DefaultActions\n cleanup={cleanup}\n connection={connection}\n domain={domain}\n provisioning={provisioning}\n />\n ) : (\n slots.actions({ cleanup, connection, domain, provisioning })\n )}\n </ReadOnly>\n ),\n \"data-domainkit-part\": \"domain-flow\",\n \"data-domain\": domain,\n },\n );\n}\n","/**\n * The fake transport `@domainkit/react` tests render against: an in-memory `domainkit/server`\n * with memory storage and a fake provider, recording every call.\n */\nimport { Testing } from \"domainkit/testing\";\n\nexport const transport = Testing.transport;\nexport type RecordedCall = Testing.RecordedCall;\nexport type RecordingTransport = Testing.RecordingTransport;\nexport type TransportOptions = Testing.TransportOptions;\n","import type { DomainKit } from \"domainkit\";\nimport * as Data from \"effect/Data\";\n\n/**\n * The failed member every controller state shares. It carries the `DomainKit.Error` itself, so a\n * host reads `error.reason`, `error.category`, and `error.isRetryable` instead of parsing text.\n */\nexport type Failure = Data.TaggedEnum<{\n Failure: { readonly error: DomainKit.Error };\n}>;\nexport const Failure = Data.taggedEnum<Failure>();\n\n/** A defect that escaped the transport, in the shape the rest of the UI already handles. */\nexport const isFailure = (state: { readonly _tag: string }): state is Failure =>\n state._tag === \"Failure\";\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAgB,QAId,gBACA,gBACA,OACA,eACc;CACd,MAAM,EAAE,WAAW,QAAQ,OAAO,GAAG,kBAAkB;CACvD,MAAM,aAGF;EACF,GAAI,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU;EAC/C;EACA,OAAO,CAAC,eAAe,aAAa;EACpC,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EACzC;EACA,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;CACzC;CACA,OAAO,UAAU,UAAU;AAC7B;;AAGA,SAAgB,SACd,gBACA,MACA;CACA,OAAO,SAAS,KAAK,OAA8D;EACjF,OAAO,QAAQ,gBAAgB,OAAO,CAAC,GAAG,EAAE,uBAAuB,KAAK,CAAC;CAC3E;AACF;;;AClCA,SAAS,MAAM,EAAE,YAA8C;CAC7D,OACE,oBAAC,OAAD;EACE,eAAY;EACZ,MAAK;EACL,QAAO;EACP,eAAc;EACd,gBAAe;EACf,aAAa;EACb,SAAQ;EAEP;CACE,CAAA;AAET;AAEA,MAAa,eAAe;CAC1B,OACE,qBAAC,OAAD,EAAA,UAAA,CACE,oBAAC,QAAD,EAAM,GAAE,aAAc,CAAA,GACtB,oBAAC,QAAD,EAAM,GAAE,aAAc,CAAA,CACjB,EAAA,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