dsh-artifact-studio 0.7.3 → 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.
- package/README.md +65 -11
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/assets/canvas.engine.js +1 -1
- package/client.canvas.js +1 -1
- package/client.doc.js +67 -79
- package/client.js +102 -23
- package/client.sheet.js +218 -0
- package/dist/contract.js +54 -10
- package/dist/host/lib/brief.js +127 -0
- package/dist/host/lib/checks.js +62 -8
- package/dist/host/lib/design-catalog.js +149 -0
- package/dist/host/lib/design-system.js +23 -2
- package/dist/host/lib/export.js +100 -0
- package/dist/host/lib/fsutil.js +41 -0
- package/dist/host/lib/generation.js +36 -0
- package/dist/host/lib/guide.js +130 -0
- package/dist/host/lib/paths.js +2 -1
- package/dist/host/lib/recipes.js +224 -0
- package/dist/host/lib/rpc.js +20 -5
- package/dist/host/lib/service.js +226 -24
- package/dist/host/lib/skill.js +87 -11
- package/dist/host/lib/store.js +107 -25
- package/dist/host/lib/tools.js +354 -52
- package/dist/host/lib/validate.js +24 -0
- package/dist/host/lib/xlsx.js +313 -0
- package/dist/html-tags.js +51 -0
- package/dist/kit.js +224 -0
- package/dist/render.js +10 -3
- package/dist/sheet/formula.js +475 -0
- package/dist/sheet/functions.js +463 -0
- package/dist/sheet/index.js +9 -0
- package/dist/sheet/model.js +628 -0
- package/dist/sheet/operations.js +384 -0
- package/dist/sheet/output.js +170 -0
- package/examples/page-design-system.html +150 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
# Artifacts for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
The agent creates pages, documents, and OpenPencil designs as versioned files, and you open them beside the chat. It works offline with no account and no hosted service.
|
|
3
|
+
The agent creates pages, documents, spreadsheets, and OpenPencil designs as versioned files, and you open them beside the chat. It works offline with no account and no hosted service.
|
|
4
4
|
|
|
5
5
|
## What it does
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Thirteen agent tools and one bundled skill: `artifact_create`, `artifact_read`, `artifact_update`, `artifact_sheet_update`, `artifact_list`, `artifact_delete`, `artifact_export`, `design_system_read`, `design_system_update`, `artifact_brief`, `artifact_guide_update`, `design_system_list`, and `artifact_rebase`.
|
|
8
|
+
- Four artifact types. A page is a self-contained HTML document rendered in a sandboxed frame with no network. A doc is Markdown edited in a Tiptap rich-text editor. A sheet is a JSON workbook edited in a grid: cells hold values or Excel formulas, the host computes formula results for export and print, and the agent edits cells with `artifact_sheet_update`. A design, shown in the UI as a mockup, is OpenPencil Design JSX: the host compiles it and renders a PNG preview, and the panel opens it on a canvas.
|
|
9
9
|
- Design previews run in a separate child process with Node's permission model: no network, no file writes, no child processes, and a 20 s deadline. The canvas loads the same engine in the browser from a local asset route. Icons come from the bundled Material Design Icons set, and Inter, Roboto, and Noto Naskh Arabic ship with the package.
|
|
10
10
|
- A mockup opens in View: the canvas fills the panel with no toolbar, a floating zoom dock, and click selection. Edit adds select, hand, frame, and text tools, undo, and redo, and opens a React inspector in the right drawer with the layer tree and the selection's position, size, rotation, radius, opacity, visibility, and text properties. Selecting a layer shows a bar that turns it into an agent request with the layer name, path, and JSX. Edits become a draft and Save writes a new version of the Design JSX. A version opened from History stays a read-only PNG. Gallery tiles show the saved PNG for visible mockups.
|
|
11
|
-
- Two storage scopes. Workspace artifacts live in `$DSH_HOME/artifacts/workspaces/<workspaceId>/`, keyed by the registered workspace, so the project folder stays clean. Library artifacts live in `$DSH_HOME/artifacts/v1/`, and every project can see them.
|
|
11
|
+
- Two storage scopes. Workspace artifacts live in `$DSH_HOME/artifacts/workspaces/<workspaceId>/`, keyed by the registered workspace, so the project folder stays clean. Library artifacts live in `$DSH_HOME/artifacts/v1/`, and every project can see them. A request that starts from another project's artifact names that project's workspace id, and the agent can pass it as `workspaceId`; without it, tools stay in the session's project.
|
|
12
12
|
- Every save creates a version. You can preview an older version and restore it, which adds a new version.
|
|
13
13
|
- A save is refused when someone else saved first, so neither the agent nor you can silently overwrite the other.
|
|
14
|
-
- Pages export as HTML. Docs export as Markdown, Word, or HTML. You can print
|
|
15
|
-
-
|
|
14
|
+
- Pages export as HTML. Docs export as Markdown, Word, or HTML. Sheets export as CSV (first sheet) or XLSX (every sheet with styles, formulas, and cached results). You can print a page, doc, or sheet or save it as a PDF from the print dialog. Mockups export as PNG, SVG, or a `.fig` document that opens in OpenPencil.
|
|
15
|
+
- Named design systems live in each scope with immutable revisions. Every saved Page or Document version pins the tokens, system identity, recipe, and kit it was made with, so editing text never silently restyles it. `artifact_rebase` is the explicit way to adopt newer settings. Light and dark palettes include page, raised, border, control, paired action/text, focus, and status roles. Existing saved palettes retain their colors; missing neutral and action roles follow their saved brand.
|
|
16
16
|
- The left sidebar opens the Artifacts page with one scope selector for all projects, one project, or the library. Artifacts open as tabs beside the chat. Back preserves gallery search, the scope and type filters, paging, and scroll.
|
|
17
|
-
-
|
|
17
|
+
- The right panel's guide offers an Artifacts page for the current project. It reuses the same search, type filter, pins, design system, create menu, and in-place view as the left page, fixed to that project.
|
|
18
|
+
- A bundled `artifact-design` skill teaches project-first styling, task-specific structure, truthful data, accessibility, and checks before saving. The packaged [page reference](<examples/page-design-system.html>) supplies reusable patterns rendered with injected tokens. The skill provides its installed path. Page writes return warnings for network URLs, browser storage, fixed widths over 960 pixels, and pages that ignore the design tokens.
|
|
18
19
|
- The interface uses the Harness's own components and follows its light and dark theme. A page follows dark mode when it declares `<meta name="color-scheme" content="light dark">`.
|
|
19
20
|
- Reload and Back ask whether to save, discard, or cancel when edits are pending. Multiple views share a draft and serialize saves. Draft recovery stays in window memory until saved or discarded. It does not survive a browser restart.
|
|
20
21
|
- Export saves current edits first and uses that exact version. History exports and prints the selected saved version. A failed save stops output.
|
|
21
|
-
- Edit with agent saves pending edits, then puts your selection and a reference to the artifact and its saved version into this conversation's message box. You finish the sentence and send it. Selections work in documents, in the page preview, and in page code. The full Artifacts page has no conversation, so it copies the same text.
|
|
22
|
-
- The gallery shows page covers
|
|
22
|
+
- Edit with agent saves pending edits, then puts your selection and a reference to the artifact, its workspace, and its saved version into this conversation's message box. You finish the sentence and send it. Selections work in documents, in sheet cells and ranges, in the page preview, and in page code. The full Artifacts page has no conversation, so it copies the same text.
|
|
23
|
+
- The gallery shows page covers, document excerpts, and spreadsheet previews, a pinned group, and one recently updated grid with full artifact names. An empty project offers starter prompts. The header version picker lists versions and opens History.
|
|
23
24
|
- When the agent publishes a newer version, an open clean tab reloads and names the new version. A dirty tab keeps its conflict bar instead.
|
|
24
|
-
- Documents render on a page styled by the design tokens, so the editor matches the export. Formatting controls appear over a selection. Page code opens read-only with highlighting; Edit code switches to the editor, which saves with Save or Ctrl/Cmd+S. Documents autosave after typing.
|
|
25
|
+
- Documents render on a page styled by the design tokens, so the editor matches the export. Formatting controls appear over a selection. Sheets render in a virtualized grid with a formula bar, cell formatting, sheet tabs, undo, and TSV copy and paste; the toolbar edits the selected range and sheets autosave after a change. Page code opens read-only with highlighting; Edit code switches to the editor, which saves with Save or Ctrl/Cmd+S. Documents autosave after typing.
|
|
25
26
|
- The chat shows a card for each create and update, and opens the artifact when the agent writes it in a live turn. The composer button lists this project's recent artifacts, starter prompts, and All artifacts.
|
|
26
27
|
|
|
27
28
|
## Install
|
|
@@ -41,4 +42,57 @@ npm run typecheck # host and client
|
|
|
41
42
|
npm test # build, then host, client, and package tests
|
|
42
43
|
```
|
|
43
44
|
|
|
44
|
-
Sources are TypeScript in `src/`. `npm run build` compiles the host into `dist/`, bundles `client.js` plus the lazy `client.doc.js` and `client.canvas.js`, and copies the canvas engine and its assets into `assets/`. Do not edit the built files.
|
|
45
|
+
Sources are TypeScript in `src/`. `npm run build` compiles the host into `dist/`, bundles `client.js` plus the lazy `client.doc.js`, `client.sheet.js`, and `client.canvas.js`, and copies the canvas engine and its assets into `assets/`. Do not edit the built files.
|
|
46
|
+
|
|
47
|
+
## Intent-aware generation
|
|
48
|
+
|
|
49
|
+
Call artifact_brief with a type to discover recipes, then with a recipe to get conventions, preferences, content sections, relevant earlier artifacts, and type-specific design guidance. Pass that recipe when creating an artifact. Use artifact_guide_update only when the user asks to save a convention or reusable structure. Workspace guides apply to a project; library guides apply across projects. A recipe ID replaces the complete wider definition.
|
|
50
|
+
|
|
51
|
+
New pages can opt into the shared component kit:
|
|
52
|
+
|
|
53
|
+
~~~html
|
|
54
|
+
<meta name="artifact-kit" content="1">
|
|
55
|
+
<main class="ak-page">
|
|
56
|
+
<header class="ak-header"><h1>Title</h1><p class="ak-lede">Summary</p></header>
|
|
57
|
+
<section class="ak-section" data-section="summary"><h2>Summary</h2><p>Content</p></section>
|
|
58
|
+
</main>
|
|
59
|
+
~~~
|
|
60
|
+
|
|
61
|
+
The renderer injects kit CSS and switch behavior after its tokens. Export includes those resources. Legacy pages remain unchanged. Diagnostics are advisory, not proof of quality or a publication gate. Invalid guide files are preserved and require manual repair.
|
|
62
|
+
|
|
63
|
+
A kit version preserves component definitions, not current token values. Updating a design system can still change an old artifact. Multiple named systems, immutable generation snapshots, and approved-example management remain planned. Recipe metadata stays current when older content is restored.
|
|
64
|
+
|
|
65
|
+
The optional [browser check](<tests/generation-browser.mjs>) uses the [synthetic fixture](<tests/fixtures/generation.html>) and an already installed Playwright module and Chrome executable:
|
|
66
|
+
|
|
67
|
+
~~~bash
|
|
68
|
+
node tests/generation-browser.mjs /absolute/path/to/playwright/index.mjs /absolute/path/to/chrome
|
|
69
|
+
~~~
|
|
70
|
+
|
|
71
|
+
It installs nothing and checks 380, 700, and 1280 pixel widths in both themes, keyboard switching, focus, overflow, print panels, and network use. It does not verify the authenticated Harness GUI or compare golden screenshots.
|
|
72
|
+
|
|
73
|
+
## Sheets
|
|
74
|
+
|
|
75
|
+
A sheet artifact stores one JSON workbook in `content/sheet.json`:
|
|
76
|
+
|
|
77
|
+
~~~json
|
|
78
|
+
{
|
|
79
|
+
"schemaVersion": 1,
|
|
80
|
+
"sheets": [
|
|
81
|
+
{
|
|
82
|
+
"name": "Budget",
|
|
83
|
+
"cells": { "A1": "Item", "B1": "Cost", "B2": 1200, "B4": "=SUM(B2:B3)" },
|
|
84
|
+
"columnWidths": { "A": 160 }
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
~~~
|
|
89
|
+
|
|
90
|
+
A plain string, number, or boolean is a cell value. A string that starts with "=" is a formula, and `{ "value": "=literal" }` stores text that starts with "=". A styled cell adds a `style` object with bold, italic, underline, strike, align, color, background, and numberFormat (general, number, integer, currency, percent, or date). The agent reads a sheet and edits it with `artifact_sheet_update` operations: set, write, clear, format, add-sheet, rename-sheet, delete-sheet, and set-column-width. A stale base version is refused, and each accepted call writes one version.
|
|
91
|
+
|
|
92
|
+
Formulas are Excel syntax and run through the bundled fast-formula-parser, with circular-reference detection and Excel-like error propagation for top-level aggregates. A formula that fails is stored and shown as #NAME?, #REF!, #DIV/0!, #VALUE!, #N/A, or #CYCLE!, and the write returns a warning. The panel and the host share one evaluator, so a cell, a CSV row, an XLSX cached result, and a print copy show the same value. XLSX output uses fflate for the OOXML package.
|
|
93
|
+
|
|
94
|
+
## Named systems and pinned versions
|
|
95
|
+
|
|
96
|
+
Each project and the library keep a catalog of named design systems. A new artifact pins the design, recipe, and kit it was generated with; later edits keep them. Choosing a newer design is an explicit rebase that appends a version and leaves the content alone. History, preview, print, and export render a saved version with its own tokens, and a version saved before pinning existed is marked as live.
|
|
97
|
+
|
|
98
|
+
Recipes, guides, and the brief work as described above. Invalid guide or catalog data is reported rather than silently replaced; a crashed writer leaves a lock file that must be removed by hand after confirming no writer is running.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -295,3 +295,59 @@ Version 2.0.
|
|
|
295
295
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
296
296
|
See the License for the specific language governing permissions and
|
|
297
297
|
limitations under the License.
|
|
298
|
+
|
|
299
|
+
## fast-formula-parser
|
|
300
|
+
|
|
301
|
+
The sheet client chunk bundles fast-formula-parser 1.0.19, and the host imports
|
|
302
|
+
it to compute formula values for CSV, XLSX, print, and warnings. It is MIT
|
|
303
|
+
licensed. Its bundled transitive dependencies are chevrotain 7.1.2 and bessel
|
|
304
|
+
1.0.2 (Apache-2.0), and jstat 1.9.6, bahttext 1.1.0, and regexp-to-ast 0.5.0
|
|
305
|
+
(MIT). The Apache License 2.0 text appears earlier in this file.
|
|
306
|
+
|
|
307
|
+
MIT License
|
|
308
|
+
|
|
309
|
+
Copyright (c) 2019 Dishu(Lester) Lyu
|
|
310
|
+
|
|
311
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
312
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
313
|
+
in the Software without restriction, including without limitation the rights
|
|
314
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
315
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
316
|
+
furnished to do so, subject to the following conditions:
|
|
317
|
+
|
|
318
|
+
The above copyright notice and this permission notice shall be included in all
|
|
319
|
+
copies or substantial portions of the Software.
|
|
320
|
+
|
|
321
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
322
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
323
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
324
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
325
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
326
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
327
|
+
SOFTWARE.
|
|
328
|
+
|
|
329
|
+
## fflate
|
|
330
|
+
|
|
331
|
+
The host bundles fflate 0.8.3 to write the XLSX ZIP package.
|
|
332
|
+
|
|
333
|
+
MIT License
|
|
334
|
+
|
|
335
|
+
Copyright (c) 2026 Arjun Barrett
|
|
336
|
+
|
|
337
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
338
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
339
|
+
in the Software without restriction, including without limitation the rights
|
|
340
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
341
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
342
|
+
furnished to do so, subject to the following conditions:
|
|
343
|
+
|
|
344
|
+
The above copyright notice and this permission notice shall be included in all
|
|
345
|
+
copies or substantial portions of the Software.
|
|
346
|
+
|
|
347
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
348
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
349
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
350
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
351
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
352
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
353
|
+
SOFTWARE.
|
package/assets/canvas.engine.js
CHANGED
|
@@ -6598,4 +6598,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6598
6598
|
|
|
6599
6599
|
Please see our testing guides for more information:
|
|
6600
6600
|
https://atlassian.design/components/pragmatic-drag-and-drop/core-package/testing
|
|
6601
|
-
`.replace(/ {2}/g,""));return}var u=r.target;if(u instanceof HTMLElement){var d=rE.get(u);if(d){var f=eE(r),y={element:d.element,dragHandle:(i=d.dragHandle)!==null&&i!==void 0?i:null,input:f};if(d.canDrag&&!d.canDrag(y)){r.preventDefault();return}if(d.dragHandle){var x=HLe({x:f.clientX,y:f.clientY});if(!d.dragHandle.contains(x)){r.preventDefault();return}}var m=(o=(s=d.getInitialDataForExternal)===null||s===void 0?void 0:s.call(d,y))!==null&&o!==void 0?o:null;if(m)for(var g=0,E=Object.entries(m);g<E.length;g++){var k=VLe(E[g],2),P=k[0],N=k[1];r.dataTransfer.setData(P,N??"")}xLe()&&!r.dataTransfer.types.includes("text/plain")&&!r.dataTransfer.types.includes("text/uri-list")&&r.dataTransfer.setData(XIt,CLe),r.dataTransfer.setData(ILe,"");var O={type:"element",payload:{element:d.element,dragHandle:(a=d.dragHandle)!==null&&a!==void 0?a:null,data:(l=(c=d.getInitialData)===null||c===void 0?void 0:c.call(d,y))!==null&&l!==void 0?l:{}},startedFrom:"internal"};t.start({event:r,dragType:O})}}}}}))},dispatchEventToSource:function(t){var n,r,i=t.eventName,o=t.payload;(n=rE.get(o.source.element))===null||n===void 0||(r=n[i])===null||r===void 0||r.call(n,o)},onPostDispatch:zLe.getOnPostDispatch()}),qLe=pY.dropTarget,$Le=pY.monitor;function YLe(e){e.dragHandle&&!e.element.contains(e.dragHandle)&&console.warn("Drag handle element must be contained in draggable element",{element:e.element,dragHandle:e.dragHandle});var t=rE.get(e.element);t&&console.warn("You have already registered a `draggable` on the same element",{existing:t,proposed:e});var n=aA(pY.registerUsage(),JIt(e),oY(e.element,{attribute:"draggable",value:"true"}));return Jp(n)}function KLe(e){let t,n=[];function r(a,l,c){if(!t){if(!a.length)return;n=[...a],t=e.beginNodePreview(c)}try{for(let u of n)t.update(u,typeof l=="function"?l(u):l)}catch(u){throw s(),u}}function i(){let a=t;return t=void 0,n=[],a}function o(){i()?.commit()}function s(){i()?.cancel()}return Yp(s),wl()&&dk(s),{update:r,commit:o,cancel:s}}function XLe(e){let t=KLe(e);function n(s,a,l){t.update(s.map(c=>c.id),{[a]:l},`Change ${a}`)}function r(s,a,l){t.update(s.map(c=>c.id),c=>{let u=e.graph.getNode(c);return u?l(u):{}},`Change ${a}`)}function i(s,a,l,c){t.commit()}function o(s,a){t.cancel()}return{updateProp:n,updateEach:r,commitProp:i,cancelProp:o}}function fY(){let e=ts(),{nodes:t,node:n,active:r,isMulti:i,prop:o}=sM(),s=At(()=>t.value.map(D=>D.id));function a(D,V){return Math.round(V==="rotation"?DD(D,e.graph):RD(D,e.graph)[V])}function l(D){return At(()=>{let V=t.value.map(Q=>a(Q,D));if(V.length===0)return 0;let U=V[0];return V.every(Q=>Q===U)?U:As})}let c=At(()=>n.value?a(n.value,"x"):0),u=At(()=>n.value?a(n.value,"y"):0),d=At(()=>n.value?.width??0),f=At(()=>n.value?.height??0),y=At(()=>n.value?a(n.value,"rotation"):0),{updateProp:x,updateEach:m,commitProp:g,cancelProp:E}=XLe(e);function k(D,V){D==="x"||D==="y"?m(t.value,D,U=>s7(U,e.graph,D,V)):D==="rotation"?m(t.value,D,U=>a7(U,e.graph,V)):x(t.value,D,V)}function P(D,V,U){g(t.value,D,V,U)}function N(D){E(t.value,D)}let O=At(()=>t.value.length>0&&t.value.every(D=>{let V=D.parentId?e.graph.getNode(D.parentId):void 0;return!!V&&V.layoutMode!=="NONE"})),j=At(()=>O.value&&t.value.every(D=>D.layoutPositioning==="ABSOLUTE"));function ee(){e.setLayoutPositioning(s.value,j.value?"AUTO":"ABSOLUTE")}function Z(D,V){e.alignNodes(s.value,D,V)}function K(D){e.flipNodes(s.value,D)}function T(D){e.rotateNodes(s.value,D)}return{editor:e,nodes:t,node:n,active:r,isMulti:i,prop:o,panelProp:l,ids:s,x:c,y:u,width:d,height:f,rotation:y,inAutoLayout:O,ignoresAutoLayout:j,toggleIgnoreAutoLayout:ee,updateProp:k,commitProp:P,cancelProp:N,align:Z,flip:K,rotate:T}}function hY(){let e=ts(),{nodes:t,node:n,active:r,isMulti:i,merged:o,updateProp:s,commitProp:a}=sM(),l={node:n,nodes:t,isMulti:i,merged:o,expandedCornerNodeId:$t(null)},c=yLe(l),u=vLe({editor:e,...l});return{editor:e,nodes:t,node:n,active:r,isMulti:i,...c,updateProp:s,commitProp:a,...u}}An();jr();function ZIt(e){let t=At(()=>{let n=e();if(n?.type!=="TEXT")return[];let r=new Set;r.add(n.fontFamily||ha);for(let i of n.styleRuns)i.style.fontFamily&&r.add(i.style.fontFamily);return[...r].filter(i=>!gt.isLoaded(i))});return{missingFonts:t,hasMissingFonts:At(()=>t.value.length>0)}}var QIt=Object.entries(Dl).map(([e,t])=>({value:Number(e),label:t}));function ePt(e){let t=$t(0),n=At(()=>Hi(e.value.map(o=>o.fontFamily)));function r(o){for(let s of o)gt.loadedFamilyFaces(s)===void 0&>.familyFaces(s).then(()=>t.value++)}ii(n,r,{immediate:!0}),Lo(gt.onFamilyFacesReset(()=>{t.value++,r(n.value)}));function i(o,s,a){return t.value,gt.offersFace(o.fontFamily,s,a)}return{weights:At(()=>QIt.filter(({value:o})=>e.value.some(s=>s.fontWeight===o)||e.value.every(s=>i(s,o,s.italic)))),supports:i}}function cM(e){let[t]=e;return e.every(n=>n===t)?t:As}function tPt(e){if(e.length===0)return[];let t=[];return e.every(n=>n.fontWeight>=700)&&t.push("bold"),e.every(n=>n.italic)&&t.push("italic"),e.every(n=>n.textDecoration==="UNDERLINE")&&t.push("underline"),e.every(n=>n.textDecoration==="STRIKETHROUGH")&&t.push("strikethrough"),t}function JLe(e){let t=ALe(()=>eY(e).filter(g=>g.type==="TEXT")),n=At(()=>t.value.at(0)??null),{missingFonts:r,hasMissingFonts:i}=ZIt(()=>n.value),o=At(()=>n.value?.fontFamily??""),s=At(()=>n.value?.fontWeight??400),a=At(()=>n.value?.fontSize??16),l=At(()=>Dl[n.value?.fontWeight??400]??"Regular"),c=At(()=>tPt(t.value)),{weights:u,supports:d}=ePt(t),f=At(()=>{e.state.textSelectionVersion;let g=cM(t.value.map(E=>X$(e,E)));return g===As?null:g});function y(g){return cM(t.value.map(E=>E[g]))}function x(g){e.state.textSelectionVersion;let E=cM(t.value.map(k=>hLe(e,k,g)));return E===null?As:E}function m(g){return cM(t.value.map(E=>E.fontFeatures.find(k=>k.tag===g)?.enabled??!0))}return{node:n,nodes:t,merged:y,paragraphSpacing:x,fontFeature:m,fontFamily:o,fontWeight:s,fontSize:a,currentWeightLabel:l,activeFormatting:c,listType:f,weights:u,supports:d,missingFonts:r,hasMissingFonts:i}}function ZLe({editor:e,nodes:t,activeFormatting:n,supports:r,options:i}){let o=mLe(e),s,a=new Map;function l(te,_,re=t.value){re.length!==0&&e.undo.runBatch(te,()=>{for(let Ae of re)e.updateNodeWithUndo(Ae.id,_(Ae),te)})}function c(te,_){l(te,()=>_)}let u=new Map;async function d(te,_,re,Ae=t.value){if(Ae.length===0)return;let ye=Symbol(te),ke=et=>_.map(ft=>`${et.id}:${ft}`);for(let et of Ae)for(let ft of ke(et))u.set(ft,ye);let Fe=await Promise.all(Ae.map(re)),Oe=Ae.filter(et=>ke(et).every(ft=>u.get(ft)===ye));for(let et of Oe)for(let ft of ke(et))u.delete(ft);let ze=new Map(Ae.map((et,ft)=>[et.id,Fe[ft]]));l(te,et=>ze.get(et.id)??{},Oe.filter(et=>e.graph.getNode(et.id)&&ze.get(et.id)))}async function f(te){let _=gt.familyFaces(te);await d("Change font",["fontFamily","fontWeight","italic"],async re=>{let Ae=await _,ye=Ae?M4(Ae,re.fontWeight,re.italic):null,ke=ye?.weight??re.fontWeight,Fe=ye?.italic??re.italic;return await i.fontLoader?.load(te,gn(ke,Fe)),{fontFamily:te,fontWeight:ke,italic:Fe}})}async function y(te,_=t.value){await d("Change font weight",["fontWeight"],async re=>(await i.fontLoader?.load(re.fontFamily,gn(te,re.italic)),{fontWeight:te}),_)}function x(te){c("Change text alignment",{textAlignHorizontal:te})}function m(te){c("Change text direction",{textDirection:te})}function g(te){c("Change vertical text alignment",{textAlignVertical:te})}function E(te){c("Change text case",{textCase:te})}function k(te){c("Change text truncation",{textTruncation:te})}function P(te,_){l(`Change ${te} feature`,re=>({fontFeatures:[...re.fontFeatures.filter(Ae=>Ae.tag!==te),{tag:te,enabled:_}]}))}function N(te){let _=t.value;_.length!==0&&e.undo.runBatch("Change list style",()=>{for(let re of _)o.setListType(re,te)})}let O,j=new Map;function ee(te,_){O!==te&&(Z(),O=te);for(let re of t.value){if(!j.has(re.id)){let{listSpacing:Ae,paragraphSpacing:ye,paragraphIndent:ke,textParagraphs:Fe}=re;j.set(re.id,{listSpacing:Ae,paragraphSpacing:ye,paragraphIndent:ke,textParagraphs:Fe})}e.updateNode(re.id,J$(e,re,te,_))}e.requestRender()}function Z(){for(let[te,_]of j)e.updateNode(te,_);j.clear(),O=void 0}function K(te,_){Z();let re=t.value;if(re.length===0)return;let Ae=`Change ${te}`;e.runTextEditStep(()=>{e.undo.runBatch(Ae,()=>{for(let ye of re){let ke=e.graph.getNode(ye.id)??ye;e.updateNodeWithUndo(ye.id,J$(e,ke,te,_),Ae)}})}),e.requestRender()}function T(te){c("Change hanging lists",{hangingList:te})}function D(){let te=n.value.includes("bold")?400:700;y(te,t.value.filter(_=>r(_,te,_.italic)))}function V(){let te=!n.value.includes("italic");d("Toggle italic",["italic"],async _=>(await i.fontLoader?.load(_.fontFamily,gn(_.fontWeight,te)),{italic:te}),t.value.filter(_=>r(_,_.fontWeight,te)))}function U(te){let _=n.value.includes(te.toLowerCase());c(`Toggle ${te.toLowerCase()}`,{textDecoration:_?"NONE":te})}function Q(te){let _=n.value,re=te.filter(ye=>!_.includes(ye)),Ae=_.filter(ye=>!te.includes(ye));for(let ye of[...re,...Ae])ye==="bold"?D():ye==="italic"?V():ye==="underline"?U("UNDERLINE"):ye==="strikethrough"&&U("STRIKETHROUGH")}function W(te,_){s!==te&&(s=te,a.clear());for(let re of t.value)a.has(re.id)||a.set(re.id,{value:re[te],textStyleId:re.textStyleId}),e.updateNode(re.id,{[te]:_})}function J(te,_,re){let Ae=t.value;if(Ae.length===0)return;let ye=s===te?a:new Map;e.undo.runBatch(`Change ${String(te)}`,()=>{for(let ke of Ae){let Fe=ye.get(ke.id);e.commitNodeUpdate(ke.id,{[te]:Fe?Fe.value:re,...Fe?{textStyleId:Fe.textStyleId}:{}},`Change ${String(te)}`)}}),s=void 0,a.clear()}return{setFamily:f,setWeight:y,setAlign:x,setDirection:m,setVerticalAlign:g,setTextCase:E,setTruncation:k,setFontFeature:P,setListType:N,previewParagraphSpacing:ee,setParagraphSpacing:K,setHangingList:T,toggleBold:D,toggleItalic:V,toggleDecoration:U,onFormattingChange:Q,updateProp:W,commitProp:J}}function mY(e={}){let t=ts(),n=JLe(t),r=ZLe({editor:t,...n,options:e});return{editor:t,...n,...r}}W4();function uM(e,t,n){let r=e.findIndex(a=>CN(a,t)),i=e.findIndex(a=>CN(a,n));if(r===-1||i===-1)return[];let[o,s]=[r,i].sort((a,l)=>a-l);return e.slice(o,s+1)}function lA(e,t){let n=typeof e=="string"&&!t?`${e}Context`:t,r=Symbol(n);return[s=>{let a=fo(r,s);if(a||a===null)return a;throw new Error(`Injection \`${r.toString()}\` not found. Component must be used within ${Array.isArray(e)?`one of the following components: ${e.join(", ")}`:`\`${e}\``}`)},s=>(Ua(r,s),s)]}function uy(){let e=document.activeElement;if(e==null)return null;for(;e!=null&&e.shadowRoot!=null&&e.shadowRoot.activeElement!=null;)e=e.shadowRoot.activeElement;return e}function gY(e){return e?e.flatMap(t=>t.type===Fo?gY(t.children):[t]):[]}var[QLe,wIn]=lA("ConfigProvider");function dM(e){let t=QLe({dir:$t("ltr")});return At(()=>e?.value||t.dir?.value||"ltr")}function eFe(e,t){let n=$t(),r=(o,s)=>{if(t.multiple&&Array.isArray(e.value))if(t.selectionBehavior==="replace")e.value=[o],n.value=o;else{let a=e.value.findIndex(l=>s(l));a!==-1?e.value=e.value.filter((l,c)=>c!==a):e.value=[...e.value,o]}else t.selectionBehavior==="replace"?e.value={...o}:!Array.isArray(e.value)&&s(e.value)?e.value=void 0:e.value={...o};return e.value};function i(o,s,a,l){if(!n?.value||!t.multiple||!Array.isArray(e.value))return;let u=a().filter(f=>f.ref.dataset.disabled!=="").find(f=>f.ref===s)?.value;if(!u)return;let d=null;switch(o){case"prev":case"next":{d=uM(l,n.value,u);break}case"first":{d=uM(l,n.value,l?.[0]);break}case"last":{d=uM(l,n.value,l.at(-1));break}}e.value=d}return{firstValue:n,onSelectItem:r,handleMultipleReplace:i}}function tFe(e){let t=$Ne("",1e3);return{search:t,handleTypeaheadSearch:(i,o)=>{if(t.value=t.value+i,e)e(i);else{let s=uy(),a=o.map(f=>({...f,textValue:f.value?.textValue??f.ref.textContent?.trim()??""})),l=a.find(f=>f.ref===s),c=a.map(f=>f.textValue),u=rPt(c,t.value,l?.textValue),d=a.find(f=>f.textValue===u);return d&&d.ref.focus(),d?.ref}},resetTypeahead:()=>{t.value=""}}}function nPt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function rPt(e,t,n){let i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1,s=nPt(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));let l=s.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}var iE=Xr({name:"PrimitiveSlot",inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let r=gY(n.default()),i=r.findIndex(l=>l.type!==_u);if(i===-1)return r;let o=r[i];delete o.props?.ref;let s=o.props?gk(t,o.props):t,a=vf({...o,props:{}},s);return r.length===1?a:(r[i]=a,r)}}});var iPt=["area","img","input"],oE=Xr({name:"Primitive",inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:"div"}},setup(e,{attrs:t,slots:n}){let r=e.asChild?"template":e.as;return typeof r=="string"&&iPt.includes(r)?()=>Vi(r,t):r!=="template"?()=>Vi(e.as,t,{default:n.default}):()=>Vi(iE,t,{default:n.default})}});function yY(){let e=$t(),t=At(()=>["#text","#comment"].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Kp(e));return{primitiveElement:e,currentElement:t}}var nFe="data-reka-collection-item";function rFe(e={}){let{key:t="",isProvider:n=!1}=e,r=`${t}CollectionProvider`,i;if(n){let d=$t(new Map);i={collectionRef:$t(),itemMap:d},Ua(r,i)}else i=fo(r);let o=(d,f=!1)=>{if(!i.collectionRef.value)return;let y=i.itemMap.value.get(d);return y&&(f||y.ref.dataset.disabled!=="")?y:void 0},s=(d=!1)=>{let f=i.collectionRef.value;if(!f)return[];let y=Array.from(f.querySelectorAll(`[${nFe}]`)),x=new Map(y.map((E,k)=>[E,k])),g=Array.from(i.itemMap.value.values()).sort((E,k)=>(x.get(E.ref)??-1)-(x.get(k.ref)??-1));return d?g:g.filter(E=>E.ref.dataset.disabled!=="")},a=Xr({name:"CollectionSlot",inheritAttrs:!1,setup(d,{slots:f,attrs:y}){let{primitiveElement:x,currentElement:m}=yY();return ii(m,()=>{i.collectionRef.value=m.value}),()=>Vi(iE,{ref:x,...y},f)}}),l=Xr({name:"CollectionItem",inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(d,{slots:f,attrs:y}){let{primitiveElement:x,currentElement:m}=yY();return vm(g=>{if(m.value){let E=Gy(m.value);i.itemMap.value.set(E,{ref:m.value,value:d.value}),g(()=>i.itemMap.value.delete(E))}}),()=>Vi(iE,{...y,[nFe]:"",ref:x},f)}}),c=At(()=>Array.from(i.itemMap.value.values())),u=At(()=>i.itemMap.value.size);return{getItems:s,getItem:o,reactiveItems:c,itemMapSize:u,CollectionSlot:a,CollectionItem:l}}var iFe="rovingFocusGroup.onEntryFocus",oFe={bubbles:!1,cancelable:!0},sFe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function aFe(e,t=!1){let n=uy();for(let r of e)if(r===n||(r.focus({preventScroll:t}),uy()!==n))return}var[iPn,oPt]=lA("RovingFocusGroup"),sPt=Xr({__name:"RovingFocusGroup",props:{orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!1},currentTabStopId:{type:[String,null],required:!1},defaultCurrentTabStopId:{type:String,required:!1},preventScrollOnEntryFocus:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["entryFocus","update:currentTabStopId"],setup(e,{expose:t,emit:n}){let r=e,i=n,{loop:o,orientation:s,dir:a}=hm(r),l=dM(a),c=Gw(r,"currentTabStopId",i,{defaultValue:r.defaultCurrentTabStopId,passive:r.currentTabStopId===void 0}),u=$t(!1),d=$t(!1),f=$t(0),{getItems:y,CollectionSlot:x}=rFe({isProvider:!0});function m(E){let k=!d.value;if(E.currentTarget&&E.target===E.currentTarget&&k&&!u.value){let P=new CustomEvent(iFe,oFe);if(E.currentTarget.dispatchEvent(P),i("entryFocus",P),!P.defaultPrevented){let N=y().map(K=>K.ref).filter(K=>K.dataset.disabled!==""),O=N.find(K=>K.getAttribute("data-active")===""),j=N.find(K=>K.getAttribute("data-highlighted")===""),ee=N.find(K=>K.id===c.value),Z=[O,j,ee,...N].filter(Boolean);aFe(Z,r.preventScrollOnEntryFocus)}}d.value=!1}function g(){setTimeout(()=>{d.value=!1},1)}return t({getItems:y}),oPt({loop:o,dir:l,orientation:s,currentTabStopId:c,onItemFocus:E=>{c.value=E},onItemShiftTab:()=>{u.value=!0},onFocusableItemAdd:()=>{f.value++},onFocusableItemRemove:()=>{f.value--}}),(E,k)=>(gf(),yf(Gi(x),null,{default:Vd(()=>[po(Gi(oE),{tabindex:u.value||f.value===0?-1:0,"data-orientation":Gi(s),as:e.as,"as-child":e.asChild,dir:Gi(l),style:{outline:"none"},onMousedown:k[0]||(k[0]=P=>d.value=!0),onMouseup:g,onFocus:m,onBlur:k[1]||(k[1]=P=>u.value=!1)},{default:Vd(()=>[Hd(E.$slots,"default")]),_:3},8,["tabindex","data-orientation","as","as-child","dir"])]),_:3}))}}),vY=sPt;function AY(e){return e.reduce((t,n)=>(t.push(n),n.children&&t.push(...AY(n.children)),t),[])}var[aPt,lPt]=lA("TreeRoot"),cPt=Xr({__name:"TreeRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},items:{type:Array,required:!1},expanded:{type:Array,required:!1},defaultExpanded:{type:Array,required:!1},getKey:{type:Function,required:!0},getChildren:{type:Function,required:!1,default:e=>e.children},selectionBehavior:{type:String,required:!1,default:"toggle"},multiple:{type:Boolean,required:!1,skipCheck:!0},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},propagateSelect:{type:Boolean,required:!1},bubbleSelect:{type:Boolean,required:!1},loop:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"ul"}},emits:["update:modelValue","update:expanded"],setup(e,{emit:t}){let n=e,r=t,{items:i,multiple:o,disabled:s,propagateSelect:a,dir:l,bubbleSelect:c,loop:u}=hm(n),{handleTypeaheadSearch:d}=tFe(),f=dM(l),y=$t(),x=$t(!1),m=g$(),g=Gw(n,"modelValue",r,{defaultValue:n.defaultValue??(o.value?[]:void 0),passive:!0,deep:!0}),E=Gw(n,"expanded",r,{defaultValue:n.defaultExpanded??[],passive:n.expanded===void 0,deep:!0}),{onSelectItem:k,handleMultipleReplace:P}=eFe(g,n),N=At(()=>o.value&&Array.isArray(g.value)?g.value.map(V=>n.getKey(V)):[n.getKey(g.value??{})]);function O(V,U=1,Q){return V.reduce((W,J,te)=>{let _=n.getKey(J),re=n.getChildren(J),Ae=E.value.includes(_),ye={_id:_,value:J,index:te,level:U,parentItem:Q,hasChildren:!!re,bind:{value:J,level:U,"aria-setsize":V.length,"aria-posinset":te+1}};return W.push(ye),re&&Ae&&W.push(...O(re,U+1,J)),W},[])}let j=At(()=>{let V=n.items,U=E.value.map(Q=>Q);return O(V??[])}),ee=["input","textarea","select"];function Z(V){let U=V.target;return U?ee.includes(U.tagName.toLowerCase())||U.isContentEditable:!1}function K(V){if(!Z(V))if(x.value)m.trigger(V);else{let U=y.value?.getItems()??[];d(V.key,U)}}function T(V){if(x.value||Z(V))return;let U=sFe[V.key];Tc(()=>{P(U,uy(),y.value?.getItems,j.value.map(Q=>Q.value))})}function D(V){if(V.parentItem!=null&&Array.isArray(g.value)&&n.multiple){let U=j.value.find(Q=>V.parentItem!=null&&n.getKey(Q.value)===n.getKey(V.parentItem));U!=null&&(n.getChildren(U.value)?.every(W=>g.value.find(J=>n.getKey(J)===n.getKey(W)))?g.value=[...g.value,U.value]:g.value=g.value.filter(W=>n.getKey(W)!==n.getKey(U.value)),D(U))}}return lPt({modelValue:g,selectedKeys:N,onSelect:V=>{let U=W=>n.getKey(W??{})===n.getKey(V),Q=n.multiple&&Array.isArray(g.value)?g.value?.findIndex(U)!==-1:void 0;if(k(V,U),n.bubbleSelect&&n.multiple&&Array.isArray(g.value)){let W=j.value.find(J=>n.getKey(J.value)===n.getKey(V));W!=null&&D(W)}if(n.propagateSelect&&n.multiple&&Array.isArray(g.value)){let W=AY(n.getChildren(V)??[]);Q?g.value=[...g.value].filter(J=>!W.some(te=>n.getKey(J??{})===n.getKey(te))):g.value=[...g.value,...W]}},expanded:E,onToggle(V){if(!(V?n.getChildren(V):void 0))return;let Q=n.getKey(V)??V;E.value.includes(Q)?E.value=E.value.filter(W=>W!==Q):E.value=[...E.value,Q]},getKey:n.getKey,getChildren:n.getChildren,items:i,expandedItems:j,disabled:s,multiple:o,dir:f,propagateSelect:a,bubbleSelect:c,loop:u,isVirtual:x,virtualKeydownHook:m,handleMultipleReplace:P}),(V,U)=>(gf(),yf(Gi(vY),{ref_key:"rovingFocusGroupRef",ref:y,"as-child":"",orientation:"vertical",dir:Gi(f),loop:Gi(u)&&!x.value},{default:Vd(()=>[po(Gi(oE),{role:"tree",as:e.as,"as-child":e.asChild,"aria-multiselectable":Gi(o)?!0:void 0,onKeydown:[K,DL(RL(T,["shift"]),["up","down"])]},{default:Vd(()=>[Hd(V.$slots,"default",{flattenItems:j.value,modelValue:Gi(g),expanded:Gi(E)})]),_:3},8,["as","as-child","aria-multiselectable","onKeydown"])]),_:3},8,["dir","loop"]))}}),bY=cPt;pt();jr();var dNn=Symbol("command-palette");function uPt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function dPt(e,t){if(e==null)return{};var n,r,i=uPt(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function dFe(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(function(i){return Object.is(e[i],t[i])})}function pFe(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dFe,t=null;return function(n){return t&&e(t.value,n)||(t={value:n}),t.value}}var pPt=["block"];function lFe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function cFe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lFe(Object(n),!0).forEach(function(r){cy(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lFe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var fFe=Symbol("tree-item-instruction");function fPt(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function SY(e){var t=e.client,n=e.borderBox,r=n.height/4;return t.y<=n.top+r?"reorder-above":t.y>=n.bottom-r?"reorder-below":"make-child"}function hPt(e){var t=e.element,n=e.input,r=e.currentLevel,i=e.indentPerLevel,o=e.mode,s={x:n.clientX,y:n.clientY},a=t.getBoundingClientRect();if(o==="standard")return{type:SY({borderBox:a,client:s}),indentPerLevel:i,currentLevel:r};var l=fPt(a);if(o==="expanded"){var c=SY({borderBox:a,client:s});return{type:c==="reorder-above"?c:"make-child",indentPerLevel:i,currentLevel:r}}var u=i*r;if(s.x<a.left+u){if(s.y<l.y)return{type:"reorder-above",indentPerLevel:i,currentLevel:r};var d=(s.x-a.left)/i;return{type:"reparent",desiredLevel:Math.max(Math.floor(d),0),indentPerLevel:i,currentLevel:r}}return{type:SY({borderBox:a,client:s}),indentPerLevel:i,currentLevel:r}}function hFe(e,t){return e.type!==t.type?!1:e.type==="instruction-blocked"&&t.type==="instruction-blocked"?hFe(e.desired,t.desired):dFe(e,t)}var mPt=pFe(hFe);function gPt(e){var t=e.desired,n=e.block;return n!=null&&n.includes(t.type)&&t.type!=="instruction-blocked"?{type:"instruction-blocked",desired:t}:t}function yPt(e,t){var n=t.block,r=mPt(gPt({desired:hPt(dPt(t,pPt)),block:n}));return cFe(cFe({},e),{},cy({},fFe,r))}function uFe(e){var t;return(t=e[fFe])!==null&&t!==void 0?t:null}function xY(e){let t=Object.values(e.variableModes);return t.length>0?t:void 0}function vPt(e){return{id:e.id,name:e.name,type:e.type,layoutMode:e.layoutMode,slot:!!pr(e),icon:!!Po(e),visible:e.visible,locked:e.locked,modeIds:xY(e)}}function mFe(e,t){let n=new Map,r=i=>{let o=e.getNode(i);if(!o)return[];let s=[];for(let a of o.childIds){let l=e.getNode(a);if(!l||l.internalOnly)continue;let c=vPt(l);n.set(c.id,c),l.childIds.length>0&&(c.children=r(c.id)),s.push(c)}return s};return{items:r(t),byId:n}}function gFe(e,t){return e.name!==t.name||e.type!==t.type||e.layoutMode!==t.layoutMode||e.slot!==!!pr(t)||e.icon!==!!Po(t)||e.visible!==t.visible||e.locked!==t.locked||!Et(e.modeIds,xY(t))?(e.name=t.name,e.type=t.type,e.layoutMode=t.layoutMode,e.slot=!!pr(t),e.icon=!!Po(t),e.visible=t.visible,e.locked=t.locked,e.modeIds=xY(t),!0):!1}function yFe(e,t){let n=[],r=(i,o)=>{for(let s of i){let a=(s.children?.length??0)>0;n.push({node:s,level:o,hasChildren:a}),a&&t.has(s.id)&&r(s.children??[],o+1)}};return r(e,1),n}function vFe(e,t,n,r,i){if(!i.range||!n){if(!i.additive)return new Set([r]);let u=new Set(t);return u.has(r)?u.delete(r):u.add(r),u}let o=e.indexOf(n),s=e.indexOf(r);if(o===-1||s===-1)return new Set([r]);let a=Math.min(o,s),l=Math.max(o,s),c=i.additive?new Set(t):new Set;for(let u=a;u<=l;u++){let d=e[u];d&&c.add(d)}return c}function APt(e,t,n){let r=e.indexOf(t);return r!==-1&&r<n?n-1:n}function AFe(e,t=16,n){let r=$t(null),i=$t(null),o=$t(null);function s(l,c){vm(u=>{let d=l.value;if(!d)return;let f=c(),y=e.graph.isContainer(f.id),x=f.hasChildren?"expanded":"standard",m=e.graph.getNode(f.id)?.parentId??e.state.currentPageId,g=y&&e.acceptsChildren(f.id),E=e.acceptsChildren(m),k=["reparent",...g?[]:["make-child"],...E?[]:["reorder-above","reorder-below"]];u(aA(YLe({element:d,canDrag:()=>E,getInitialData:()=>({id:f.id}),onDragStart:()=>{r.value=f.id},onDrop:()=>{r.value=null}}),qLe({element:d,getData:({input:P,element:N})=>yPt({id:f.id},{input:P,element:N,indentPerLevel:t,currentLevel:f.level,mode:x,block:k}),canDrop:({source:P})=>P.data.id!==f.id,onDrag:({self:P})=>{let N=uFe(P.data);if(!N||N.type==="instruction-blocked"){i.value=null,o.value=null;return}i.value=N,o.value=f.id},onDragLeave:()=>{i.value=null,o.value=null},onDrop:()=>{i.value=null,o.value=null},getIsSticky:()=>!0})))})}let a=$Le({onDrop:({source:l,location:c})=>{let u=c.current.dropTargets.at(0);if(!u)return;let d=l.data.id,f=u.data.id,y=uFe(u.data);if(!y||y.type==="instruction-blocked")return;let x=y;if(!d||!f||e.graph.isDescendant(f,d))return;let m=e.graph.getNode(f);if(!m)return;let g=m.parentId??e.state.currentPageId,E=e.graph.getNode(g);if(!E)return;let k=E.childIds.indexOf(f),P=N=>APt(E.childIds,d,N);if(x.type==="reorder-above")e.reorderChildWithUndo(d,g,P(k));else if(x.type==="reorder-below")e.reorderChildWithUndo(d,g,P(k+1));else{let N=e.graph.getNode(f);if(!N||!e.graph.isContainer(f))return;e.reorderChildWithUndo(d,f,N.childIds.length),n?.(f)}r.value=null,i.value=null,o.value=null}});return Lo(a),{draggingId:r,instruction:i,instructionTargetId:o,setupItem:s}}var pNn=Symbol("list-item-instruction");var fNn=pFe();var hNn=Symbol("BindableValue");var mNn=Symbol("ChannelSlider");var bFe=Symbol("layer-tree");function bPt(e){Ua(bFe,e)}function CY(){let e=fo(bFe);if(!e)throw new Error("[open-pencil] useLayerTree() called outside <LayerTreeRoot>");return e}var SPt=Xr({__name:"LayerTreeRoot",props:{indentPerLevel:{type:Number,required:!1,default:16}},emits:["select","toggleExpand","toggleVisibility","toggleLock","rename"],setup(e,{expose:t,emit:n}){t();let r=n,i=ts(),o=$t([]),s=$t([]),a=$t(0),l=At(()=>i.state.selectedIds),c=$t(!1),u=At(()=>yFe(o.value,new Set(s.value))),d=new Map,f=null,y=null,x=!1;function m(Oe){s.value.includes(Oe)||(s.value=[...s.value,Oe])}let{draggingId:g,instruction:E,instructionTargetId:k,setupItem:P}=AFe(i,e.indentPerLevel,m),N=!1,O=0;function j(){N=!1,O++;let Oe=mFe(i.graph,i.state.currentPageId);o.value=Oe.items,d=Oe.byId,s.value=s.value.filter(ze=>d.has(ze)),a.value++}function ee(){if(N)return;N=!0;let Oe=++O;queueMicrotask(()=>{!N||Oe!==O||j()})}j();let Z=new Set(["name","type","layoutMode","visible","locked","variableModes"]);function K(Oe,ze){if("childIds"in ze||"parentId"in ze){j();return}if(!Object.keys(ze).some($e=>Z.has($e)))return;let et=d.get(Oe),ft=i.graph.getNode(Oe);et&&ft&&gFe(Cc(et),ft)}let T=new Map;function D(Oe,ze){ze?T.set(Oe,ze):T.delete(Oe)}function V(Oe){let ze=new Set(s.value);for(let et of Oe){let ft=i.graph.getNode(et);for(;ft?.parentId&&ft.parentId!==i.state.currentPageId;)ze.add(ft.parentId),ft=i.graph.getNode(ft.parentId)}ze.size!==s.value.length&&(s.value=[...ze])}function U(Oe){Tc(()=>{let ze=u.value.findIndex(et=>et.node.id===Oe);if(ze!==-1&&f){f.scrollToIndex(ze,{align:"auto"});return}T.get(Oe)?.scrollIntoView({block:"nearest"})})}function Q(Oe){if(V(Oe),x)return;let ze=new Set(u.value.map(et=>et.node.id));y=Oe.find(et=>ze.has(et))??null,y&&U(y)}let W=[i.onEditorEvent("graph:replaced",j),i.onEditorEvent("page:changed",j),i.onEditorEvent("node:created",ee),i.onEditorEvent("node:deleted",ee),i.onEditorEvent("node:reparented",ee),i.onEditorEvent("node:reordered",ee),i.onEditorEvent("node:updated",K),i.onEditorEvent("selection:changed",Q)];Lo(()=>{for(let Oe of W)Oe()});function J(Oe){let ze=i.graph.getNode(Oe);if(!ze)return;let et=ze.parentId;for(;et&&et!==i.state.currentPageId;){if(i.graph.isContainer(et)){i.enterContainer(et);return}et=i.graph.getNode(et)?.parentId??null}i.state.enteredContainerId=null}function te(Oe,ze){let et=typeof ze=="boolean"?{additive:ze,range:!1}:ze;r("select",Oe,et.additive);let ft=vFe(u.value.map($e=>$e.node.id),i.state.selectedIds,y,Oe,et);et.range||(y=Oe),x=!0;try{et.additive&&!et.range?i.select([Oe],!0):i.select([...ft])}finally{x=!1}!et.additive&&!et.range&&J(Oe),U(Oe)}function _(Oe){r("toggleExpand",Oe),s.value.indexOf(Oe)!==-1?s.value=s.value.filter(ze=>ze!==Oe):m(Oe)}function re(Oe){return Oe.id}function Ae(Oe){return Oe.children}function ye(Oe){f=Oe}let ke={select:te,toggleExpand:_,setFocused:Oe=>{c.value=Oe},setVirtualizer:ye};bPt({editor:i,items:o,expanded:s,visibleRows:u,treeVersion:a,selectedIds:l,focused:c,indentPerLevel:e.indentPerLevel,draggingId:g,instruction:E,instructionTargetId:k,setupDrag:P,select:te,toggleExpand:_,setFocused:ke.setFocused,setVirtualizer:ye,toggleVisibility:Oe=>{r("toggleVisibility",Oe),i.toggleNodeVisibility(Oe)},toggleLock:Oe=>{r("toggleLock",Oe),i.toggleNodeLock(Oe)},rename:(Oe,ze)=>{r("rename",Oe,ze),i.renameNode(Oe,ze)},setRowRef:D});let Fe={emit:r,editor:i,items:o,expanded:s,treeVersion:a,selectedIds:l,focused:c,visibleRows:u,get nodesById(){return d},set nodesById(Oe){d=Oe},get virtualizer(){return f},set virtualizer(Oe){f=Oe},get selectionAnchorId(){return y},set selectionAnchorId(Oe){y=Oe},get applyingSelection(){return x},set applyingSelection(Oe){x=Oe},expandNode:m,draggingId:g,instruction:E,instructionTargetId:k,setupItem:P,get rebuildPending(){return N},set rebuildPending(Oe){N=Oe},get rebuildToken(){return O},set rebuildToken(Oe){O=Oe},rebuildTree:j,scheduleTreeRebuild:ee,PATCHABLE_NODE_KEYS:Z,patchTreeNode:K,rowRefs:T,setRowRef:D,expandSelectionAncestors:V,scrollToNode:U,onSelectionChanged:Q,unsubscribe:W,syncCanvasScope:J,select:te,toggleExpand:_,getKey:re,getChildren:Ae,setVirtualizer:ye,actions:ke,get TreeRoot(){return bY}};return Object.defineProperty(Fe,"__isScriptSetup",{enumerable:!1,value:!0}),Fe}});function xPt(e,t,n,r,i,o){return gf(),yf(r.TreeRoot,{expanded:r.expanded,"onUpdate:expanded":t[0]||(t[0]=s=>r.expanded=s),as:"div",class:"flex min-h-0 flex-1 flex-col overflow-hidden",items:r.items,"get-key":r.getKey,"get-children":r.getChildren},{default:Vd(({flattenItems:s})=>[Hd(e.$slots,"default",{items:r.items,flattenItems:s,visibleRows:r.visibleRows,expanded:r.expanded,treeVersion:r.treeVersion,selectedIds:r.selectedIds,focused:r.focused,draggingId:r.draggingId,instruction:r.instruction,instructionTargetId:r.instructionTargetId,actions:r.actions})]),_:3},8,["expanded","items"])}var TY=I$(SPt,[["render",xPt],["__file","/home/runner/work/open-pencil/open-pencil/packages/vue/src/primitives/LayerTree/LayerTreeRoot.vue"]]);var gNn=Symbol("LayoutControlsContext");var yNn=Symbol("PropertyList");function wY(e){let t=Symbol(e);return[()=>{let i=fo(t);if(!i)throw new Error(`[open-pencil] Injection \`${e}\` not found. Component must be used within the corresponding Root.`);return i},i=>(Ua(t,i),i)]}var[CPt,vNn]=wY("PropertySection");var[TPt,ANn]=wY("SegmentedControl");var[SFe,bNn]=wY("NumberField");function pM(e){return Xr({name:`NumberField${e[0]?.toUpperCase()??""}${e.slice(1)}`,inheritAttrs:!1,setup(t,{attrs:n,slots:r}){let i=SFe();return()=>Vi("span",{...n,...i.stateAttrs.value,"data-slot":e},r.default?.(i.slotProps.value))}})}var wPt=pM("leading"),EPt=pM("unit"),kPt=pM("trailing"),IPt=pM("menu");var SNn=Symbol("toolbar");function PPt(e){if(e===null||typeof e!="object")return!1;let t={...e};return!(typeof t.prefix!="string"||t.prefix===""||t.icons===null||typeof t.icons!="object")}function NPt(e){return e===null||typeof e!="object"?!1:typeof e.body=="string"}function xFe(e){let t=null,n=()=>(t??=e().then(i=>{if(!PPt(i))throw new Error("The bundled icon set is malformed.");return i}),t.catch(()=>{t=null}),t),r=async()=>(await n()).prefix;return CD({async fetchCollection(i,o){let s=await n();if(i!==s.prefix)throw new Error('Icon set "'+i+'" is not bundled. Use '+s.prefix+":<name>.");let a={};for(let l of o){let c=s.icons[l];NPt(c)&&(a[l]={body:c.body,width:c.width,height:c.height})}return{prefix:i,width:s.width,height:s.height,icons:a,aliases:s.aliases}},async collections(){let i=await n();return[{prefix:i.prefix,name:"Material Design Icons",total:Object.keys(i.icons).length,category:"General",license:"Apache-2.0",multicolor:!1}]},async collectionIcons(){let i=await n();return Object.keys(i.icons).map(o=>i.prefix+":"+o)},async search(i,o){let s=await n(),a=await r(),l=o?.limit??20,c=i.toLowerCase(),u=Object.keys(s.icons).filter(d=>d.toLowerCase().includes(c)).slice(0,l).map(d=>a+":"+d);return{icons:u,total:u.length,collections:{[a]:{name:"Material Design Icons",total:Object.keys(s.icons).length,category:"General"}}}}})}var CFe={selection:[],rows:[],properties:{ids:[],name:null,type:null,x:null,y:null,width:null,height:null,rotation:null,radius:null,opacity:null,visible:null,text:null},isText:!1,canUndo:!1,canRedo:!1,zoom:1,tool:"select",fit:!0};function dy(e){return typeof e=="number"?e:null}function TFe(e,t,n){let r=new Set,i=CFe,o=!1,s=!1,a=null,l=()=>{if(a===null)return CFe;let{tree:y,position:x,appearance:m,typography:g}=a,E=e.getSelectedNodes(),k=e.state.currentPageId,P=E.map(Z=>{let K=Z.parentId===null||Z.parentId===k?void 0:e.graph.getNode(Z.parentId);return{id:Z.id,name:Z.name,type:Z.type,parentName:K?.name??""}}),N=y.visibleRows.value.map(Z=>({id:Z.node.id,name:Z.node.name,type:Z.node.type,level:Z.level,hasChildren:Z.hasChildren,expanded:y.expanded.value.includes(Z.node.id),visible:Z.node.visible,locked:Z.node.locked,selected:y.selectedIds.value.has(Z.node.id)})),O=x.node.value??x.nodes.value[0],j={ids:[...x.ids.value],name:O?.name??null,type:O?.type??null,x:dy(x.prop("x").value),y:dy(x.prop("y").value),width:dy(x.prop("width").value),height:dy(x.prop("height").value),rotation:dy(x.prop("rotation").value),radius:dy(m.cornerRadiusValue.value),opacity:dy(m.opacityPercent.value),visible:m.visibilityState.value==="mixed"?null:m.visibilityState.value==="visible",text:g.node.value?.type==="TEXT"?{family:g.fontFamily.value,weight:g.fontWeight.value,fontSize:g.fontSize.value}:null},ee=E.length===1&&E[0]?.type==="TEXT";return{selection:P,rows:N,properties:j,isText:ee,canUndo:e.undo.canUndo,canRedo:e.undo.canRedo,zoom:e.state.zoom,tool:t(e.state.activeTool),fit:n()}},c=()=>{i=l();for(let y of r)y(i)},u=()=>{o||(o=!0,queueMicrotask(()=>{o=!1,c()}))},d=[e.onEditorEvent("history:changed",u),e.onEditorEvent("selection:changed",u),e.onEditorEvent("viewport:changed",u),e.onEditorEvent("tool:changed",u),e.onEditorEvent("node:updated",u),e.onEditorEvent("node:previewUpdated",u),e.onEditorEvent("graph:replaced",u),e.onEditorEvent("page:changed",u)];return{component:Xr({name:"DesignInspectorBridge",setup(){let y=CY(),x=fY(),m=hY(),g=mY();a={tree:y,position:x,appearance:m,typography:g};let E=ii(()=>[y.treeVersion.value,y.expanded.value.join(","),[...y.selectedIds.value].join(","),x.prop("x").value,x.prop("y").value,x.prop("width").value,x.prop("height").value,x.prop("rotation").value,m.opacityPercent.value,m.cornerRadiusValue.value,m.visibilityState.value,g.fontFamily.value,g.fontWeight.value,g.fontSize.value],u,{flush:"post"});return Lo(E),s=!0,u(),()=>null}}),snapshot:()=>(s&&(i=l()),i),subscribe(y){return r.add(y),()=>r.delete(y)},notify:u,select(y,x){a?.tree.select(y,{additive:x==="add",range:x==="range"})},clearSelection(){e.clearSelection()},toggleExpand(y){a?.tree.toggleExpand(y)},toggleVisibility(y){a?.tree.toggleVisibility(y)},toggleLock(y){a?.tree.toggleLock(y)},rename(y,x){a?.tree.rename(y,x)},setVisible(y){let x=[...e.state.selectedIds];x.length!==0&&e.undo.runBatch("Change visibility",()=>{for(let m of x)e.updateNodeWithUndo(m,{visible:y},"Change visibility")})},preview(y,x){a!==null&&(y==="radius"?a.appearance.updateUniformRadius(x):y==="opacity"?a.appearance.updateProp("opacityPercent",x):y==="fontSize"?a.typography.updateProp("fontSize",x):a.position.updateProp(y,x))},commit(y,x,m){a!==null&&(y==="radius"?(a.appearance.updateUniformRadius(x),a.appearance.commitUniformRadius()):y==="opacity"?a.appearance.commitProp("opacityPercent",x,m):y==="fontSize"?a.typography.commitProp("fontSize",x,m):a.position.commitProp(y,x,m))},setFamily(y){a?.typography.setFamily(y)},setWeight(y){a?.typography.setWeight(y)},dispose(){for(let y of d)y();r.clear(),a=null,s=!1}}}var RPt=Math.log(1.15),DPt=.01386,_Pt=Math.log(2),OPt=Math.log(1.2),MPt=40,LPt=800;function wFe(e){return Math.min(4,Math.max(.25,e))}function FPt(e,t){let n=t===1?e*MPt:t===2?e*LPt:e,r=Math.abs(n)>=50?-(n/100)*RPt:-n*DPt,i=Math.abs(n)>=50?_Pt:OPt;return Math.exp(Math.min(i,Math.max(-i,r)))}function EFe(e,t,n){let r=e*FPt(t,n);return Math.min(Math.max(r,Math.min(e,.25)),Math.max(e,4))}var kFe=Xr({name:"DesignCanvasSurface",props:{mode:{type:String,default:"edit"}},setup(e){let t=ts(),n=P$();K$(n.canvasRef,t,n.hitTestSectionTitle,n.hitTestComponentLabel,n.hitTestFrameTitle,void 0,void 0,()=>e.mode==="edit");let r=null,i=$t(null),o=u=>{let d=n.canvasRef.value;if(d===null)return null;let f=d.getBoundingClientRect(),y=u.clientX-f.left,x=u.clientY-f.top,m=t.screenToCanvas(y,x);return{sx:y,sy:x,cx:m.x,cy:m.y}},s=u=>{if(!u.ctrlKey&&!u.metaKey)return;let d=n.canvasRef.value;if(d===null)return;u.preventDefault(),u.stopPropagation();let f=d.getBoundingClientRect(),y=EFe(t.state.zoom,u.deltaY,u.deltaMode);t.setZoomAroundPoint(y,u.clientX-f.left,u.clientY-f.top)},a=u=>{if(e.mode!=="view")return;let d=o(u);if(d===null)return;if(u.button===1){u.preventDefault(),r={startX:u.clientX,startY:u.clientY,panX:t.state.panX,panY:t.state.panY};return}if(u.button!==0)return;let f=t.hitTestAtPoint(d.cx,d.cy);if(f!==null){t.select([f.id],u.shiftKey||u.metaKey||u.ctrlKey);return}t.clearSelection(),r={startX:u.clientX,startY:u.clientY,panX:t.state.panX,panY:t.state.panY}},l=u=>{r!==null&&(t.state.panX=r.panX+(u.clientX-r.startX),t.state.panY=r.panY+(u.clientY-r.startY),t.requestRepaint())},c=()=>{r=null};return Af(()=>{i.value?.addEventListener("wheel",s,{capture:!0,passive:!1})}),cb(()=>{i.value?.removeEventListener("wheel",s,!0)}),()=>Vi("div",{class:"op-surface",ref:i},[Vi("canvas",{ref:u=>{n.canvasRef.value=u},style:"display:block;width:100%;height:100%;outline:none",onMousedown:a,onMousemove:l,onMouseup:c,onMouseleave:c,onDblclick:u=>{e.mode==="view"&&u.preventDefault()}})])}});var BPt="/artifacts-canvas/",cA={select:"SELECT",hand:"HAND",frame:"FRAME",text:"TEXT"},zPt={SELECT:"select",HAND:"hand",FRAME:"frame",TEXT:"text"},GPt=[["Regular","Roboto-Regular.woff2"],["Medium","Roboto-Medium.woff2"],["Bold","Roboto-Bold.woff2"]];function fM(e){return BPt+e+"?v=0.7.2"}function VPt(e){return e instanceof Error?e.message:String(e)}async function jPt(){for(let[e,t]of GPt){let n=await fetch(fM("fonts/"+t));if(!n.ok)throw new Error("The bundled font "+t+" is missing.");gt.markLoaded("Roboto",e,await n.arrayBuffer())}}async function IFe(e){let t=new Ja;await mO(xFe(async()=>{let r=await fetch(fM("icons.json"));if(!r.ok)throw new Error("The bundled icon set is missing.");return r.json()})).renderJSX(t,e);let n=t.getPages()[0];if(n===void 0)throw new Error("The design has no page.");return{graph:t,page:n}}function HPt(e,t,n){let r=[],i=e.getNode(t),o="";if(i===void 0)return{names:r,parentName:o};r.push(i.name);let s=i.parentId,a=!0;for(;s!==null&&s!==n;){let l=e.getNode(s);if(l===void 0)break;a&&(o=l.name),a=!1,r.unshift(l.name),s=l.parentId}return{names:r,parentName:o}}async function bRn(e){let t=e.element;await r0({locateFile:N=>fM(N)}),gt.setBundledFontLocator(N=>fM("fonts/"+N)),await jPt();let n=await IFe(e.source),r=hO({graph:n.graph,state:Cc(ZC(n.page.id)),getViewportSize:()=>({width:Math.max(1,t.clientWidth),height:Math.max(1,t.clientHeight)})});r.zoomToFit();let i=$t(e.mode),o=!0,s=!1,a=e.source,l=!1,c=TFe(r,N=>zPt[N]??"select",()=>o),u=Xr({setup(){return w$(r),()=>Vi("div",{class:"op-root"},[Vi("div",{class:"op-canvas"},[Vi(N$,null,{default:()=>Vi(kFe,{mode:i.value})})]),Vi(TY,{class:"op-bridge",indentPerLevel:14},{default:()=>Vi(c.component)})])}}),d=KX(u);d.mount(t);let f=0,y=()=>{if(!l){if(r.renderer===null&&f<300){f+=1,requestAnimationFrame(y);return}r.zoomToFit(),o=!0,c.notify()}};requestAnimationFrame(y);let x=r.onEditorEvent("history:changed",()=>{if(l)return;let N=N0(n.page.childIds,n.graph);N!==a&&(a=N,e.onChange(N))}),m=r.onEditorEvent("viewport:changed",()=>{s?(s=!1,o=!0):o=!1,c.notify()}),g=r.onEditorEvent("graph:replaced",()=>c.notify()),E=N=>{i.value!==N&&(i.value=N,r.setTool(cA.select),c.notify())},k=N=>{if(r.isInteractiveEditing())return;let O=i.value==="edit",j=N.ctrlKey||N.metaKey,ee=N.key.toLowerCase();if(j&&ee==="s"){N.preventDefault(),e.onSave();return}if(O){if(j&&ee==="z"){N.preventDefault(),N.shiftKey?r.undo.redo():r.undo.undo();return}if(j&&ee==="y"){N.preventDefault(),r.undo.redo();return}if(!(j||N.altKey)){if(ee==="delete"||ee==="backspace"){N.preventDefault(),r.deleteSelected();return}ee==="v"?r.setTool(cA.select):ee==="h"?r.setTool(cA.hand):ee==="f"?r.setTool(cA.frame):ee==="t"&&r.setTool(cA.text)}}},P=()=>{t.focus({preventScroll:!0})};return t.addEventListener("keydown",k),t.addEventListener("pointerdown",P),{setSource(N){(async()=>{try{let O=await IFe(N);if(l)return;n=O,a=N,r.replaceGraph(O.graph),r.zoomToFit(),o=!0,c.notify()}catch(O){l||e.onFailure?.(VPt(O))}})()},setMode(N){E(N)},setTool(N){r.setTool(cA[N])},undo(){r.undo.undo()},redo(){r.undo.redo()},zoomToFit(){o=!0,r.zoomToFit(),c.notify()},setZoom(N){o=!1,r.zoomToLevel(wFe(N)),c.notify()},getSnapshot(){return c.snapshot()},subscribe(N){return c.subscribe(N)},select(N,O){c.select(N,O)},clearSelection(){c.clearSelection()},toggleExpand(N){c.toggleExpand(N)},toggleVisibility(N){c.toggleVisibility(N)},toggleLock(N){c.toggleLock(N)},rename(N,O){c.rename(N,O)},setVisible(N){c.setVisible(N)},preview(N,O){c.preview(N,O)},commit(N,O,j){c.commit(N,O,j)},setFamily(N){c.setFamily(N)},setWeight(N){c.setWeight(N)},quoteSelection(){let O=r.getSelectedNodes()[0];if(O===void 0)return null;let{names:j,parentName:ee}=HPt(r.graph,O.id,r.state.currentPageId);return{name:O.name,path:j.join(" / "),type:O.type,parentName:ee,jsx:N0([O.id],r.graph)??""}},destroy(){l||(l=!0,t.removeEventListener("keydown",k),t.removeEventListener("pointerdown",P),x(),m(),g(),c.dispose(),d.unmount(),r.dispose())}}}export{bRn as mountDesignCanvas};
|
|
6601
|
+
`.replace(/ {2}/g,""));return}var u=r.target;if(u instanceof HTMLElement){var d=rE.get(u);if(d){var f=eE(r),y={element:d.element,dragHandle:(i=d.dragHandle)!==null&&i!==void 0?i:null,input:f};if(d.canDrag&&!d.canDrag(y)){r.preventDefault();return}if(d.dragHandle){var x=HLe({x:f.clientX,y:f.clientY});if(!d.dragHandle.contains(x)){r.preventDefault();return}}var m=(o=(s=d.getInitialDataForExternal)===null||s===void 0?void 0:s.call(d,y))!==null&&o!==void 0?o:null;if(m)for(var g=0,E=Object.entries(m);g<E.length;g++){var k=VLe(E[g],2),P=k[0],N=k[1];r.dataTransfer.setData(P,N??"")}xLe()&&!r.dataTransfer.types.includes("text/plain")&&!r.dataTransfer.types.includes("text/uri-list")&&r.dataTransfer.setData(XIt,CLe),r.dataTransfer.setData(ILe,"");var O={type:"element",payload:{element:d.element,dragHandle:(a=d.dragHandle)!==null&&a!==void 0?a:null,data:(l=(c=d.getInitialData)===null||c===void 0?void 0:c.call(d,y))!==null&&l!==void 0?l:{}},startedFrom:"internal"};t.start({event:r,dragType:O})}}}}}))},dispatchEventToSource:function(t){var n,r,i=t.eventName,o=t.payload;(n=rE.get(o.source.element))===null||n===void 0||(r=n[i])===null||r===void 0||r.call(n,o)},onPostDispatch:zLe.getOnPostDispatch()}),qLe=pY.dropTarget,$Le=pY.monitor;function YLe(e){e.dragHandle&&!e.element.contains(e.dragHandle)&&console.warn("Drag handle element must be contained in draggable element",{element:e.element,dragHandle:e.dragHandle});var t=rE.get(e.element);t&&console.warn("You have already registered a `draggable` on the same element",{existing:t,proposed:e});var n=aA(pY.registerUsage(),JIt(e),oY(e.element,{attribute:"draggable",value:"true"}));return Jp(n)}function KLe(e){let t,n=[];function r(a,l,c){if(!t){if(!a.length)return;n=[...a],t=e.beginNodePreview(c)}try{for(let u of n)t.update(u,typeof l=="function"?l(u):l)}catch(u){throw s(),u}}function i(){let a=t;return t=void 0,n=[],a}function o(){i()?.commit()}function s(){i()?.cancel()}return Yp(s),wl()&&dk(s),{update:r,commit:o,cancel:s}}function XLe(e){let t=KLe(e);function n(s,a,l){t.update(s.map(c=>c.id),{[a]:l},`Change ${a}`)}function r(s,a,l){t.update(s.map(c=>c.id),c=>{let u=e.graph.getNode(c);return u?l(u):{}},`Change ${a}`)}function i(s,a,l,c){t.commit()}function o(s,a){t.cancel()}return{updateProp:n,updateEach:r,commitProp:i,cancelProp:o}}function fY(){let e=ts(),{nodes:t,node:n,active:r,isMulti:i,prop:o}=sM(),s=At(()=>t.value.map(D=>D.id));function a(D,V){return Math.round(V==="rotation"?DD(D,e.graph):RD(D,e.graph)[V])}function l(D){return At(()=>{let V=t.value.map(Q=>a(Q,D));if(V.length===0)return 0;let U=V[0];return V.every(Q=>Q===U)?U:As})}let c=At(()=>n.value?a(n.value,"x"):0),u=At(()=>n.value?a(n.value,"y"):0),d=At(()=>n.value?.width??0),f=At(()=>n.value?.height??0),y=At(()=>n.value?a(n.value,"rotation"):0),{updateProp:x,updateEach:m,commitProp:g,cancelProp:E}=XLe(e);function k(D,V){D==="x"||D==="y"?m(t.value,D,U=>s7(U,e.graph,D,V)):D==="rotation"?m(t.value,D,U=>a7(U,e.graph,V)):x(t.value,D,V)}function P(D,V,U){g(t.value,D,V,U)}function N(D){E(t.value,D)}let O=At(()=>t.value.length>0&&t.value.every(D=>{let V=D.parentId?e.graph.getNode(D.parentId):void 0;return!!V&&V.layoutMode!=="NONE"})),j=At(()=>O.value&&t.value.every(D=>D.layoutPositioning==="ABSOLUTE"));function ee(){e.setLayoutPositioning(s.value,j.value?"AUTO":"ABSOLUTE")}function Z(D,V){e.alignNodes(s.value,D,V)}function K(D){e.flipNodes(s.value,D)}function T(D){e.rotateNodes(s.value,D)}return{editor:e,nodes:t,node:n,active:r,isMulti:i,prop:o,panelProp:l,ids:s,x:c,y:u,width:d,height:f,rotation:y,inAutoLayout:O,ignoresAutoLayout:j,toggleIgnoreAutoLayout:ee,updateProp:k,commitProp:P,cancelProp:N,align:Z,flip:K,rotate:T}}function hY(){let e=ts(),{nodes:t,node:n,active:r,isMulti:i,merged:o,updateProp:s,commitProp:a}=sM(),l={node:n,nodes:t,isMulti:i,merged:o,expandedCornerNodeId:$t(null)},c=yLe(l),u=vLe({editor:e,...l});return{editor:e,nodes:t,node:n,active:r,isMulti:i,...c,updateProp:s,commitProp:a,...u}}An();jr();function ZIt(e){let t=At(()=>{let n=e();if(n?.type!=="TEXT")return[];let r=new Set;r.add(n.fontFamily||ha);for(let i of n.styleRuns)i.style.fontFamily&&r.add(i.style.fontFamily);return[...r].filter(i=>!gt.isLoaded(i))});return{missingFonts:t,hasMissingFonts:At(()=>t.value.length>0)}}var QIt=Object.entries(Dl).map(([e,t])=>({value:Number(e),label:t}));function ePt(e){let t=$t(0),n=At(()=>Hi(e.value.map(o=>o.fontFamily)));function r(o){for(let s of o)gt.loadedFamilyFaces(s)===void 0&>.familyFaces(s).then(()=>t.value++)}ii(n,r,{immediate:!0}),Lo(gt.onFamilyFacesReset(()=>{t.value++,r(n.value)}));function i(o,s,a){return t.value,gt.offersFace(o.fontFamily,s,a)}return{weights:At(()=>QIt.filter(({value:o})=>e.value.some(s=>s.fontWeight===o)||e.value.every(s=>i(s,o,s.italic)))),supports:i}}function cM(e){let[t]=e;return e.every(n=>n===t)?t:As}function tPt(e){if(e.length===0)return[];let t=[];return e.every(n=>n.fontWeight>=700)&&t.push("bold"),e.every(n=>n.italic)&&t.push("italic"),e.every(n=>n.textDecoration==="UNDERLINE")&&t.push("underline"),e.every(n=>n.textDecoration==="STRIKETHROUGH")&&t.push("strikethrough"),t}function JLe(e){let t=ALe(()=>eY(e).filter(g=>g.type==="TEXT")),n=At(()=>t.value.at(0)??null),{missingFonts:r,hasMissingFonts:i}=ZIt(()=>n.value),o=At(()=>n.value?.fontFamily??""),s=At(()=>n.value?.fontWeight??400),a=At(()=>n.value?.fontSize??16),l=At(()=>Dl[n.value?.fontWeight??400]??"Regular"),c=At(()=>tPt(t.value)),{weights:u,supports:d}=ePt(t),f=At(()=>{e.state.textSelectionVersion;let g=cM(t.value.map(E=>X$(e,E)));return g===As?null:g});function y(g){return cM(t.value.map(E=>E[g]))}function x(g){e.state.textSelectionVersion;let E=cM(t.value.map(k=>hLe(e,k,g)));return E===null?As:E}function m(g){return cM(t.value.map(E=>E.fontFeatures.find(k=>k.tag===g)?.enabled??!0))}return{node:n,nodes:t,merged:y,paragraphSpacing:x,fontFeature:m,fontFamily:o,fontWeight:s,fontSize:a,currentWeightLabel:l,activeFormatting:c,listType:f,weights:u,supports:d,missingFonts:r,hasMissingFonts:i}}function ZLe({editor:e,nodes:t,activeFormatting:n,supports:r,options:i}){let o=mLe(e),s,a=new Map;function l(te,_,re=t.value){re.length!==0&&e.undo.runBatch(te,()=>{for(let Ae of re)e.updateNodeWithUndo(Ae.id,_(Ae),te)})}function c(te,_){l(te,()=>_)}let u=new Map;async function d(te,_,re,Ae=t.value){if(Ae.length===0)return;let ye=Symbol(te),ke=et=>_.map(ft=>`${et.id}:${ft}`);for(let et of Ae)for(let ft of ke(et))u.set(ft,ye);let Fe=await Promise.all(Ae.map(re)),Oe=Ae.filter(et=>ke(et).every(ft=>u.get(ft)===ye));for(let et of Oe)for(let ft of ke(et))u.delete(ft);let ze=new Map(Ae.map((et,ft)=>[et.id,Fe[ft]]));l(te,et=>ze.get(et.id)??{},Oe.filter(et=>e.graph.getNode(et.id)&&ze.get(et.id)))}async function f(te){let _=gt.familyFaces(te);await d("Change font",["fontFamily","fontWeight","italic"],async re=>{let Ae=await _,ye=Ae?M4(Ae,re.fontWeight,re.italic):null,ke=ye?.weight??re.fontWeight,Fe=ye?.italic??re.italic;return await i.fontLoader?.load(te,gn(ke,Fe)),{fontFamily:te,fontWeight:ke,italic:Fe}})}async function y(te,_=t.value){await d("Change font weight",["fontWeight"],async re=>(await i.fontLoader?.load(re.fontFamily,gn(te,re.italic)),{fontWeight:te}),_)}function x(te){c("Change text alignment",{textAlignHorizontal:te})}function m(te){c("Change text direction",{textDirection:te})}function g(te){c("Change vertical text alignment",{textAlignVertical:te})}function E(te){c("Change text case",{textCase:te})}function k(te){c("Change text truncation",{textTruncation:te})}function P(te,_){l(`Change ${te} feature`,re=>({fontFeatures:[...re.fontFeatures.filter(Ae=>Ae.tag!==te),{tag:te,enabled:_}]}))}function N(te){let _=t.value;_.length!==0&&e.undo.runBatch("Change list style",()=>{for(let re of _)o.setListType(re,te)})}let O,j=new Map;function ee(te,_){O!==te&&(Z(),O=te);for(let re of t.value){if(!j.has(re.id)){let{listSpacing:Ae,paragraphSpacing:ye,paragraphIndent:ke,textParagraphs:Fe}=re;j.set(re.id,{listSpacing:Ae,paragraphSpacing:ye,paragraphIndent:ke,textParagraphs:Fe})}e.updateNode(re.id,J$(e,re,te,_))}e.requestRender()}function Z(){for(let[te,_]of j)e.updateNode(te,_);j.clear(),O=void 0}function K(te,_){Z();let re=t.value;if(re.length===0)return;let Ae=`Change ${te}`;e.runTextEditStep(()=>{e.undo.runBatch(Ae,()=>{for(let ye of re){let ke=e.graph.getNode(ye.id)??ye;e.updateNodeWithUndo(ye.id,J$(e,ke,te,_),Ae)}})}),e.requestRender()}function T(te){c("Change hanging lists",{hangingList:te})}function D(){let te=n.value.includes("bold")?400:700;y(te,t.value.filter(_=>r(_,te,_.italic)))}function V(){let te=!n.value.includes("italic");d("Toggle italic",["italic"],async _=>(await i.fontLoader?.load(_.fontFamily,gn(_.fontWeight,te)),{italic:te}),t.value.filter(_=>r(_,_.fontWeight,te)))}function U(te){let _=n.value.includes(te.toLowerCase());c(`Toggle ${te.toLowerCase()}`,{textDecoration:_?"NONE":te})}function Q(te){let _=n.value,re=te.filter(ye=>!_.includes(ye)),Ae=_.filter(ye=>!te.includes(ye));for(let ye of[...re,...Ae])ye==="bold"?D():ye==="italic"?V():ye==="underline"?U("UNDERLINE"):ye==="strikethrough"&&U("STRIKETHROUGH")}function W(te,_){s!==te&&(s=te,a.clear());for(let re of t.value)a.has(re.id)||a.set(re.id,{value:re[te],textStyleId:re.textStyleId}),e.updateNode(re.id,{[te]:_})}function J(te,_,re){let Ae=t.value;if(Ae.length===0)return;let ye=s===te?a:new Map;e.undo.runBatch(`Change ${String(te)}`,()=>{for(let ke of Ae){let Fe=ye.get(ke.id);e.commitNodeUpdate(ke.id,{[te]:Fe?Fe.value:re,...Fe?{textStyleId:Fe.textStyleId}:{}},`Change ${String(te)}`)}}),s=void 0,a.clear()}return{setFamily:f,setWeight:y,setAlign:x,setDirection:m,setVerticalAlign:g,setTextCase:E,setTruncation:k,setFontFeature:P,setListType:N,previewParagraphSpacing:ee,setParagraphSpacing:K,setHangingList:T,toggleBold:D,toggleItalic:V,toggleDecoration:U,onFormattingChange:Q,updateProp:W,commitProp:J}}function mY(e={}){let t=ts(),n=JLe(t),r=ZLe({editor:t,...n,options:e});return{editor:t,...n,...r}}W4();function uM(e,t,n){let r=e.findIndex(a=>CN(a,t)),i=e.findIndex(a=>CN(a,n));if(r===-1||i===-1)return[];let[o,s]=[r,i].sort((a,l)=>a-l);return e.slice(o,s+1)}function lA(e,t){let n=typeof e=="string"&&!t?`${e}Context`:t,r=Symbol(n);return[s=>{let a=fo(r,s);if(a||a===null)return a;throw new Error(`Injection \`${r.toString()}\` not found. Component must be used within ${Array.isArray(e)?`one of the following components: ${e.join(", ")}`:`\`${e}\``}`)},s=>(Ua(r,s),s)]}function uy(){let e=document.activeElement;if(e==null)return null;for(;e!=null&&e.shadowRoot!=null&&e.shadowRoot.activeElement!=null;)e=e.shadowRoot.activeElement;return e}function gY(e){return e?e.flatMap(t=>t.type===Fo?gY(t.children):[t]):[]}var[QLe,wIn]=lA("ConfigProvider");function dM(e){let t=QLe({dir:$t("ltr")});return At(()=>e?.value||t.dir?.value||"ltr")}function eFe(e,t){let n=$t(),r=(o,s)=>{if(t.multiple&&Array.isArray(e.value))if(t.selectionBehavior==="replace")e.value=[o],n.value=o;else{let a=e.value.findIndex(l=>s(l));a!==-1?e.value=e.value.filter((l,c)=>c!==a):e.value=[...e.value,o]}else t.selectionBehavior==="replace"?e.value={...o}:!Array.isArray(e.value)&&s(e.value)?e.value=void 0:e.value={...o};return e.value};function i(o,s,a,l){if(!n?.value||!t.multiple||!Array.isArray(e.value))return;let u=a().filter(f=>f.ref.dataset.disabled!=="").find(f=>f.ref===s)?.value;if(!u)return;let d=null;switch(o){case"prev":case"next":{d=uM(l,n.value,u);break}case"first":{d=uM(l,n.value,l?.[0]);break}case"last":{d=uM(l,n.value,l.at(-1));break}}e.value=d}return{firstValue:n,onSelectItem:r,handleMultipleReplace:i}}function tFe(e){let t=$Ne("",1e3);return{search:t,handleTypeaheadSearch:(i,o)=>{if(t.value=t.value+i,e)e(i);else{let s=uy(),a=o.map(f=>({...f,textValue:f.value?.textValue??f.ref.textContent?.trim()??""})),l=a.find(f=>f.ref===s),c=a.map(f=>f.textValue),u=rPt(c,t.value,l?.textValue),d=a.find(f=>f.textValue===u);return d&&d.ref.focus(),d?.ref}},resetTypeahead:()=>{t.value=""}}}function nPt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function rPt(e,t,n){let i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1,s=nPt(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));let l=s.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}var iE=Xr({name:"PrimitiveSlot",inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let r=gY(n.default()),i=r.findIndex(l=>l.type!==_u);if(i===-1)return r;let o=r[i];delete o.props?.ref;let s=o.props?gk(t,o.props):t,a=vf({...o,props:{}},s);return r.length===1?a:(r[i]=a,r)}}});var iPt=["area","img","input"],oE=Xr({name:"Primitive",inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:"div"}},setup(e,{attrs:t,slots:n}){let r=e.asChild?"template":e.as;return typeof r=="string"&&iPt.includes(r)?()=>Vi(r,t):r!=="template"?()=>Vi(e.as,t,{default:n.default}):()=>Vi(iE,t,{default:n.default})}});function yY(){let e=$t(),t=At(()=>["#text","#comment"].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Kp(e));return{primitiveElement:e,currentElement:t}}var nFe="data-reka-collection-item";function rFe(e={}){let{key:t="",isProvider:n=!1}=e,r=`${t}CollectionProvider`,i;if(n){let d=$t(new Map);i={collectionRef:$t(),itemMap:d},Ua(r,i)}else i=fo(r);let o=(d,f=!1)=>{if(!i.collectionRef.value)return;let y=i.itemMap.value.get(d);return y&&(f||y.ref.dataset.disabled!=="")?y:void 0},s=(d=!1)=>{let f=i.collectionRef.value;if(!f)return[];let y=Array.from(f.querySelectorAll(`[${nFe}]`)),x=new Map(y.map((E,k)=>[E,k])),g=Array.from(i.itemMap.value.values()).sort((E,k)=>(x.get(E.ref)??-1)-(x.get(k.ref)??-1));return d?g:g.filter(E=>E.ref.dataset.disabled!=="")},a=Xr({name:"CollectionSlot",inheritAttrs:!1,setup(d,{slots:f,attrs:y}){let{primitiveElement:x,currentElement:m}=yY();return ii(m,()=>{i.collectionRef.value=m.value}),()=>Vi(iE,{ref:x,...y},f)}}),l=Xr({name:"CollectionItem",inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(d,{slots:f,attrs:y}){let{primitiveElement:x,currentElement:m}=yY();return vm(g=>{if(m.value){let E=Gy(m.value);i.itemMap.value.set(E,{ref:m.value,value:d.value}),g(()=>i.itemMap.value.delete(E))}}),()=>Vi(iE,{...y,[nFe]:"",ref:x},f)}}),c=At(()=>Array.from(i.itemMap.value.values())),u=At(()=>i.itemMap.value.size);return{getItems:s,getItem:o,reactiveItems:c,itemMapSize:u,CollectionSlot:a,CollectionItem:l}}var iFe="rovingFocusGroup.onEntryFocus",oFe={bubbles:!1,cancelable:!0},sFe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function aFe(e,t=!1){let n=uy();for(let r of e)if(r===n||(r.focus({preventScroll:t}),uy()!==n))return}var[iPn,oPt]=lA("RovingFocusGroup"),sPt=Xr({__name:"RovingFocusGroup",props:{orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!1},currentTabStopId:{type:[String,null],required:!1},defaultCurrentTabStopId:{type:String,required:!1},preventScrollOnEntryFocus:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["entryFocus","update:currentTabStopId"],setup(e,{expose:t,emit:n}){let r=e,i=n,{loop:o,orientation:s,dir:a}=hm(r),l=dM(a),c=Gw(r,"currentTabStopId",i,{defaultValue:r.defaultCurrentTabStopId,passive:r.currentTabStopId===void 0}),u=$t(!1),d=$t(!1),f=$t(0),{getItems:y,CollectionSlot:x}=rFe({isProvider:!0});function m(E){let k=!d.value;if(E.currentTarget&&E.target===E.currentTarget&&k&&!u.value){let P=new CustomEvent(iFe,oFe);if(E.currentTarget.dispatchEvent(P),i("entryFocus",P),!P.defaultPrevented){let N=y().map(K=>K.ref).filter(K=>K.dataset.disabled!==""),O=N.find(K=>K.getAttribute("data-active")===""),j=N.find(K=>K.getAttribute("data-highlighted")===""),ee=N.find(K=>K.id===c.value),Z=[O,j,ee,...N].filter(Boolean);aFe(Z,r.preventScrollOnEntryFocus)}}d.value=!1}function g(){setTimeout(()=>{d.value=!1},1)}return t({getItems:y}),oPt({loop:o,dir:l,orientation:s,currentTabStopId:c,onItemFocus:E=>{c.value=E},onItemShiftTab:()=>{u.value=!0},onFocusableItemAdd:()=>{f.value++},onFocusableItemRemove:()=>{f.value--}}),(E,k)=>(gf(),yf(Gi(x),null,{default:Vd(()=>[po(Gi(oE),{tabindex:u.value||f.value===0?-1:0,"data-orientation":Gi(s),as:e.as,"as-child":e.asChild,dir:Gi(l),style:{outline:"none"},onMousedown:k[0]||(k[0]=P=>d.value=!0),onMouseup:g,onFocus:m,onBlur:k[1]||(k[1]=P=>u.value=!1)},{default:Vd(()=>[Hd(E.$slots,"default")]),_:3},8,["tabindex","data-orientation","as","as-child","dir"])]),_:3}))}}),vY=sPt;function AY(e){return e.reduce((t,n)=>(t.push(n),n.children&&t.push(...AY(n.children)),t),[])}var[aPt,lPt]=lA("TreeRoot"),cPt=Xr({__name:"TreeRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},items:{type:Array,required:!1},expanded:{type:Array,required:!1},defaultExpanded:{type:Array,required:!1},getKey:{type:Function,required:!0},getChildren:{type:Function,required:!1,default:e=>e.children},selectionBehavior:{type:String,required:!1,default:"toggle"},multiple:{type:Boolean,required:!1,skipCheck:!0},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},propagateSelect:{type:Boolean,required:!1},bubbleSelect:{type:Boolean,required:!1},loop:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"ul"}},emits:["update:modelValue","update:expanded"],setup(e,{emit:t}){let n=e,r=t,{items:i,multiple:o,disabled:s,propagateSelect:a,dir:l,bubbleSelect:c,loop:u}=hm(n),{handleTypeaheadSearch:d}=tFe(),f=dM(l),y=$t(),x=$t(!1),m=g$(),g=Gw(n,"modelValue",r,{defaultValue:n.defaultValue??(o.value?[]:void 0),passive:!0,deep:!0}),E=Gw(n,"expanded",r,{defaultValue:n.defaultExpanded??[],passive:n.expanded===void 0,deep:!0}),{onSelectItem:k,handleMultipleReplace:P}=eFe(g,n),N=At(()=>o.value&&Array.isArray(g.value)?g.value.map(V=>n.getKey(V)):[n.getKey(g.value??{})]);function O(V,U=1,Q){return V.reduce((W,J,te)=>{let _=n.getKey(J),re=n.getChildren(J),Ae=E.value.includes(_),ye={_id:_,value:J,index:te,level:U,parentItem:Q,hasChildren:!!re,bind:{value:J,level:U,"aria-setsize":V.length,"aria-posinset":te+1}};return W.push(ye),re&&Ae&&W.push(...O(re,U+1,J)),W},[])}let j=At(()=>{let V=n.items,U=E.value.map(Q=>Q);return O(V??[])}),ee=["input","textarea","select"];function Z(V){let U=V.target;return U?ee.includes(U.tagName.toLowerCase())||U.isContentEditable:!1}function K(V){if(!Z(V))if(x.value)m.trigger(V);else{let U=y.value?.getItems()??[];d(V.key,U)}}function T(V){if(x.value||Z(V))return;let U=sFe[V.key];Tc(()=>{P(U,uy(),y.value?.getItems,j.value.map(Q=>Q.value))})}function D(V){if(V.parentItem!=null&&Array.isArray(g.value)&&n.multiple){let U=j.value.find(Q=>V.parentItem!=null&&n.getKey(Q.value)===n.getKey(V.parentItem));U!=null&&(n.getChildren(U.value)?.every(W=>g.value.find(J=>n.getKey(J)===n.getKey(W)))?g.value=[...g.value,U.value]:g.value=g.value.filter(W=>n.getKey(W)!==n.getKey(U.value)),D(U))}}return lPt({modelValue:g,selectedKeys:N,onSelect:V=>{let U=W=>n.getKey(W??{})===n.getKey(V),Q=n.multiple&&Array.isArray(g.value)?g.value?.findIndex(U)!==-1:void 0;if(k(V,U),n.bubbleSelect&&n.multiple&&Array.isArray(g.value)){let W=j.value.find(J=>n.getKey(J.value)===n.getKey(V));W!=null&&D(W)}if(n.propagateSelect&&n.multiple&&Array.isArray(g.value)){let W=AY(n.getChildren(V)??[]);Q?g.value=[...g.value].filter(J=>!W.some(te=>n.getKey(J??{})===n.getKey(te))):g.value=[...g.value,...W]}},expanded:E,onToggle(V){if(!(V?n.getChildren(V):void 0))return;let Q=n.getKey(V)??V;E.value.includes(Q)?E.value=E.value.filter(W=>W!==Q):E.value=[...E.value,Q]},getKey:n.getKey,getChildren:n.getChildren,items:i,expandedItems:j,disabled:s,multiple:o,dir:f,propagateSelect:a,bubbleSelect:c,loop:u,isVirtual:x,virtualKeydownHook:m,handleMultipleReplace:P}),(V,U)=>(gf(),yf(Gi(vY),{ref_key:"rovingFocusGroupRef",ref:y,"as-child":"",orientation:"vertical",dir:Gi(f),loop:Gi(u)&&!x.value},{default:Vd(()=>[po(Gi(oE),{role:"tree",as:e.as,"as-child":e.asChild,"aria-multiselectable":Gi(o)?!0:void 0,onKeydown:[K,DL(RL(T,["shift"]),["up","down"])]},{default:Vd(()=>[Hd(V.$slots,"default",{flattenItems:j.value,modelValue:Gi(g),expanded:Gi(E)})]),_:3},8,["as","as-child","aria-multiselectable","onKeydown"])]),_:3},8,["dir","loop"]))}}),bY=cPt;pt();jr();var dNn=Symbol("command-palette");function uPt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function dPt(e,t){if(e==null)return{};var n,r,i=uPt(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function dFe(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(function(i){return Object.is(e[i],t[i])})}function pFe(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dFe,t=null;return function(n){return t&&e(t.value,n)||(t={value:n}),t.value}}var pPt=["block"];function lFe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function cFe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lFe(Object(n),!0).forEach(function(r){cy(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lFe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var fFe=Symbol("tree-item-instruction");function fPt(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function SY(e){var t=e.client,n=e.borderBox,r=n.height/4;return t.y<=n.top+r?"reorder-above":t.y>=n.bottom-r?"reorder-below":"make-child"}function hPt(e){var t=e.element,n=e.input,r=e.currentLevel,i=e.indentPerLevel,o=e.mode,s={x:n.clientX,y:n.clientY},a=t.getBoundingClientRect();if(o==="standard")return{type:SY({borderBox:a,client:s}),indentPerLevel:i,currentLevel:r};var l=fPt(a);if(o==="expanded"){var c=SY({borderBox:a,client:s});return{type:c==="reorder-above"?c:"make-child",indentPerLevel:i,currentLevel:r}}var u=i*r;if(s.x<a.left+u){if(s.y<l.y)return{type:"reorder-above",indentPerLevel:i,currentLevel:r};var d=(s.x-a.left)/i;return{type:"reparent",desiredLevel:Math.max(Math.floor(d),0),indentPerLevel:i,currentLevel:r}}return{type:SY({borderBox:a,client:s}),indentPerLevel:i,currentLevel:r}}function hFe(e,t){return e.type!==t.type?!1:e.type==="instruction-blocked"&&t.type==="instruction-blocked"?hFe(e.desired,t.desired):dFe(e,t)}var mPt=pFe(hFe);function gPt(e){var t=e.desired,n=e.block;return n!=null&&n.includes(t.type)&&t.type!=="instruction-blocked"?{type:"instruction-blocked",desired:t}:t}function yPt(e,t){var n=t.block,r=mPt(gPt({desired:hPt(dPt(t,pPt)),block:n}));return cFe(cFe({},e),{},cy({},fFe,r))}function uFe(e){var t;return(t=e[fFe])!==null&&t!==void 0?t:null}function xY(e){let t=Object.values(e.variableModes);return t.length>0?t:void 0}function vPt(e){return{id:e.id,name:e.name,type:e.type,layoutMode:e.layoutMode,slot:!!pr(e),icon:!!Po(e),visible:e.visible,locked:e.locked,modeIds:xY(e)}}function mFe(e,t){let n=new Map,r=i=>{let o=e.getNode(i);if(!o)return[];let s=[];for(let a of o.childIds){let l=e.getNode(a);if(!l||l.internalOnly)continue;let c=vPt(l);n.set(c.id,c),l.childIds.length>0&&(c.children=r(c.id)),s.push(c)}return s};return{items:r(t),byId:n}}function gFe(e,t){return e.name!==t.name||e.type!==t.type||e.layoutMode!==t.layoutMode||e.slot!==!!pr(t)||e.icon!==!!Po(t)||e.visible!==t.visible||e.locked!==t.locked||!Et(e.modeIds,xY(t))?(e.name=t.name,e.type=t.type,e.layoutMode=t.layoutMode,e.slot=!!pr(t),e.icon=!!Po(t),e.visible=t.visible,e.locked=t.locked,e.modeIds=xY(t),!0):!1}function yFe(e,t){let n=[],r=(i,o)=>{for(let s of i){let a=(s.children?.length??0)>0;n.push({node:s,level:o,hasChildren:a}),a&&t.has(s.id)&&r(s.children??[],o+1)}};return r(e,1),n}function vFe(e,t,n,r,i){if(!i.range||!n){if(!i.additive)return new Set([r]);let u=new Set(t);return u.has(r)?u.delete(r):u.add(r),u}let o=e.indexOf(n),s=e.indexOf(r);if(o===-1||s===-1)return new Set([r]);let a=Math.min(o,s),l=Math.max(o,s),c=i.additive?new Set(t):new Set;for(let u=a;u<=l;u++){let d=e[u];d&&c.add(d)}return c}function APt(e,t,n){let r=e.indexOf(t);return r!==-1&&r<n?n-1:n}function AFe(e,t=16,n){let r=$t(null),i=$t(null),o=$t(null);function s(l,c){vm(u=>{let d=l.value;if(!d)return;let f=c(),y=e.graph.isContainer(f.id),x=f.hasChildren?"expanded":"standard",m=e.graph.getNode(f.id)?.parentId??e.state.currentPageId,g=y&&e.acceptsChildren(f.id),E=e.acceptsChildren(m),k=["reparent",...g?[]:["make-child"],...E?[]:["reorder-above","reorder-below"]];u(aA(YLe({element:d,canDrag:()=>E,getInitialData:()=>({id:f.id}),onDragStart:()=>{r.value=f.id},onDrop:()=>{r.value=null}}),qLe({element:d,getData:({input:P,element:N})=>yPt({id:f.id},{input:P,element:N,indentPerLevel:t,currentLevel:f.level,mode:x,block:k}),canDrop:({source:P})=>P.data.id!==f.id,onDrag:({self:P})=>{let N=uFe(P.data);if(!N||N.type==="instruction-blocked"){i.value=null,o.value=null;return}i.value=N,o.value=f.id},onDragLeave:()=>{i.value=null,o.value=null},onDrop:()=>{i.value=null,o.value=null},getIsSticky:()=>!0})))})}let a=$Le({onDrop:({source:l,location:c})=>{let u=c.current.dropTargets.at(0);if(!u)return;let d=l.data.id,f=u.data.id,y=uFe(u.data);if(!y||y.type==="instruction-blocked")return;let x=y;if(!d||!f||e.graph.isDescendant(f,d))return;let m=e.graph.getNode(f);if(!m)return;let g=m.parentId??e.state.currentPageId,E=e.graph.getNode(g);if(!E)return;let k=E.childIds.indexOf(f),P=N=>APt(E.childIds,d,N);if(x.type==="reorder-above")e.reorderChildWithUndo(d,g,P(k));else if(x.type==="reorder-below")e.reorderChildWithUndo(d,g,P(k+1));else{let N=e.graph.getNode(f);if(!N||!e.graph.isContainer(f))return;e.reorderChildWithUndo(d,f,N.childIds.length),n?.(f)}r.value=null,i.value=null,o.value=null}});return Lo(a),{draggingId:r,instruction:i,instructionTargetId:o,setupItem:s}}var pNn=Symbol("list-item-instruction");var fNn=pFe();var hNn=Symbol("BindableValue");var mNn=Symbol("ChannelSlider");var bFe=Symbol("layer-tree");function bPt(e){Ua(bFe,e)}function CY(){let e=fo(bFe);if(!e)throw new Error("[open-pencil] useLayerTree() called outside <LayerTreeRoot>");return e}var SPt=Xr({__name:"LayerTreeRoot",props:{indentPerLevel:{type:Number,required:!1,default:16}},emits:["select","toggleExpand","toggleVisibility","toggleLock","rename"],setup(e,{expose:t,emit:n}){t();let r=n,i=ts(),o=$t([]),s=$t([]),a=$t(0),l=At(()=>i.state.selectedIds),c=$t(!1),u=At(()=>yFe(o.value,new Set(s.value))),d=new Map,f=null,y=null,x=!1;function m(Oe){s.value.includes(Oe)||(s.value=[...s.value,Oe])}let{draggingId:g,instruction:E,instructionTargetId:k,setupItem:P}=AFe(i,e.indentPerLevel,m),N=!1,O=0;function j(){N=!1,O++;let Oe=mFe(i.graph,i.state.currentPageId);o.value=Oe.items,d=Oe.byId,s.value=s.value.filter(ze=>d.has(ze)),a.value++}function ee(){if(N)return;N=!0;let Oe=++O;queueMicrotask(()=>{!N||Oe!==O||j()})}j();let Z=new Set(["name","type","layoutMode","visible","locked","variableModes"]);function K(Oe,ze){if("childIds"in ze||"parentId"in ze){j();return}if(!Object.keys(ze).some($e=>Z.has($e)))return;let et=d.get(Oe),ft=i.graph.getNode(Oe);et&&ft&&gFe(Cc(et),ft)}let T=new Map;function D(Oe,ze){ze?T.set(Oe,ze):T.delete(Oe)}function V(Oe){let ze=new Set(s.value);for(let et of Oe){let ft=i.graph.getNode(et);for(;ft?.parentId&&ft.parentId!==i.state.currentPageId;)ze.add(ft.parentId),ft=i.graph.getNode(ft.parentId)}ze.size!==s.value.length&&(s.value=[...ze])}function U(Oe){Tc(()=>{let ze=u.value.findIndex(et=>et.node.id===Oe);if(ze!==-1&&f){f.scrollToIndex(ze,{align:"auto"});return}T.get(Oe)?.scrollIntoView({block:"nearest"})})}function Q(Oe){if(V(Oe),x)return;let ze=new Set(u.value.map(et=>et.node.id));y=Oe.find(et=>ze.has(et))??null,y&&U(y)}let W=[i.onEditorEvent("graph:replaced",j),i.onEditorEvent("page:changed",j),i.onEditorEvent("node:created",ee),i.onEditorEvent("node:deleted",ee),i.onEditorEvent("node:reparented",ee),i.onEditorEvent("node:reordered",ee),i.onEditorEvent("node:updated",K),i.onEditorEvent("selection:changed",Q)];Lo(()=>{for(let Oe of W)Oe()});function J(Oe){let ze=i.graph.getNode(Oe);if(!ze)return;let et=ze.parentId;for(;et&&et!==i.state.currentPageId;){if(i.graph.isContainer(et)){i.enterContainer(et);return}et=i.graph.getNode(et)?.parentId??null}i.state.enteredContainerId=null}function te(Oe,ze){let et=typeof ze=="boolean"?{additive:ze,range:!1}:ze;r("select",Oe,et.additive);let ft=vFe(u.value.map($e=>$e.node.id),i.state.selectedIds,y,Oe,et);et.range||(y=Oe),x=!0;try{et.additive&&!et.range?i.select([Oe],!0):i.select([...ft])}finally{x=!1}!et.additive&&!et.range&&J(Oe),U(Oe)}function _(Oe){r("toggleExpand",Oe),s.value.indexOf(Oe)!==-1?s.value=s.value.filter(ze=>ze!==Oe):m(Oe)}function re(Oe){return Oe.id}function Ae(Oe){return Oe.children}function ye(Oe){f=Oe}let ke={select:te,toggleExpand:_,setFocused:Oe=>{c.value=Oe},setVirtualizer:ye};bPt({editor:i,items:o,expanded:s,visibleRows:u,treeVersion:a,selectedIds:l,focused:c,indentPerLevel:e.indentPerLevel,draggingId:g,instruction:E,instructionTargetId:k,setupDrag:P,select:te,toggleExpand:_,setFocused:ke.setFocused,setVirtualizer:ye,toggleVisibility:Oe=>{r("toggleVisibility",Oe),i.toggleNodeVisibility(Oe)},toggleLock:Oe=>{r("toggleLock",Oe),i.toggleNodeLock(Oe)},rename:(Oe,ze)=>{r("rename",Oe,ze),i.renameNode(Oe,ze)},setRowRef:D});let Fe={emit:r,editor:i,items:o,expanded:s,treeVersion:a,selectedIds:l,focused:c,visibleRows:u,get nodesById(){return d},set nodesById(Oe){d=Oe},get virtualizer(){return f},set virtualizer(Oe){f=Oe},get selectionAnchorId(){return y},set selectionAnchorId(Oe){y=Oe},get applyingSelection(){return x},set applyingSelection(Oe){x=Oe},expandNode:m,draggingId:g,instruction:E,instructionTargetId:k,setupItem:P,get rebuildPending(){return N},set rebuildPending(Oe){N=Oe},get rebuildToken(){return O},set rebuildToken(Oe){O=Oe},rebuildTree:j,scheduleTreeRebuild:ee,PATCHABLE_NODE_KEYS:Z,patchTreeNode:K,rowRefs:T,setRowRef:D,expandSelectionAncestors:V,scrollToNode:U,onSelectionChanged:Q,unsubscribe:W,syncCanvasScope:J,select:te,toggleExpand:_,getKey:re,getChildren:Ae,setVirtualizer:ye,actions:ke,get TreeRoot(){return bY}};return Object.defineProperty(Fe,"__isScriptSetup",{enumerable:!1,value:!0}),Fe}});function xPt(e,t,n,r,i,o){return gf(),yf(r.TreeRoot,{expanded:r.expanded,"onUpdate:expanded":t[0]||(t[0]=s=>r.expanded=s),as:"div",class:"flex min-h-0 flex-1 flex-col overflow-hidden",items:r.items,"get-key":r.getKey,"get-children":r.getChildren},{default:Vd(({flattenItems:s})=>[Hd(e.$slots,"default",{items:r.items,flattenItems:s,visibleRows:r.visibleRows,expanded:r.expanded,treeVersion:r.treeVersion,selectedIds:r.selectedIds,focused:r.focused,draggingId:r.draggingId,instruction:r.instruction,instructionTargetId:r.instructionTargetId,actions:r.actions})]),_:3},8,["expanded","items"])}var TY=I$(SPt,[["render",xPt],["__file","/home/runner/work/open-pencil/open-pencil/packages/vue/src/primitives/LayerTree/LayerTreeRoot.vue"]]);var gNn=Symbol("LayoutControlsContext");var yNn=Symbol("PropertyList");function wY(e){let t=Symbol(e);return[()=>{let i=fo(t);if(!i)throw new Error(`[open-pencil] Injection \`${e}\` not found. Component must be used within the corresponding Root.`);return i},i=>(Ua(t,i),i)]}var[CPt,vNn]=wY("PropertySection");var[TPt,ANn]=wY("SegmentedControl");var[SFe,bNn]=wY("NumberField");function pM(e){return Xr({name:`NumberField${e[0]?.toUpperCase()??""}${e.slice(1)}`,inheritAttrs:!1,setup(t,{attrs:n,slots:r}){let i=SFe();return()=>Vi("span",{...n,...i.stateAttrs.value,"data-slot":e},r.default?.(i.slotProps.value))}})}var wPt=pM("leading"),EPt=pM("unit"),kPt=pM("trailing"),IPt=pM("menu");var SNn=Symbol("toolbar");function PPt(e){if(e===null||typeof e!="object")return!1;let t={...e};return!(typeof t.prefix!="string"||t.prefix===""||t.icons===null||typeof t.icons!="object")}function NPt(e){return e===null||typeof e!="object"?!1:typeof e.body=="string"}function xFe(e){let t=null,n=()=>(t??=e().then(i=>{if(!PPt(i))throw new Error("The bundled icon set is malformed.");return i}),t.catch(()=>{t=null}),t),r=async()=>(await n()).prefix;return CD({async fetchCollection(i,o){let s=await n();if(i!==s.prefix)throw new Error('Icon set "'+i+'" is not bundled. Use '+s.prefix+":<name>.");let a={};for(let l of o){let c=s.icons[l];NPt(c)&&(a[l]={body:c.body,width:c.width,height:c.height})}return{prefix:i,width:s.width,height:s.height,icons:a,aliases:s.aliases}},async collections(){let i=await n();return[{prefix:i.prefix,name:"Material Design Icons",total:Object.keys(i.icons).length,category:"General",license:"Apache-2.0",multicolor:!1}]},async collectionIcons(){let i=await n();return Object.keys(i.icons).map(o=>i.prefix+":"+o)},async search(i,o){let s=await n(),a=await r(),l=o?.limit??20,c=i.toLowerCase(),u=Object.keys(s.icons).filter(d=>d.toLowerCase().includes(c)).slice(0,l).map(d=>a+":"+d);return{icons:u,total:u.length,collections:{[a]:{name:"Material Design Icons",total:Object.keys(s.icons).length,category:"General"}}}}})}var CFe={selection:[],rows:[],properties:{ids:[],name:null,type:null,x:null,y:null,width:null,height:null,rotation:null,radius:null,opacity:null,visible:null,text:null},isText:!1,canUndo:!1,canRedo:!1,zoom:1,tool:"select",fit:!0};function dy(e){return typeof e=="number"?e:null}function TFe(e,t,n){let r=new Set,i=CFe,o=!1,s=!1,a=null,l=()=>{if(a===null)return CFe;let{tree:y,position:x,appearance:m,typography:g}=a,E=e.getSelectedNodes(),k=e.state.currentPageId,P=E.map(Z=>{let K=Z.parentId===null||Z.parentId===k?void 0:e.graph.getNode(Z.parentId);return{id:Z.id,name:Z.name,type:Z.type,parentName:K?.name??""}}),N=y.visibleRows.value.map(Z=>({id:Z.node.id,name:Z.node.name,type:Z.node.type,level:Z.level,hasChildren:Z.hasChildren,expanded:y.expanded.value.includes(Z.node.id),visible:Z.node.visible,locked:Z.node.locked,selected:y.selectedIds.value.has(Z.node.id)})),O=x.node.value??x.nodes.value[0],j={ids:[...x.ids.value],name:O?.name??null,type:O?.type??null,x:dy(x.prop("x").value),y:dy(x.prop("y").value),width:dy(x.prop("width").value),height:dy(x.prop("height").value),rotation:dy(x.prop("rotation").value),radius:dy(m.cornerRadiusValue.value),opacity:dy(m.opacityPercent.value),visible:m.visibilityState.value==="mixed"?null:m.visibilityState.value==="visible",text:g.node.value?.type==="TEXT"?{family:g.fontFamily.value,weight:g.fontWeight.value,fontSize:g.fontSize.value}:null},ee=E.length===1&&E[0]?.type==="TEXT";return{selection:P,rows:N,properties:j,isText:ee,canUndo:e.undo.canUndo,canRedo:e.undo.canRedo,zoom:e.state.zoom,tool:t(e.state.activeTool),fit:n()}},c=()=>{i=l();for(let y of r)y(i)},u=()=>{o||(o=!0,queueMicrotask(()=>{o=!1,c()}))},d=[e.onEditorEvent("history:changed",u),e.onEditorEvent("selection:changed",u),e.onEditorEvent("viewport:changed",u),e.onEditorEvent("tool:changed",u),e.onEditorEvent("node:updated",u),e.onEditorEvent("node:previewUpdated",u),e.onEditorEvent("graph:replaced",u),e.onEditorEvent("page:changed",u)];return{component:Xr({name:"DesignInspectorBridge",setup(){let y=CY(),x=fY(),m=hY(),g=mY();a={tree:y,position:x,appearance:m,typography:g};let E=ii(()=>[y.treeVersion.value,y.expanded.value.join(","),[...y.selectedIds.value].join(","),x.prop("x").value,x.prop("y").value,x.prop("width").value,x.prop("height").value,x.prop("rotation").value,m.opacityPercent.value,m.cornerRadiusValue.value,m.visibilityState.value,g.fontFamily.value,g.fontWeight.value,g.fontSize.value],u,{flush:"post"});return Lo(E),s=!0,u(),()=>null}}),snapshot:()=>(s&&(i=l()),i),subscribe(y){return r.add(y),()=>r.delete(y)},notify:u,select(y,x){a?.tree.select(y,{additive:x==="add",range:x==="range"})},clearSelection(){e.clearSelection()},toggleExpand(y){a?.tree.toggleExpand(y)},toggleVisibility(y){a?.tree.toggleVisibility(y)},toggleLock(y){a?.tree.toggleLock(y)},rename(y,x){a?.tree.rename(y,x)},setVisible(y){let x=[...e.state.selectedIds];x.length!==0&&e.undo.runBatch("Change visibility",()=>{for(let m of x)e.updateNodeWithUndo(m,{visible:y},"Change visibility")})},preview(y,x){a!==null&&(y==="radius"?a.appearance.updateUniformRadius(x):y==="opacity"?a.appearance.updateProp("opacityPercent",x):y==="fontSize"?a.typography.updateProp("fontSize",x):a.position.updateProp(y,x))},commit(y,x,m){a!==null&&(y==="radius"?(a.appearance.updateUniformRadius(x),a.appearance.commitUniformRadius()):y==="opacity"?a.appearance.commitProp("opacityPercent",x,m):y==="fontSize"?a.typography.commitProp("fontSize",x,m):a.position.commitProp(y,x,m))},setFamily(y){a?.typography.setFamily(y)},setWeight(y){a?.typography.setWeight(y)},dispose(){for(let y of d)y();r.clear(),a=null,s=!1}}}var RPt=Math.log(1.15),DPt=.01386,_Pt=Math.log(2),OPt=Math.log(1.2),MPt=40,LPt=800;function wFe(e){return Math.min(4,Math.max(.25,e))}function FPt(e,t){let n=t===1?e*MPt:t===2?e*LPt:e,r=Math.abs(n)>=50?-(n/100)*RPt:-n*DPt,i=Math.abs(n)>=50?_Pt:OPt;return Math.exp(Math.min(i,Math.max(-i,r)))}function EFe(e,t,n){let r=e*FPt(t,n);return Math.min(Math.max(r,Math.min(e,.25)),Math.max(e,4))}var kFe=Xr({name:"DesignCanvasSurface",props:{mode:{type:String,default:"edit"}},setup(e){let t=ts(),n=P$();K$(n.canvasRef,t,n.hitTestSectionTitle,n.hitTestComponentLabel,n.hitTestFrameTitle,void 0,void 0,()=>e.mode==="edit");let r=null,i=$t(null),o=u=>{let d=n.canvasRef.value;if(d===null)return null;let f=d.getBoundingClientRect(),y=u.clientX-f.left,x=u.clientY-f.top,m=t.screenToCanvas(y,x);return{sx:y,sy:x,cx:m.x,cy:m.y}},s=u=>{if(!u.ctrlKey&&!u.metaKey)return;let d=n.canvasRef.value;if(d===null)return;u.preventDefault(),u.stopPropagation();let f=d.getBoundingClientRect(),y=EFe(t.state.zoom,u.deltaY,u.deltaMode);t.setZoomAroundPoint(y,u.clientX-f.left,u.clientY-f.top)},a=u=>{if(e.mode!=="view")return;let d=o(u);if(d===null)return;if(u.button===1){u.preventDefault(),r={startX:u.clientX,startY:u.clientY,panX:t.state.panX,panY:t.state.panY};return}if(u.button!==0)return;let f=t.hitTestAtPoint(d.cx,d.cy);if(f!==null){t.select([f.id],u.shiftKey||u.metaKey||u.ctrlKey);return}t.clearSelection(),r={startX:u.clientX,startY:u.clientY,panX:t.state.panX,panY:t.state.panY}},l=u=>{r!==null&&(t.state.panX=r.panX+(u.clientX-r.startX),t.state.panY=r.panY+(u.clientY-r.startY),t.requestRepaint())},c=()=>{r=null};return Af(()=>{i.value?.addEventListener("wheel",s,{capture:!0,passive:!1})}),cb(()=>{i.value?.removeEventListener("wheel",s,!0)}),()=>Vi("div",{class:"op-surface",ref:i},[Vi("canvas",{ref:u=>{n.canvasRef.value=u},style:"display:block;width:100%;height:100%;outline:none",onMousedown:a,onMousemove:l,onMouseup:c,onMouseleave:c,onDblclick:u=>{e.mode==="view"&&u.preventDefault()}})])}});var BPt="/artifacts-canvas/",cA={select:"SELECT",hand:"HAND",frame:"FRAME",text:"TEXT"},zPt={SELECT:"select",HAND:"hand",FRAME:"frame",TEXT:"text"},GPt=[["Regular","Roboto-Regular.woff2"],["Medium","Roboto-Medium.woff2"],["Bold","Roboto-Bold.woff2"]];function fM(e){return BPt+e+"?v=0.9.0"}function VPt(e){return e instanceof Error?e.message:String(e)}async function jPt(){for(let[e,t]of GPt){let n=await fetch(fM("fonts/"+t));if(!n.ok)throw new Error("The bundled font "+t+" is missing.");gt.markLoaded("Roboto",e,await n.arrayBuffer())}}async function IFe(e){let t=new Ja;await mO(xFe(async()=>{let r=await fetch(fM("icons.json"));if(!r.ok)throw new Error("The bundled icon set is missing.");return r.json()})).renderJSX(t,e);let n=t.getPages()[0];if(n===void 0)throw new Error("The design has no page.");return{graph:t,page:n}}function HPt(e,t,n){let r=[],i=e.getNode(t),o="";if(i===void 0)return{names:r,parentName:o};r.push(i.name);let s=i.parentId,a=!0;for(;s!==null&&s!==n;){let l=e.getNode(s);if(l===void 0)break;a&&(o=l.name),a=!1,r.unshift(l.name),s=l.parentId}return{names:r,parentName:o}}async function bRn(e){let t=e.element;await r0({locateFile:N=>fM(N)}),gt.setBundledFontLocator(N=>fM("fonts/"+N)),await jPt();let n=await IFe(e.source),r=hO({graph:n.graph,state:Cc(ZC(n.page.id)),getViewportSize:()=>({width:Math.max(1,t.clientWidth),height:Math.max(1,t.clientHeight)})});r.zoomToFit();let i=$t(e.mode),o=!0,s=!1,a=e.source,l=!1,c=TFe(r,N=>zPt[N]??"select",()=>o),u=Xr({setup(){return w$(r),()=>Vi("div",{class:"op-root"},[Vi("div",{class:"op-canvas"},[Vi(N$,null,{default:()=>Vi(kFe,{mode:i.value})})]),Vi(TY,{class:"op-bridge",indentPerLevel:14},{default:()=>Vi(c.component)})])}}),d=KX(u);d.mount(t);let f=0,y=()=>{if(!l){if(r.renderer===null&&f<300){f+=1,requestAnimationFrame(y);return}r.zoomToFit(),o=!0,c.notify()}};requestAnimationFrame(y);let x=r.onEditorEvent("history:changed",()=>{if(l)return;let N=N0(n.page.childIds,n.graph);N!==a&&(a=N,e.onChange(N))}),m=r.onEditorEvent("viewport:changed",()=>{s?(s=!1,o=!0):o=!1,c.notify()}),g=r.onEditorEvent("graph:replaced",()=>c.notify()),E=N=>{i.value!==N&&(i.value=N,r.setTool(cA.select),c.notify())},k=N=>{if(r.isInteractiveEditing())return;let O=i.value==="edit",j=N.ctrlKey||N.metaKey,ee=N.key.toLowerCase();if(j&&ee==="s"){N.preventDefault(),e.onSave();return}if(O){if(j&&ee==="z"){N.preventDefault(),N.shiftKey?r.undo.redo():r.undo.undo();return}if(j&&ee==="y"){N.preventDefault(),r.undo.redo();return}if(!(j||N.altKey)){if(ee==="delete"||ee==="backspace"){N.preventDefault(),r.deleteSelected();return}ee==="v"?r.setTool(cA.select):ee==="h"?r.setTool(cA.hand):ee==="f"?r.setTool(cA.frame):ee==="t"&&r.setTool(cA.text)}}},P=()=>{t.focus({preventScroll:!0})};return t.addEventListener("keydown",k),t.addEventListener("pointerdown",P),{setSource(N){(async()=>{try{let O=await IFe(N);if(l)return;n=O,a=N,r.replaceGraph(O.graph),r.zoomToFit(),o=!0,c.notify()}catch(O){l||e.onFailure?.(VPt(O))}})()},setMode(N){E(N)},setTool(N){r.setTool(cA[N])},undo(){r.undo.undo()},redo(){r.undo.redo()},zoomToFit(){o=!0,r.zoomToFit(),c.notify()},setZoom(N){o=!1,r.zoomToLevel(wFe(N)),c.notify()},getSnapshot(){return c.snapshot()},subscribe(N){return c.subscribe(N)},select(N,O){c.select(N,O)},clearSelection(){c.clearSelection()},toggleExpand(N){c.toggleExpand(N)},toggleVisibility(N){c.toggleVisibility(N)},toggleLock(N){c.toggleLock(N)},rename(N,O){c.rename(N,O)},setVisible(N){c.setVisible(N)},preview(N,O){c.preview(N,O)},commit(N,O,j){c.commit(N,O,j)},setFamily(N){c.setFamily(N)},setWeight(N){c.setWeight(N)},quoteSelection(){let O=r.getSelectedNodes()[0];if(O===void 0)return null;let{names:j,parentName:ee}=HPt(r.graph,O.id,r.state.currentPageId);return{name:O.name,path:j.join(" / "),type:O.type,parentName:ee,jsx:N0([O.id],r.graph)??""}},destroy(){l||(l=!0,t.removeEventListener("keydown",k),t.removeEventListener("pointerdown",P),x(),m(),g(),c.dispose(),d.unmount(),r.dispose())}}}export{bRn as mountDesignCanvas};
|
package/client.canvas.js
CHANGED
|
@@ -4,7 +4,7 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
factory(require) {
|
|
5
5
|
var module = { exports: {} };
|
|
6
6
|
var exports = module.exports;
|
|
7
|
-
"use strict";var o=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(n,s)=>{for(var e in s)o(n,e,{get:s[e],enumerable:!0})},c=(n,s,e,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of r(s))!g.call(n,a)&&a!==e&&o(n,a,{get:()=>s[a],enumerable:!(i=t(s,a))||i.enumerable});return n};var C=n=>c(o({},"__esModule",{value:!0}),n);var _={};v(_,{mountDesignCanvas:()=>u});module.exports=C(_);var d=["/artifacts-canvas/canvas.engine.js?v=","0.
|
|
7
|
+
"use strict";var o=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(n,s)=>{for(var e in s)o(n,e,{get:s[e],enumerable:!0})},c=(n,s,e,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of r(s))!g.call(n,a)&&a!==e&&o(n,a,{get:()=>s[a],enumerable:!(i=t(s,a))||i.enumerable});return n};var C=n=>c(o({},"__esModule",{value:!0}),n);var _={};v(_,{mountDesignCanvas:()=>u});module.exports=C(_);var d=["/artifacts-canvas/canvas.engine.js?v=","0.9.0"].join("");function l(n){return n===null||typeof n!="object"?!1:typeof{...n}.mountDesignCanvas=="function"}async function u(n){let s=await import(d);if(!l(s))throw new Error("The canvas engine did not load.");return s.mountDesignCanvas(n)}
|
|
8
8
|
|
|
9
9
|
return module.exports;
|
|
10
10
|
},
|