@mxstage/mxstage 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,20 +7,20 @@
7
7
  [![IBM Maximo / MAS Manage](https://img.shields.io/badge/IBM_Maximo-MAS_Manage-0f62fe)](#requirements)
8
8
  [![EAM / CMMS](https://img.shields.io/badge/category-EAM_%7C_CMMS-6f42c1)](#requirements)
9
9
  [![MCP server](https://img.shields.io/badge/MCP-server-555555)](https://modelcontextprotocol.io)
10
- [![Glama MCP server score](https://glama.ai/mcp/servers/mxstage/mxstage/badges/score.svg)](https://glama.ai/mcp/servers/mxstage/mxstage)
11
10
  [![Free for test environments](https://img.shields.io/badge/free-test_environments-2ea44f)](https://mxstage.tsunagi.app/pricing)
12
11
  [![License: BSL 1.1](https://img.shields.io/badge/license-BSL_1.1_%E2%86%92_Apache_2.0-blue)](LICENSE)
13
12
  [![Windows](https://img.shields.io/badge/platform-Windows-0078d4)](#requirements)
14
13
 
15
14
  English | [日本語](README.ja.md)
16
15
 
17
- **MX Stage is a local-only AI workbench for correcting IBM Maximo data with your own AI assistant (Claude Desktop, ChatGPT, IBM Bob): every change is staged, diffed and approved by a human before it is written to Maximo.**
16
+ **MX Stage is a local-only AI workbench for correcting IBM Maximo data with your own AI assistant (Claude Desktop, ChatGPT, Antigravity, IBM Bob): every change is staged, diffed and approved by a human before it is written to Maximo.**
18
17
 
19
18
  Website: https://mxstage.tsunagi.app · Contact: mxstage@tsunagi.app
20
19
 
21
- - **Your AI works on a staging sheet, not on Maximo.** The AI assistant loads Maximo data into a sheet in the *work screen* (a browser tab), analyses it and proposes changes with reasons. You see every changed cell.
22
- - **Only a person can commit.** The AI's tools cannot write to Maximo. Changes are written only when you press **Commit to Maximo** in the work screen. MX Stage writes one record first, checks it, then continues, and stops on conflicts. Any batch of changes can be undone before you commit.
23
- - **Nothing leaves your PC except calls to your Maximo and your AI assistant.** There is no MX Stage cloud and no telemetry. The only exception is optional: if you turn on **Settings → Updates → Update automatically** (off by default), the bridge asks GitHub once a day for the latest version number. Installs made with the setup script then update themselves while no work is open; the Claude Desktop extension downloads and checks the new file for you to install. A small local process (the *bridge*) serves the work screen, talks MCP to your AI assistant and relays requests to Maximo, so Maximo needs no CORS settings. Your Maximo API key is saved on this PC by the bridge, encrypted with Windows data protection (DPAPI) or the macOS Keychain, and is never sent to the browser. Every window of the work screen — the installed app, a browser tab, or the browser inside your AI assistant — connects automatically, even after a restart, and you can switch between saved Maximo environments in Settings. (You can also connect without saving; the key then stays only in the tab's memory.)
20
+ - **Your AI works on a staging sheet, not on Maximo.** The AI assistant loads Maximo data into a sheet in the *work screen* (a browser tab), analyses it and proposes changes with reasons. You see every changed cell. The sheets live only in the work screen tab and the bridge's memory; loaded tables are never written to disk.
21
+ - **Only a person can commit.** The AI's tools cannot write to Maximo. Changes are written only when you press **Commit to Maximo** in the work screen. MX Stage writes one record first and lets you check it before it sends the rest. Records that someone else changed after you loaded them are skipped and listed; it stops on an error or a result it cannot confirm. Any batch of changes can be undone before you commit. You choose in the commit panel how many records one commit sends (all of them, or a number; 200 by default).
22
+ - **Keep a record of what was approved.** The commit panel saves a diff report (Excel): one row per changed cell with the old value, the new value, who changed it (the AI assistant or a person) and why. After a commit, it also holds the write log of that commit.
23
+ - **Nothing leaves your PC except calls to your Maximo and your AI assistant.** There is no MX Stage cloud and no telemetry. There are two optional exceptions: if you turn on **Settings → Updates → Update automatically** (off by default), the bridge asks GitHub once a day for the latest version number; and if you choose **Settings → Demo → Download data and connect**, it downloads fictional sample data once from `mxstage-demo.pages.dev` (nothing is sent). Installs made with the setup script then update themselves while no work is open (the new version from GitHub, its packages from the npm registry); the Claude Desktop extension downloads the new file from GitHub and checks it for you to install. A small local process (the *bridge*) serves the work screen, talks MCP to your AI assistant and relays requests to Maximo, so Maximo needs no CORS settings. Your Maximo API key is saved on this PC by the bridge, encrypted with Windows data protection (DPAPI), and is not sent to the browser (on macOS, untested, the Keychain protects it; on Linux, a file only your user can read). Every window of the work screen — the installed app, a browser tab, or the browser inside your AI assistant — connects automatically, even after a restart, and you can switch between saved Maximo environments in Settings. (You can also connect without saving; the key then stays only in the tab's memory.)
24
24
  - **Teach it your procedures.** Save a procedure worked out in a conversation as a *Skill*; the AI follows it next time.
25
25
 
26
26
  ## Why not call the Maximo REST API from the AI directly?
@@ -33,14 +33,14 @@ Several Maximo MCP servers let the AI call the REST API. That is fine for readin
33
33
  |---|---|
34
34
  | Claude Desktop (chat and Code tab) | Supported |
35
35
  | ChatGPT desktop — **Codex** or **Work** mode (Chat mode cannot use local MCP servers) | Supported |
36
- | Claude Code, Codex CLI and IDE extension, Antigravity | Work, not officially supported |
36
+ | Antigravity (2.0, IDE) | Supported (registered by the installer) |
37
37
  | IBM Bob | Supported (registered by the installer) |
38
- | LM Studio | Coming |
38
+ | Claude Code, Codex CLI and IDE extension | Work, not officially supported |
39
39
 
40
40
  ## Requirements
41
41
 
42
42
  - Windows (macOS and Linux are untested)
43
- - Node.js 22.6 or later and Git (the installer offers to install them)
43
+ - For the installer: Node.js 22.6 or later and Git (the installer offers to install them). The Claude Desktop extension needs neither; the npm package (`npx @mxstage/mxstage`) needs Node.js 20 or later.
44
44
  - Chrome or Edge
45
45
  - IBM Maximo or Maximo Application Suite (Manage) with the JSON API at `/maximo/api` and an API key
46
46
 
@@ -55,6 +55,16 @@ Several Maximo MCP servers let the AI call the REST API. That is fine for readin
55
55
 
56
56
  The extension needs no Node.js or Git: Claude Desktop runs it. To use MX Stage from other assistants as well (ChatGPT desktop, IBM Bob, Claude Code in the terminal, Antigravity), use the installer below; it detects the extension and does not register MX Stage twice.
57
57
 
58
+ ### Try without Maximo
59
+
60
+ No Maximo at hand? MX Stage includes a demo: a fictional Maximo with three waste incineration plants (assets, locations, about 52,000 work orders, inventory and the data quality problems migrations leave behind), in Japanese or English, running inside the bridge on your PC.
61
+
62
+ 1. Install MX Stage (above), then open `http://127.0.0.1:8788/settings#demo`.
63
+ 2. Choose **Download data and connect**. MX Stage downloads about 10 MB of fictional data (no programs) once from `mxstage-demo.pages.dev` and checks it against a SHA-256 built into this version.
64
+ 3. Ask your AI assistant, for example "Check the data quality of the operating assets at North Clean Center and list the problems with counts."
65
+
66
+ Commits change only the copy on your PC (**Reset to the initial state** puts it back), and no license is needed. The demo takes about 0.5 GB of memory while in use. Five sample Excel files to merge with Maximo (purchase orders without work order numbers, a legacy equipment register, daily work reports printed as A4 forms (a repair log table in the English data), an equipment register ahead of Maximo, a star chart) are in the same tab. See [docs/demo.en.md](docs/demo.en.md).
67
+
58
68
  ### Claude plugin (Skills)
59
69
 
60
70
  The `mxstage` plugin in [`plugin/`](plugin) adds two Skills to Claude (planning a safe bulk correction of Maximo data; explaining, installing and troubleshooting MX Stage) and, in Claude Code and Cowork, starts the MX Stage server with `npx @mxstage/mxstage` (Node.js 20 or later). Chat does not start local servers, so use the extension there. In Claude Code: `/plugin marketplace add mxstage/mxstage`, then `/plugin install mxstage@mxstage`.
@@ -86,8 +96,28 @@ To update, say "update MX Stage"; to remove it, say "uninstall MX Stage" (see [U
86
96
  | Codex (ChatGPT desktop, CLI, IDE extension) | `[mcp_servers.mxstage]` in `~\.codex\config.toml` | `~\.agents\skills\<name>\SKILL.md` | Restart Codex |
87
97
  | IBM Bob | `mcpServers.mxstage` in `~\.bob\settings\mcp.json` | `~\.bob\skills\<name>\SKILL.md` | Restart IBM Bob |
88
98
 
99
+ The installer copies the 17 built-in Skills (the index `mxstage-workbench`, the basic operations `mxstage-core-*` and the standard objects `mxstage-obj-*`) and your own Skills (in `~\.config\mxstage\skills\`). Assistants that get no Skill files (Claude Desktop chat, the `agy` CLI) still receive the index and the list of Skills in tool results (see [Skills](#skills)).
100
+
101
+ ### Checking in each assistant
102
+
103
+ Screen names are those in each product's documentation (English UI, September 2026).
104
+
105
+ | Assistant | MCP (`mxstage` and its tools) | Skills (`mxstage-workbench` and others) |
106
+ |---|---|---|
107
+ | Claude Code (CLI) | `/mcp` in a conversation (list and connection state). In a shell: `claude mcp list`, `claude mcp get mxstage` | `/skills` in a conversation. Typing `/` shows `/mxstage-workbench` |
108
+ | Claude Desktop (Code tab) | **+** in the input box → **Connectors** | Type `/` in the input box, or **+** → **Slash commands** |
109
+ | Claude Desktop (chat) | **+** in the input box → **Connectors** → **Manage connectors** shows the tools. Connection state and logs: Settings → **Developer** (log: `%APPDATA%\Claude\logs\mcp-server-mxstage.log`) | Not shown (no files are copied). Ask "show the MX Stage Skills" and the tools return the list |
110
+ | Antigravity 2.0 | Settings at the bottom left (`Ctrl+,`) → **Customizations** → **Installed MCP Servers** (refresh to reload) | The same **Customizations**. Call one with `/<name>` in a conversation |
111
+ | Antigravity IDE | **…** at the top of the agent panel → **MCP Servers** → **Manage MCP Servers** (**View raw config** opens the file) | **Customizations** in the agent panel |
112
+ | `agy` CLI | `/mcp` in a conversation | Not shown (no files are copied) |
113
+ | Codex (ChatGPT desktop) | Settings → **MCP servers**. `/mcp` in the input box | **Skills** on the left. Type `@` in the input box to pick one |
114
+ | Codex CLI | `codex mcp list`. `/mcp` in a conversation | `/skills` in a conversation, or `$mxstage-workbench` |
115
+ | Codex IDE extension | Gear menu → **MCP servers** | `/skills`, or type `$` to pick one |
116
+
89
117
  ## Uninstall
90
118
 
119
+ ### Remove everything
120
+
91
121
  Say "uninstall MX Stage" to Claude Code, or run in `%USERPROFILE%\mxstage`:
92
122
 
93
123
  ```bash
@@ -96,6 +126,20 @@ node scripts/setup-local.mjs --uninstall
96
126
 
97
127
  This removes the `mxstage` entries from every assistant (restoring any setting the installer replaced), the Skills it copied (unless you edited them), the sign-in shortcut and desktop shortcut, and the bridge it started. It keeps your own Skills (`~\.config\mxstage\skills\`) and the backups. To remove everything, also delete `%USERPROFILE%\mxstage` and `~\.config\mxstage` (the backups are full copies of the original settings files, including any tokens in them), and clear the site data for `127.0.0.1:8788` in your browser.
98
128
 
129
+ ### Remove it from some assistants only
130
+
131
+ The installer has no option to remove a single assistant, so delete only the `mxstage` entry from that assistant's settings. Other servers' settings stay.
132
+
133
+ | Assistant | Remove the MCP server | Remove the Skills |
134
+ |---|---|---|
135
+ | Claude Code (CLI) | `claude mcp remove --scope user mxstage` | In `~\.claude\skills\`, delete the folders MX Stage copied (`mxstage-workbench`, `mxstage-core-*`, `mxstage-obj-*` and your own Skills' names) |
136
+ | Claude Desktop (chat and Code tab) | Settings → **Developer** → **Edit Config** opens `claude_desktop_config.json`: delete the `"mxstage"` entry under `mcpServers` and reopen Claude Desktop. To remove it from the Code tab too, also remove it from Claude Code | None in chat. The Code tab uses Claude Code's |
137
+ | Antigravity | Delete the `"mxstage"` entry under `mcpServers` in `~\.gemini\config\mcp_config.json` (**View raw config** in the IDE opens it) | Delete the same folders in `~\.gemini\config\skills\` |
138
+ | Codex | Delete the `[mcp_servers.mxstage]` table (up to the next `[` line) in `~\.codex\config.toml` and reopen Codex | Delete the same folders in `~\.agents\skills\` |
139
+ | IBM Bob | Delete the `"mxstage"` entry under `mcpServers` in `~\.bob\settings\mcp.json` and restart IBM Bob | Delete the same folders in `~\.bob\skills\` |
140
+
141
+ Running the installer again registers it with that assistant again, unless you add `--no-claude-desktop`, `--no-antigravity`, `--no-codex` or `--no-bob` (Claude Code has no such option, but it is not registered while the MX Stage extension is enabled in Claude Desktop, unless you add `--claude-code`).
142
+
99
143
  ## Installation steps for Claude Code
100
144
 
101
145
  When the user asks to install MX Stage, follow these steps and get the user's approval before each command.
@@ -110,6 +154,16 @@ When the user asks to install MX Stage, follow these steps and get the user's ap
110
154
 
111
155
  **Update**: steps 2 to 4. Ask the user to restart their assistant afterwards so the new bridge is used. **Uninstall**: `node scripts/setup-local.mjs --uninstall --json`. **Status**: `node scripts/setup-local.mjs --status --json` (changes nothing).
112
156
 
157
+ ## What the installer does
158
+
159
+ | What | Details |
160
+ |---|---|
161
+ | Bridge | Starts on port `8788` (fixed, never shifted). There is one per PC; bridges started by AI assistants relay to it |
162
+ | MCP and Skills | Registers them as in [Where it is registered](#where-it-is-registered). To leave some out: `--no-claude-desktop`, `--no-antigravity`, `--no-codex`, `--no-bob`, `--no-skills` |
163
+ | Startup and shortcuts | A shortcut that starts the bridge at sign-in, and `mxstage` on the desktop |
164
+
165
+ Running it again is safe. See [docs/local.md](docs/local.md) (in Japanese) for details.
166
+
113
167
  ## Skills
114
168
 
115
169
  A Skill is a procedure the AI assistant follows.
@@ -128,22 +182,25 @@ A Skill is a procedure the AI assistant follows.
128
182
 
129
183
  ## Documentation
130
184
 
131
- The detailed guides are in Japanese for now:
185
+ The detailed guides are in Japanese for now, except the demo guide:
132
186
 
133
- - [docs/local.md](docs/local.md) — daily use, updates, troubleshooting
187
+ - [docs/demo.en.md](docs/demo.en.md) — trying MX Stage without Maximo (the built-in demo; in English)
188
+ - [docs/local.md](docs/local.md) — daily use, updates, uninstalling, troubleshooting, where things are written
134
189
  - [docs/status.md](docs/status.md) — what works today
135
- - [docs/publish.md](docs/publish.md) — checks before publishing
190
+ - [docs/publish.md](docs/publish.md) — checks before pushing to GitHub (no customer data)
191
+ - [docs/design.md](docs/design.md) — the design rules of the work screen
136
192
 
137
193
  ## Development
138
194
 
139
195
  ```bash
140
196
  npm run typecheck # tsc (app and bridge)
141
- npx vitest run # tests (app and bridge)
197
+ npx vitest run # tests (app, bridge and the demo data generator)
142
198
  npm run test:setup # installer tests (write only to temporary folders)
143
199
  npm run build # build the built-in Skills and the work screen (dist/app)
144
- npm run dev:app # dev server for the work screen (http://localhost:5173/app?demo=1 shows sample data; relays to the dev bridge on 8790)
200
+ npm run dev:app # dev server for the work screen (http://localhost:5173/app?samples=1 shows sample data; relays to the dev bridge on 8790)
145
201
  npm run dev:fake-maximo # a fake Maximo at https://127.0.0.1:9797 (API key: test-api-key)
146
202
  npm run dev:bridge # a bridge on port 8790 that accepts the development license for the fake Maximo
203
+ node scripts/check-publish.mjs --worktree # checks before pushing (docs/publish.md)
147
204
  ```
148
205
 
149
206
  Disable IBM telemetry when installing dependencies (`$env:IBM_TELEMETRY_DISABLED='true'; npm install` in PowerShell); the installer does this itself. See [dev/README.md](dev/README.md) for developing and testing license checks.
@@ -155,9 +212,9 @@ Disable IBM telemetry when installing dependencies (`$env:IBM_TELEMETRY_DISABLED
155
212
  MX Stage is licensed under the [Business Source License 1.1](LICENSE). The source is available, but it is not open source. The [LICENSE](LICENSE) file is authoritative; this is a summary.
156
213
 
157
214
  - **Free**: everything except committing to a production Maximo — loading, analysing and editing production data, building Skills, and committing to test environments. You may read, modify and redistribute the source under the same license.
158
- - **License needed**: using MX Stage to create, change or delete data in a **production Maximo environment** — US$4,800 per production environment per year, for any number of users and PCs. The license key names the environment's URLs (up to three aliases). [Pricing](https://mxstage.tsunagi.app/pricing).
215
+ - **License needed**: using MX Stage to create, change or delete data in a **production Maximo environment** — US$4,800 per production environment per year, for any number of users and PCs. The license key names the environment's URLs (up to three aliases). [License and purchase](https://mxstage.tsunagi.app/license).
159
216
  - **Production environment**: the Maximo your organization uses to record day-to-day operations, and an environment being prepared to replace it (for example, a migration target before go-live). **Test environment**: everything else (development, test, training, demonstration, migration rehearsal), even if it holds a copy of production data.
160
- - **Each version becomes Apache License 2.0 four years after its release.**
217
+ - **Each version becomes Apache License 2.0 four years after its release.** From then on, that version can also write to production under Apache 2.0.
161
218
  - Third-party packages and fonts (IBM Carbon Design System, IBM Plex and others) keep their own licenses ([THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)).
162
219
 
163
220
  IBM and Maximo are trademarks of International Business Machines Corporation. MX Stage is an independent product and is not affiliated with or endorsed by IBM.
@@ -1 +1 @@
1
- import{s as L,r,i as D,a as $,b as z,c as J,T as Q,C as U,m as Z}from"./index-B0jyW4RU.js";const ee=()=>t=>t.targetX,te=()=>t=>t.targetY,re=()=>t=>t.targetWidth,ne=()=>t=>t.targetHeight,ie=()=>t=>t.targetY+10,se=()=>t=>Math.max(0,(t.targetHeight-28)/2),ae=L("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[te(),"px"],"d19meir1-1":[ee(),"px"],"d19meir1-2":[re(),"px"],"d19meir1-3":[ne(),"px"],"d19meir1-4":[ie(),"px"],"d19meir1-5":[se(),"px"]}});function oe(){const[t,s]=r.useState();return[t??void 0,s]}function de(){const[t,s]=oe(),[n,p]=r.useState(0),[f,b]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&b(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(f||t===void 0)return;let a;const o=()=>{const{right:v}=t.getBoundingClientRect();p(g=>Math.min(g+window.innerWidth-v-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,f]);const C=r.useMemo(()=>({transform:`translateX(${n}px)`}),[n]);return{ref:s,style:C}}const ue=t=>{const{target:s,content:n,onFinishEditing:p,forceEditMode:f,initialValue:b,imageEditorOverride:C,markdownDivCreateNode:a,highlight:o,className:v,theme:g,id:G,cell:x,bloom:I,validateCell:m,getCellRenderer:w,provideEditor:F,isOutsideClick:H}=t,[d,X]=r.useState(f?n:void 0),O=r.useRef(d??n);O.current=d??n;const[y,S]=r.useState(()=>m===void 0?!0:!(D(n)&&m?.(x,n,O.current)===!1)),u=r.useCallback((e,i)=>{p(y?e:void 0,i)},[y,p]),A=r.useCallback(e=>{if(m!==void 0&&e!==void 0&&D(e)){const i=m(x,e,O.current);i===!1?S(!1):(typeof i=="object"&&(e=i),S(!0))}X(e)},[x,m]),h=r.useRef(!1),c=r.useRef(void 0),K=r.useCallback(()=>{u(d,[0,0]),h.current=!0},[d,u]),W=r.useCallback((e,i)=>{u(e,i??c.current??[0,0]),h.current=!0},[u]),Y=r.useCallback(async e=>{let i=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),c.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),c.current=[0,1],i=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),c.current=[e.shiftKey?-1:1,0],i=!0),window.setTimeout(()=>{!h.current&&c.current!==void 0&&(u(i?d:void 0,c.current),h.current=!0)},0)},[u,d]),k=d??n,[l,j]=r.useMemo(()=>{if($(n))return[];const e=F?.(n);return e!==void 0?[e,!1]:[w(n)?.provideEditor?.(n),!1]},[n,w,F]),{ref:q,style:B}=de();let P=!0,M,_=!0,E;if(l!==void 0){P=l.disablePadding!==!0,_=l.disableStyling!==!0;const e=z(l);e&&(E=l.styleOverride);const i=e?l.editor:l;M=r.createElement(i,{isHighlighted:o,onChange:A,value:k,initialValue:b,onFinishedEditing:W,validatedSelection:D(k)?k.selectionRange:void 0,forceEditMode:f,target:s,imageEditorOverride:C,markdownDivCreateNode:a,isValid:y,theme:g})}E={...E,...B};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `<div id="portal" />` as the last child of your `<body>`.'),null;let R=_?"gdg-style":"gdg-unstyle";y||(R+=" gdg-invalid"),P&&(R+=" gdg-pad");const T=I?.[0]??1,V=I?.[1]??1;return J.createPortal(r.createElement(Q.Provider,{value:g},r.createElement(U,{style:Z(g),className:v,onClickOutside:K,isOutsideClick:H},r.createElement(ae,{ref:q,id:G,className:R,style:E,as:j===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:Y},M)))),N)};export{ue as default};
1
+ import{s as L,r,i as D,a as $,b as z,c as J,T as Q,C as U,m as Z}from"./index-BAUH5zpJ.js";const ee=()=>t=>t.targetX,te=()=>t=>t.targetY,re=()=>t=>t.targetWidth,ne=()=>t=>t.targetHeight,ie=()=>t=>t.targetY+10,se=()=>t=>Math.max(0,(t.targetHeight-28)/2),ae=L("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[te(),"px"],"d19meir1-1":[ee(),"px"],"d19meir1-2":[re(),"px"],"d19meir1-3":[ne(),"px"],"d19meir1-4":[ie(),"px"],"d19meir1-5":[se(),"px"]}});function oe(){const[t,s]=r.useState();return[t??void 0,s]}function de(){const[t,s]=oe(),[n,p]=r.useState(0),[f,b]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&b(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(f||t===void 0)return;let a;const o=()=>{const{right:v}=t.getBoundingClientRect();p(g=>Math.min(g+window.innerWidth-v-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,f]);const C=r.useMemo(()=>({transform:`translateX(${n}px)`}),[n]);return{ref:s,style:C}}const ue=t=>{const{target:s,content:n,onFinishEditing:p,forceEditMode:f,initialValue:b,imageEditorOverride:C,markdownDivCreateNode:a,highlight:o,className:v,theme:g,id:G,cell:x,bloom:I,validateCell:m,getCellRenderer:w,provideEditor:F,isOutsideClick:H}=t,[d,X]=r.useState(f?n:void 0),O=r.useRef(d??n);O.current=d??n;const[y,S]=r.useState(()=>m===void 0?!0:!(D(n)&&m?.(x,n,O.current)===!1)),u=r.useCallback((e,i)=>{p(y?e:void 0,i)},[y,p]),A=r.useCallback(e=>{if(m!==void 0&&e!==void 0&&D(e)){const i=m(x,e,O.current);i===!1?S(!1):(typeof i=="object"&&(e=i),S(!0))}X(e)},[x,m]),h=r.useRef(!1),c=r.useRef(void 0),K=r.useCallback(()=>{u(d,[0,0]),h.current=!0},[d,u]),W=r.useCallback((e,i)=>{u(e,i??c.current??[0,0]),h.current=!0},[u]),Y=r.useCallback(async e=>{let i=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),c.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),c.current=[0,1],i=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),c.current=[e.shiftKey?-1:1,0],i=!0),window.setTimeout(()=>{!h.current&&c.current!==void 0&&(u(i?d:void 0,c.current),h.current=!0)},0)},[u,d]),k=d??n,[l,j]=r.useMemo(()=>{if($(n))return[];const e=F?.(n);return e!==void 0?[e,!1]:[w(n)?.provideEditor?.(n),!1]},[n,w,F]),{ref:q,style:B}=de();let P=!0,M,_=!0,E;if(l!==void 0){P=l.disablePadding!==!0,_=l.disableStyling!==!0;const e=z(l);e&&(E=l.styleOverride);const i=e?l.editor:l;M=r.createElement(i,{isHighlighted:o,onChange:A,value:k,initialValue:b,onFinishedEditing:W,validatedSelection:D(k)?k.selectionRange:void 0,forceEditMode:f,target:s,imageEditorOverride:C,markdownDivCreateNode:a,isValid:y,theme:g})}E={...E,...B};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `<div id="portal" />` as the last child of your `<body>`.'),null;let R=_?"gdg-style":"gdg-unstyle";y||(R+=" gdg-invalid"),P&&(R+=" gdg-pad");const T=I?.[0]??1,V=I?.[1]??1;return J.createPortal(r.createElement(Q.Provider,{value:g},r.createElement(U,{style:Z(g),className:v,onClickOutside:K,isOutsideClick:H},r.createElement(ae,{ref:q,id:G,className:R,style:E,as:j===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:Y},M)))),N)};export{ue as default};