> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# SearchElement (레거시)

> 레거시 SearchElement 레퍼런스입니다. 새로운 통합에는 @whop/elements의 검색 오버레이를 사용하세요.

## 개요

사용자가 채널, DM 또는 지원 채팅에서 메시지를 검색할 수 있게 해 주는 UI 요소입니다.

## 사용법

### 기본 사용법

```typescript theme={null}
// Create the element
const element = session.createElement("search-element", {
  onClose: (ev) => {
    console.log("Search element closed");
  },
});

// Mount it to a container
element.mount("#search-container");
```

### 모달로 사용하기

```typescript theme={null}
// Show the element in a modal overlay
const modal = session.showSearchModal({
  channelId: "feed_XXXXXXXXXXXXXX",
  onResultClick: (ev) => {
    console.log("Result clicked!", ev.detail.messageId);
    // Element auto-unmounts by default
  },
});
```

```typescript theme={null}
const element = session.createElement("search-element", {
  channelId: "feed_XXXXXXXXXXXXXX",
  onReady: (element) => {
    console.log("Search element is ready");
  },
});
```

## 이벤트

SearchElement가 발생시키는 이벤트입니다.

`on()` 메서드를 사용하거나 옵션에 콜백 함수를 전달하여 이 이벤트를 수신할 수 있습니다.

### `error`

요소 초기화 또는 작업 중 오류가 발생하면 발생합니다.

**콜백 시그니처:** (error: `unknown`) => void

### `ready`

요소가 로딩을 마치고 사용자 상호작용 준비가 완료되면 발생합니다.

**콜백 시그니처:** (element: `SearchElement`) => void

### `optionsUpdated`

`updateOptions()`를 통해 요소의 옵션이 업데이트되면 발생합니다.

**콜백 시그니처:** (options: [`SearchElementOptions`](#searchelementoptions)) => void

### `snapshot`

요소의 내부 상태가 변경되면 발생합니다.

**콜백 시그니처:** (snapshot: [`SearchElementSnapshot`](#searchelementsnapshot)) => void

### `close`

사용자가 검색 요소를 닫으면 발생합니다.
요소가 자동으로 마운트 해제되지 않도록 하려면 `ev.preventDefault()`를 호출하세요.

**콜백 시그니처:** (ev: `CustomEvent`\<`any`>) => void

### `resultClick`

사용자가 검색 결과를 클릭하면 실행되는 콜백입니다.
요소가 자동으로 마운트 해제되지 않도록 하려면 `ev.preventDefault()`를 호출하세요.

**콜백 시그니처:** (ev: `CustomEvent`\<\{ messageId: `string`; channelId: `string`; }>) => void

## 메서드

### `mount(container)`

요소를 DOM 컨테이너에 마운트합니다.

컨테이너는 빈 요소여야 합니다. 요소는 자식으로 추가됩니다.
요소가 이미 마운트된 경우 이 메서드는 경고를 기록하고 반환합니다.

| 매개변수 | 타입 | 설명 |
| - | - | - |
| `container` | `HTMLElement` \| `#$\{`string`\}` | 컨테이너 요소 또는 '#'으로 시작하는 CSS 선택자 |

```typescript theme={null}
// Using a selector
element.mount("#my-container");

// Using an element reference
const container = document.getElementById("my-container");
element.mount(container);
```

### `unmount()`

DOM에서 요소를 제거하고 모든 이벤트 리스너를 정리합니다.

마운트 해제한 후에는 요소 인스턴스를 재사용하면 안 됩니다.
다시 마운트해야 하는 경우 새 요소 인스턴스를 생성하세요.

```typescript theme={null}
// Unmount when done
element.unmount();

// Commonly used in event handlers
element.on("complete", () => {
  element.unmount();
});
```

### `updateOptions(options)`

생성 후 요소의 구성 옵션을 업데이트합니다.

제공된 옵션만 업데이트되며, 다른 옵션은 변경되지 않습니다.
요소는 새 옵션으로 다시 렌더링됩니다.

| 매개변수 | 타입 | 설명 |
| - | - | - |
| `options` | `Partial`\<[`SearchElementOptions`](#searchelementoptions)> | 업데이트할 값이 담긴 부분 옵션 객체 |

```typescript theme={null}
// Update a single option
element.updateOptions({
  onComplete: (ev) => {
    console.log("New handler!");
  },
});
```

### `getSnapshot()`

요소의 현재 상태 스냅샷을 가져옵니다.

스냅샷에는 로딩 상태, 폼 값 또는 기타 요소별 데이터 등
요소의 현재 내부 상태가 포함됩니다.

**반환값:** [`SearchElementSnapshot`](#searchelementsnapshot)

```typescript theme={null}
const snapshot = element.getSnapshot();
console.log("Current state:", snapshot.state);

// Or listen for changes
element.on("snapshot", (snapshot) => {
  console.log("State changed:", snapshot);
});
```

## 스타일링

`appearance.classes`로 이 요소를 사용자 지정할 수 있습니다. 안정적인 클래스 이름의 전체 목록과 예제 스니펫은 [스타일링 레퍼런스](https://docs.whop.com/ko/sdk/elements/styling-reference.md)를 참조하세요.

## 타입

### SearchElementOptions

SearchElement의 구성 옵션입니다.

| 속성 | 타입 | 필수 | 기본값 | 설명 |
| - | - | - | - | - |
| `companyId` | `string \| undefined` | 아니요 | - | 메시지를 검색할 계정의 ID입니다. |
| `channelId` | `string \| undefined` | 아니요 | - | 메시지를 검색할 채널, DM 또는 지원 채팅의 ID입니다. |
| `onReady` | `((element: SearchElement) => void) \| undefined` | 아니요 | - | 요소가 로딩을 마치고 상호작용 준비가 완료되면 실행되는 콜백입니다. 'ready' 이벤트를 수신하는 것과 동일합니다. |
| `onClose` | `((ev: CustomEvent) => void) \| undefined` | 아니요 | - | 사용자가 요소를 닫으면 실행되는 콜백입니다. 기본적으로 요소는 닫힐 때 마운트 해제됩니다. 마운트된 상태로 유지하려면 'ev.preventDefault()'를 호출하세요. |
| `onResultClick` | `((ev: CustomEvent<{ messageId: string; channelId: string; }>) => void) \| undefined` | 아니요 | - | 사용자가 검색 결과를 클릭하면 실행되는 콜백입니다. 기본적으로 결과를 클릭하면 요소가 마운트 해제됩니다. 마운트된 상태로 유지하려면 'ev.preventDefault()'를 호출하세요. |

### SearchElementSnapshot

SearchElement의 현재 상태를 나타냅니다.

현재 상태를 가져오려면 `element.getSnapshot()`을 사용하고, 변경 사항을 확인하려면 `snapshot` 이벤트를 수신하세요.

| 속성 | 타입 | 필수 | 기본값 | 설명 |
| - | - | - | - | - |
| `state` | `"ready" \| "loading"` | 예 | - | 요소의 현재 로딩 상태입니다. - '"loading"' - 요소가 초기화 중입니다 - '"ready"' - 요소가 완전히 로드되어 상호작용이 가능합니다 |


## Related topics

- [SearchElement](https://docs.whop.com/ko/elements/latest/chat/search.md)
- [Element 세션(레거시)](https://docs.whop.com/ko/sdk/elements/overview.md)
- [ChatElement(레거시)](https://docs.whop.com/ko/sdk/elements/chat-element.md)
