{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popup-share-access",
  "type": "registry:component",
  "title": "Share Access Dialog",
  "description": "A document sharing dialog with email chips that validate as you type or paste, a permission picker, a people list with role changes and removal, and a general access switch whose lock turns into a globe.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "share",
    "permissions",
    "invite",
    "collaboration",
    "dialog",
    "chips"
  ],
  "docs": "https://hyperblur.dev/effects/popup-share-access",
  "files": [
    {
      "path": "registry/hyperblur/popup-share-access.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/popup-share-access.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type PopupShareRole = \"view\" | \"comment\" | \"edit\";\n\nexport interface PopupSharePerson {\n  email: string;\n  name?: string;\n  role: PopupShareRole | \"owner\";\n  pending?: boolean;\n}\n\nexport interface PopupShareAccessProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\" | \"onCopy\"> {\n  documentName?: string;\n  link?: string;\n  people?: PopupSharePerson[];\n  defaultAccess?: \"restricted\" | \"link\";\n  onInvite?: (emails: string[], role: PopupShareRole) => void;\n  onAccessChange?: (access: \"restricted\" | \"link\") => void;\n  onRoleChange?: (email: string, role: PopupShareRole | \"remove\") => void;\n  onCopy?: (link: string) => void;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  showTrigger?: boolean;\n  triggerLabel?: string;\n  embedded?: boolean;\n  accent?: string;\n}\n\nconst defaultPeople: PopupSharePerson[] = [\n  { email: \"nora@lumen.studio\", name: \"Nora Achebe (you)\", role: \"owner\" },\n  { email: \"tom.reyes@lumen.studio\", name: \"Tom Reyes\", role: \"edit\" },\n  { email: \"ines@partner.co\", name: \"Inès Moreau\", role: \"comment\" },\n];\n\nconst roleText: Record<PopupShareRole, string> = { view: \"Can view\", comment: \"Can comment\", edit: \"Can edit\" };\n\nconst focusable = 'a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction useModal(active: boolean, panelRef: React.RefObject<HTMLElement | null>, onClose: () => void) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!active) return;\n    const panel = panelRef.current;\n    if (!panel) return;\n    const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n    const html = document.documentElement;\n    const prevOverflow = html.style.overflow;\n    html.style.overflow = \"hidden\";\n    (panel.querySelector<HTMLElement>(\"[data-autofocus]\") ?? panel).focus({ preventScroll: true });\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const nodes = Array.from(panel.querySelectorAll<HTMLElement>(focusable)).filter((n) => n.getClientRects().length > 0);\n      if (!nodes.length) {\n        e.preventDefault();\n        return;\n      }\n      const first = nodes[0];\n      const last = nodes[nodes.length - 1];\n      const cur = document.activeElement;\n      if (e.shiftKey && (cur === first || cur === panel || !panel.contains(cur))) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && (cur === last || !panel.contains(cur))) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      html.style.overflow = prevOverflow;\n      opener?.focus({ preventScroll: true });\n    };\n  }, [active, panelRef]);\n}\n\nfunction usePresence(open: boolean, ms: number) {\n  const [mounted, setMounted] = React.useState(open);\n  if (open && !mounted) setMounted(true);\n  React.useEffect(() => {\n    if (open || !mounted) return;\n    const t = window.setTimeout(() => setMounted(false), ms);\n    return () => window.clearTimeout(t);\n  }, [open, mounted, ms]);\n  return mounted;\n}\n\nfunction hue(s: string) {\n  let x = 2166136261;\n  for (let i = 0; i < s.length; i++) x = Math.imul(x ^ s.charCodeAt(i), 16777619);\n  return (x >>> 0) % 360;\n}\n\nconst isEmail = (v: string) => /^[^\\s@,;]+@[^\\s@,;]+\\.[^\\s@,;]{2,}$/.test(v);\n\nconst css = `\n.hb-xf12 { --hb-xf12-accent: #2f7bff; box-sizing: border-box; font-family: inherit; color: #ededed; }\n.hb-xf12 *, .hb-xf12 *::before, .hb-xf12 *::after { box-sizing: border-box; }\n.hb-xf12-embedded { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }\n.hb-xf12-trigger { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 11px; border-radius: 10px; font-size: 13px; font-weight: 600; color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xf12-accent) 85%, #fff), var(--hb-xf12-accent)); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 6px 16px -8px var(--hb-xf12-accent); cursor: pointer; transition: transform .15s cubic-bezier(.3,.7,.4,1), filter .2s; }\n.hb-xf12-trigger:hover { filter: brightness(1.08); }\n.hb-xf12-trigger:active { transform: scale(.97); }\n.hb-xf12-trigger:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-xf12-trigger svg { width: 14px; height: 14px; }\n.hb-xf12-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; min-height: 100dvh; }\n.hb-xf12-embedded .hb-xf12-overlay { position: relative; inset: auto; min-height: 0; padding: 0; width: 100%; }\n.hb-xf12-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); animation: hb-xf12-fade .3s ease both; }\n.hb-xf12-embedded .hb-xf12-scrim { display: none; }\n.hb-xf12-overlay[data-state=\"closed\"] .hb-xf12-scrim { animation: hb-xf12-fade .2s ease reverse both; }\n.hb-xf12-panel { position: relative; width: min(470px, 100%); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 20px; background: #111; border: 1px solid #2a2a2a; box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 40px 80px -30px rgba(0,0,0,.9); outline: none; animation: hb-xf12-in .45s cubic-bezier(.16,1,.3,1) both; }\n.hb-xf12-overlay[data-state=\"closed\"] .hb-xf12-panel { animation: hb-xf12-out .2s cubic-bezier(.4,0,1,1) both; }\n.hb-xf12-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px 18px; }\n.hb-xf12-doc { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex: none; color: #fff; background: linear-gradient(160deg, #3c7bff, #1e4fc4); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }\n.hb-xf12-doc svg { width: 15px; height: 15px; }\n.hb-xf12-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xf12-close { all: unset; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #8f8f8f; cursor: pointer; transition: background .2s, color .2s; flex: none; }\n.hb-xf12-close:hover { background: #1f1f1f; color: #ededed; }\n.hb-xf12-close:focus-visible { outline: 2px solid var(--hb-xf12-accent); }\n.hb-xf12-close svg { width: 14px; height: 14px; }\n.hb-xf12-invite { display: flex; gap: 6px; padding: 0 16px 0 18px; align-items: flex-start; }\n.hb-xf12-field { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-height: 38px; padding: 5px 6px 5px 8px; border-radius: 11px; background: #0b0b0b; border: 1px solid #2a2a2a; cursor: text; transition: border-color .2s, box-shadow .2s; }\n.hb-xf12-field:focus-within { border-color: color-mix(in srgb, var(--hb-xf12-accent) 60%, #2a2a2a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-xf12-accent) 16%, transparent); }\n.hb-xf12-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 24px; padding: 0 3px 0 3px; border-radius: 999px; font-size: 11.5px; background: #1c1c1c; border: 1px solid #2c2c2c; animation: hb-xf12-chip .3s cubic-bezier(.3,1.5,.5,1) both; }\n.hb-xf12-chip[data-bad=\"true\"] { color: #ffb0a8; border-color: rgba(255,93,93,.45); background: rgba(255,93,93,.1); }\n.hb-xf12-chipava { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 700; color: #fff; flex: none; }\n.hb-xf12-chiptext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xf12-chipx { all: unset; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #8f8f8f; cursor: pointer; flex: none; }\n.hb-xf12-chipx:hover { background: #2c2c2c; color: #ededed; }\n.hb-xf12-chipx:focus-visible { outline: 2px solid var(--hb-xf12-accent); }\n.hb-xf12-chipx svg { width: 9px; height: 9px; }\n.hb-xf12-input { flex: 1; min-width: 120px; height: 26px; border: 0; outline: 0; background: transparent; color: #ededed; font: inherit; font-size: 13px; }\n.hb-xf12-input::placeholder { color: #5f5f5f; }\n.hb-xf12-select { position: relative; flex: none; }\n.hb-xf12-select select { appearance: none; -webkit-appearance: none; height: 38px; padding: 0 28px 0 11px; border-radius: 11px; font: inherit; font-size: 12.5px; color: #ededed; background: #171717; border: 1px solid #2a2a2a; cursor: pointer; transition: border-color .2s; }\n.hb-xf12-select select:hover { border-color: #3a3a3a; }\n.hb-xf12-select select:focus-visible { outline: 2px solid var(--hb-xf12-accent); outline-offset: 1px; }\n.hb-xf12-select svg { position: absolute; right: 10px; top: 50%; width: 10px; height: 10px; margin-top: -5px; color: #8f8f8f; pointer-events: none; }\n.hb-xf12-mini select { height: 28px; border-color: transparent; background: transparent; color: #a1a1a1; padding-right: 24px; }\n.hb-xf12-mini select:hover { background: #1a1a1a; border-color: #262626; color: #ededed; }\n.hb-xf12-btn { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 11px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .2s, transform .15s cubic-bezier(.3,.7,.4,1), filter .2s, opacity .2s; }\n.hb-xf12-btn:active { transform: scale(.97); }\n.hb-xf12-btn:focus-visible { outline: 2px solid var(--hb-xf12-accent); outline-offset: 2px; }\n.hb-xf12-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }\n.hb-xf12-primary { color: #fff; background: var(--hb-xf12-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.22); }\n.hb-xf12-primary:not(:disabled):hover { filter: brightness(1.1); }\n.hb-xf12-hint { margin: 6px 18px 0; min-height: 15px; font-size: 11px; color: #ff8a7a; }\n.hb-xf12-sec { padding: 6px 16px 4px 18px; }\n.hb-xf12-label { margin: 0 0 6px; font-size: 11.5px; font-weight: 500; color: #7a7a7a; }\n.hb-xf12-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }\n.hb-xf12-person { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-radius: 10px; animation: hb-xf12-row .4s cubic-bezier(.2,.8,.2,1) both; }\n.hb-xf12-person[data-new=\"true\"] { animation: hb-xf12-row .4s cubic-bezier(.2,.8,.2,1) both, hb-xf12-flash 1.4s ease .2s both; }\n.hb-xf12-person[data-leaving=\"true\"] { animation: hb-xf12-leave .28s cubic-bezier(.4,0,1,1) forwards; }\n.hb-xf12-ava { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff; }\n.hb-xf12-who { flex: 1; min-width: 0; }\n.hb-xf12-name { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xf12-mail { margin: 1px 0 0; font-size: 11px; color: #7a7a7a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xf12-pending { font-size: 9.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; color: #f5b445; background: rgba(245,180,69,.12); }\n.hb-xf12-owner { font-size: 12px; color: #6f6f6f; padding-right: 8px; }\n.hb-xf12-access { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0 16px 0 18px; border-radius: 13px; background: #151515; border: 1px solid #222; }\n.hb-xf12-globe { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none; transition: background .35s, color .35s; color: #a1a1a1; background: #222; }\n.hb-xf12-access[data-a=\"link\"] .hb-xf12-globe { color: #3ddc84; background: rgba(61,220,132,.13); }\n.hb-xf12-globe svg { position: absolute; width: 16px; height: 16px; transition: opacity .3s, transform .45s cubic-bezier(.3,1.4,.5,1); }\n.hb-xf12-access[data-a=\"link\"] .hb-xf12-g-lock, .hb-xf12-access[data-a=\"restricted\"] .hb-xf12-g-world { opacity: 0; transform: rotate(-90deg) scale(.4); }\n.hb-xf12-acc-text { flex: 1; min-width: 0; }\n.hb-xf12-acc-btn { all: unset; display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: 5px; }\n.hb-xf12-acc-btn:focus-visible { outline: 2px solid var(--hb-xf12-accent); outline-offset: 2px; }\n.hb-xf12-acc-btn svg { width: 12px; height: 12px; color: #8f8f8f; }\n.hb-xf12-acc-desc { margin: 1px 0 0; font-size: 11px; color: #7a7a7a; animation: hb-xf12-fade .3s ease both; }\n.hb-xf12-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 16px 16px 18px; }\n.hb-xf12-copy { color: #ededed; background: #171717; border: 1px solid #2a2a2a; padding: 0 13px 0 11px; }\n.hb-xf12-copy:hover { border-color: #3a3a3a; }\n.hb-xf12-copy[data-done=\"true\"] { color: #3ddc84; border-color: rgba(61,220,132,.35); background: rgba(61,220,132,.07); }\n.hb-xf12-cicon { position: relative; width: 15px; height: 15px; }\n.hb-xf12-cicon svg { position: absolute; inset: 0; width: 15px; height: 15px; transition: opacity .2s, transform .35s cubic-bezier(.3,1.5,.5,1); }\n.hb-xf12-copy[data-done=\"true\"] .hb-xf12-c-link, .hb-xf12-copy[data-done=\"false\"] .hb-xf12-c-ok { opacity: 0; transform: scale(.4) rotate(-30deg); }\n.hb-xf12-c-ok path { stroke-dasharray: 16; stroke-dashoffset: 16; }\n.hb-xf12-copy[data-done=\"true\"] .hb-xf12-c-ok path { stroke-dashoffset: 0; transition: stroke-dashoffset .35s ease .08s; }\n.hb-xf12-done { color: #0a0a0a; background: linear-gradient(#f5f5f5, #dadada); box-shadow: inset 0 -1px 0 rgba(0,0,0,.2); }\n.hb-xf12-done:hover { background: #fff; }\n@keyframes hb-xf12-fade { from { opacity: 0; } }\n@keyframes hb-xf12-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }\n@keyframes hb-xf12-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }\n@keyframes hb-xf12-chip { from { opacity: 0; transform: scale(.6); } }\n@keyframes hb-xf12-row { from { opacity: 0; transform: translateY(-6px); } }\n@keyframes hb-xf12-flash { 0% { background: color-mix(in srgb, var(--hb-xf12-accent) 18%, transparent); } 100% { background: transparent; } }\n@keyframes hb-xf12-leave { to { opacity: 0; transform: translateX(16px); height: 0; padding: 0; } }\n@media (max-width: 440px) {\n  .hb-xf12-invite { flex-wrap: wrap; }\n  .hb-xf12-field { flex-basis: 100%; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-xf12 *, .hb-xf12 *::before { animation: none !important; transition: none !important; }\n  .hb-xf12-person[data-leaving=\"true\"] { display: none; }\n}\n`;\n\nfunction Chevron() {\n  return (\n    <svg viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"m2.5 4 2.5 2.5L7.5 4\" /></svg>\n  );\n}\n\nexport function PopupShareAccess({\n  documentName = \"Q4 Launch Plan\",\n  link = \"https://docs.lumen.studio/d/q4-launch-plan\",\n  people: peopleProp = defaultPeople,\n  defaultAccess = \"restricted\",\n  onInvite,\n  onAccessChange,\n  onRoleChange,\n  onCopy,\n  open,\n  defaultOpen,\n  onOpenChange,\n  showTrigger = true,\n  triggerLabel = \"Share\",\n  embedded = false,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: PopupShareAccessProps) {\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const mounted = usePresence(isOpen, 220);\n  const panelRef = React.useRef<HTMLDivElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const inputRef = React.useRef<HTMLInputElement>(null);\n  const touched = React.useRef(false);\n  const timers = React.useRef<number[]>([]);\n  const [people, setPeople] = React.useState(peopleProp);\n  const [fresh, setFresh] = React.useState<string[]>([]);\n  const [leaving, setLeaving] = React.useState<string[]>([]);\n  const [chips, setChips] = React.useState<string[]>([]);\n  const [draft, setDraft] = React.useState(\"\");\n  const [role, setRole] = React.useState<PopupShareRole>(\"edit\");\n  const [access, setAccess] = React.useState(defaultAccess);\n  const [copied, setCopied] = React.useState(false);\n\n  const setOpen = React.useCallback(\n    (value: boolean) => {\n      touched.current = true;\n      if (open === undefined) setInner(value);\n      onOpenChange?.(value);\n    },\n    [open, onOpenChange],\n  );\n  const close = React.useCallback(() => setOpen(false), [setOpen]);\n  useModal(isOpen && !embedded, panelRef, close);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => window.clearTimeout(t));\n  }, []);\n\n  React.useEffect(() => {\n    if (!embedded || !touched.current) return;\n    if (isOpen) panelRef.current?.focus({ preventScroll: true });\n    else triggerRef.current?.focus({ preventScroll: true });\n  }, [embedded, isOpen]);\n\n  const addChips = (raw: string) => {\n    const parts = raw.split(/[\\s,;]+/).map((p) => p.trim().toLowerCase()).filter(Boolean);\n    if (!parts.length) return;\n    setChips((c) => [...c, ...parts.filter((p) => !c.includes(p) && !people.some((x) => x.email === p))]);\n    setDraft(\"\");\n  };\n\n  const bad = chips.filter((c) => !isEmail(c));\n  const good = chips.filter(isEmail);\n\n  const invite = () => {\n    const pendingDraft = draft.trim() ? draft.split(/[\\s,;]+/).map((p) => p.trim().toLowerCase()).filter(isEmail) : [];\n    const list = [...new Set([...good, ...pendingDraft])].filter((e) => !people.some((p) => p.email === e));\n    if (!list.length || bad.length) return;\n    onInvite?.(list, role);\n    setPeople((p) => [...p, ...list.map((email) => ({ email, role, pending: true }))]);\n    setFresh(list);\n    setChips([]);\n    setDraft(\"\");\n    inputRef.current?.focus();\n  };\n\n  const changeRole = (email: string, value: PopupShareRole | \"remove\") => {\n    onRoleChange?.(email, value);\n    if (value === \"remove\") {\n      setLeaving((l) => [...l, email]);\n      timers.current.push(\n        window.setTimeout(() => {\n          setPeople((p) => p.filter((x) => x.email !== email));\n          setLeaving((l) => l.filter((x) => x !== email));\n        }, 280),\n      );\n      return;\n    }\n    setPeople((p) => p.map((x) => (x.email === email ? { ...x, role: value } : x)));\n  };\n\n  const toggleAccess = () => {\n    const next = access === \"restricted\" ? \"link\" : \"restricted\";\n    setAccess(next);\n    onAccessChange?.(next);\n  };\n\n  const copy = () => {\n    navigator.clipboard?.writeText(link).catch(() => {});\n    onCopy?.(link);\n    setCopied(true);\n    timers.current.push(window.setTimeout(() => setCopied(false), 1800));\n  };\n\n  const count = good.length + (draft.trim() && isEmail(draft.trim().toLowerCase()) ? 1 : 0);\n\n  return (\n    <div\n      className={`hb-xf12 ${embedded ? \"hb-xf12-embedded\" : \"\"} ${className}`}\n      style={{ \"--hb-xf12-accent\": accent, ...style } as React.CSSProperties}\n      onKeyDown={(e) => {\n        if (embedded && e.key === \"Escape\" && isOpen) {\n          e.stopPropagation();\n          close();\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-popup-share-access\" precedence=\"default\">{css}</style>\n      {showTrigger && (!embedded || !mounted) && (\n        <button ref={triggerRef} type=\"button\" className=\"hb-xf12-trigger\" aria-haspopup=\"dialog\" onClick={() => setOpen(true)}>\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"8\" r=\"3.5\" /><path d=\"M3 19c.8-3.2 3.2-5 6-5s5.2 1.8 6 5M17 8v6M14 11h6\" /></svg>\n          {triggerLabel}\n        </button>\n      )}\n      {mounted && (\n        <div className=\"hb-xf12-overlay\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xf12-scrim\" onClick={close} aria-hidden=\"true\" />\n          <div ref={panelRef} className=\"hb-xf12-panel\" role=\"dialog\" aria-modal={embedded ? undefined : true} aria-labelledby={`${uid}-t`} tabIndex={-1}>\n            <div className=\"hb-xf12-head\">\n              <span className=\"hb-xf12-doc\" aria-hidden=\"true\">\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M9 13h6M9 17h4\" /></svg>\n              </span>\n              <h2 className=\"hb-xf12-title\" id={`${uid}-t`}>Share “{documentName}”</h2>\n              <button type=\"button\" className=\"hb-xf12-close\" aria-label=\"Close\" onClick={close}>\n                <svg viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"m3 3 8 8M11 3l-8 8\" /></svg>\n              </button>\n            </div>\n            <div className=\"hb-xf12-invite\">\n              <div className=\"hb-xf12-field\" onClick={() => inputRef.current?.focus()}>\n                {chips.map((c) => {\n                  const ok = isEmail(c);\n                  return (\n                    <span key={c} className=\"hb-xf12-chip\" data-bad={!ok}>\n                      <span className=\"hb-xf12-chipava\" style={{ background: ok ? `hsl(${hue(c)} 55% 45%)` : \"#5a2a2a\" }} aria-hidden=\"true\">\n                        {ok ? c[0].toUpperCase() : \"!\"}\n                      </span>\n                      <span className=\"hb-xf12-chiptext\">{c}</span>\n                      <button type=\"button\" className=\"hb-xf12-chipx\" aria-label={`Remove ${c}`} onClick={() => setChips((x) => x.filter((y) => y !== c))}>\n                        <svg viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"m2.5 2.5 5 5M7.5 2.5l-5 5\" /></svg>\n                      </button>\n                    </span>\n                  );\n                })}\n                <input\n                  ref={inputRef}\n                  data-autofocus\n                  className=\"hb-xf12-input\"\n                  type=\"text\"\n                  inputMode=\"email\"\n                  autoComplete=\"off\"\n                  value={draft}\n                  placeholder={chips.length ? \"\" : \"Add people by email\"}\n                  aria-label=\"Add people by email\"\n                  aria-describedby={`${uid}-h`}\n                  onChange={(e) => {\n                    const v = e.target.value;\n                    if (/[\\s,;]$/.test(v)) addChips(v);\n                    else setDraft(v);\n                  }}\n                  onPaste={(e) => {\n                    const text = e.clipboardData.getData(\"text\");\n                    if (/[\\s,;]/.test(text.trim())) {\n                      e.preventDefault();\n                      addChips(draft + text);\n                    }\n                  }}\n                  onKeyDown={(e) => {\n                    if (e.key === \"Enter\") {\n                      e.preventDefault();\n                      if (draft.trim()) addChips(draft);\n                      else invite();\n                    } else if (e.key === \"Backspace\" && !draft && chips.length) {\n                      setChips((c) => c.slice(0, -1));\n                    }\n                  }}\n                  onBlur={() => draft.trim() && addChips(draft)}\n                />\n              </div>\n              <span className=\"hb-xf12-select\">\n                <select value={role} aria-label=\"Permission for new people\" onChange={(e) => setRole(e.target.value as PopupShareRole)}>\n                  <option value=\"view\">Can view</option>\n                  <option value=\"comment\">Can comment</option>\n                  <option value=\"edit\">Can edit</option>\n                </select>\n                <Chevron />\n              </span>\n              <button type=\"button\" className=\"hb-xf12-btn hb-xf12-primary\" disabled={count === 0 || bad.length > 0} onClick={invite}>\n                Invite{count > 1 ? ` ${count}` : \"\"}\n              </button>\n            </div>\n            <p className=\"hb-xf12-hint\" id={`${uid}-h`} role=\"alert\">\n              {bad.length ? `${bad[0]} is not a valid email` : \"\"}\n            </p>\n            <div className=\"hb-xf12-sec\">\n              <p className=\"hb-xf12-label\">People with access</p>\n              <ul className=\"hb-xf12-people\">\n                {people.map((p) => {\n                  const display = p.name ?? p.email.split(\"@\")[0];\n                  const init = display.replace(/\\(.*\\)/, \"\").trim().split(/[\\s.]+/).map((s) => s[0]).join(\"\").slice(0, 2).toUpperCase();\n                  return (\n                    <li key={p.email} className=\"hb-xf12-person\" data-new={fresh.includes(p.email)} data-leaving={leaving.includes(p.email)}>\n                      <span className=\"hb-xf12-ava\" style={{ background: `linear-gradient(140deg, hsl(${hue(p.email)} 60% 55%), hsl(${(hue(p.email) + 40) % 360} 55% 38%))` }} aria-hidden=\"true\">{init}</span>\n                      <div className=\"hb-xf12-who\">\n                        <p className=\"hb-xf12-name\">{display}{p.pending && <span className=\"hb-xf12-pending\">Invited</span>}</p>\n                        <p className=\"hb-xf12-mail\">{p.email}</p>\n                      </div>\n                      {p.role === \"owner\" ? (\n                        <span className=\"hb-xf12-owner\">Owner</span>\n                      ) : (\n                        <span className=\"hb-xf12-select hb-xf12-mini\">\n                          <select value={p.role} aria-label={`Permission for ${display}`} onChange={(e) => changeRole(p.email, e.target.value as PopupShareRole | \"remove\")}>\n                            {(Object.keys(roleText) as PopupShareRole[]).map((r) => (\n                              <option key={r} value={r}>{roleText[r]}</option>\n                            ))}\n                            <option value=\"remove\">Remove access</option>\n                          </select>\n                          <Chevron />\n                        </span>\n                      )}\n                    </li>\n                  );\n                })}\n              </ul>\n            </div>\n            <div className=\"hb-xf12-sec\">\n              <p className=\"hb-xf12-label\">General access</p>\n            </div>\n            <div className=\"hb-xf12-access\" data-a={access}>\n              <span className=\"hb-xf12-globe\" aria-hidden=\"true\">\n                <svg className=\"hb-xf12-g-lock\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\"><rect x=\"5\" y=\"11\" width=\"14\" height=\"10\" rx=\"2.5\" /><path d=\"M8 11V8a4 4 0 0 1 8 0v3\" /></svg>\n                <svg className=\"hb-xf12-g-world\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\"><circle cx=\"12\" cy=\"12\" r=\"8.5\" /><path d=\"M3.5 12h17M12 3.5c2.5 2.6 3.6 5.4 3.6 8.5s-1.1 5.9-3.6 8.5c-2.5-2.6-3.6-5.4-3.6-8.5S9.5 6.1 12 3.5Z\" /></svg>\n              </span>\n              <div className=\"hb-xf12-acc-text\">\n                <button type=\"button\" className=\"hb-xf12-acc-btn\" aria-pressed={access === \"link\"} onClick={toggleAccess}>\n                  {access === \"link\" ? \"Anyone with the link\" : \"Restricted\"}\n                  <Chevron />\n                </button>\n                <p className=\"hb-xf12-acc-desc\" key={access}>\n                  {access === \"link\" ? \"Anyone on the internet with the link can view\" : \"Only people with access can open the link\"}\n                </p>\n              </div>\n            </div>\n            <div className=\"hb-xf12-foot\">\n              <button type=\"button\" className=\"hb-xf12-btn hb-xf12-copy\" data-done={copied} onClick={copy} aria-live=\"polite\">\n                <span className=\"hb-xf12-cicon\" aria-hidden=\"true\">\n                  <svg className=\"hb-xf12-c-link\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\"><path d=\"M10 14a4.5 4.5 0 0 0 6.4 0l3-3a4.5 4.5 0 0 0-6.4-6.4l-1 1M14 10a4.5 4.5 0 0 0-6.4 0l-3 3a4.5 4.5 0 0 0 6.4 6.4l1-1\" /></svg>\n                  <svg className=\"hb-xf12-c-ok\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"m5 12.5 4.5 4.5L19 7.5\" /></svg>\n                </span>\n                {copied ? \"Link copied\" : \"Copy link\"}\n              </button>\n              <button type=\"button\" className=\"hb-xf12-btn hb-xf12-done\" onClick={close}>Done</button>\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}