@hazem3500/palette 0.9.131 → 0.9.132
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 +10 -6
- package/dist/adapters/css-variables.js +1 -1
- package/dist/adapters/tailwind.d.ts +1 -1
- package/dist/adapters/tailwind.js +1 -1
- package/dist/chunk-DQPAVGRB.js +1 -0
- package/dist/{chunk-UUV356RI.js → chunk-KMRWUNT7.js} +1 -1
- package/dist/{chunk-RAAJF54I.js → chunk-OAGWNW4W.js} +1 -1
- package/dist/chunk-UVWLXKWZ.js +1 -0
- package/dist/{color-editor-I5ELNYPO.js → color-editor-GCCLM3TV.js} +1 -1
- package/dist/design-comment-LHFSWNU7.js +1 -0
- package/dist/{design-export-55QSPEWM.js → design-export-I766FRDX.js} +1 -1
- package/dist/{design-geometry-OXGWR5J2.js → design-geometry-W7PSW5J2.js} +1 -1
- package/dist/design-mode.js +1 -1
- package/dist/design-system.d.ts +1 -1
- package/dist/frame-size-E6OGNHNX.js +1 -0
- package/dist/frame-size.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{inline-text-editor-S4LVCKZL.js → inline-text-editor-5JSAHEHE.js} +1 -1
- package/dist/message-links.d.ts +2 -0
- package/dist/node.mjs +100 -21
- package/dist/open-state.d.ts +7 -0
- package/dist/postgres/011_comment_api_key_name.sql +1 -0
- package/dist/postgres/012_comment_images.sql +25 -0
- package/dist/react-props-panel-P47YFFSU.js +1 -0
- package/dist/react-props-panel.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/server.js +97 -20
- package/dist/setup.js +1 -1
- package/dist/snapshot-TUAELSKH.js +1 -0
- package/dist/snapshot-annotate-T3XC5ENZ.js +1 -0
- package/dist/snapshot-annotate.d.ts +16 -0
- package/dist/snapshot.d.ts +15 -4
- package/dist/thread-snapshot-2V4AV3UN.js +1 -0
- package/dist/thread-snapshot.d.ts +4 -6
- package/dist/token-adapter.d.ts +1 -0
- package/dist/{token-custom-7MJFPGVB.js → token-custom-CPPHGYMJ.js} +1 -1
- package/dist/{token-page-YQ52JS6G.js → token-page-63C3T4DY.js} +1 -1
- package/dist/{token-picker-HHT4OC3V.js → token-picker-ARVCFUCY.js} +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/server/bot-tokens.ts +7 -3
- package/server/index.ts +80 -17
- package/server/migrations/0025_comment_api_key_name.sql +1 -0
- package/server/migrations/0026_comment_images.sql +22 -0
- package/server/setup-client.txt +115 -79
- package/server/snapshots.ts +2 -1
- package/server/tokens.ts +2 -2
- package/src/types.ts +4 -0
- package/dist/chunk-EVRPBA4F.js +0 -1
- package/dist/design-comment-VXRH45UI.js +0 -1
- package/dist/frame-size-EAVSR4SA.js +0 -1
- package/dist/react-props-panel-VON2NO7N.js +0 -1
- package/dist/snapshot-BFHCCGOL.js +0 -1
- package/dist/thread-snapshot-TJHRZZOR.js +0 -1
- /package/dist/{design-panel-DBAUVCIJ.js → design-panel-GU2SWV33.js} +0 -0
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ const tokens: TailwindToken[] = [
|
|
|
363
363
|
{ path: "radius.md", type: "dimension", class: "rounded-md", properties: ["border-radius"], value: "6px" },
|
|
364
364
|
{ path: "typography.h1", type: "typography", class: "text-h1",
|
|
365
365
|
properties: ["font-size", "line-height", "font-weight"], value: "32px/40px 600" },
|
|
366
|
-
...tailwindSpacing(), // p-*, px-*, …, m-*, gap-* on the 4px scale
|
|
366
|
+
...tailwindSpacing(), // p-*, px-*, …, m-*, gap-*, w-*, h-* on the 4px scale
|
|
367
367
|
];
|
|
368
368
|
|
|
369
369
|
initPalette({ project, design: { tokens: tailwindTokens({ tokens }, { themes: [mode, product] }), themes: [mode, product] } });
|
|
@@ -373,7 +373,7 @@ initPalette({ project, design: { tokens: tailwindTokens({ tokens }, { themes: [m
|
|
|
373
373
|
- `values` keys are option ids (`dark`), `axis=option` pairs (`mode=dark`), or combinations joined with `+` (`track+dark`). The most specific match wins, then `value`.
|
|
374
374
|
- `resolve()` reads base-state classes only; variants such as `hover:` or `md:` are ignored. When classes overlap, the narrower class wins, as in Tailwind (`p-4 px-2` reads `padding-left` from `px-2`). Properties with no table class are reported off-token with their computed value; pass `offToken: [...]` to narrow the list or `false` to turn it off.
|
|
375
375
|
- Previews replace table classes the new class fully covers, keep everything else in place, and stack; undoing restores the original `class` exactly. Classes outside the table, such as `text-[14px]`, are left alone.
|
|
376
|
-
- `tailwindSpacing({ prefix, scale, steps })` narrows the families (`p`, `px`, `py`, `pt`, `pr`, `pb`, `pl`, `m`, `mx`, …, `gap`, `gap-x`, `gap-y`), the pixels per step (default 4), and the steps (default Tailwind's 0 to 96). Paths are `spacing.<class>`, for example `spacing.p-4`.
|
|
376
|
+
- `tailwindSpacing({ prefix, scale, steps })` narrows the families (`p`, `px`, `py`, `pt`, `pr`, `pb`, `pl`, `m`, `mx`, …, `gap`, `gap-x`, `gap-y`, `w`, `h`), the pixels per step (default 4), and the steps (default Tailwind's 0 to 96). Paths are `spacing.<class>`, for example `spacing.p-4`.
|
|
377
377
|
- Tailwind's JIT only emits CSS for classes it finds in source, so a full table can list classes such as `p-9` or `mt-96` that have no rule and preview nothing. `tailwindTokens(table, { onlyGenerated: true })` lists only tokens whose first class has a rule in the page's stylesheets, including rules inside `@media`, `@supports`, `@layer`, `@container`, nested rules and same-origin `@import`. Names are matched exactly as escaped CSS, so `p-1.5`, `w-1/2`, `-mt-4`, `p-[13px]`, `md:p-4` and `!p-4` each need their own rule. The scan runs on the first `list()` and again only when a stylesheet is added, removed, replaced, loads or gains rules, including `adoptedStyleSheets`. With `onlyGenerated`, the adapter also has `subscribe()`: adding, removing, editing or loading a `<style>` or `<link>` refreshes the list in Design mode, including an open picker. Rules added only through `insertRule()` or `adoptedStyleSheets` show with the next such change.
|
|
378
378
|
- Cross-origin sheets: Palette cannot read a cross-origin stylesheet served without CORS, such as a font stylesheet pulled in with `@import url(https://fonts…)`. By default it skips each unreadable sheet or `@import`, assumes it holds no utility CSS, and filters with the rest. It hides nothing while a `<link>` stylesheet is still loading or failed, or when no readable sheet has a style rule. If your utilities themselves come from another origin, pass `onlyGenerated: { strict: true }`, which hides nothing while any sheet is unreadable, or serve that CSS with `crossorigin` on the `<link>` and `Access-Control-Allow-Origin`. `onlyGenerated: true` is the default object.
|
|
379
379
|
- `filter(token)` returning `false` leaves a token out of `list()`, alone or with `onlyGenerated`. Hidden tokens still resolve on elements that already use their class.
|
|
@@ -496,6 +496,10 @@ Tokens start with `palette_pat_` (`komo_pat_` for tokens issued before the renam
|
|
|
496
496
|
| `comments:read` | List and read threads, `palette whoami`. |
|
|
497
497
|
| `comments:write` | Create threads, reply, edit, react, resolve, tag, move. |
|
|
498
498
|
|
|
499
|
+
Comments and replies support Markdown links, bold, emphasis, inline code, and fenced code blocks. Raw HTML is displayed as text.
|
|
500
|
+
|
|
501
|
+
To attach a PNG or WebP (up to 256 KiB) with a token, post the comment first, then send the image as the raw body of `PUT /threads/{threadId}/comments/{commentId}/image` with its image content type. The comment author can upload or replace the image. The authenticated thread response includes the image URL. To add or remove your reaction, send `POST /threads/{threadId}/comments/{commentId}/reactions` with `{"emoji":"👍","active":true}` or `active:false`. Project bot tokens can use both endpoints for the projects they belong to.
|
|
502
|
+
|
|
499
503
|
A token acts as its owner, narrowed by its scopes and project list: it never passes an ownership check or private-project invitation its owner would fail, and it cannot manage tokens, projects, members, or webhooks. Credentials resolve in this order: `PALETTE_TOKEN`, a token saved by `palette login --token`, then a browser login session.
|
|
500
504
|
|
|
501
505
|
**Rotate** by creating a replacement, updating the secret, confirming `palette whoami`, then revoking the old token. Prefer an expiry of 90 days or less. **Revoke** from **Account → API tokens** or `/account`; the token stops working on its next request (HTTP 401), and so does an expired one.
|
|
@@ -635,7 +639,7 @@ Pass these to `initPalette(config)` from `@hazem3500/palette` or `usePalette(con
|
|
|
635
639
|
| `sessionEndpoint` | `string` | `endpoint` | Canonical API identity for trusted gateways to the same service; never share across independent APIs. |
|
|
636
640
|
| `avatar` | `(user: { id, name }) => string \| undefined` | None | Photo URL for signed-in reviewers the server has none for, such as IAP sign-in. HTTPS only; guests keep their initial. |
|
|
637
641
|
| `snapshots` | `{ image?, html?, maxBytes?, redact?(element) }` | Off | Save an image and/or trimmed HTML of the commented element with each new thread. See [Comment snapshots](#comment-snapshots). |
|
|
638
|
-
| `share` | `{ label }` | Off | Let reviewers keep new comments out of a webhook integration, e.g. `{ label: "Post to the GitHub PR" }`. Adds
|
|
642
|
+
| `share` | `{ label }` | Off | Let reviewers keep new comments out of a webhook integration, e.g. `{ label: "Post to the GitHub PR" }`. Adds an account default and a checkbox for each new comment; a kept comment's `comment.created` event carries `share: false`. Needs a server with `config.share` ([NODE.md](NODE.md#keeping-comments-out-of-integrations)). |
|
|
639
643
|
|
|
640
644
|
Google sign-in uses the account photo (`picture`) automatically, loaded from `lh3.googleusercontent.com`. Under a restrictive CSP, allow that host (or your `avatar` host) in `img-src`; blocked or failed photos fall back to the initial.
|
|
641
645
|
|
|
@@ -769,7 +773,7 @@ Worker bindings: `DB` (D1), optional `EDGE_LIMIT` (rate limiter). Variables: `PR
|
|
|
769
773
|
|
|
770
774
|
### Element snapshots
|
|
771
775
|
|
|
772
|
-
A comment can carry a snapshot of its target element: one image (`image/webp` or `image/png`, up to 256 KiB) and one trimmed HTML capture (`text/html`, UTF-8, up to 32 KiB) per thread.
|
|
776
|
+
A comment can carry a snapshot of its target element: one image (`image/webp` or `image/png`, up to 256 KiB) and one trimmed HTML capture (`text/html`, UTF-8, up to 32 KiB) per thread. Element capture is opt-in on the client. Dragging a region in comment mode previews an image of that area unless image capture is disabled. You can attach a PNG, JPEG, or WebP to a new comment and click the image to open a larger preview for marking it up before posting. **Snapshots may contain page content and user data**, so treat them like the comments they belong to.
|
|
773
777
|
|
|
774
778
|
- `POST /threads/:id/snapshot?kind=image|html` takes the raw file with its `Content-Type`, or `multipart/form-data` with `kind` and `file` fields. A new upload replaces the thread's previous snapshot of that kind. Uploads need a session with write access to the project; guests are refused unless the project sets `allowGuestSnapshots`, and then only on their own threads. The thread's author or a signed-in reviewer can replace or `DELETE /threads/:id/snapshot/:kind`.
|
|
775
779
|
- `GET /threads/:id/snapshot/:kind` needs a session, even on link-access projects, and returns `Cache-Control: private`, `X-Content-Type-Options: nosniff` and `Content-Security-Policy: sandbox`. HTML is always served as `text/plain`; show it to agents or in a sandboxed viewer, never as live markup.
|
|
@@ -870,12 +874,12 @@ The `@hazem3500/palette/server` export loads built ESM in Node and includes Work
|
|
|
870
874
|
|
|
871
875
|
### Experimental page-element resize and move
|
|
872
876
|
|
|
873
|
-
|
|
877
|
+
Resize handles and movement are available in Design mode. To turn them off:
|
|
874
878
|
|
|
875
879
|
```ts
|
|
876
880
|
initPalette({
|
|
877
881
|
// ...your existing endpoint/project/repo/branch options
|
|
878
|
-
design: { experimentalGeometry:
|
|
882
|
+
design: { experimentalGeometry: false },
|
|
879
883
|
});
|
|
880
884
|
```
|
|
881
885
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var t=["padding","margin","gap"],r={color:["color",["color","background-color","border-color"],"Color"],spacing:["dimension",t,"Spacing"],radius:["dimension",["border-radius"],"Radius"],text:["dimension",["font-size"],"Font size"],font:["fontFamily",["font-family"],"Font"],leading:["lineHeight",["line-height"],"Line height"],"font-weight":["fontWeight",["font-weight"],"Font weight"]},o=/^(#[0-9a-f]{3,8}|(rgb|hsl|hwb|lab|lch|oklab|oklch|color)a?\(.*\))$/i,l=/^-?\d*\.?\d+(px|rem|em|%|vw|vh|ch)$/,n=(e,t=("object"==typeof window?window:null))=>{let{conditionText:r}=e;return"string"!=typeof r||("media"in e?"function"!=typeof t?.matchMedia||t.matchMedia(r).matches:!!(typeof CSS<"u"&&"supports"in CSS&&e.constructor.name.includes("Supports"))&&CSS.supports(r))},a=/^(:root|html|:host)$/,i=(e,t,r,o)=>{for(let l of Array.from(e))if("selectorText"in l&&l.style){let{selectorText:e,style:n}=l,i=e.split(",").map(e=>e.trim()),s=i.some(e=>a.test(e));if(!s&&!i.some(e=>o.has(e)))continue;for(let e of Array.from(n))e.startsWith("--")&&(s?t:r).set(e,n.getPropertyValue(e).trim())}else"cssRules"in l&&i(l.cssRules,t,r,o)},s=/^(\d{1,3})(\s*,\s*|\s+)(\d{1,3})\2(\d{1,3})$/,c=e=>t=>{let r=document.createElement("span").style;r.color=t;let o=r.color.match(/[\d.]+/g);return o&&o.length>2?o.slice(0,3).map(e=>Math.round(+e)).join(e):t};function p(e,n){let a=e.slice(2),i=Object.keys(r).sort((e,t)=>t.length-e.length).find(e=>a===e||a.startsWith(`${e}-`));if(i){let[e,t,o]=r[i];if("fontFamily"!==e||!/^\d+$/.test(n))return{type:e,properties:t,group:o,ns:i}}return o.test(n)?{type:"color",properties:r.color[1],group:"Color"}:l.test(n)?{type:"dimension",properties:[...t,"border-radius"],group:"Size"}:null}var u=e=>{let t=e.replace(/::?(not|is|where|has)\(([^)]*)\)/g," $2 ");return 1e6*(t.match(/#[\w-]+/g)??[]).length+1e3*(t.match(/\.[\w-]+|\[[^\]]*\]|:(?!:)[\w-]+/g)??[]).length+(t.replace(/#[\w-]+|\.[\w-]+|\[[^\]]*\]|::?[\w-]+/g," ").match(/(^|[\s>+~])[a-z][\w-]*/gi)??[]).length},f={"background-color":["background-color","background"],"border-color":["border-color","border"],padding:["padding"],margin:["margin"],gap:["gap"],"border-radius":["border-radius"],font:["font"]};function d(t={}){let r=t.include??(e=>!e.startsWith("--tw-")),o=t.limit??300,l=t.scopes??{},a=new Map,d=new Map;function h(e={}){let t=new Map,n=new Map,c=new Set(Object.values(e).flatMap(e=>l[e]?[l[e]]:[]));for(let e of Array.from(document.styleSheets))try{i(e.cssRules,t,n,c)}catch{}let u=getComputedStyle(document.documentElement),f=new Map;for(let[e,l]of t){let t=u.getPropertyValue(e).trim(),a=t&&r(e)?p(e,t):null;if(!a||f.size>=o)continue;let i=e.slice(2),{ns:c,...d}=a,h=c?c.length:i.indexOf("-"),m=h>0&&i.length>h?`${i.slice(0,h)}.${i.slice(h+1)}`:i,g="color"===a.type?s.exec(t):null,y=g&&[g[1],g[3],g[4]].map(Number);y?.every(e=>e<256)&&(t=`#${y.map(e=>e.toString(16).padStart(2,"0")).join("")}`),f.set(e,{name:e,path:m,value:t,...d,declared:n.get(e)??l,...y?{channels:g[2].includes(",")?", ":" "}:{}})}return a=f,f}let m=e=>{let t=/^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/.exec(e.trim());return t&&a.has(t[1])?t[1]:null};function g(e,t){let r=e.style,o=f[t]??[t];for(let e of o){let t=r?.getPropertyValue(e);if(t&&"important"!==r.getPropertyPriority(e))return m(t)}let l=null,a=0,i=t=>{for(let r of Array.from(t))if("selectorText"in r&&r.style){let{selectorText:t,style:n}=r;for(let r of t.split(",")){let t=!1;try{t=e.matches(r.trim())}catch{}if(t)for(let e of o){let t=n.getPropertyValue(e);if(!t)continue;let o=(n.getPropertyPriority(e)?1e12:0)+1e3*u(r)+a++;(!l||o>=l.rank)&&(l={rank:o,value:t})}}}else"cssRules"in r&&n(r,e.ownerDocument.defaultView)&&i(r.cssRules)};for(let t of Array.from(e.ownerDocument.styleSheets))try{i(t.cssRules)}catch{}return l?m(l.value):null}function y(e){let t=[...h(e).values()].map(e=>{let t=m(e.declared??"");return{path:e.path,type:e.type,value:e.value,properties:[...e.properties],group:e.group,ref:e.name,cssVariable:e.name,...t&&t!==e.name?{alias:a.get(t).path}:{},...e.channels?{toCss:c(e.channels)}:{}}});return d=new Map(t.map(e=>[e.path,e])),t}return{id:"css-variables",list:y,previewValues:(t,r,o)=>(d.size||y(),function(t,r,o={},l,n=document){let a=[];for(let n of t){let t=r(n.path),i=e(t);if(!t||!i)continue;let s=n.alias?e(r(n.alias)):void 0,c=n.value;try{c=s?`var(${s})`:t.toCss?t.toCss(n.value):n.value}catch{}if(!c||/[{};<]/.test(c))continue;let p=n.theme?.split("+")??[],u=p.flatMap(e=>o[e]?[`:is(${o[e]})`]:[]),f=n.theme?Object.entries(o).filter(([e])=>!p.includes(e)).map(([,e])=>`:not(${e})`):[];n.theme&&!u.length&&!f.length&&n.theme!==l||a.push(`${u.join("")||":root"}${f.join("")}{${i}:${c}!important}`)}if(!a.length)return()=>{};let i=n.createElement("style");return i.dataset.paletteTokenPreview="",i.textContent=a.join(""),(n.head??n.documentElement).append(i),()=>i.remove()}(t,e=>d.get(e),l,r,o?.document)),resolve(e){a.size||h();let t={},r=getComputedStyle(e);for(let o of new Set([...a.values()].flatMap(e=>e.properties))){let l=g(e,o);t[o]=l?{path:a.get(l).path}:{offToken:r.getPropertyValue(o).trim()}}return t},preview(e,t,r){let o=e.style,l=o.getPropertyValue(t),n=o.getPropertyPriority(t);return o.setProperty(t,`var(${r.ref??`--${r.path.replace(".","-")}`})`),()=>{l?o.setProperty(t,l,n):o.removeProperty(t)}},describe(e,t,r,o){let l=`var(${o.ref})`,n="path"in r?[...a.values()].find(e=>e.path===r.path)?.name:void 0;return n?n===o.ref?`Keep ${t}: ${l}`:`Replace var(${n}) with ${l} for ${t}`:`Set ${t} to ${l}`}}}export{d as discoverCssTokens};
|
|
1
|
+
var e=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var t=["padding","margin","gap","width","height"],r={color:["color",["color","background-color","border-color"],"Color"],spacing:["dimension",t,"Spacing"],radius:["dimension",["border-radius"],"Radius"],text:["dimension",["font-size"],"Font size"],font:["fontFamily",["font-family"],"Font"],leading:["lineHeight",["line-height"],"Line height"],"font-weight":["fontWeight",["font-weight"],"Font weight"]},o=/^(#[0-9a-f]{3,8}|(rgb|hsl|hwb|lab|lch|oklab|oklch|color)a?\(.*\))$/i,l=/^-?\d*\.?\d+(px|rem|em|%|vw|vh|ch)$/,n=(e,t=("object"==typeof window?window:null))=>{let{conditionText:r}=e;return"string"!=typeof r||("media"in e?"function"!=typeof t?.matchMedia||t.matchMedia(r).matches:!!(typeof CSS<"u"&&"supports"in CSS&&e.constructor.name.includes("Supports"))&&CSS.supports(r))},a=/^(:root|html|:host)$/,i=(e,t,r,o)=>{for(let l of Array.from(e))if("selectorText"in l&&l.style){let{selectorText:e,style:n}=l,i=e.split(",").map(e=>e.trim()),s=i.some(e=>a.test(e));if(!s&&!i.some(e=>o.has(e)))continue;for(let e of Array.from(n))e.startsWith("--")&&(s?t:r).set(e,n.getPropertyValue(e).trim())}else"cssRules"in l&&i(l.cssRules,t,r,o)},s=/^(\d{1,3})(\s*,\s*|\s+)(\d{1,3})\2(\d{1,3})$/,c=e=>t=>{let r=document.createElement("span").style;r.color=t;let o=r.color.match(/[\d.]+/g);return o&&o.length>2?o.slice(0,3).map(e=>Math.round(+e)).join(e):t};function p(e,n){let a=e.slice(2),i=Object.keys(r).sort((e,t)=>t.length-e.length).find(e=>a===e||a.startsWith(`${e}-`));if(i){let[e,t,o]=r[i];if("fontFamily"!==e||!/^\d+$/.test(n))return{type:e,properties:t,group:o,ns:i}}return o.test(n)?{type:"color",properties:r.color[1],group:"Color"}:l.test(n)?{type:"dimension",properties:[...t,"border-radius"],group:"Size"}:null}var u=e=>{let t=e.replace(/::?(not|is|where|has)\(([^)]*)\)/g," $2 ");return 1e6*(t.match(/#[\w-]+/g)??[]).length+1e3*(t.match(/\.[\w-]+|\[[^\]]*\]|:(?!:)[\w-]+/g)??[]).length+(t.replace(/#[\w-]+|\.[\w-]+|\[[^\]]*\]|::?[\w-]+/g," ").match(/(^|[\s>+~])[a-z][\w-]*/gi)??[]).length},f={"background-color":["background-color","background"],"border-color":["border-color","border"],padding:["padding"],margin:["margin"],gap:["gap"],"border-radius":["border-radius"],font:["font"]};function d(t={}){let r=t.include??(e=>!e.startsWith("--tw-")),o=t.limit??300,l=t.scopes??{},a=new Map,d=new Map;function h(e={}){let t=new Map,n=new Map,c=new Set(Object.values(e).flatMap(e=>l[e]?[l[e]]:[]));for(let e of Array.from(document.styleSheets))try{i(e.cssRules,t,n,c)}catch{}let u=getComputedStyle(document.documentElement),f=new Map;for(let[e,l]of t){let t=u.getPropertyValue(e).trim(),a=t&&r(e)?p(e,t):null;if(!a||f.size>=o)continue;let i=e.slice(2),{ns:c,...d}=a,h=c?c.length:i.indexOf("-"),m=h>0&&i.length>h?`${i.slice(0,h)}.${i.slice(h+1)}`:i,g="color"===a.type?s.exec(t):null,y=g&&[g[1],g[3],g[4]].map(Number);y?.every(e=>e<256)&&(t=`#${y.map(e=>e.toString(16).padStart(2,"0")).join("")}`),f.set(e,{name:e,path:m,value:t,...d,declared:n.get(e)??l,...y?{channels:g[2].includes(",")?", ":" "}:{}})}return a=f,f}let m=e=>{let t=/^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/.exec(e.trim());return t&&a.has(t[1])?t[1]:null};function g(e,t){let r=e.style,o=f[t]??[t];for(let e of o){let t=r?.getPropertyValue(e);if(t&&"important"!==r.getPropertyPriority(e))return m(t)}let l=null,a=0,i=t=>{for(let r of Array.from(t))if("selectorText"in r&&r.style){let{selectorText:t,style:n}=r;for(let r of t.split(",")){let t=!1;try{t=e.matches(r.trim())}catch{}if(t)for(let e of o){let t=n.getPropertyValue(e);if(!t)continue;let o=(n.getPropertyPriority(e)?1e12:0)+1e3*u(r)+a++;(!l||o>=l.rank)&&(l={rank:o,value:t})}}}else"cssRules"in r&&n(r,e.ownerDocument.defaultView)&&i(r.cssRules)};for(let t of Array.from(e.ownerDocument.styleSheets))try{i(t.cssRules)}catch{}return l?m(l.value):null}function y(e){let t=[...h(e).values()].map(e=>{let t=m(e.declared??"");return{path:e.path,type:e.type,value:e.value,properties:[...e.properties],group:e.group,ref:e.name,cssVariable:e.name,...t&&t!==e.name?{alias:a.get(t).path}:{},...e.channels?{toCss:c(e.channels)}:{}}});return d=new Map(t.map(e=>[e.path,e])),t}return{id:"css-variables",list:y,previewValues:(t,r,o)=>(d.size||y(),function(t,r,o={},l,n=document){let a=[];for(let n of t){let t=r(n.path),i=e(t);if(!t||!i)continue;let s=n.alias?e(r(n.alias)):void 0,c=n.value;try{c=s?`var(${s})`:t.toCss?t.toCss(n.value):n.value}catch{}if(!c||/[{};<]/.test(c))continue;let p=n.theme?.split("+")??[],u=p.flatMap(e=>o[e]?[`:is(${o[e]})`]:[]),f=n.theme?Object.entries(o).filter(([e])=>!p.includes(e)).map(([,e])=>`:not(${e})`):[];n.theme&&!u.length&&!f.length&&n.theme!==l||a.push(`${u.join("")||":root"}${f.join("")}{${i}:${c}!important}`)}if(!a.length)return()=>{};let i=n.createElement("style");return i.dataset.paletteTokenPreview="",i.textContent=a.join(""),(n.head??n.documentElement).append(i),()=>i.remove()}(t,e=>d.get(e),l,r,o?.document)),resolve(e){a.size||h();let t={},r=getComputedStyle(e);for(let o of new Set([...a.values()].flatMap(e=>e.properties))){let l=g(e,o);t[o]=l?{path:a.get(l).path}:{offToken:r.getPropertyValue(o).trim()}}return t},preview(e,t,r){let o=e.style,l=o.getPropertyValue(t),n=o.getPropertyPriority(t);return o.setProperty(t,`var(${r.ref??`--${r.path.replace(".","-")}`})`),()=>{l?o.setProperty(t,l,n):o.removeProperty(t)}},describe(e,t,r,o){let l=`var(${o.ref})`,n="path"in r?[...a.values()].find(e=>e.path===r.path)?.name:void 0;return n?n===o.ref?`Keep ${t}: ${l}`:`Replace var(${n}) with ${l} for ${t}`:`Set ${t} to ${l}`}}}export{d as discoverCssTokens};
|
|
@@ -76,7 +76,7 @@ export declare function tailwindTokens(table: TailwindTable, options?: TailwindT
|
|
|
76
76
|
/** Tailwind's default spacing steps (multiples of the base unit). */
|
|
77
77
|
export declare const defaultSpacingSteps: number[];
|
|
78
78
|
export interface TailwindSpacingOptions {
|
|
79
|
-
/** Utility families; defaults to every padding, margin and
|
|
79
|
+
/** Utility families; defaults to every padding, margin, gap and size family (p, px, ..., m, ..., gap, w, h). */
|
|
80
80
|
prefix?: string[];
|
|
81
81
|
/** Pixels per step; Tailwind's default is 4. */
|
|
82
82
|
scale?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return(e=>"http://www.w3.org/2000/svg"===e?.namespaceURI)(e)||"http://www.w3.org/1999/xhtml"===e?.namespaceURI}var t=new WeakMap;var r=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var l=/^\s*((?:(?:italic|oblique|normal|small-caps|bold|bolder|lighter|[1-9]00)\s+)*)([+-]?(?:\d*\.)?\d+[a-z%]*)(?:\s*\/\s*((?:\d*\.)?\d+[a-z%]*|normal))?(?:\s+([\s\S]+?))?\s*$/i;var s,n=["top","right","bottom","left"],o={padding:n.map(e=>`padding-${e}`),margin:n.map(e=>`margin-${e}`),gap:["row-gap","column-gap"],"border-radius":["top-left","top-right","bottom-right","bottom-left"].map(e=>`border-${e}-radius`),"border-width":n.map(e=>`border-${e}-width`),"border-color":n.map(e=>`border-${e}-color`)},a=e=>(Array.isArray(e)?e:[e]).flatMap(e=>e.split(/\s+/)).filter(Boolean),i=e=>e.getAttribute("class"),p=e=>e.includes(":")?null:e.replace(/^!|!$/g,""),u=/\.((?:\\[\da-f]{1,6} ?|\\[^]|[\w-]|[^\0-\x7f])+)/gi,c=[new Set,0,!1,!1],d=e=>[...e.styleSheets,...e.adoptedStyleSheets??[]];function
|
|
1
|
+
function e(e){return(e=>"http://www.w3.org/2000/svg"===e?.namespaceURI)(e)||"http://www.w3.org/1999/xhtml"===e?.namespaceURI}var t=new WeakMap;var r=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var l=/^\s*((?:(?:italic|oblique|normal|small-caps|bold|bolder|lighter|[1-9]00)\s+)*)([+-]?(?:\d*\.)?\d+[a-z%]*)(?:\s*\/\s*((?:\d*\.)?\d+[a-z%]*|normal))?(?:\s+([\s\S]+?))?\s*$/i;var s,n=["top","right","bottom","left"],o={padding:n.map(e=>`padding-${e}`),margin:n.map(e=>`margin-${e}`),gap:["row-gap","column-gap"],"border-radius":["top-left","top-right","bottom-right","bottom-left"].map(e=>`border-${e}-radius`),"border-width":n.map(e=>`border-${e}-width`),"border-color":n.map(e=>`border-${e}-color`)},a=e=>(Array.isArray(e)?e:[e]).flatMap(e=>e.split(/\s+/)).filter(Boolean),i=e=>e.getAttribute("class"),p=e=>e.includes(":")?null:e.replace(/^!|!$/g,""),u=/\.((?:\\[\da-f]{1,6} ?|\\[^]|[\w-]|[^\0-\x7f])+)/gi,c=[new Set,0,!1,!1],d=e=>[...e.styleSheets,...e.adoptedStyleSheets??[]];function g(e,t=d(e)){let r=[...e.querySelectorAll("link[rel~=stylesheet]:not([disabled])")].map(e=>e.sheet);for(let e of t){let t;try{t=e.cssRules.length}catch{}r.push(e,t)}return r}var f=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]),y=e=>/^(style|link)$/i.test(e?.nodeName??""),h=e=>y(e.target)||y(e.target.parentNode)||[...e.addedNodes,...e.removedNodes].some(e=>y(e)||!!e.querySelector?.("style,link"));function m(e,t){let r=t?.document??document,l=g(r),s=()=>{let t=g(r);f(t,l)||(l=t,e())},n=new MutationObserver(e=>e.some(h)&&s()),o=new AbortController;n.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["disabled","media","rel","href"]});for(let e of["load","error"])r.addEventListener(e,s,{capture:!0,signal:o.signal});return()=>{n.disconnect(),o.abort()}}function b(e,t){let r=CSS.escape(t),l=e=>e===r||e===`\\!${r}`||e===`${r}\\!`||e.endsWith(`\\:${r}`)||e.endsWith(`\\:\\!${r}`),s=[],n=e=>{let t;try{t=e()}catch{return}for(let e of t)null!=e.selectorText&&[...e.selectorText.matchAll(u)].some(e=>l(e[1]))&&s.push(e),e.cssRules&&n(()=>e.cssRules),"styleSheet"in e&&n(()=>e.styleSheet.cssRules)};for(let t of d(e))n(()=>t.cssRules);return s}function v(e,t){if("typography"===e.token.type){let e=function(e){let t=l.exec(e);if(!t)return;let r=t[1].trim().split(/\s+/).filter(Boolean);return{style:r.filter(e=>/^(italic|oblique|small-caps)$/i.test(e)).join(" "),weight:r.find(e=>/^(bold|bolder|lighter|[1-9]00)$/i.test(e))??"",size:t[2],lineHeight:t[3]??"",family:t[4]??""}}(t);return e?[["font-style",e.style],["font-weight",e.weight],["font-size",e.size],["line-height",e.lineHeight],["font-family",e.family]].flatMap(([e,t])=>t?[[e,t,!0]]:[]):[]}return[...e.covers].map(e=>[e,t,!1])}function w(e,t={}){let r,l=0;for(let[s,n]of Object.entries(e.values??{})){let e=s.split("+");e.every(e=>{let[r,l]=e.split("=");return void 0===l?Object.values(t).includes(r):t[r]===l})&&e.length>l&&([r,l]=[n,e.length])}return r??e.value??""}function k(l,n={}){let y=l.tokens.map(e=>({token:e,classes:a(e.class),covers:new Set(e.properties.flatMap(e=>[e,...o[e]??[]]))})),h=new Map;for(let e of y)for(let t of e.classes)h.set(t,e);let k=new Map(y.map(e=>[e.token.path,e])),P=!1===n.offToken?[]:n.offToken??[...new Set(l.tokens.flatMap(e=>e.properties))],$=new WeakMap,S=e=>(e??"").split(/\s+/).flatMap(e=>{let t=p(e),r=t?h.get(t):void 0;return r?[{name:e,entry:r}]:[]});function x(e,t){if(!t.stack.length)return null===t.original?e.removeAttribute("class"):e.setAttribute("class",t.original),void $.delete(e);e.setAttribute("class",t.stack.reduce((e,t)=>function(e,t,r){let l=e.split(/\s+/).filter(Boolean),s=r.classes[0],n=-1,a=l.filter((e,l)=>{let s=p(e),a=s?h.get(s):void 0,i=!!a&&(a===r||[...a.covers].every(e=>r.covers.has(e))&&(a.covers.has(t)||(o[t]??[]).some(e=>a.covers.has(e))));return i&&n<0&&(n=l),!i}),i=l.slice(0,n<0?l.length:n).filter(e=>a.includes(e)).length;return a.splice(i,0,s),a.join(" ")}(e,t.property,t.entry),t.original??""))}return{id:"tailwind",list(e,t){let r=e??Object.fromEntries((n.themes??[]).map(e=>[e.id,e.current()])),l=n.onlyGenerated?function(e,t){let r=d(t),l=g(t,r);if(!s||!f(l,s)){s=l,c=[new Set,0,!1,l.includes(null)];let e=t=>{let r;try{r=t()}catch{return void(c[2]=!0)}for(let t of r){if(null!=t.selectorText){c[1]++;for(let e of t.selectorText.matchAll(u))c[0].add(e[1])}t.cssRules&&e(()=>t.cssRules),"styleSheet"in t&&e(()=>t.styleSheet.cssRules)}};for(let t of r)e(()=>t.cssRules)}return c[3]||!c[1]||e&&c[2]?null:c[0]}(!0!==n.onlyGenerated&&!!n.onlyGenerated.strict,t?.document??document):null;return y.filter(({token:e,classes:t})=>(!l||l.has(CSS.escape(t[0])))&&(!n.filter||n.filter(e))).map(({token:e,classes:t})=>({path:e.path,type:e.type,value:w(e,r),properties:[...e.properties],ref:t[0],...e.label?{label:e.label}:{},...e.group?{group:e.group}:{},...e.description?{description:e.description}:{},...e.states?{states:[...e.states]}:{},...e.cssVariable?{cssVariable:e.cssVariable}:{},...e.toCss?{toCss:e.toCss}:{}}))},previewValues(e,t,l){let s=l?.document??document,o=function(e,t,l={},s,n=document){let o=[];for(let n of e){let e=t(n.path),a=r(e);if(!e||!a)continue;let i=n.alias?r(t(n.alias)):void 0,p=n.value;try{p=i?`var(${i})`:e.toCss?e.toCss(n.value):n.value}catch{}if(!p||/[{};<]/.test(p))continue;let u=n.theme?.split("+")??[],c=u.flatMap(e=>l[e]?[`:is(${l[e]})`]:[]),d=n.theme?Object.entries(l).filter(([e])=>!u.includes(e)).map(([,e])=>`:not(${e})`):[];n.theme&&!c.length&&!d.length&&n.theme!==s||o.push(`${c.join("")||":root"}${d.join("")}{${a}:${p}!important}`)}if(!o.length)return()=>{};let a=n.createElement("style");return a.dataset.paletteTokenPreview="",a.textContent=o.join(""),(n.head??n.documentElement).append(a),()=>a.remove()}(e,e=>k.get(e)?.token,n.scopes,t,s),a=function(e,t,r,l){let s=[];for(let n of e){let e=t(n.path);if(!e||e.token.cssVariable||/[{};<]/.test(n.value)||n.theme&&n.theme!==r)continue;let o=v(e,n.value);if(o.length)for(let t of b(l,e.classes[0]))for(let[e,r,l]of o){let n="box-shadow"===e&&t.style.getPropertyValue("--tw-shadow")?"--tw-shadow":e,o=t.style.getPropertyValue(n);if(!o&&!l)continue;let a=t.style.getPropertyPriority(n);t.style.setProperty(n,r,a),s.push(()=>o?t.style.setProperty(n,o,a):t.style.removeProperty(n))}}return()=>{for(let e of s.reverse())e()}}(e,e=>k.get(e),t,s);return()=>{a(),o()}},...n.onlyGenerated?{subscribe:m}:{},resolve(t){let r,l={},s=function(e){let t=new Map;for(let r of S(e))for(let e of r.entry.covers){let l=t.get(e);(!l||r.entry.covers.size<=l.entry.covers.size)&&t.set(e,r)}for(let[e,r]of t)o[e]?.some(e=>t.get(e)?.entry!==r.entry)&&t.delete(e);return t}(i(t));if(e(t)){for(let[e,r]of s){let l=t.style.getPropertyValue(e),n=r.name.startsWith("!")||r.name.endsWith("!");l&&(!n||"important"===t.style.getPropertyPriority(e))&&s.delete(e)}for(let[e,t]of s)o[e]?.some(e=>s.get(e)?.entry!==t.entry)&&s.delete(e)}for(let[e,t]of s)l[e]={path:t.entry.token.path};for(let e of P){if(s.has(e)||o[e]?.some(e=>s.has(e)))continue;r??=getComputedStyle(t);let n=r.getPropertyValue(e);n&&(l[e]={offToken:n})}return l},preview(r,l,s){let n=k.get(s.path);if(!n)return()=>{};let o=$.get(r)??{original:i(r),stack:[],inline:new Map};$.set(r,o),e(r)&&(o.inline.has(l)||o.inline.set(l,function(e,r){let l=e.getAttribute("style"),s=e.style.cssText,n=e.style.getPropertyValue(r),o=e.style.getPropertyPriority(r),a=getComputedStyle(e).getPropertyValue(r).trim(),i=t=>{let l=e.ownerDocument.createElement("span").style;return l.cssText=t,l.setProperty(r,""),l.cssText},p=i(s),u={value:n,priority:o,computed:a,absent:null===l,restore(){t.get(e)?.push(()=>{e.style.getPropertyValue(r)===n&&e.style.getPropertyPriority(r)===o&&u.restore()}),i(e.style.cssText)===p?null===l?(e.getAttribute("style"),e.removeAttribute("style")):e.setAttribute("style",l):(e.style.setProperty(r,n,o),null===l&&!e.style.length&&function(e){e.style.length||(e.getAttribute("style"),e.removeAttribute("style"))}(e))}};return u}(r,l)),r.style.setProperty(l,""));let a={property:l,entry:n};return o.stack.push(a),x(r,o),()=>{let e=o.stack.indexOf(a);e<0||(o.stack.splice(e,1),x(r,o),o.stack.some(e=>e.property===l)||(o.inline.get(l)?.restore(),o.inline.delete(l)))}},describe(e,t,r,l){let s=k.get(l.path)?.classes[0]??l.ref??l.path;if("path"in r){let t=k.get(r.path),l=$.get(e)?.original??i(e),n=S(l).find(e=>e.entry===t)?.name??t?.classes[0]??r.path;return n===s?`Keep class "${s}"`:`Replace class "${n}" with "${s}"`}return`Add class "${s}"`}}}var P={p:["Padding",["padding"]],px:["Padding",["padding-left","padding-right"]],py:["Padding",["padding-top","padding-bottom"]],pt:["Padding",["padding-top"]],pr:["Padding",["padding-right"]],pb:["Padding",["padding-bottom"]],pl:["Padding",["padding-left"]],m:["Margin",["margin"]],mx:["Margin",["margin-left","margin-right"]],my:["Margin",["margin-top","margin-bottom"]],mt:["Margin",["margin-top"]],mr:["Margin",["margin-right"]],mb:["Margin",["margin-bottom"]],ml:["Margin",["margin-left"]],gap:["Gap",["gap"]],"gap-x":["Gap",["column-gap"]],"gap-y":["Gap",["row-gap"]],w:["Size",["width"]],h:["Size",["height"]]},$=[0,.5,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96];function S(e={}){let t=e.scale??4,r=e.steps??$;return(e.prefix??Object.keys(P)).flatMap(e=>{let l=P[e];if(!l)throw new Error(`Palette: unknown spacing prefix "${e}"`);return r.map(r=>{let s=`${e}-${r}`;return{path:`spacing.${s}`,type:"dimension",class:s,properties:l[1],value:r*t+"px",group:l[0],label:s}})})}export{$ as defaultSpacingSteps,S as tailwindSpacing,k as tailwindTokens,w as tokenValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e="data-palette-no-snapshot",t=`[${e}],[data-komo-no-snapshot]`,a=e=>e.matches(t),n="[data-branch-comments],[data-palette-move-clone],[data-palette-viewport],[data-palette-snapshot-sandbox]",r="[redacted]",i=new Set(["script","noscript","template","style","link","meta","base","title"]),o=/^(?:href|src|action|formaction|xlink:href|poster|data|background)$/i,l=e=>"textarea"===e.localName||"input"===e.localName&&!/^(?:button|submit|reset|image|checkbox|radio|range|color)$/i.test(e.getAttribute("type")??""),s=2e4,h=200,c=500,d=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,u=e=>(new TextEncoder).encode(e).length,m=e=>!!e.closest(`${t},${n}`);function f(e,t=1/0){for(let{name:a,value:n}of[...e.attributes])/^on/i.test(a)||"srcdoc"===a||/^data-(palette|komo)-/.test(a)&&!/-no-snapshot$/.test(a)||o.test(a)&&/^\s*(?:javascript|vbscript):/i.test(n)?e.removeAttribute(a):n.length>t&&e.setAttribute(a,d(n,t))}function g(e,t,o=s){let h=e.ownerDocument,c=o,m=e=>{if(3===e.nodeType){let t=d(e.nodeValue??"",500);return c-=t.length,h.createTextNode(t)}if(1!==e.nodeType)return null;let o=e;if(i.has(o.localName)||o.matches(n))return null;let s=o.cloneNode(!1);if(f(s,200),l(o)&&function(e,t){let a=e.value??e.getAttribute("value")??"";"textarea"===e.localName?t.textContent=a?r:"":(a||t.hasAttribute("value"))&&t.setAttribute("value",r)}(o,s),c-=s.outerHTML.length,a(o))return s;if(t?.(o))return l(o)||(s.textContent=r),s;if("textarea"===o.localName)return s;for(let e of o.childNodes){if(c<=0){s.append(h.createComment(" trimmed "));break}let t=m(e);t&&s.append(t)}return s},g=m(e);if(!g)return"";let p=g.outerHTML;if(u(p)<=o)return p;let w=h.createComment(" trimmed ");g.append(w);for(let e=u(g.outerHTML)-o;e>0&&g.firstChild!==w;e=u(g.outerHTML)-o)for(;e>0&&g.firstChild!==w;){let t=w.previousSibling;for(;t.lastChild;)t=t.lastChild;e-=1===t.nodeType?t.outerHTML.length:(t.nodeValue?.length??0)+7,t.parentNode.removeChild(t)}return p=g.outerHTML,u(p)>o?"":p}var p=class extends Error{constructor(e){super(e),this.reason=e}reason},w=25e4,y=1200,b=16,x=e=>new Promise((t,a)=>{let n=new FileReader;n.onload=()=>t(n.result),n.onerror=()=>a(n.error),n.readAsDataURL(e)});async function v(e,t){if(e.startsWith("data:"))return e;let a=new URL(e,t.document.baseURI);try{let e=await fetch(a,{mode:"cors",signal:AbortSignal.timeout(5e3)});return e.ok?await x(await e.blob()):""}catch{if(a.origin!==t.location.origin)throw new p("cross-origin");return""}}var $=["top","right","bottom","left","block-start","block-end","inline-start","inline-end"],M=(e,t)=>"none"===e||"hidden"===e||"0px"===t;function C(e,t=t=>e.get(t),a){for(let n of $){let r=`border-${n}-style`,i=`border-${n}-width`;M(t(r),t(i))&&(e.delete(r),e.delete(i),e.delete(`border-${n}-color`),a?.has(r)&&!M(a.get(r),a.get(i))&&e.set(r,"none"))}if(M(t("outline-style"),t("outline-width"))){for(let t of[...e.keys()])t.startsWith("outline")&&e.delete(t);a?.has("outline-style")&&!M(a.get("outline-style"),a.get("outline-width"))&&e.set("outline-style","none")}}function A(e,t,a){let n=new Map;for(let r=0;r<e.length;r++){let i=e[r];if(i.startsWith("--"))continue;let o=e.getPropertyValue(i);(o!==t.get(i)||a&&o!==a.getPropertyValue(i))&&n.set(i,o)}C(n,t=>e.getPropertyValue(t),t);let r="";for(let[e,t]of n)r+=`${e}:${t};`;return r}var k=/url\((['"]?)(.*?)\1\)/g;async function P(e,t,o){let s=e.ownerDocument,h=s.defaultView,c=e.getBoundingClientRect(),d=e.offsetWidth??c.width,u=e.offsetHeight??c.height,m=Math.min(u,2e3);if(!d||!m)throw new p("failed");let g={width:d+32,height:m+32},w=o?{x:b+o.x*d,y:b+o.y*u,width:o.width*d,height:Math.min(o.height*u,m-o.y*u)}:{x:0,y:0,...g};if(w.width<=0||w.height<=0)throw new p("too-large");let x=o?Math.min(3,y/w.width,2e3/w.height):1,$={width:Math.max(1,Math.round(w.width*x)),height:Math.max(1,Math.round(w.height*x))},M=o?x:Math.min(h.devicePixelRatio||1,2,y/g.width),C=function(){let e=document.createElement("iframe");e.setAttribute("data-palette-snapshot-sandbox",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.style.cssText="position:fixed;left:-10px;top:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none",document.documentElement.append(e);let t=e.contentDocument;try{t.open(),t.write("<!doctype html><html><head></head><body></body></html>"),t.close()}catch{}let a=new Map;return{of(e){let n=`${e.namespaceURI} ${e.localName}`,r=a.get(n);if(!r){let i=t.createElementNS(e.namespaceURI,e.localName);(t.body??t.documentElement).append(i);let o=t.defaultView.getComputedStyle(i);r=new Map;for(let e=0;e<o.length;e++)r.set(o[e],o.getPropertyValue(o[e]));i.remove(),a.set(n,r)}return r},dispose:()=>e.remove()}}(),P=[],E=new Set,N=new Map,T=[],R="",W=0,I=e=>(e.catch(()=>{}),e),L=e=>{for(let[,,t]of e.matchAll(k))t&&!t.startsWith("data:")&&!N.has(t)&&N.set(t,I(v(t,h)));return e},S=(e,o)=>{if(3===e.nodeType)return s.createTextNode(e.nodeValue??"");if(1!==e.nodeType)return null;let c=e,u=c.localName;if(i.has(u)||c.matches(n))return null;if(++W>3e3)throw new p("too-large");let g,w=h.getComputedStyle(c);if("none"===w.display)return null;if("canvas"===u||"video"===u){g=s.createElement("img");let e=document.createElement("canvas");e.width=c.width||c.videoWidth||1,e.height=c.height||c.videoHeight||1;try{e.getContext("2d").drawImage(c,0,0,e.width,e.height),g.setAttribute("src",e.toDataURL("image/png"))}catch{throw new p("cross-origin")}}else if("iframe"===u||"embed"===u||"object"===u)g=s.createElement("div");else{g=c.cloneNode(!1),f(g);for(let e of["id","class","srcset","sizes","loading","style"])g.removeAttribute(e)}l(c)&&(g.removeAttribute("value"),g.hasAttribute("placeholder")&&t?.(c)&&g.setAttribute("placeholder",r)),"img"===u&&P.push(I(async function(e,t,a){let n=e.currentSrc||e.src;if(!n||n.startsWith("data:"))return n;await e.decode().catch(()=>{});let r=Math.min(e.naturalWidth,Math.ceil(e.offsetWidth*t)||e.naturalWidth),i=Math.round(r*e.naturalHeight/(e.naturalWidth||1));if(r&&i){let t=document.createElement("canvas");t.width=r,t.height=i;try{return t.getContext("2d").drawImage(e,0,0,r,i),t.toDataURL("image/png")}catch{}}return v(n,a)}(c,M,h).then(e=>g.setAttribute("src",e)))),E.add(w.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase());let y=A(w,C.of(c),o);o||(y+=`${"inline"===w.display?"display:inline-block;":""}margin:0;position:relative;inset:auto;float:none;transform:none;translate:none;rotate:none;scale:none;flex:none;box-sizing:border-box;width:${d}px;height:${m}px;max-width:none;max-height:none;min-width:0;min-height:0;`);let b=a(c)&&!!o;b&&(y+="color:transparent;background:#e5e5e5;background-image:none;"),T.push([g,L(y)]);for(let e of["::before","::after"]){let t=h.getComputedStyle(c,e);b||/^(?:none|normal)$/.test(t.content)||(g.setAttribute("data-snapshot",String(W)),R+=`[data-snapshot="${W}"]${e}{${L(A(t,C.of(c),w))}content:${t.content};}`)}if(b)return g;if(t?.(c))return l(c)||(g.textContent=r),g;if("textarea"===u)return g;for(let e of c.childNodes){if("picture"===u&&"img"!==e.localName)continue;let t=S(e,w);t&&g.append(t)}return g};try{await(s.fonts?.ready);let t=S(e),a=new Map(await Promise.all([...N].map(async([e,t])=>[e,await t]))),n=e=>e.replace(k,(e,t,n)=>a.has(n)?`url("${a.get(n)}")`:e);for(let[e,t]of T)e.setAttribute("style",n(t));R=n(R),await Promise.all(P);let r=s.createElement("div");r.setAttribute("style",`width:${d+32}px;height:${m+32}px;padding:16px;box-sizing:border-box;overflow:hidden;background:${function(e,t){for(let a=e.parentElement;a;a=a.parentElement){let e=t.getComputedStyle(a).backgroundColor;if(e&&!/^(?:transparent|rgba\(.*,\s*0\))$/.test(e))return e}return"#fff"}(e,h)}`);let i=s.createElement("style");i.textContent=await async function(e,t,a){let n=[],r=2e6,i=async(e,o)=>{for(let l of e){if(l.cssRules&&await i(l.cssRules,o),!l.cssText.startsWith("@font-face"))continue;let e=l.style,s=e.getPropertyValue("font-family").replace(/["']/g,"").trim().toLowerCase(),h=e.getPropertyValue("src").match(/url\((['"]?)(.*?)\1\)/)?.[2];if(!t.has(s)||!h||r<=0)continue;let c=await v(new URL(h,o).href,a).catch(()=>"");c&&(r-=c.length,n.push(`@font-face{font-family:"${s}";src:url("${c}");${["font-weight","font-style","font-stretch","unicode-range"].map(t=>e.getPropertyValue(t)?`${t}:${e.getPropertyValue(t)};`:"").join("")}}`))}};for(let t of e.styleSheets){let a;try{a=t.cssRules}catch{continue}await i(a,t.href??e.baseURI)}return n.join("")}(s,E,h)+R,r.append(i,t);let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${$.width}" height="${$.height}" viewBox="${w.x} ${w.y} ${w.width} ${w.height}"><foreignObject x="0" y="0" width="${g.width}" height="${g.height}">${(new XMLSerializer).serializeToString(r)}</foreignObject></svg>`,l=new Image;return l.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`,await l.decode(),{image:l,...$}}finally{C.dispose()}}var E=(e,t)=>new Promise((a,n)=>{try{e.toBlob(a,"image/webp",t)}catch(e){n(e)}});async function N(e,t,a,n=1){let r=Math.min(n,2,y/t.width),i=document.createElement("canvas"),o=.8;for(let n=0;n<12;n++){i.width=Math.max(1,Math.round(t.width*r)),i.height=Math.max(1,Math.round(t.height*r));let n,l=i.getContext("2d");if(!l)throw new p("unsupported");l.drawImage(e,t.x,t.y,t.width,t.height,0,0,i.width,i.height);try{n=await E(i,o)}catch{throw new p("cross-origin")}if(!n||"image/webp"!==n.type)throw new p("unsupported");if(n.size<=a)return x(n);o>.5?o=Math.round(100*(o-.15))/100:r*=Math.min(.85,Math.max(.3,.95*Math.sqrt(a/n.size)))}throw new p("too-large")}async function T(e,t={},a){let n=a?1:e.ownerDocument.defaultView?.devicePixelRatio||1,{image:r,width:i,height:o}=await P(e,t.redact,a);return N(r,{x:0,y:0,width:i,height:o},t.maxBytes??w,n)}async function R(e,t){if(!["image/png","image/jpeg","image/webp"].includes(e.type)||e.size>20971520)throw new Error("Choose a PNG, JPEG or WebP image under 20 MB.");let a=await createImageBitmap(e);try{if(a.width*a.height>4e7)throw new Error("Choose an image with fewer than 40 megapixels.");return{image:await N(a,{x:0,y:0,width:a.width,height:a.height},t)}}finally{a.close()}}var W={"cross-origin":"cross-origin images","too-large":"the element is too large to draw",unsupported:"this browser can't encode WebP",failed:"it couldn't be drawn"},I=e=>`\x3c!-- palette: no image snapshot, ${W[e]}. --\x3e`;async function L(e,t,a=s,n){if(!e?.isConnected||m(e))return null;let r={},i=()=>g(e,t.redact,a-120);if(t.html&&(r.html=i()),t.image){await new Promise(e=>"function"==typeof requestIdleCallback?requestIdleCallback(e,{timeout:500}):setTimeout(e));try{r.image=await T(e,t,n)}catch(e){r.note=e instanceof p?e.reason:"failed","cross-origin"===r.note&&(r.html??=i()),r.html&&(r.html=I(r.note)+r.html)}}return r}var S=e=>{let[t,a]=e.split(","),n=Uint8Array.from(atob(a),e=>e.charCodeAt(0));return new Blob([n],{type:t.slice(5,-7)})},V=new WeakMap;function B(e,t,a,n,r,i,o){let l=o??V.get(e);if(!l){let r={...a,maxBytes:Math.min(a.maxBytes??w,n.maxImageBytes||1/0)};l=a.image||a.html?L(t(e),r,Math.min(s,n.maxHtmlBytes||1/0),i).catch(()=>({note:"failed"})):Promise.resolve(null),V.set(e,l)}return r&&l.then(async e=>{let t="failed"===e?.note;for(let a of["image","html"]){let n=e?.[a];n&&await r(a,"image"===a?S(n):new Blob([n],{type:"text/html;charset=utf-8"})).catch(()=>t=!0)}if(n.readiness&&(t||!e?.image&&!e?.html))return r("status",new Blob([`{"status":"${t?"failed":"skipped"}"}`],{type:"application/json"})).catch(()=>{})}),l}export{e as a,r as b,s as c,h as d,c as e,m as f,g,w as h,C as i,N as j,T as k,R as l,I as m,L as n,B as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,h as t}from"./chunk-4FX5IS2U.js";import{a as r}from"./chunk-XOMOONGK.js";import{e as n,s as o}from"./chunk-4HBBEVFK.js";var a=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent".split(" ")),i=new Map,l=new Map,s=new WeakMap,u=new WeakMap,d=new Map,p=new WeakMap,c=new WeakMap,f=!1;function g(e,t){let r=l.get(e);r?.delete(t),r?.size||l.delete(e)}function h(t,n,o,d,p){let c=s.get(t);if(c||s.set(t,c=new Map),(!c.has(n)||!i.has(t)&&!l.has(t))&&(c.set(n,o),r(t))){let r=u.get(t);r||u.set(t,r=new Map);let o=e(t,n),i=o.value.trim().toLowerCase(),l=/^(?:inherit|initial|unset|revert(?:-layer)?|currentcolor|context-fill|context-stroke)$|%|\b(?:var|env|attr|calc|min|max|clamp|color-mix|light-dark|anchor|anchor-size)\(|\(\s*from\b|\d(?:r?(?:em|ex|ch|cap|ic|lh)|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))\b/.test(i),s=!!i&&!l&&(a.has(i)||
|
|
1
|
+
import{f as e,h as t}from"./chunk-4FX5IS2U.js";import{a as r}from"./chunk-XOMOONGK.js";import{e as n,s as o}from"./chunk-4HBBEVFK.js";var a=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent".split(" ")),i=new Map,l=new Map,s=new WeakMap,u=new WeakMap,d=new Map,p=new WeakMap,c=new WeakMap,f=!1;function g(e,t){let r=l.get(e);r?.delete(t),r?.size||l.delete(e)}function h(t,n,o,d,p){let c=s.get(t);if(c||s.set(t,c=new Map),(!c.has(n)||!i.has(t)&&!l.has(t))&&(c.set(n,o),r(t))){let r=u.get(t);r||u.set(t,r=new Map);let o=e(t,n),i=o.value.trim().toLowerCase(),l=/^(?:inherit|initial|unset|revert(?:-layer)?|currentcolor|context-fill|context-stroke)$|%|\b(?:var|env|attr|calc|min|max|clamp|color-mix|light-dark|anchor|anchor-size)\(|\(\s*from\b|\d(?:r?(?:em|ex|ch|cap|ic|lh)|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))\b/.test(i),s=!!i&&!l&&(a.has(i)||q(i)===q(o.computed)),p=r.get(n);if(p?.adapter===d)p.original=o,p.concrete=s;else{let e={adapter:d,original:o,concrete:s,style:o,token:void 0};e.style={get value(){let r=e.original;if(!e.concrete||!e.token)return r.value;let o=t.ownerDocument.createElement("span").style;return o.setProperty(n,e.token.value),o.getPropertyValue(n)||r.value},get priority(){return e.original.priority},get absent(){return e.original.absent},get computed(){return e.token?.value??e.original.computed},restore(){let r=e.original;r.restore(),e.concrete&&e.token&&q(e.token.value)!==q(r.value)&&t.style.setProperty(n,e.token.value,r.priority)}},r.set(n,e)}}return y(t,d,p),c.get(n)}function m(e,t){return e?s.get(e)?.get(t):void 0}function y(e,t,r,n){let o=n&&new Set(n);for(let[n,a]of u.get(e)??[]){if(a.adapter!==t)continue;let i=m(e,n);a.token=i&&"path"in i?r.find(e=>e.path===i.path):void 0,a.token&&o?.has(n)&&a.style.restore()}}function k(e,t,r){if(l.get(e)?.has(t))return{offToken:getComputedStyle(e).getPropertyValue(t).trim()};let n=B(e,t);return n?{path:n.path}:r}function b(e,t){if(!s.get(e)?.has(t))return;let r=l.get(e),n=r?.has(t)??!1,o=s.get(e)?.get(t),a=!!B(e,t)||!!o&&"path"in o;return r||l.set(e,r=new Set),r.add(t),{priority:"important",...n?{}:{undo:()=>{g(e,t),a&&!f&&(V(!0),V(!1))}}}}function v(e,t){return u.get(e)?.get(t)?.style??i.get(e)?.find(e=>e.property===t)?.inline}function w(e){let t={};for(let r of e?.themes??[])try{t[r.id]=r.current(n())}catch{}return t}function $(e,t,r,a){if(function(e,t,r){if(!e?.subscribe||r.aborted)return;p.delete(e);let a,i,l=()=>{let r=c.get(e)??p.get(e);c.set(e,r),queueMicrotask(()=>c.delete(e)),p.delete(e),Promise.all([...r??[]].map(([t,r])=>Promise.all([r,M(e,Object.fromEntries(JSON.parse(t)))]).then(([e,t])=>JSON.stringify(e)===JSON.stringify(t)))).then(e=>e.length&&e.every(Boolean)||t(),t)},s=()=>{try{i?.()}catch{}i=void 0},u=()=>{let t=n();if(r.aborted||t.document===a)return;let o=void 0!==a;s(),a=t.document;try{i=e.subscribe(l,t)}catch{}o&&l()};u(),o((e,t)=>{u(),t.addEventListener("abort",()=>queueMicrotask(u),{once:!0})},r),r.addEventListener("abort",s,{once:!0})}(e?.tokens,r,a),a.aborted||!e?.themes?.length)return;let i=JSON.stringify(w(e)),l=()=>{let t=JSON.stringify(w(e));t===i||a.aborted||(i=t,r())},s=[],u=!1;for(let t of e.themes)try{t.subscribe?s.push(t.subscribe(l)):u=!0}catch{u=!0}let d=u?new MutationObserver(l):void 0,f=n().document;d?.observe(f.documentElement,{attributes:!0}),f.body&&d?.observe(f.body,{attributes:!0}),a.addEventListener("abort",()=>{d?.disconnect();for(let e of s)e()},{once:!0})}function M(e,t={}){let r=p.get(e);r||p.set(e,r=new Map);let o=JSON.stringify(Object.entries(t).sort()),a=r.get(o);return a||(a=Promise.resolve().then(()=>e.list(Object.keys(t).length?t:void 0,n())).then(e=>Array.isArray(e)?e.filter(e=>e&&"string"==typeof e.path):[]),a.catch(()=>r.delete(o)),r.set(o,a)),a}function S(e,t){return Promise.resolve().then(()=>e.resolve(t)).then(e=>e??{},()=>({}))}function j(e,t){return e.filter(e=>e.properties?.includes(t))}function q(e){let t,r=e.trim().toLowerCase().replace(/\s+/g," "),n=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/.exec(r)?.[1];if(n)t=(n.length<5?[...n].map(e=>e+e).join(""):n).match(/../g).map((e,t)=>parseInt(e,16)/(t>2?255:1));else{let e=/^rgba?\(([^)]*)\)$/.exec(r)?.[1].split(/\s*[,/]\s*|\s+/);e&&(3===e.length||4===e.length)&&e.every(e=>/^[\d.]+%?$/.test(e))&&(t=e.map((e,t)=>parseFloat(e)*(e.endsWith("%")?t>2?.01:2.55:1)))}if(!t)return r.replace(/\s*,\s*/g,",");let[o,a,i,l=1]=t.map((e,t)=>t>2?+e.toFixed(2):Math.round(e));return 1===l?`rgb(${o},${a},${i})`:`rgba(${o},${a},${i},${l})`}function O(e,t){let r=q(t);return r?e.find(e=>"string"==typeof e.value&&q(e.value)===r):void 0}function x(e){return e.label||e.path}function E(e,t=e.value,r){return[e.path,e.ref,t,r,e.states?.length?`States: ${e.states.join(", ")}`:"",e.description].filter(Boolean).join(" · ")}function P(){let e=document.createElement("span");return e.className="design-token-off",e.setAttribute("role","img"),e}function N(e,t,r){e.title=`Not from a token · ${t||"unset"}${r?` · matches ${x(r)}`:""}`,e.setAttribute("aria-label",e.title)}function T(n,o,a,i){let l=r(o)?e(o,a):void 0;try{r(o)&&o.style.setProperty(a,"");let e=n.preview?n.preview(o,a,i):t(o,a,i.value),s=!0;return()=>{s&&(s=!1,e?.(),l?.restore())}}catch{throw l?.restore(),new Error("This token could not be previewed.")}}function B(e,t){if(!l.get(e)?.has(t))return[...i.get(e)??[]].reverse().find(e=>e.property===t)?.token}function A(t,n,o,a,s,u){let d=i.get(n);d||i.set(n,d=[]);let p=d.find(e=>e.property===o),c=r(n)?e(n,o):void 0,f=l.get(n)?.has(o)??!1,h=T(t,n,o,a);return g(n,o),d.push({adapter:t,property:o,token:a,from:p?.from??s,fromToken:p?p.fromToken:u,undo:h,inline:c,customBefore:f}),()=>J(n)}function J(e){let t=i.get(e),r=t?.pop();if(r?.undo(),r?.customBefore){let t=l.get(e);t||l.set(e,t=new Set),t.add(r.property)}else r&&g(e,r.property);t&&!t.length&&i.delete(e)}function z(e){return!!i.get(e)?.length}function L(e){return!!l.get(e)?.size}function W(e){for(;i.has(e);)J(e);l.delete(e)}function F(){for(let e of[...i.keys()])W(e);l.clear(),d.clear()}function C(e){return[...new Set(i.get(e)?.map(e=>e.property))].filter(t=>!l.get(e)?.has(t))}function V(t){if(t!==f){f=t,t&&(d=new Map([...l].flatMap(([t,n])=>r(t)?[[t,new Map([...n].map(r=>[r,e(t,r)]))]]:[])));for(let[n,o]of i)if(t)for(let e of[...o].reverse())e.undo();else for(let t of o)t.customBefore&&t.inline?.restore(),r(n)&&(t.inline=e(n,t.property)),t.undo=T(t.adapter,n,t.property,t.token);if(!t){for(let e of d.values())for(let t of e.values())t.restore();d.clear()}}}function I(e,t){let r=f;r||V(!0);for(let r of new Set([...i.keys(),...l.keys()])){let n=[...(i.get(r)??[]).filter(t=>t.adapter===e).map(e=>e.property),...l.get(r)??[]];y(r,e,t,n)}for(let r of i.values())for(let n of r)n.adapter===e&&(n.token=t.find(e=>e.path===n.token.path)??n.token,"path"in n.from&&(n.fromToken=t.find(e=>e.path===n.from.path)));r||V(!1)}function K(e,t){try{let r=t.adapter.describe?.(e,t.property,t.from,t.token);return r?String(r).replace(/\s+/g," ").replace(/→/g,"->").trim().slice(0,300):void 0}catch{return}}function X(e){let t=[],r=new Set;for(let n of function(e){let t=new Map;for(let r of i.get(e)??[])t.set(r.property,r);return[...t.values()].filter(t=>!(l.get(e)?.has(t.property)||"path"in t.from&&t.from.path===t.token.path))}(e)){r.add(n.adapter.id);let o="path"in n.from?`${n.fromToken?.value?`${n.fromToken.value} `:""}[${n.from.path}]`:n.from.offToken||"(unset)";t.push(`Element ${n.property}: ${o} → ${n.token.value} [${n.token.path}]`);let a=K(e,n);a&&t.push(`Apply: ${a}`)}if(t.length)return["Proposed design-token changes (preview only)",...t,`Token adapter: ${[...r].join(", ")}`].join("\n")}export{g as a,h as b,m as c,y as d,k as e,b as f,v as g,w as h,$ as i,M as j,S as k,j as l,O as m,x as n,E as o,P as p,N as q,T as r,B as s,A as t,z as u,L as v,W as w,F as x,C as y,V as z,I as A,X as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-QFDNGHSH.js";import{a as t,c as n}from"./chunk-RBHY7UDS.js";import{a as o}from"./chunk-XOMOONGK.js";import{a as i,d as r}from"./chunk-VX6XCU4E.js";import{B as a,E as s,F as d,c as l,h as p,i as c,z as g}from"./chunk-4HBBEVFK.js";function f(e,t=!1){return e.composedPath().some(e=>c(e)&&!(t&&e.matches("button,a[href],summary")&&!e.matches("[contenteditable],[inert],[role]:not([role=button]):not([role=link])"))&&e.matches('input,textarea,select,button,a[href],summary,dialog,[contenteditable]:not([contenteditable="false"]),[inert],[role]:not([role="none"]):not([role="presentation"]):not([role="img"]):not([role="group"]):not([role="region"]):not([role="main"]):not([role="article"]):not([role="heading"]):not([role="paragraph"]):not([role="generic"])'))}function m(e){let r=e.keys??t(),s=t=>{let n=t.composedPath()[0];n instanceof HTMLSelectElement&&t.composedPath().includes(e.host)&&!g(n)&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&(/^[b?]$/i.test(t.key)||e.reserved?.(t))&&t.preventDefault()},{root:d,signal:m}=e;addEventListener("keydown",s,{signal:m}),d?.addEventListener("keydown",e=>a(e,d)&&s(e),{signal:m});return t=>{if(t.isComposing||229===t.keyCode)return!1;let a=t.key.toLowerCase(),s=t.composedPath(),m=g(s[0]),u=i()?t.metaKey&&!t.ctrlKey:t.ctrlKey&&!t.metaKey,h=m||!u||t.altKey?void 0:"z"===a?t.shiftKey?e.redo:e.undo:"y"!==a||i()||t.shiftKey?void 0:e.redo;if(h)return!h.disabled&&(t.preventDefault(),t.stopImmediatePropagation(),((t,n)=>{let o=d?.activeElement??document.activeElement,i=o?.closest("[data-field-property]")?.dataset.fieldProperty;t.click();let r=e.selected();r&&(!n.includes(e.host)||o?.matches(".design-geometry__frame"))&&e.select(r);let a=o?.isConnected?o:i&&d?.querySelector(`[data-field-property="${CSS.escape(i)}"] ${o.localName}`);a instanceof HTMLElement&&a.focus({preventScroll:!0}),!n.includes(e.host)&&d?.activeElement!==p()&&d?.activeElement?.blur()})(h,s),!0);if("escape"===a)return m?(s.some(e=>c(e)&&e.matches("[data-field-property]"))||(t.preventDefault(),s[0].blur()),!0):s.some(e=>c(e)&&e.matches("[popover],[role=listbox]"));if(t.defaultPrevented||e.reserved?.(t))return!1;let b=!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey),x=!!n(t,r.before)||!n(t,r.after)&&void 0,y=m||s.some(e=>c(e)&&e.matches("input[type=range],[role=slider],.design-geometry__frame"));if(!e.compare.hidden&&(void 0!==x&&!y||b&&"b"===a&&!m))return t.preventDefault(),t.stopImmediatePropagation(),e.compareBefore(x),!0;if("?"===t.key&&e.help&&!m&&!t.altKey&&!t.ctrlKey&&!t.metaKey)return t.preventDefault(),t.stopImmediatePropagation(),e.help(),!0;let _=b&&" "===a;if(b&&"enter"===a&&!t.repeat){let n=m||s.some(e=>c(e)&&e.matches("[data-field-property],[popover],[role=listbox],[role=menu],textarea,.new-comment-composer,.reply-composer")),o=s.includes(e.host)&&f(t);if(!n&&!o)return!(!e.selected()?.isConnected||!e.comment?.())&&(t.preventDefault(),t.stopImmediatePropagation(),!0)}if(s.includes(e.host)||f(t,_))return!1;let v=e.selected(),w=t=>o(t)&&t.isConnected&&t!==t.ownerDocument.body&&t!==t.ownerDocument.documentElement&&!e.host.contains(t)&&!t.matches("script,style,defs,title,desc,metadata,[hidden],[inert]")&&"none"!==getComputedStyle(t).display&&"hidden"!==getComputedStyle(t).visibility,k=l(),E=k.activeElement,$=!E||E===k.body||E===k.documentElement||E===v,C=null,S=n(t,r.next)?"nextElementSibling":n(t,r.prev)?"previousElementSibling":void 0,K=t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(v?.isConnected&&S){for(C=v[S];C&&!w(C);)C=C[S];t.preventDefault(),t.stopImmediatePropagation()}else v?.isConnected&&$&&(n(t,r.child)||K&&"arrowdown"===a)?C=[...v.children].find(w)??null:v?.isConnected&&(n(t,r.parent)||K&&"arrowup"===a)?C=v.parentElement:_&&(C=E);return w(C)?(t.preventDefault(),t.stopImmediatePropagation(),C.scrollIntoView?.({block:"nearest",inline:"nearest"}),e.select(C),!0):t.defaultPrevented}}function u(e,t,n,o){let i=e.getRootNode(),r=function(e){let t=e.closest("[data-field-property]")?.dataset.fieldProperty,n=t?`[data-field-property=${JSON.stringify(t)}] `:"",o=e.getAttribute("data-property"),i=e.getAttribute("aria-label");return o?`${e.localName}[data-property=${JSON.stringify(o)}]`:i?`${n}${e.localName}[aria-label=${JSON.stringify(i)}]`:e.id?`[id=${JSON.stringify(e.id)}]`:n&&`${n}${e.localName}`}(t),a=()=>!(i.activeElement||document.activeElement&&document.activeElement!==document.body),s=e=>{d.disconnect(),clearTimeout(l),n(),e&&a()&&o()},d=new MutationObserver(()=>{if(!a())return s(!1);let t=r?e.querySelector(r):null;t&&(t.focus({preventScroll:!0}),s(!1))});d.observe(e,{childList:!0,subtree:!0});let l=setTimeout(s,400,!0);return s}var h={style:"style","inline text":"text","design-token":"token",token:"token","React prop":"prop",geometry:"geometry"};function b(e=""){let t=[...e.matchAll(/^Proposed (.+?) changes? \(preview only\)$/gm)].map(([,e])=>h[e]);return t.includes("geometry")?"geometry":t.find(Boolean)??"style"}var x=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="${e}"/></svg>`,y={style:"M8 2.5c2 2.4 4 4.6 4 6.8a4 4 0 0 1-8 0c0-2.2 2-4.4 4-6.8z",token:"M8 2.5 13.5 8 8 13.5 2.5 8z",text:"M3.5 4.5V3h9v1.5M8 3v10M6 13h4",prop:"M2.5 5h6m3 0h2m-11 6h2m3 0h6M10 3.5v3m-4 3v3",geometry:"M2.5 6V2.5H6m4 0h3.5V6m0 4v3.5H10m-4 0H2.5V10"},_=e=>`${e} change${1===e?"":"s"}`;function v(e,t,n,o){e.innerHTML=x(y[t]??y.style),e.dataset.kind=t,e.append(s("span","",n),s("small","",String(o))),e.setAttribute("aria-label",`${n} · ${_(o)}`)}function w(t){let n=s("div","design-inspector__empty");n.append(d("design"),s("strong","","Select an element"),s("p","","Click to inspect · Double-click text to edit"));let o=(e,t,n="")=>{let o=s("button",n,e);return o.type="button",o.addEventListener("click",t),o},a=(e,t,n=t)=>(e.setAttribute("aria-label",t),e.dataset.tip=n,e),p=s("section","design-inspector__pending design-card");p.setAttribute("aria-label","Unsaved changes"),p.hidden=!0;let c=s("div","design-card-head"),g=s("div","design-card-label"),f=s("h3","design-card-title");g.append(f,s("p","design-card-target","Preview only. Nothing is saved until you comment or copy.")),c.append(g);let m=s("div","design-rows design-pending__list"),u=s("div","design-pending__actions");p.append(c,m,u);let h=e=>t.mode?.root.dispatchEvent(new CustomEvent("palette-announce",{detail:e})),y=[],w=[],k=0,E=0,$=()=>[...y.map(e=>e.proposal),L?.proposal()].filter(Boolean).join("\n\n"),S=a(o("",async()=>{try{await navigator.clipboard.writeText($()),t.message("Changes copied")}catch{t.message("Couldn't copy changes. Try again.")}}),"Copy changes");S.append(d("copy")),u.append(o("Comment with changes",()=>{let e=$(),[n]=y,o=1===y.length&&!L?.size&&n.here?n.element:l().body;t.reset(),t.mode?.onComment(o,e||void 0)}),S,a(o("Discard all",()=>{T(),t.mode?.root.querySelector(".design-inspector__target")?.focus({preventScroll:!0})}),"Discard all","Undo · "+(i()?"⌘Z":"Ctrl+Z")));let K=e=>{p.removeEventListener("pointerover",K),p.removeEventListener("focusin",K),t.mode&&t.signal&&C(p,t.mode.root,t.signal,e)};function T(){E=k,t.before(!0),h(`${_(E)} discarded`)}p.addEventListener("pointerover",K),p.addEventListener("focusin",K);let L,M=()=>{E&&(E=0,t.reset())},{history:z=[]}=t,D=()=>{let e=new Set(L?.steps);for(let t=z.length;t--;)"token"===z[t].kind&&!e.delete(z[t].step)&&z.splice(t,1);for(let t of e)z.push({kind:"token",step:t});t.update?.()},P=t.mode&&{...t.mode,link:e=>(L=e,D)},j=o("Edit tokens",()=>{M();let e=t.mode?.root.querySelector(".design-inspector");e&&P&&import("./token-page-YQ52JS6G.js").then(t=>t.openTokenPage(e,P),()=>t.message("Tokens unavailable · try again"))},"design-inspector__tokens"),N=o("Keyboard shortcuts",()=>t.help?.(),"design-inspector__help");N.setAttribute("aria-label","Keyboard shortcuts"),N.setAttribute("aria-keyshortcuts","?"),N.append(r(["?"],"?")),N.hidden=!t.help,n.append(j,N);let A=()=>{t.clear?.(),L?.open()},O=o("",A,"design-change-row"),H=o("",A,"design-change-row design-inspector__token-chip");return H.title="Open the Tokens view",H.hidden=!0,{empty:n,pending:p,chip:H,get tokens(){return L},get parked(){return E>0},settle:M,discard:T,restore:()=>!!E&&(h(`${_(E)} restored`),E=0,t.before(!1),!0),icons:{undo:x("M5.5 3.5 2.5 6.5l3 3m-3-3h7a4 4 0 0 1 0 8h-2"),redo:x("M10.5 3.5 13.5 6.5l-3 3m3-3h-7a4 4 0 0 0 0 8h2"),reset:x("M2.5 2.5v3h3M3 5.5a5.5 5.5 0 1 1-.5 2.5")},styles:'@keyframes design-status{from{opacity:0;translate:0 2px}}.design-inspector__count{white-space:nowrap;font-variant-numeric:tabular-nums}.design-inspector__status{display:none;min-width:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;animation:design-status .2s var(--ease-smooth-out)}.design-inspector__bar[data-message] .design-inspector__status{display:block}.design-inspector__bar[data-message] .design-inspector__count,.design-inspector__bar:not([data-changes]) .design-inspector__tool{display:none}.design-inspector__compare { display:inline-flex; flex:none; padding:2px; border-radius:7px; background:#ffffff0a; }.design-inspector__compare[hidden],.design-inspector__bar[data-message] .design-inspector__compare { display:none; }.design-inspector__compare button { height:22px; padding:0 8px; border-radius:5px; color:#9a9a9a; font:inherit; font-size:11px; }.design-inspector__compare button:hover { color:#fff; }.design-inspector__compare button[aria-pressed="true"] { color:#fff; background:#ffffff1a; }.design-inspector__empty { display:flex; flex-direction:column; align-items:center; gap:4px; padding:0 24px 28px; color:#898680; font-size:11px; text-align:center; }.design-inspector__empty > svg { box-sizing:content-box; width:20px; height:20px; margin-bottom:8px; padding:8px; border-radius:10px; background:#ffffff0a; color:#77736f; }.design-inspector__empty strong { color:#e9e6e1; font-size:12px; font-weight:600; }.design-inspector__empty p { margin:2px 0 0; line-height:1.5; }.design-inspector__pick-hint{flex:none;margin:0 12px 10px;color:#989898;font-size:10px;line-height:1.5}.design-inspector__pending{margin:0 12px 12px;min-width:0;border-radius:10px;background:#ffffff08;box-shadow:inset 0 0 0 1px #ffffff0d;font-size:12px;animation:design-status .2s var(--ease-smooth-out)}.design-inspector__pending[hidden]{display:none}.design-inspector__pending .design-card-head{display:flex;min-width:0;padding:10px 12px}.design-inspector__pending .design-card-label{display:grid;flex:1;min-width:0;gap:2px}.design-inspector__pending .design-card-title{margin:0;overflow:hidden;color:#eee;font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.design-inspector__pending .design-card-target{margin:0;color:#8a8a8a;font-size:11px;line-height:1.45}.design-pending__list{display:flex;flex-direction:column;max-height:168px;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;border-top:1px solid #ffffff0a}.design-pending__list .design-change-row{padding:0 12px;border-radius:0}.design-pending__list .design-change-row+.design-change-row{border-top:1px solid #ffffff06}.design-change-row{display:grid;grid-template-columns:12px minmax(0,1fr) auto;align-items:center;gap:8px;flex:none;box-sizing:border-box;height:28px;padding:0 8px;border-radius:6px;color:#ddd;font:inherit;font-size:12px;text-align:left}.design-change-row:hover:not([aria-disabled]){background:#ffffff0a;color:#fff}.design-change-row:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px}.design-change-row[aria-disabled]{opacity:.5;cursor:default}.design-change-row svg{width:12px;height:12px;color:#8a8a8a}.design-change-row[data-kind=token] svg{color:var(--accent,#bda6ef)}.design-change-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-change-row small{color:#8a8a8a;font-size:11px;font-variant-numeric:tabular-nums}.design-pending__actions{display:flex;align-items:center;gap:4px;padding:8px 8px 8px 12px;border-top:1px solid #ffffff0a}.design-pending__actions button{display:grid;place-items:center;min-width:28px;height:28px;padding:0 8px;border-radius:7px;color:#9a9a9a;font:inherit;font-size:12px}.design-pending__actions button:hover{background:#ffffff0f;color:#fff}.design-pending__actions button:first-child{padding:0 12px;background:var(--accent,#bda6ef);color:#211b2d;font-weight:500}.design-pending__actions button:first-child:hover{background:var(--accent,#bda6ef);color:#211b2d;filter:brightness(1.08)}.design-pending__actions button:last-child{margin-left:auto}.design-pending__actions svg{width:16px;height:16px}.design-pending__actions button:focus-visible{outline:2px solid #bda6ef;outline-offset:1px}@media (prefers-reduced-motion:reduce){.design-inspector__pending{animation:none}}@media (pointer:coarse){.design-change-row,.design-pending__actions button{height:36px}}.design-inspector__tokens{margin-top:16px;min-height:34px;padding:0 14px;border-radius:8px;background:var(--accent,#bda6ef);color:#211b2d;font:inherit;font-size:12px;font-weight:500}.design-inspector__tokens:hover{filter:brightness(1.08)}.design-inspector__help{gap:6px;margin-top:8px;min-height:28px;padding:0 8px;border-radius:7px;color:#898680;font:inherit;font-size:11px}.design-inspector__tokens[hidden]+.design-inspector__help{margin-top:14px}.design-inspector__help:hover{background:#ffffff0a;color:#e9e6e1}.design-inspector__tokens[hidden],.design-inspector__help[hidden]{display:none}.design-inspector__token-chip{flex:none;align-self:flex-start;margin:0 12px 8px;background:#ffffff08;box-shadow:inset 0 0 0 1px #ffffff0d}.design-inspector__token-chip[hidden]{display:none}',update(n=!1){let i=E?0:L?.size??0;y=n||E?[]:t.items().reverse(),k=y.reduce((e,t)=>e+t.count,i),p.hidden=n||!!E||!k,f.textContent=`${k} unsaved change${1===k?"":"s"}`;let r=[...y.flatMap(e=>[e.element,e.count,e.here,e.proposal]),i];(r.length!==w.length||r.some((e,t)=>e!==w[t]))&&(w=r,function(n){t.peek(null),m.replaceChildren(...y.map(n=>{let i=o("",()=>{n.here&&(t.peek(null),n.element.scrollIntoView?.({block:"nearest",inline:"nearest"}),t.select(n.element))},"design-change-row"),r=/^Component: (.+?)(?: \(.*\))?$/m.exec(n.proposal??"")?.[1];if(v(i,b(n.proposal),r||e(n.element),n.count),n.here)for(let[e,o]of[["pointerenter",n.element],["pointerleave",null],["focus",n.element],["blur",null]])i.addEventListener(e,()=>t.peek(o));else i.setAttribute("aria-disabled","true"),i.dataset.tip="On another page";return i})),n&&(v(O,"token","Token changes",n),m.append(O))}(i)),j.hidden=!t.mode?.design?.tokens&&!l().querySelector("[data-palette-design-tokens],[data-komo-design-tokens]"),j.textContent=i?`Edit tokens · ${_(i)}`:"Edit tokens",H.hidden=!n||!i,v(H,"token","Token changes",i)}}}function k(e){let t=[];for(let n=e;n;n=n.parentElement){let o=n.id&&!/^radix-|^:r|_r_|«r/.test(n.id)?`#${CSS.escape(n.id)}`:"";if(o&&1===n.ownerDocument.querySelectorAll(o).length)return[o,...t].join(" > ");if(n===n.ownerDocument.body||!n.parentElement)return[n.tagName.toLowerCase(),...t].join(" > ");let i=n===e?[...n.classList].slice(0,2).map(e=>`.${CSS.escape(e)}`).join(""):"",r=[...n.parentElement.children].filter(e=>e.tagName===n.tagName).indexOf(n)+1;t.unshift(`${n.tagName.toLowerCase()}${i}:nth-of-type(${r})`)}return t.join(" > ")}function E(e,t){return`${k(e)} {\n${[...t].map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`}function $(e,t,n,o,i,r=[]){let a=[...t??[]].filter(([e])=>!o?.has(e)).map(([e,t])=>`- ${e}: ${n(e)||"(unset)"} → ${t}`),s=[a.length?`Proposed style changes (preview only)\nTarget: ${k(e)}\n${a.join("\n")}`:"",...i.map(t=>t&&!/^Target: /m.test(t)?t.replace("\n",`\nTarget: ${k(e)}\n`):t)].filter(e=>!!e);if(s[0]&&r.length){let e=s[0].split("\n"),t=r.filter(t=>!t.startsWith("Component: ")||!e.some(e=>e.startsWith("Component: ")));e.splice(e[1]?.startsWith("Target: ")?2:1,0,...t),s[0]=e.join("\n")}return s.join("\n\n")||void 0}function C(e,t,n,o,i){if(n.aborted)return;let r=s("div","morphing-menu__tooltip sidebar-tooltip");r.setAttribute("aria-hidden","true"),t.append(r);let a=0,d=()=>{clearTimeout(a),delete r.dataset.open},l=e=>{let t=e.target?.closest?.("[data-tip]");if(!t||"focusin"===e.type&&!t.matches(":focus-visible"))return d();clearTimeout(a),a=window.setTimeout(()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect();r.textContent=t.dataset.tip??"";let n=r.offsetWidth/2;r.style.left=`${Math.max(8+n,Math.min(document.documentElement.clientWidth-8-n,e.left+e.width/2))}px`,r.style.top=e.top-8-r.offsetHeight+"px",i?.(r,t),r.dataset.open="true"},r.dataset.open?0:400)};e.addEventListener("pointerover",l,{signal:n}),e.addEventListener("focusin",l,{signal:n});for(let t of["pointerleave","pointerdown","focusout","scroll"])e.addEventListener(t,d,{signal:n});n.addEventListener("abort",()=>{d(),r.remove()}),("focusin"===o.type||e.matches(":hover"))&&l(o)}function S(e,t,n,o){let i=0,r=new MutationObserver(()=>{let o=e.textContent??"";e.title=o,t.toggleAttribute("data-message",!!o),clearTimeout(i),o&&(i=window.setTimeout(function t(){n()?i=window.setTimeout(t,2600):e.textContent=""},2600))});r.observe(e,{childList:!0,characterData:!0,subtree:!0}),o.addEventListener("abort",()=>{r.disconnect(),clearTimeout(i)},{once:!0})}export{m as a,u as b,b as c,v as d,w as e,k as f,E as g,$ as h,C as i,S as j};
|
|
1
|
+
import{a as e}from"./chunk-QFDNGHSH.js";import{a as t,c as n}from"./chunk-RBHY7UDS.js";import{a as o}from"./chunk-XOMOONGK.js";import{a as i,d as r}from"./chunk-VX6XCU4E.js";import{B as a,E as s,F as d,c as l,h as p,i as c,z as g}from"./chunk-4HBBEVFK.js";function f(e,t=!1){return e.composedPath().some(e=>c(e)&&!(t&&e.matches("button,a[href],summary")&&!e.matches("[contenteditable],[inert],[role]:not([role=button]):not([role=link])"))&&e.matches('input,textarea,select,button,a[href],summary,dialog,[contenteditable]:not([contenteditable="false"]),[inert],[role]:not([role="none"]):not([role="presentation"]):not([role="img"]):not([role="group"]):not([role="region"]):not([role="main"]):not([role="article"]):not([role="heading"]):not([role="paragraph"]):not([role="generic"])'))}function m(e){let r=e.keys??t(),s=t=>{let n=t.composedPath()[0];n instanceof HTMLSelectElement&&t.composedPath().includes(e.host)&&!g(n)&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&(/^[b?]$/i.test(t.key)||e.reserved?.(t))&&t.preventDefault()},{root:d,signal:m}=e;addEventListener("keydown",s,{signal:m}),d?.addEventListener("keydown",e=>a(e,d)&&s(e),{signal:m});return t=>{if(t.isComposing||229===t.keyCode)return!1;let a=t.key.toLowerCase(),s=t.composedPath(),m=g(s[0]),u=i()?t.metaKey&&!t.ctrlKey:t.ctrlKey&&!t.metaKey,h=m||!u||t.altKey?void 0:"z"===a?t.shiftKey?e.redo:e.undo:"y"!==a||i()||t.shiftKey?void 0:e.redo;if(h)return!h.disabled&&(t.preventDefault(),t.stopImmediatePropagation(),((t,n)=>{let o=d?.activeElement??document.activeElement,i=o?.closest("[data-field-property]")?.dataset.fieldProperty;t.click();let r=e.selected();r&&(!n.includes(e.host)||o?.matches(".design-geometry__frame"))&&e.select(r);let a=o?.isConnected?o:i&&d?.querySelector(`[data-field-property="${CSS.escape(i)}"] ${o.localName}`);a instanceof HTMLElement&&a.focus({preventScroll:!0}),!n.includes(e.host)&&d?.activeElement!==p()&&d?.activeElement?.blur()})(h,s),!0);if("escape"===a)return m?(s.some(e=>c(e)&&e.matches("[data-field-property]"))||(t.preventDefault(),s[0].blur()),!0):s.some(e=>c(e)&&e.matches("[popover],[role=listbox]"));if(t.defaultPrevented||e.reserved?.(t))return!1;let b=!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey),x=!!n(t,r.before)||!n(t,r.after)&&void 0,y=m||s.some(e=>c(e)&&e.matches("input[type=range],[role=slider],.design-geometry__frame"));if(!e.compare.hidden&&(void 0!==x&&!y||b&&"b"===a&&!m))return t.preventDefault(),t.stopImmediatePropagation(),e.compareBefore(x),!0;if("?"===t.key&&e.help&&!m&&!t.altKey&&!t.ctrlKey&&!t.metaKey)return t.preventDefault(),t.stopImmediatePropagation(),e.help(),!0;let _=b&&" "===a;if(b&&"enter"===a&&!t.repeat){let n=m||s.some(e=>c(e)&&e.matches("[data-field-property],[popover],[role=listbox],[role=menu],textarea,.new-comment-composer,.reply-composer")),o=s.includes(e.host)&&f(t);if(!n&&!o)return!(!e.selected()?.isConnected||!e.comment?.())&&(t.preventDefault(),t.stopImmediatePropagation(),!0)}if(s.includes(e.host)||f(t,_))return!1;let v=e.selected(),w=t=>o(t)&&t.isConnected&&t!==t.ownerDocument.body&&t!==t.ownerDocument.documentElement&&!e.host.contains(t)&&!t.matches("script,style,defs,title,desc,metadata,[hidden],[inert]")&&"none"!==getComputedStyle(t).display&&"hidden"!==getComputedStyle(t).visibility,k=l(),E=k.activeElement,$=!E||E===k.body||E===k.documentElement||E===v,C=null,S=n(t,r.next)?"nextElementSibling":n(t,r.prev)?"previousElementSibling":void 0,K=t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(v?.isConnected&&S){for(C=v[S];C&&!w(C);)C=C[S];t.preventDefault(),t.stopImmediatePropagation()}else v?.isConnected&&$&&(n(t,r.child)||K&&"arrowdown"===a)?C=[...v.children].find(w)??null:v?.isConnected&&(n(t,r.parent)||K&&"arrowup"===a)?C=v.parentElement:_&&(C=E);return w(C)?(t.preventDefault(),t.stopImmediatePropagation(),C.scrollIntoView?.({block:"nearest",inline:"nearest"}),e.select(C),!0):t.defaultPrevented}}function u(e,t,n,o){let i=e.getRootNode(),r=function(e){let t=e.closest("[data-field-property]")?.dataset.fieldProperty,n=t?`[data-field-property=${JSON.stringify(t)}] `:"",o=e.getAttribute("data-property"),i=e.getAttribute("aria-label");return o?`${e.localName}[data-property=${JSON.stringify(o)}]`:i?`${n}${e.localName}[aria-label=${JSON.stringify(i)}]`:e.id?`[id=${JSON.stringify(e.id)}]`:n&&`${n}${e.localName}`}(t),a=()=>!(i.activeElement||document.activeElement&&document.activeElement!==document.body),s=e=>{d.disconnect(),clearTimeout(l),n(),e&&a()&&o()},d=new MutationObserver(()=>{if(!a())return s(!1);let t=r?e.querySelector(r):null;t&&(t.focus({preventScroll:!0}),s(!1))});d.observe(e,{childList:!0,subtree:!0});let l=setTimeout(s,400,!0);return s}var h={style:"style","inline text":"text","design-token":"token",token:"token","React prop":"prop",geometry:"geometry"};function b(e=""){let t=[...e.matchAll(/^Proposed (.+?) changes? \(preview only\)$/gm)].map(([,e])=>h[e]);return t.includes("geometry")?"geometry":t.find(Boolean)??"style"}var x=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="${e}"/></svg>`,y={style:"M8 2.5c2 2.4 4 4.6 4 6.8a4 4 0 0 1-8 0c0-2.2 2-4.4 4-6.8z",token:"M8 2.5 13.5 8 8 13.5 2.5 8z",text:"M3.5 4.5V3h9v1.5M8 3v10M6 13h4",prop:"M2.5 5h6m3 0h2m-11 6h2m3 0h6M10 3.5v3m-4 3v3",geometry:"M2.5 6V2.5H6m4 0h3.5V6m0 4v3.5H10m-4 0H2.5V10"},_=e=>`${e} change${1===e?"":"s"}`;function v(e,t,n,o){e.innerHTML=x(y[t]??y.style),e.dataset.kind=t,e.append(s("span","",n),s("small","",String(o))),e.setAttribute("aria-label",`${n} · ${_(o)}`)}function w(t){let n=s("div","design-inspector__empty");n.append(d("design"),s("strong","","Select an element"),s("p","","Click to inspect · Double-click text to edit"));let o=(e,t,n="")=>{let o=s("button",n,e);return o.type="button",o.addEventListener("click",t),o},a=(e,t,n=t)=>(e.setAttribute("aria-label",t),e.dataset.tip=n,e),p=s("section","design-inspector__pending design-card");p.setAttribute("aria-label","Unsaved changes"),p.hidden=!0;let c=s("div","design-card-head"),g=s("div","design-card-label"),f=s("h3","design-card-title");g.append(f,s("p","design-card-target","Preview only. Nothing is saved until you comment or copy.")),c.append(g);let m=s("div","design-rows design-pending__list"),u=s("div","design-pending__actions");p.append(c,m,u);let h=e=>t.mode?.root.dispatchEvent(new CustomEvent("palette-announce",{detail:e})),y=[],w=[],k=0,E=0,$=()=>[...y.map(e=>e.proposal),L?.proposal()].filter(Boolean).join("\n\n"),S=a(o("",async()=>{try{await navigator.clipboard.writeText($()),t.message("Changes copied")}catch{t.message("Couldn't copy changes. Try again.")}}),"Copy changes");S.append(d("copy")),u.append(o("Comment with changes",()=>{let e=$(),[n]=y,o=1===y.length&&!L?.size&&n.here?n.element:l().body;t.reset(),t.mode?.onComment(o,e||void 0)}),S,a(o("Discard all",()=>{T(),t.mode?.root.querySelector(".design-inspector__target")?.focus({preventScroll:!0})}),"Discard all","Undo · "+(i()?"⌘Z":"Ctrl+Z")));let K=e=>{p.removeEventListener("pointerover",K),p.removeEventListener("focusin",K),t.mode&&t.signal&&C(p,t.mode.root,t.signal,e)};function T(){E=k,t.before(!0),h(`${_(E)} discarded`)}p.addEventListener("pointerover",K),p.addEventListener("focusin",K);let L,M=()=>{E&&(E=0,t.reset())},{history:z=[]}=t,D=()=>{let e=new Set(L?.steps);for(let t=z.length;t--;)"token"===z[t].kind&&!e.delete(z[t].step)&&z.splice(t,1);for(let t of e)z.push({kind:"token",step:t});t.update?.()},P=t.mode&&{...t.mode,link:e=>(L=e,D)},j=o("Edit tokens",()=>{M();let e=t.mode?.root.querySelector(".design-inspector");e&&P&&import("./token-page-63C3T4DY.js").then(t=>t.openTokenPage(e,P),()=>t.message("Tokens unavailable · try again"))},"design-inspector__tokens"),N=o("Keyboard shortcuts",()=>t.help?.(),"design-inspector__help");N.setAttribute("aria-label","Keyboard shortcuts"),N.setAttribute("aria-keyshortcuts","?"),N.append(r(["?"],"?")),N.hidden=!t.help,n.append(j,N);let A=()=>{t.clear?.(),L?.open()},O=o("",A,"design-change-row"),H=o("",A,"design-change-row design-inspector__token-chip");return H.title="Open the Tokens view",H.hidden=!0,{empty:n,pending:p,chip:H,get tokens(){return L},get parked(){return E>0},settle:M,discard:T,restore:()=>!!E&&(h(`${_(E)} restored`),E=0,t.before(!1),!0),icons:{undo:x("M5.5 3.5 2.5 6.5l3 3m-3-3h7a4 4 0 0 1 0 8h-2"),redo:x("M10.5 3.5 13.5 6.5l-3 3m3-3h-7a4 4 0 0 0 0 8h2"),reset:x("M2.5 2.5v3h3M3 5.5a5.5 5.5 0 1 1-.5 2.5")},styles:'@keyframes design-status{from{opacity:0;translate:0 2px}}.design-inspector__count{white-space:nowrap;font-variant-numeric:tabular-nums}.design-inspector__status{display:none;min-width:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;animation:design-status .2s var(--ease-smooth-out)}.design-inspector__bar[data-message] .design-inspector__status{display:block}.design-inspector__bar[data-message] .design-inspector__count,.design-inspector__bar:not([data-changes]) .design-inspector__tool{display:none}.design-inspector__compare { display:inline-flex; flex:none; padding:2px; border-radius:7px; background:#ffffff0a; }.design-inspector__compare[hidden],.design-inspector__bar[data-message] .design-inspector__compare { display:none; }.design-inspector__compare button { height:22px; padding:0 8px; border-radius:5px; color:#9a9a9a; font:inherit; font-size:11px; }.design-inspector__compare button:hover { color:#fff; }.design-inspector__compare button[aria-pressed="true"] { color:#fff; background:#ffffff1a; }.design-inspector__empty { display:flex; flex-direction:column; align-items:center; gap:4px; padding:0 24px 28px; color:#898680; font-size:11px; text-align:center; }.design-inspector__empty > svg { box-sizing:content-box; width:20px; height:20px; margin-bottom:8px; padding:8px; border-radius:10px; background:#ffffff0a; color:#77736f; }.design-inspector__empty strong { color:#e9e6e1; font-size:12px; font-weight:600; }.design-inspector__empty p { margin:2px 0 0; line-height:1.5; }.design-inspector__pick-hint{flex:none;margin:0 12px 10px;color:#989898;font-size:10px;line-height:1.5}.design-inspector__pending{margin:0 12px 12px;min-width:0;border-radius:10px;background:#ffffff08;box-shadow:inset 0 0 0 1px #ffffff0d;font-size:12px;animation:design-status .2s var(--ease-smooth-out)}.design-inspector__pending[hidden]{display:none}.design-inspector__pending .design-card-head{display:flex;min-width:0;padding:10px 12px}.design-inspector__pending .design-card-label{display:grid;flex:1;min-width:0;gap:2px}.design-inspector__pending .design-card-title{margin:0;overflow:hidden;color:#eee;font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.design-inspector__pending .design-card-target{margin:0;color:#8a8a8a;font-size:11px;line-height:1.45}.design-pending__list{display:flex;flex-direction:column;max-height:168px;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;border-top:1px solid #ffffff0a}.design-pending__list .design-change-row{padding:0 12px;border-radius:0}.design-pending__list .design-change-row+.design-change-row{border-top:1px solid #ffffff06}.design-change-row{display:grid;grid-template-columns:12px minmax(0,1fr) auto;align-items:center;gap:8px;flex:none;box-sizing:border-box;height:28px;padding:0 8px;border-radius:6px;color:#ddd;font:inherit;font-size:12px;text-align:left}.design-change-row:hover:not([aria-disabled]){background:#ffffff0a;color:#fff}.design-change-row:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px}.design-change-row[aria-disabled]{opacity:.5;cursor:default}.design-change-row svg{width:12px;height:12px;color:#8a8a8a}.design-change-row[data-kind=token] svg{color:var(--accent,#bda6ef)}.design-change-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-change-row small{color:#8a8a8a;font-size:11px;font-variant-numeric:tabular-nums}.design-pending__actions{display:flex;align-items:center;gap:4px;padding:8px 8px 8px 12px;border-top:1px solid #ffffff0a}.design-pending__actions button{display:grid;place-items:center;min-width:28px;height:28px;padding:0 8px;border-radius:7px;color:#9a9a9a;font:inherit;font-size:12px}.design-pending__actions button:hover{background:#ffffff0f;color:#fff}.design-pending__actions button:first-child{padding:0 12px;background:var(--accent,#bda6ef);color:#211b2d;font-weight:500}.design-pending__actions button:first-child:hover{background:var(--accent,#bda6ef);color:#211b2d;filter:brightness(1.08)}.design-pending__actions button:last-child{margin-left:auto}.design-pending__actions svg{width:16px;height:16px}.design-pending__actions button:focus-visible{outline:2px solid #bda6ef;outline-offset:1px}@media (prefers-reduced-motion:reduce){.design-inspector__pending{animation:none}}@media (pointer:coarse){.design-change-row,.design-pending__actions button{height:36px}}.design-inspector__tokens{margin-top:16px;min-height:34px;padding:0 14px;border-radius:8px;background:var(--accent,#bda6ef);color:#211b2d;font:inherit;font-size:12px;font-weight:500}.design-inspector__tokens:hover{filter:brightness(1.08)}.design-inspector__help{gap:6px;margin-top:8px;min-height:28px;padding:0 8px;border-radius:7px;color:#898680;font:inherit;font-size:11px}.design-inspector__tokens[hidden]+.design-inspector__help{margin-top:14px}.design-inspector__help:hover{background:#ffffff0a;color:#e9e6e1}.design-inspector__tokens[hidden],.design-inspector__help[hidden]{display:none}.design-inspector__token-chip{flex:none;align-self:flex-start;margin:0 12px 8px;background:#ffffff08;box-shadow:inset 0 0 0 1px #ffffff0d}.design-inspector__token-chip[hidden]{display:none}',update(n=!1){let i=E?0:L?.size??0;y=n||E?[]:t.items().reverse(),k=y.reduce((e,t)=>e+t.count,i),p.hidden=n||!!E||!k,f.textContent=`${k} unsaved change${1===k?"":"s"}`;let r=[...y.flatMap(e=>[e.element,e.count,e.here,e.proposal]),i];(r.length!==w.length||r.some((e,t)=>e!==w[t]))&&(w=r,function(n){t.peek(null),m.replaceChildren(...y.map(n=>{let i=o("",()=>{n.here&&(t.peek(null),n.element.scrollIntoView?.({block:"nearest",inline:"nearest"}),t.select(n.element))},"design-change-row"),r=/^Component: (.+?)(?: \(.*\))?$/m.exec(n.proposal??"")?.[1];if(v(i,b(n.proposal),r||e(n.element),n.count),n.here)for(let[e,o]of[["pointerenter",n.element],["pointerleave",null],["focus",n.element],["blur",null]])i.addEventListener(e,()=>t.peek(o));else i.setAttribute("aria-disabled","true"),i.dataset.tip="On another page";return i})),n&&(v(O,"token","Token changes",n),m.append(O))}(i)),j.hidden=!t.mode?.design?.tokens&&!l().querySelector("[data-palette-design-tokens],[data-komo-design-tokens]"),j.textContent=i?`Edit tokens · ${_(i)}`:"Edit tokens",H.hidden=!n||!i,v(H,"token","Token changes",i)}}}function k(e){let t=[];for(let n=e;n;n=n.parentElement){let o=n.id&&!/^radix-|^:r|_r_|«r/.test(n.id)?`#${CSS.escape(n.id)}`:"";if(o&&1===n.ownerDocument.querySelectorAll(o).length)return[o,...t].join(" > ");if(n===n.ownerDocument.body||!n.parentElement)return[n.tagName.toLowerCase(),...t].join(" > ");let i=n===e?[...n.classList].slice(0,2).map(e=>`.${CSS.escape(e)}`).join(""):"",r=[...n.parentElement.children].filter(e=>e.tagName===n.tagName).indexOf(n)+1;t.unshift(`${n.tagName.toLowerCase()}${i}:nth-of-type(${r})`)}return t.join(" > ")}function E(e,t){return`${k(e)} {\n${[...t].map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`}function $(e,t,n,o,i,r=[]){let a=[...t??[]].filter(([e])=>!o?.has(e)).map(([e,t])=>`- ${e}: ${n(e)||"(unset)"} → ${t}`),s=[a.length?`Proposed style changes (preview only)\nTarget: ${k(e)}\n${a.join("\n")}`:"",...i.map(t=>t&&!/^Target: /m.test(t)?t.replace("\n",`\nTarget: ${k(e)}\n`):t)].filter(e=>!!e);if(s[0]&&r.length){let e=s[0].split("\n"),t=r.filter(t=>!t.startsWith("Component: ")||!e.some(e=>e.startsWith("Component: ")));e.splice(e[1]?.startsWith("Target: ")?2:1,0,...t),s[0]=e.join("\n")}return s.join("\n\n")||void 0}function C(e,t,n,o,i){if(n.aborted)return;let r=s("div","morphing-menu__tooltip sidebar-tooltip");r.setAttribute("aria-hidden","true"),t.append(r);let a=0,d=()=>{clearTimeout(a),delete r.dataset.open},l=e=>{let t=e.target?.closest?.("[data-tip]");if(!t||"focusin"===e.type&&!t.matches(":focus-visible"))return d();clearTimeout(a),a=window.setTimeout(()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect();r.textContent=t.dataset.tip??"";let n=r.offsetWidth/2;r.style.left=`${Math.max(8+n,Math.min(document.documentElement.clientWidth-8-n,e.left+e.width/2))}px`,r.style.top=e.top-8-r.offsetHeight+"px",i?.(r,t),r.dataset.open="true"},r.dataset.open?0:400)};e.addEventListener("pointerover",l,{signal:n}),e.addEventListener("focusin",l,{signal:n});for(let t of["pointerleave","pointerdown","focusout","scroll"])e.addEventListener(t,d,{signal:n});n.addEventListener("abort",()=>{d(),r.remove()}),("focusin"===o.type||e.matches(":hover"))&&l(o)}function S(e,t,n,o){let i=0,r=new MutationObserver(()=>{let o=e.textContent??"";e.title=o,t.toggleAttribute("data-message",!!o),clearTimeout(i),o&&(i=window.setTimeout(function t(){n()?i=window.setTimeout(t,2600):e.textContent=""},2600))});r.observe(e,{childList:!0,characterData:!0,subtree:!0}),o.addEventListener("abort",()=>{r.disconnect(),clearTimeout(i)},{once:!0})}export{m as a,u as b,b as c,v as d,w as e,k as f,E as g,$ as h,C as i,S as j};
|