@popmelt.com/core 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -863
- package/THIRD_PARTY_NOTICES.md +46 -0
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ExploreAttachment-TTEKD4AU.mjs +1 -0
- package/dist/PagePreviewLayer-TJZOJBSD.mjs +1 -0
- package/dist/ParticipantRuntime-BQAOTSQZ.mjs +1 -0
- package/dist/PhoneHostGate-LNSDZOG2.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-NCCF7YUX.mjs +1 -0
- package/dist/{PreviewRuntime-EYKB7MG5.mjs → PreviewRuntime-H2UOLP6T.mjs} +1 -1
- package/dist/QueuedReplies-LQUBEZ6K.mjs +1 -0
- package/dist/SuppliedContext-YKQSMF3J.mjs +1 -0
- package/dist/ThreadErrorCard-4MOA34C4.mjs +1 -0
- package/dist/ThreadPanel-T6IXWFLA.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/browser-runtime-HQM2Y6EL.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/{checkFixture-AMLLLJNS.mjs → checkFixture-BXILOUP5.mjs} +1 -1
- package/dist/{chunk-2ETPREWQ.mjs → chunk-66VOM5NA.mjs} +1 -1
- package/dist/chunk-APP5IYTE.mjs +1 -0
- package/dist/chunk-AYDREFWN.mjs +1 -0
- package/dist/chunk-CRJPE33X.mjs +1 -0
- package/dist/chunk-DC47WNPG.mjs +1 -0
- package/dist/chunk-DJTGR3RO.mjs +1 -0
- package/dist/chunk-DOJBWTT5.mjs +1 -0
- package/dist/chunk-F45IVFS3.mjs +1 -0
- package/dist/chunk-GKOMTSWV.mjs +1 -0
- package/dist/chunk-HU2XWUJC.mjs +1 -0
- package/dist/{chunk-MJ2PFKF3.mjs → chunk-KTRMNVPZ.mjs} +1 -1
- package/dist/{chunk-YXPRWW6B.mjs → chunk-M5P6VHZY.mjs} +1 -1
- package/dist/{chunk-QQB5G3VB.mjs → chunk-N4737FRL.mjs} +1 -1
- package/dist/{chunk-YTUQYKLM.mjs → chunk-NDGM4DAP.mjs} +1 -1
- package/dist/{chunk-GSEMSZDB.mjs → chunk-OAHYSDJ4.mjs} +1 -1
- package/dist/chunk-PYGRFSUU.mjs +1 -0
- package/dist/chunk-R34FOW4D.mjs +1 -0
- package/dist/{chunk-H2RLTCUJ.mjs → chunk-R3AJWOID.mjs} +1 -1
- package/dist/{chunk-RSUMSUAW.mjs → chunk-S7BCEQKP.mjs} +1 -1
- package/dist/{chunk-E5WNW4WE.mjs → chunk-T4CCY2EL.mjs} +1 -1
- package/dist/chunk-TH7DML4A.mjs +1 -0
- package/dist/chunk-UEGDSECJ.mjs +1 -0
- package/dist/chunk-WDAXARLI.mjs +1 -0
- package/dist/{chunk-Y6WD56SO.mjs → chunk-XG2YIAJS.mjs} +1 -1
- package/dist/chunk-Y3SF5YCR.mjs +1 -0
- package/dist/{chunk-BACXPVHP.mjs → chunk-ZG6XHKYO.mjs} +1 -1
- package/dist/chunk-ZG7MAEEV.mjs +30 -0
- package/dist/chunk-ZSL57PQ7.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-OUG4S6XE.mjs +1 -0
- package/dist/codex-project-B5466BL6.mjs +1 -0
- package/dist/focus-inspection-SZJ5KP23.mjs +1 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- package/dist/media.d.mts +3 -3
- package/dist/{participantBootstrap-ClKpD2qC.d.mts → participantBootstrap-DFJlcKRI.d.mts} +2 -2
- package/dist/peer-client-SCSWLRCX.mjs +1 -0
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.mjs +1 -1
- package/dist/{steerStyles-VKQD57KC.mjs → steerStyles-E76E44PI.mjs} +1 -1
- package/dist/{subjects-EWAR5-0S.d.mts → subjects-DdavjSTL.d.mts} +12 -0
- package/dist/{video-adapter-BUMpNTCP.d.mts → video-adapter-DB6Hex1f.d.mts} +1 -1
- package/package.json +1 -3
- package/dist/ExploreAttachment-BG7ZOQSA.mjs +0 -1
- package/dist/PagePreviewLayer-CBDGPMJQ.mjs +0 -1
- package/dist/ParticipantRuntime-FSZX2PUQ.mjs +0 -1
- package/dist/PhoneHostGate-OM7FLOJ2.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-KJSBPJQR.mjs +0 -1
- package/dist/QueuedReplies-ZYUDSTS2.mjs +0 -1
- package/dist/SuppliedContext-7THB2WZY.mjs +0 -1
- package/dist/ThreadErrorCard-J2VTA5JW.mjs +0 -1
- package/dist/ThreadPanel-PNVMIIYJ.mjs +0 -1
- package/dist/browser-runtime-FFT5NH66.mjs +0 -1
- package/dist/chunk-3WSTAV5B.mjs +0 -1
- package/dist/chunk-67OWRNU3.mjs +0 -30
- package/dist/chunk-BFVLMSG5.mjs +0 -1
- package/dist/chunk-BJ25TGJN.mjs +0 -1
- package/dist/chunk-FMI4VQDZ.mjs +0 -1
- package/dist/chunk-GRPDZGPP.mjs +0 -1
- package/dist/chunk-JRP5XFYN.mjs +0 -1
- package/dist/chunk-LD3532UC.mjs +0 -1
- package/dist/chunk-MP6ZV2DN.mjs +0 -1
- package/dist/chunk-N66ZZG3L.mjs +0 -1
- package/dist/chunk-P4KM3K5M.mjs +0 -1
- package/dist/chunk-R3FPXDQS.mjs +0 -1
- package/dist/chunk-TRHC7WBO.mjs +0 -1
- package/dist/chunk-XSMCZUDR.mjs +0 -1
- package/dist/chunk-YC5CUNRU.mjs +0 -1
- package/dist/codex-note-context-NUKGR2WT.mjs +0 -1
- package/dist/codex-project-KE7ZZ6YX.mjs +0 -1
- package/dist/focus-inspection-BPPRCMNN.mjs +0 -1
- package/dist/peer-client-UQDASAO7.mjs +0 -1
- /package/dist/{chunk-G6RYESYI.mjs → chunk-6LBPTCGC.mjs} +0 -0
- /package/dist/{chunk-3GXLNBXU.mjs → chunk-XM6RE6HT.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{c as e}from"./chunk-UEGDSECJ.mjs";import{a as t}from"./chunk-YFDD7HGT.mjs";import"./chunk-F5XSNRGT.mjs";import{b as r}from"./chunk-NDGM4DAP.mjs";import{a as n}from"./chunk-PH2MLB3T.mjs";import{ja as a,_ as i,w as o}from"./chunk-AYDREFWN.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-G2ZHJXHZ.mjs";import{a as l}from"./chunk-6LBPTCGC.mjs";import{ta as s,Ma as d,D as c,I as u,ja as p,Q as h,L as g,ra as f,N as m,ma as v,E as y,qa as b,pa as w,r as x,S as k,C as S,B as C,Ka as $,s as R}from"./chunk-F45IVFS3.mjs";import"./chunk-4LHTPRFY.mjs";import{d as E}from"./chunk-HU2XWUJC.mjs";import"./chunk-XT6PHPPG.mjs";import{c as T,b as I,a as N}from"./chunk-Q6N77LIS.mjs";import"./chunk-RR4SHK7O.mjs";import"./chunk-53SKVMWR.mjs";import{a as A}from"./chunk-57FM7XQV.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import{b as L}from"./chunk-67QNAAUC.mjs";import"./chunk-5D2ADU7H.mjs";import{x as z,w as D,e as j,f as P,r as M,l as O,v as W,t as F,b as B,p as q,g as H,d as U,j as V,c as K,o as Y,k as J,s as X,m as _,h as G,i as Z,q as Q,a as ee,n as te,u as re}from"./chunk-O4HZP3RP.mjs";import"./chunk-XTOCFTVW.mjs";import{a as ne}from"./chunk-LVEMYZOA.mjs";import"./chunk-WHJEKDNP.mjs";import{createContext as ae,useRef as ie,useState as oe,useSyncExternalStore as le,useLayoutEffect as se,useEffect as de,useCallback as ce,useMemo as ue,isValidElement as pe,useId as he,Fragment as ge,createElement as fe,useContext as me}from"react";import{jsx as ve,jsxs as ye,Fragment as be}from"react/jsx-runtime";import{createPortal as we}from"react-dom";var xe=["display","boxSizing","width","height","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","flexGrow","flexShrink","gridTemplateColumns","rowGap","columnGap","gap","padding","paddingInline","paddingBlock","border","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft","borderTop","borderRight","borderBottom","borderLeft","borderColor","borderWidth","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","color","backgroundColor","backgroundImage","boxShadow","opacity","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","textTransform","textDecoration","whiteSpace","overflow","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","objectFit"],ke=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function Se(e,t){return!!Ee(t)&&("flexGrow"===e||"flexShrink"===e?ke.test(t)&&Number.isFinite(Number(t))&&Number(t)>=0:["display","boxSizing","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","textAlign","whiteSpace","overflow","strokeLinecap","strokeLinejoin","objectFit"].includes(e)?!ke.test(t):!!/^(none|normal|auto|transparent|currentcolor)$/i.test(t)||(/^(?:width|height|gridTemplateColumns)$/.test(e)?/^(?:min-content|max-content|fit-content|subgrid)$/.test(t):/^(?:padding|margin|border.*Radius|gap|rowGap|columnGap|letterSpacing|strokeWidth)/.test(e)?/^0(?:px|em|rem|%)?$/.test(t):/^border(Top|Right|Bottom|Left)$/.test(e)?/^(?:0px\b|.*\bnone\b)/.test(t):"opacity"===e?"1"===t:/^(?:backgroundColor|fill|stroke)$/.test(e)&&/^rgba\([^)]*,\s*0\)$/.test(t)))}function Ce(e,t){return{...e,tokens:[...e.tokens,...t.tokens??[]]}}function $e(e){return/^(width|height|marginTop|marginRight|marginBottom|marginLeft|gridTemplateColumns)$/.test(e)}var Re=e=>{throw new re(e)},Ee=e=>"string"==typeof e&&e.length>0&&e.length<=512&&!/[;{}\\]|\b(?:url|expression|var)\s*\(/i.test(e)&&![...e].some(e=>e.charCodeAt(0)<32),Te=e=>"string"==typeof e&&/^[a-zA-Z0-9_-]{1,80}$/.test(e),Ie=new Set(["div","span","img","svg","path","circle","rect","line","polyline","polygon","ellipse","g"]),Ne=e=>"string"==typeof e&&e.length<=2e4&&/^(https?:\/\/|blob:https?:\/\/|data:image\/(png|jpeg|webp|gif);base64,)/i.test(e),Ae=new Set(["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fillRule","clipRule"]);function Le(e,t,r){try{let n,a=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(r);if("token"===t.kind){let r=e.tokens.find(e=>e.id===t.id);n=r?M(r.value,e.constraints,!a):null}else{let r=j(e.constraints,t.id,t.step??0);n=P(r),"layout"===r.kind&&!r.unit&&!a&&(n+="px")}return Ee(n)?n:null}catch{return null}}function ze(e,t){let r=["div","span","img"].includes(t.tag)?{all:"initial"}:{};for(let[e,n]of Object.entries(t.localStyles??{}))xe.includes(e)&&(Se(e,n)||$e(e)&&Ee(n))&&(r[e]=["flexGrow","flexShrink","opacity","strokeWidth"].includes(e)&&Number.isFinite(Number(n))?Number(n):n);for(let[n,a]of Object.entries(t.styles)){if(!xe.includes(n))continue;let t=Le(e,a,n);null!==t&&(r[n]=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(n)&&Number.isFinite(Number(t))?Number(t):t)}return r}function De(e,t=!1){if("string"!=typeof e||!e||e.length>800||!/^[a-z\d\s.,%+#()\-/]+$/i.test(e))return!1;let r=0;for(let t of e)if("("===t&&++r>8||")"===t&&--r<0)return!1;if(r)return!1;let n=e.replace(/#[\da-f]{3,8}\b/gi,"").replace(/[-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?(?:px|rem|em|deg|turn|rad|%)?/gi,"").match(/[a-z][a-z-]*/gi)??[],a=new Set("none transparent black white currentcolor rgb rgba hsl hsla hwb oklch oklab lab lch color color-mix srgb srgb-linear display-p3 in shorter longer increasing decreasing hue solid dashed dotted double groove ridge inset outset".split(" "));if(t)for(let e of"linear-gradient radial-gradient conic-gradient repeating-linear-gradient repeating-radial-gradient repeating-conic-gradient to top right bottom left circle ellipse closest-side farthest-side closest-corner farthest-corner at center from".split(" "))a.add(e);return n.every(e=>a.has(e.toLowerCase()))}function je(e){if(void 0===e.border)return e;let{border:t,...r}=e,n=String(t).match(/(?:[^\s(]+\([^)]*\)|[^\s]+)/g)??[],a=n.find(e=>/^(?:[\d.]+(?:[a-z%]+)?|thin|medium|thick)$/.test(e)),i=n.find(e=>/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/.test(e)),o=n.filter(e=>e!==a&&e!==i).join(" ");return{borderWidth:a??"medium",borderStyle:i??"none",borderColor:o||"currentColor",...r}}function Pe(e){if(void 0===e.background)return e;let{background:t,...r}=e,n=String(t);if(typeof document<"u"){let e=document.createElement("span").style;if(e.background=n,e.background)return{backgroundColor:e.backgroundColor||"transparent",backgroundImage:e.backgroundImage||"none",...r}}return{backgroundColor:/gradient\(/i.test(n)||"none"===n?"transparent":n,backgroundImage:/gradient\(/i.test(n)?n:"none",...r}}function Me(e){if(!e||"object"!=typeof e)return;let t={};for(let r of["body","heading","card","button","input"]){let n=e[r];if(!n||"object"!=typeof n)continue;let a={};for(let[e,t]of Object.entries(n)){let r=String(t??"");"fontFamily"===e&&r.length<=200&&/^[a-zA-Z][a-zA-Z0-9 ,"'_-]*$/.test(r.replace(/^["']/,""))&&(a[e]=r),"color"===e&&De(t)&&(a[e]=r),["background","backgroundColor","backgroundImage","border","borderColor","boxShadow","outline"].includes(e)&&De(t,e.startsWith("background"))&&(a[e]=r),"opacity"===e&&"number"==typeof t&&Number.isFinite(t)&&(a[e]=Math.max(0,Math.min(1,t))),"transform"===e&&r.length<150&&/^(?:none|(?:\s*(?:translate(?:X|Y)?\(-?[\d.]+(?:px|rem|%)(?:,\s*-?[\d.]+(?:px|rem|%))?\)|scale\(\d*\.?\d+\))\s*){1,3})$/.test(r)&&(a[e]=r),"transition"===e&&r.length<200&&/^(?:(?:all|color|background-color|border-color|box-shadow|transform|opacity)\s+\d*\.?\d+(?:ms|s)(?:\s+(?:ease|ease-in|ease-out|ease-in-out|linear))?\s*,?\s*){1,5}$/.test(r)&&(a[e]=r),"fontWeight"===e&&"number"==typeof t&&t>=100&&t<=900&&(a[e]=t),"fontStyle"===e&&["normal","italic"].includes(r)&&(a[e]=r),"textTransform"===e&&["none","uppercase","lowercase","capitalize"].includes(r)&&(a[e]=r),["fontSize","letterSpacing","lineHeight","padding","margin","marginTop","marginBottom","gap","borderRadius","borderWidth","outlineOffset"].includes(e)&&r.length<100&&/^-?\d*\.?\d+(?:px|rem|em|%)?(?:\s+-?\d*\.?\d+(?:px|rem|em|%)?){0,3}$/.test(r)&&(a[e]=r)}t[r]=a}return t}function Oe(e,t=640,r=!1){if(!e)return{};let n={...e};for(let[e,a]of Object.entries(n))"fontFamily"===e||"fontWeight"===e||!r&&"string"==typeof a&&(n[e]=a.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(e,r,n)=>`${Math.max(-12,Math.min(12,Number(r)*("rem"===n?16:1)/(t/100)))}cqw`));if(e.fontFamily){let t=We(e.fontFamily);/^Geist\s?Mono$/i.test(t)?n.fontFamily='"Popmelt Geist Mono", ui-monospace, monospace':/^Geist$/i.test(t)?n.fontFamily='"Popmelt Geist", system-ui, sans-serif':t&&!Fe(t)&&(n.fontFamily=`"Popmelt Taste ${t}", ${e.fontFamily}`)}return Pe(je(n))}var We=e=>e.split(",")[0].trim().replace(/^["']|["']$/g,""),Fe=e=>/^(inherit|initial|unset|serif|sans-serif|monospace|system-ui|ui-.+|Arial|Helvetica|Verdana|Georgia|Times New Roman|Courier New|SFMono-Regular|Menlo|Monaco|Consolas)$/i.test(e),Be=new Map;var qe=e=>!!e&&"object"==typeof e&&!Array.isArray(e),He=(e,t=512)=>"string"==typeof e&&e.length<=t,Ue=e=>He(e,100)&&/^[a-zA-Z0-9_-]+$/.test(e),Ve=e=>He(e,4096)&&![...e].some(e=>e.charCodeAt(0)<9)&&!/[;{}<>]|\b(?:url|expression|javascript)\s*[:(]/i.test(e),Ke=(e,t)=>Object.keys(e).every(e=>t.includes(e)),Ye=(e,t)=>new Set(e.map(e=>e[t])).size===e.length,Je=new Set("display boxSizing width height flexDirection flexWrap alignItems justifyContent alignSelf flexGrow flexShrink gridTemplateColumns rowGap columnGap gap padding paddingInline paddingBlock border borderRadius paddingTop paddingRight paddingBottom paddingLeft marginTop marginRight marginBottom marginLeft borderTop borderRight borderBottom borderLeft borderColor borderWidth borderTopLeftRadius borderTopRightRadius borderBottomLeftRadius borderBottomRightRadius color backgroundColor backgroundImage boxShadow opacity fontFamily fontSize fontWeight fontStyle lineHeight letterSpacing textAlign textTransform textDecoration whiteSpace overflow fill stroke strokeWidth strokeLinecap strokeLinejoin objectFit".split(" ")),Xe=new Set("div span img svg path circle rect line polyline polygon ellipse g".split(" ")),_e=new Set("src alt viewBox d cx cy r x y x1 x2 y1 y2 rx ry width height points preserveAspectRatio transform fillRule clipRule".split(" "));function Ge(e){return Array.isArray(e)?"["+e.map(Ge).join(",")+"]":qe(e)?"{"+Object.keys(e).sort().map(t=>JSON.stringify(t)+":"+Ge(e[t])).join(",")+"}":JSON.stringify(e)}function Ze(e){if(!function(e){try{if(!qe(e)||!Ke(e,["format","schemaVersion","draft"])||"popmelt.taste.graph"!==e.format||1!==e.schemaVersion||(new TextEncoder).encode(JSON.stringify(e)).byteLength>512e3)return!1;let t=e.draft;if(!qe(t)||!Ke(t,["schemaVersion","name","constraints","tokens","usage","fragments","featuredComponentId"])||1!==t.schemaVersion||!He(t.name,80)||!t.name.trim()||!Array.isArray(t.constraints)||t.constraints.length<1||t.constraints.length>32||!t.constraints.every(e=>qe(e)&&Ke(e,["id","name","kind","group","typographyRole","scaleMode","value","parentId","derivative","scale"])&&Ue(e.id)&&He(e.name,80)&&(void 0===e.group||"typography"===e.group)&&(void 0===e.typographyRole||"body"===e.typographyRole||"heading"===e.typographyRole)&&["layout","color","font"].includes(String(e.kind))&&Ve(e.value)&&(null===e.parentId||Ue(e.parentId))&&Number.isFinite(e.derivative)&&Number.isFinite(e.scale)&&"number"==typeof e.scale&&e.scale>=0&&(void 0===e.scaleMode||"increment"===e.scaleMode))||!Ye(t.constraints,"id"))return!1;let r=new Map(t.constraints.map(e=>[String(e.id),e]));for(let e of t.constraints){let t=new Set,n=e;for(;null!==n.parentId;){if(t.has(n.id))return!1;t.add(n.id);let e=r.get(n.parentId);if(!e||e.kind!==n.kind)return!1;n=e}if(!n.value.trim())return!1}let n=e=>Array.isArray(e)&&e.length<=128&&e.every(e=>qe(e)&&Ke(e,["id","name","value"])&&Ue(e.id)&&Ue(e.name)&&Ve(e.value)&&e.value.trim()&&[...e.value.matchAll(/@([a-zA-Z0-9_-]+)/g)].every(e=>r.has(e[1])))&&Ye(e,"id")&&Ye(e,"name");if(!n(t.tokens))return!1;let a=t.tokens,i=(e,t)=>qe(e)&&Ke(e,["kind","id","step"])&&("dimension"===e.kind?r.has(String(e.id)):"token"===e.kind&&t.some(t=>t.id===e.id))&&(void 0===e.step||"number"==typeof e.step&&Number.isInteger(e.step)&&Math.abs(e.step)<=100);if(void 0!==t.usage&&(!Array.isArray(t.usage)||t.usage.length>256||!t.usage.every(e=>qe(e)&&Ke(e,["target","property","source"])&&["page","heading","body","muted","card","button","input"].includes(String(e.target))&&Je.has(String(e.property))&&i(e.source,a))))return!1;let o=t.fragments??[];if(!Array.isArray(o)||o.length>32||!Ye(o,"id"))return!1;for(let e of o){if(!(qe(e)&&Ke(e,["id","name","width","height","root","tokens"])&&Ue(e.id)&&He(e.name,80)&&e.name.trim()&&[e.width,e.height].every(e=>"number"==typeof e&&Number.isFinite(e)&&e>0&&e<=2e4)&&n(e.tokens??[])))return!1;let t=e.tokens??[];if(!n(t))return!1;let r=[...a,...t];if(!Ye(r,"id")||!Ye(r,"name"))return!1;let o=new Set,l=0,s=(e,t)=>"string"==typeof e?e.length<=1e4:!(!qe(e)||!Ke(e,["id","tag","styles","localStyles","attributes","children"])||!Ue(e.id)||o.has(e.id)||++l>256||t>16||!Xe.has(String(e.tag))||!qe(e.styles)||!Array.isArray(e.children)||e.children.length>256||(o.add(e.id),!Object.entries(e.styles).every(([e,t])=>Je.has(e)&&i(t,r)))||!(void 0===e.localStyles||qe(e.localStyles)&&Object.entries(e.localStyles).every(([e,t])=>Je.has(e)&&Ve(t)))||!(void 0===e.attributes||qe(e.attributes)&&Object.entries(e.attributes).every(([e,t])=>_e.has(e)&&He(t,2e4)&&("src"!==e||/^https:\/\//.test(t)))))&&e.children.every(e=>s(e,t+1));if(!s(e.root,0))return!1}return null==t.featuredComponentId||o.some(e=>e.id===t.featuredComponentId)}catch{return!1}}(e))return;let t=e;try{for(let e of t.draft.constraints)j(t.draft.constraints,e.id);for(let e of t.draft.fragments??[]){let r=Ce(t.draft,e),n=e=>Object.entries(e.styles).every(([e,t])=>null!==Le(r,t,e))&&e.children.every(e=>"string"==typeof e||n(e));if(!n(e.root))return}return t}catch{return}}function Qe(e){let t={format:"popmelt.taste.graph",schemaVersion:1,draft:e};if(!Ze(t))throw Error("This Taste has incomplete or invalid dimensions, tokens, or component bindings.");return t}function et(e){if(!e||"object"!=typeof e)return;let t=e;for(let e of["background","surface","foreground","muted","accent","border"])if(!De(t[e],!0))return;for(let e of["radius","spacing"])if("number"!=typeof t[e]||!Number.isFinite(t[e])||t[e]<0||t[e]>32)return;let r={...t};delete r.savedDocument;let n=t.savedDocument;if(n&&"string"==typeof n.id&&Number.isSafeInteger(n.revision)&&n.revision>0&&Ze(n.document)&&(r.savedDocument=n),delete r.detail,void 0!==t.detail&&(r.detail=Me(t.detail)),delete r.states,t.states&&"object"==typeof t.states){r.states={};for(let e of["card","button","input"]){let n=t.states[e];if(n&&"object"==typeof n){r.states[e]={};for(let t of["hover","focus","active"])r.states[e][t]=Me({[e]:n[t]})?.[e]}}}if(delete r.parts,void 0!==t.parts){if(!t.parts||"object"!=typeof t.parts)return;let e={};for(let n of["card","button","content"]){let a=t.parts[n];if(!a||"number"!=typeof a.radius||!Number.isFinite(a.radius)||a.radius<0||a.radius>999)return;let i=a.backdropFilter;e[n]={background:De(a.background,!0)?a.background:r.surface,border:De(a.border)?a.border:`1px solid ${r.border}`,radius:a.radius,shadow:De(a.shadow)?a.shadow:"none",...void 0!==a.backgroundImage?{backgroundImage:De(a.backgroundImage,!0)?a.backgroundImage:"none"}:{},...void 0!==a.backgroundBlendMode?{backgroundBlendMode:["normal","overlay","multiply","screen","soft-light","hard-light"].includes(a.backgroundBlendMode)?a.backgroundBlendMode:"normal"}:{},...void 0!==i?{backdropFilter:"string"==typeof i&&i.length<150&&/^(?:none|(?:\s*(?:blur\(\d*\.?\d+(?:px|rem)\)|saturate\(\d*\.?\d+%?\))\s*){1,3})$/.test(i)?i:"none"}:{},...void 0!==a.opacity?{opacity:Number.isFinite(a.opacity)?Math.max(0,Math.min(1,a.opacity)):1}:{}}}r.parts=e}return(!Number.isSafeInteger(r.recipeRevision)||r.recipeRevision<0)&&delete r.recipeRevision,("string"!=typeof r.contentRevision||!/^[a-f\d]{24}$/.test(r.contentRevision))&&delete r.contentRevision,r}function tt({recipe:e}){let t=.45*e.radius,r=e=>e.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(e,t,r)=>`${Math.max(-32,Math.min(32,Number(t)*("rem"===r?16:1)*.45))}px`),n=e=>e?{background:e.background,...e.backgroundImage&&"none"!==e.backgroundImage?{backgroundImage:e.backgroundImage}:{},backgroundBlendMode:e.backgroundBlendMode,backdropFilter:e.backdropFilter?r(e.backdropFilter).replace(/saturate\(([\d.]+)%\)/g,(e,t)=>`saturate(${Math.min(400,Number(t))}%)`):void 0,WebkitBackdropFilter:e.backdropFilter?r(e.backdropFilter):void 0,opacity:e.opacity,border:r(e.border),borderRadius:.45*e.radius,boxShadow:r(e.shadow)}:{};return ve("span",{"data-taste-specimen":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,background:e.background,pointerEvents:"none",overflow:"hidden"},children:ye("span",{"data-specimen-window":!0,style:{position:"absolute",left:"19.23%",top:"19.23%",width:"110%",height:"110%",background:e.surface,border:`1px solid ${e.border}`,borderRadius:t,overflow:"hidden",boxSizing:"border-box",...n(e.parts?.card),borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0},children:[ve("span",{"data-specimen-title":!0,style:{position:"absolute",left:0,top:0,width:"100%",height:"18.18%",background:e.parts?"transparent":e.accent}}),ve("span",{"data-specimen-control":!0,style:{position:"absolute",left:"7.95%",top:"26.14%",width:"90.91%",height:"18.18%",background:e.muted,border:`1px solid ${e.border}`,borderRadius:.6*t,boxSizing:"border-box",...n(e.parts?.button)}}),ve("span",{"data-specimen-content":!0,style:{position:"absolute",left:"7.95%",top:"53.41%",width:"90.91%",height:"67.05%",background:e.background,border:`1px solid ${e.border}`,borderRadius:.6*t,boxSizing:"border-box",...n(e.parts?.content)}})]})})}function rt(e,t=!1,r=640){let[n,a]=oe(!1),[i,o]=oe(!1),[l,s]=oe(!1);return{handlers:{onPointerEnter:()=>a(!0),onPointerLeave:()=>{a(!1),s(!1)},onPointerDown:()=>s(!0),onPointerUp:()=>s(!1),onPointerCancel:()=>s(!1),onKeyDown:e=>{t&&["Enter"," "].includes(e.key)&&s(!0)},onKeyUp:()=>s(!1),onFocus:()=>o(!0),onBlur:()=>{o(!1),s(!1)}},style:{...Oe(n?e?.hover:void 0,r),...Oe(i?e?.focus:void 0,r),...Oe(l?e?.active:void 0,r)}}}function nt({recipe:e,usageStyles:t}){let r=void 0!==t,n=n=>Oe({...e.detail?.[n]??{},...t?.[n]},640,r),a=rt(e.states?.button,!0),i=rt(e.states?.input),o=rt(e.states?.card),l=r?`${e.spacing}px`:e.spacing/6.4+"cqw";de(()=>{!function(e){if(!e||typeof FontFace>"u"||!document.fonts)return Promise.resolve();let t=new Map;for(let r of Object.values(e)){if(!r?.fontFamily)continue;let e=We(r.fontFamily);if(Fe(e)||/^Geist(?:\s?Mono)?$/i.test(e)||!/^[a-zA-Z][a-zA-Z0-9 _-]{0,79}$/.test(e))continue;let n=Number(r.fontWeight)||400,a="italic"===r.fontStyle;t.set(`${e}:${n}:${a}`,{family:e,weight:n,italic:a})}Promise.all([...t.entries()].slice(0,5).map(([e,t])=>{let r=Be.get(e);if(r)return r;let n=(async()=>{let e=new AbortController,r=setTimeout(()=>e.abort(),8e3);try{let r=new URLSearchParams({family:`${t.family}:${t.italic?"ital,wght@1,":"wght@"}${t.weight}`,display:"swap"}),n=await fetch(`https://fonts.googleapis.com/css2?${r}`,{signal:e.signal,credentials:"omit",referrerPolicy:"no-referrer"});if(n.ok||(n=await fetch(`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t.family)}&display=swap`,{signal:e.signal,credentials:"omit",referrerPolicy:"no-referrer"})),!n.ok)throw new Error("Font unavailable");if(![...(await n.text()).matchAll(/@font-face\s*\{([^}]+)\}/g)].slice(0,32).flatMap(e=>{let r=e[1],n=r.match(/url\((https:\/\/fonts\.gstatic\.com\/[^\s)"']+)\)/)?.[1];if(!n)return[];let a=new FontFace(`Popmelt Taste ${t.family}`,`url(${JSON.stringify(n)})`,{weight:r.match(/font-weight:\s*([^;]+);/)?.[1]??"400",style:r.match(/font-style:\s*([^;]+);/)?.[1]??"normal",unicodeRange:r.match(/unicode-range:\s*([^;]+);/)?.[1]??"U+0-10FFFF",display:"swap"});return document.fonts.add(a),[a]}).length)throw new Error("Font unavailable");await document.fonts.load(`${t.italic?"italic ":""}${t.weight} 16px "Popmelt Taste ${t.family}"`,"Your workspace A little space for big ideas. Create a project")}finally{clearTimeout(r)}})().catch(r=>{console.warn(`[Popmelt] Preview font ${t.family} unavailable; using its fallback.`,r instanceof Error?r.message:"Font request failed"),Be.delete(e)});return Be.set(e,n),n})).then(()=>{})}({...e.detail,...t})},[e.detail,t]);let s=e=>e.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(e,t,r)=>`${Math.max(-16,Math.min(16,Number(t)*("rem"===r?16:1)/6.4))}cqw`),d=e=>e?{...Pe({background:e.background}),...e.backgroundImage&&"none"!==e.backgroundImage?{backgroundImage:e.backgroundImage}:{},backgroundBlendMode:e.backgroundBlendMode,...je({border:s(e.border)}),borderRadius:e.radius/6.4+"cqw",boxShadow:s(e.shadow),backdropFilter:e.backdropFilter?s(e.backdropFilter):void 0,WebkitBackdropFilter:e.backdropFilter?s(e.backdropFilter):void 0,opacity:e.opacity}:{};return ve("div",{"data-taste-detail-specimen":!0,role:"group","aria-label":"Interactive taste preview",style:{position:r?"relative":"absolute",...r?{width:640,padding:0,boxSizing:"border-box"}:{inset:0},containerType:"inline-size",...Pe({background:e.background}),color:e.foreground,fontSynthesis:"none",...n("body"),...n("page"),overflow:r?"visible":"hidden"},children:ve("div",{"data-taste-component":"card",style:{position:r?"relative":"absolute",...r?{}:{inset:"9% 8%"},...Pe({background:e.surface}),...je({border:`1px solid ${e.border}`}),borderRadius:e.radius,...d(e.parts?.card),padding:r?0:"5cqw",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:l,...n("card")},children:ye("div",{style:{display:"grid",gridTemplateColumns:"1.35fr 1fr",gap:r?n("card").gap??l:`calc(${l} * 2)`,alignItems:"center",flex:1,minHeight:0},children:[ye("div",{children:[ye("h2",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",lineHeight:1.1,letterSpacing:"-0.03em",marginBottom:l,...n("heading"),...r?{}:{fontSize:`clamp(3.8cqw, ${Oe(e.detail?.heading).fontSize??"4.6cqw"}, 5.4cqw)`}},children:["A little space",ve("br",{}),"for big ideas."]}),ye("p",{"data-taste-component":"paragraph",style:{margin:0,fontSize:r?"inherit":"2.4cqw",lineHeight:1.5,marginBottom:l,...n("body"),...n("muted")},children:["Gather your thoughts.",ve("br",{}),"Make something your own."]}),ve("button",{"data-taste-component":"button",...a.handlers,type:"button",style:{fontFamily:"inherit",color:"inherit",display:"inline-block",...Pe({background:e.accent}),...je({border:`1px solid ${e.border}`}),borderRadius:e.radius,...d(e.parts?.button),padding:r?0:"1.5cqw 2.5cqw",fontSize:r?"inherit":"2.3cqw",fontWeight:"inherit",lineHeight:1.2,...n("button"),cursor:"pointer",...a.style},children:"Create a project ↗"})]}),ye("div",{"data-taste-component":"card",...o.handlers,style:{...Pe({background:e.surface}),...je({border:`1px solid ${e.border}`}),borderRadius:e.radius,...d(e.parts?.card),padding:r?0:"3cqw",fontSize:r?"inherit":"2.1cqw",lineHeight:1.5,...n("card"),...o.style},children:[ve("h3",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",...n("heading"),...r?{}:{fontSize:"2.6cqw"},marginBottom:l},children:"In the works"}),ve("input",{"data-taste-component":"input",...i.handlers,"aria-label":"Preview project name",defaultValue:"A fresh start",style:{appearance:"none",outline:"none",borderWidth:0,borderStyle:"none",borderColor:"transparent",...Pe({background:"transparent"}),...d(e.parts?.content),font:"inherit",color:"inherit",padding:r?0:"1.5cqw",...n("input"),width:"100%",minWidth:0,boxSizing:"border-box",marginBottom:l,...i.style}}),ve("div",{children:"02 What comes next"})]})]})})})}function at(e){let t=e.ownerDocument.defaultView;if(!t||E(e))throw Error("Choose an element on the page.");let r=e.getBoundingClientRect(),n={id:`fragment-${crypto.randomUUID()}`,width:r.width,height:r.height,root:null,values:[]},a=new Map,i=0,o=(e,r)=>{if(e.matches("script,style,noscript,template,[hidden],[contenteditable]")||E(e))return null;let l=e.getBoundingClientRect(),s=t.getComputedStyle(e);if(!l.width||!l.height||l.bottom<=0||l.right<=0||l.top>=t.innerHeight||l.left>=t.innerWidth||"none"===s.display||"visible"!==s.visibility||"0"===s.opacity)return null;if(++i>64||r>12)throw Error("This component is too complex. Click a smaller element.");if(e.matches("video,canvas,iframe,object,embed,use,foreignObject")||e.shadowRoot)throw Error("This component contains media or embedded content not supported by static capture yet. Try a text, button or layout element.");if(/url\(/i.test(s.backgroundImage))throw Error("Image backgrounds are not supported by static capture yet.");let d="http://www.w3.org/2000/svg"===e.namespaceURI,c=d?e.localName:"img"===e.localName?"img":"inline"===s.display?"span":"div",u={id:`n${i}`,tag:c,children:[],styles:{}};if(e instanceof HTMLImageElement){if(!Ne(e.currentSrc||e.src))throw Error("This image cannot be captured safely.");u.attributes={src:e.currentSrc||e.src}}if(d){u.attributes={};for(let t of["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fill-rule","clip-rule"]){let r=e.getAttribute(t);null!==r&&(u.attributes[t.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())]=r)}}for(let t of xe){if(["gap","padding","paddingInline","paddingBlock","border","borderRadius","borderColor","borderWidth"].includes(t)||!d&&["fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin"].includes(t)||d&&"svg"!==c&&["width","height"].includes(t))continue;let r=s[t],i=!1;if($e(t)){let n=e.computedStyleMap?.().get(t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`))?.toString();n&&Ee(n)&&(r=n),i=!n||/^(auto|min-content|max-content|fit-content|none)$/.test(n)||"gridTemplateColumns"===t}if(!r)continue;if(!Ee(r))throw Error("This component has an unsupported style. Try a smaller element.");let o=`${t}:${r}:${i}`,l=a.get(o);l||(l=`s${a.size}`,a.set(o,l),n.values.push({id:l,property:t,value:r,...i?{local:!0}:{}})),u.styles[t]=l}if(!e.matches("input,textarea,select,option"))for(let t of e.childNodes)if(3===t.nodeType)t.textContent&&u.children.push(t.textContent);else if(t instanceof Element){let e=o(t,r+1);e&&u.children.push(e)}return u},l=o(e,0);if(!l)throw Error("Choose a visible element on the page.");return n.root=l,function(e){(!e||"object"!=typeof e||JSON.stringify(e).length>24e4)&&Re("Invalid fragment capture.");let t=e,{evidence:r,draft:n}=t;(!r||!Te(r.id)||![r.width,r.height].every(e=>Number.isFinite(e)&&e>0&&e<=1e4)||!Array.isArray(r.values)||r.values.length>180||!n||!Array.isArray(n.constraints)||n.constraints.length>32||!Array.isArray(n.tokens)||n.tokens.length>128)&&Re("This component is too large to capture. Try a smaller element.");let a=new Set;for(let e of r.values)(!e||!Te(e.id)||a.has(e.id)||!xe.includes(e.property)||void 0!==e.local&&(!0!==e.local||!$e(e.property))||!Ee(e.value))&&Re("Unsupported captured style."),a.add(e.id);let i=0,o=new Set,l=(e,t)=>{(!e||!Te(e.id)||o.has(e.id)||!Ie.has(e.tag)||++i>64||t>12||!Array.isArray(e.children)||e.children.length>128||!e.styles||"object"!=typeof e.styles)&&Re("This component is too complex. Try a smaller element."),o.add(e.id);for(let[t,n]of Object.entries(e.styles))r.values.some(e=>e.id===n&&e.property===t)||Re("Invalid captured style reference.");for(let[t,r]of Object.entries(e.attributes??{}))"img"===e.tag&&"src"===t&&Ne(r)||(!Ae.has(t)||"string"!=typeof r||r.length>12e3||!/^[\d\w\s.,+()-]*$/.test(r))&&Re("Unsupported vector geometry.");for(let r of e.children)"string"==typeof r?r.length>2e3&&Re("Too much captured text."):l(r,t+1)};l(r.root,0)}({evidence:n,draft:ee()}),n}function it({fragment:e,draft:t,height:r=160,highlightedNodes:n=[]}){let a=ie(null),i=ie(null),[o,l]=oe(null),[s,d]=oe({scale:1,width:e.width,height:e.height}),{scale:c}=s;se(()=>{a.current&&l(a.current.shadowRoot??a.current.attachShadow({mode:"open"}))},[]),se(()=>{let e=()=>{if(!a.current||!i.current)return;let e=i.current,t=Math.max(1,e.scrollWidth),n=Math.max(1,e.scrollHeight),o={width:t,height:n,scale:Math.min(1,a.current.clientWidth/t,r/n)};d(e=>e.width===o.width&&e.height===o.height&&e.scale===o.scale?e:o)};if(e(),typeof ResizeObserver>"u")return;let t=new ResizeObserver(e);return a.current&&t.observe(a.current),i.current&&t.observe(i.current),()=>t.disconnect()},[o,t,r]);let u=r=>{let a=ze(Ce(t,e),r);return fe(r.tag,{...r.attributes,key:r.id,style:{...a,color:a.color??"inherit",fontFamily:a.fontFamily??"inherit",fontSize:a.fontSize??"inherit",lineHeight:a.lineHeight??"inherit",fontWeight:a.fontWeight??"inherit",...n.includes(r.id)?{outline:"2px solid #888",outlineOffset:"2px"}:{}},"data-fragment-node":r.id},...r.children.map(e=>"string"==typeof e?e:u(e)))};return ve("div",{ref:a,role:"img","aria-label":`${e.name} static preview`,style:{height:r,width:"100%",overflow:"hidden",borderRadius:8,pointerEvents:"none",backgroundColor:ze(Ce(t,e),e.root).backgroundColor??F(t).page?.backgroundColor},children:o&&we(ve("div",{style:{height:r,display:"grid",placeItems:"center",overflow:"hidden"},children:ve("div",{style:{width:s.width*c,height:s.height*c},children:ve("div",{ref:i,style:{width:e.width,transform:`scale(${c})`,transformOrigin:"top left"},children:u(e.root)})})}),o)})}function ot(e){let{session:t,draft:n,visible:a,bridgeUrl:i}=e,[o,l]=oe([]),s=ie(null),d=ie(new Map),c=ie(null),u=ie(null),p=ie(e);p.current=e;let h=ie(!1),g=t.getSnapshot().runId,f=t.getSnapshot().state,m=A[e.theme];return se(()=>{let e=s.current?.closest(".tc-scroll");if(!e||!a)return;let t=()=>{c.current=null},r=e=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&t()};return e.addEventListener("wheel",t,{passive:!0}),e.addEventListener("touchmove",t,{passive:!0}),e.addEventListener("pointerdown",t,{passive:!0}),e.addEventListener("keydown",r),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t),e.removeEventListener("pointerdown",t),e.removeEventListener("keydown",r)}},[a]),se(()=>{let e=c.current;if(!e||!a)return;let t=d.current.get(e),r=t?.closest(".tc-scroll");if(!t||!r)return;let n=t.getBoundingClientRect(),i=r.getBoundingClientRect(),o=n.bottom+16-i.bottom;o>0&&r.scrollTo({top:r.scrollTop+o,behavior:"instant"})},[o,a,n]),de(()=>(h.current=!0,()=>{h.current=!1,u.current?.abort(),u.current=null}),[]),de(()=>{if(a)return r(e=>{let t;try{let r=at(e);t={id:r.id,evidence:r,state:"pending"}}catch(e){t={id:crypto.randomUUID(),state:"error",message:e instanceof Error?e.message:"Could not capture this element."}}l(e=>e.length+(p.current.draft.fragments?.length??0)>=16?e:(c.current=t.id,[...e,t]))})},[a]),de(()=>{if(!a||u.current||"running"===f)return;let e=o.find(e=>"pending"===e.state&&e.evidence);if(!e)return;let r=new AbortController;u.current=r;let n=t=>{h.current&&!r.signal.aborted&&l(r=>r.map(r=>r.id===e.id?{...r,...t}:r))};n({state:"running"});let s=setTimeout(()=>{n({state:"error",message:"Capture took too long. Try again."}),r.abort()},19e4);(async()=>{try{if(await Promise.resolve(),r.signal.aborted)return;if(!i)throw Error("Connect the local bridge to capture a component.");let a=t.getSnapshot(),o=await L(`${i}/cloud-taste/fragment`,{method:"POST",headers:{"Content-Type":"application/json"},signal:r.signal,body:JSON.stringify({evidence:e.evidence,draft:{...a.draft,fragments:void 0}})});if(!o.ok||!o.body)throw Error("Component capture is unavailable. Retry when the bridge is ready.");let s,d=o.body.getReader(),c=new TextDecoder,u="",f=e=>{if(!e.trim())return;let t=JSON.parse(e);if("error"===t.type)throw Error(t.message);"status"===t.type&&n({message:t.message}),"progress"===t.type&&n({name:t.draft.fragment.name}),"complete"===t.type&&(s=t.draft)};try{for(;;){let e,t=await d.read();if(t.done)break;if(u+=c.decode(t.value,{stream:!0}),u.length>256e3)throw Error("Component response was too large.");for(;-1!==(e=u.indexOf("\n"));)f(u.slice(0,e)),u=u.slice(e+1)}f(u+c.decode())}finally{d.releaseLock()}if(!s)throw Error("The component ended before its styles arrived. Retry capture.");!r.signal.aborted&&h.current&&(p.current.onDraft(t.addFragment(g,s)),l(t=>t.filter(t=>t.id!==e.id)))}catch(e){n({state:"error",message:e instanceof Error?e.message:"Capture failed. Please retry."})}finally{clearTimeout(s),u.current===r&&(u.current=null),h.current&&l(e=>[...e])}})()},[o,f,a,i,g,t]),ye("section",{ref:s,"aria-label":"Components",style:{display:"flex",flexDirection:"column",gap:16},children:[ve("h3",{style:{margin:0,fontSize:12,fontWeight:400,color:m.primary},children:"Components"}),!n.fragments?.length&&!o.length&&ve("p",{style:{margin:0,fontSize:12,color:m.secondary},children:"Click an element on the page to capture a static component."}),n.fragments?.map(r=>ye("div",{ref:e=>{e?d.current.set(r.id,e):d.current.delete(r.id)},style:{display:"flex",flexDirection:"column",gap:4},children:[ve("button",{type:"button","aria-label":`Inspect ${r.name}`,onClick:()=>e.onInspect?.(r.id),style:{background:m.control,borderRadius:8,width:"100%",padding:0,display:"block"},children:ve(it,{draft:n,fragment:r})}),ye("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 4px",color:m.secondary},children:[ve("button",{type:"button",onClick:()=>e.onInspect?.(r.id),style:{flex:1,justifyContent:"flex-start",fontSize:12,letterSpacing:".12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.name}),ve("button",{type:"button",onClick:()=>(r=>{if("running"===t.getSnapshot().state)return;let n=t.getSnapshot().draft;if(!n)return;let a={...n,featuredComponentId:r};t.history.current.past.push(n),t.history.current.future=[],t.edit(a),e.onDraft(a)})(r.id),"aria-label":`Use ${r.name} as preview`,"aria-pressed":n.featuredComponentId===r.id,disabled:"running"===f,style:{fontSize:12},children:n.featuredComponentId===r.id?"Preview":"Use as preview"}),ve("button",{type:"button",onClick:()=>e.onInspect?.(r.id),"aria-label":`Uses for ${r.name}`,title:"Styles are linked to this Taste’s dimensions and tokens",style:{fontSize:14,fontWeight:500,letterSpacing:"-.14px"},children:"uses"})]})]},r.id)),o.map(e=>ye("div",{ref:t=>{t?d.current.set(e.id,t):d.current.delete(e.id)},"data-taste-fragment-capture":e.id,style:{borderRadius:8,background:m.control,minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:8,padding:12,boxSizing:"border-box"},children:[ve("span",{role:"error"===e.state?"alert":"status",className:"tc-proposal-status","data-state":"running"===e.state?"in-progress":e.state,style:{whiteSpace:"normal",textAlign:"center"},children:"error"===e.state?e.message:"pending"===e.state?"Pending":e.message??`Tracing ${e.name??"component"}…`}),"error"===e.state&&ye("div",{style:{display:"flex",gap:12},children:[e.evidence&&ve("button",{type:"button",onClick:()=>l(t=>t.map(t=>t.id===e.id?{...t,state:"pending",message:void 0}:t)),children:"Retry"}),ve("button",{type:"button",onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),children:"Dismiss"})]})]},e.id))]})}function lt({document:e}){let t=ie(null),[r,n]=oe(160);se(()=>{let e=()=>n(t.current?.clientHeight||160);if(e(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(e);return t.current&&r.observe(t.current),()=>r.disconnect()},[]);let a=e.draft,i=a.fragments?.find(e=>e.id===a.featuredComponentId);return ve("div",{ref:t,"data-taste-document-preview":!0,style:{width:"100%",height:"100%"},children:i?ve(it,{fragment:i,draft:a,height:r}):null})}function st({preview:t,thumbnailUrl:r,zoom:n=!0,background:a}){let[i,o]=oe(null),l=t?.savedDocument?.document.draft.featuredComponentId?ve(lt,{document:t.savedDocument.document}):t?ve(nt,{recipe:t}):r&&r!==i?ve("img",{src:r,alt:"",referrerPolicy:"no-referrer",onError:()=>o(r),style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):null;return ve("div",{"data-detail-preview":!0,style:{aspectRatio:"16 / 9",width:"100%",position:"relative",border:0,padding:0,borderRadius:8,overflow:"hidden",background:a,font:"inherit"},children:n?ve(e,{children:l}):l})}var dt=200;function ct(e){let t=new Map;if(!e)return t;let r=e.getBoundingClientRect();for(let n of e.querySelectorAll("[data-taste-tile]")){let e=n.dataset.tasteEntryId;if(!e)continue;let a=n.getBoundingClientRect();t.set(e,{x:a.x-r.x,y:a.y-r.y})}return t}function ut(e,t,r,n,a){if(!e)return;let i=ct(e);for(let o of e.querySelectorAll("[data-taste-tile]")){let e=o.dataset.tasteEntryId,l=e?t.get(e):null,s=e?i.get(e):null;if(!l||!s||!o.animate)continue;let d=(l.x-s.x)/(r||1),c=(l.y-s.y)/(r||1);Math.abs(d)<.5&&Math.abs(c)<.5||a.push(o.animate([{transform:`translate(${d}px, ${c}px)`},{transform:"translate(0, 0)"}],{duration:n,easing:"ease-in-out"}))}}function pt({entry:e,onAdd:t,onRemove:r,active:n,featured:a=!1,previewBackground:i,hasActiveTaste:o=!1,onOpenDetails:l,onPrefetchDetails:s}){let[c,u]=oe(null),p=ie(null),h=ie(s);h.current=s;let g=ie(e);g.current=e,de(()=>{if(!p.current||typeof IntersectionObserver>"u")return;let e=new IntersectionObserver(([t])=>{t?.isIntersecting&&(g.current.preview||h.current?.(g.current),e.disconnect())},{root:p.current.closest("[data-taste-scroll]"),rootMargin:"180px"});return e.observe(p.current),()=>e.disconnect()},[e.id]);let f=ie(void 0),m=()=>clearTimeout(f.current);de(()=>()=>clearTimeout(f.current),[]);let b=!!e.documentRevision||!!e.preview?.savedDocument,w=n?r:b?l:t,x=n?"Remove":b?"View":o?"Switch":"Add",k=ve("span",{"data-taste-add":!0,"aria-hidden":"true",style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:3,padding:n?"4px 9px 4px 10px":"4px 10px 4px 6px",border:0,borderRadius:8,font:"inherit",fontWeight:500,letterSpacing:"-.12px",whiteSpace:"nowrap"},children:ye(be,n?{children:["Remove",ve(d,{size:12,"aria-hidden":"true"})]}:{children:[ve(b?y:v,{size:12,"aria-hidden":"true"}),x]})});return ye("li",{"data-taste-tile":!0,"data-taste-entry-id":e.id,"data-taste-featured":a||void 0,ref:p,onMouseEnter:()=>{m(),f.current=setTimeout(()=>s?.(e),100)},onMouseLeave:m,onFocus:()=>{m(),s?.(e)},style:{minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[a?ye("div",{"data-taste-thumbnail":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:8,overflow:"hidden"},children:[ve("div",{"data-taste-preview-art":!0,"aria-hidden":"true",inert:!0,children:ve(st,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,zoom:!1,background:i??"transparent"},e.id)}),ve("button",{type:"button","data-taste-featured-action":!0,"aria-label":`${x} ${e.name}`,"aria-pressed":n,disabled:!w,onClick:()=>w?.(e),style:{position:"absolute",inset:0,width:"100%",padding:0,border:0,background:"transparent",font:"inherit",cursor:w?"pointer":"default"},children:k})]}):ye("button",{type:"button","data-taste-thumbnail":!0,"aria-label":`${x} ${e.name}`,"aria-pressed":n,disabled:!w,onClick:()=>w?.(e),style:{display:"block",padding:0,border:0,font:"inherit",cursor:w?"pointer":"default",aspectRatio:"1",width:"100%",borderRadius:8,overflow:"hidden",position:"relative"},children:[ve("span",{"data-taste-preview-art":!0,style:{position:"absolute",inset:0},children:e.preview?.savedDocument?.document.draft.featuredComponentId?ve(lt,{document:e.preview.savedDocument.document}):e.thumbnailUrl&&e.thumbnailUrl!==c?ve("img",{src:e.thumbnailUrl,alt:"",referrerPolicy:"no-referrer",onError:()=>u(e.thumbnailUrl??null),style:{display:"block",width:"100%",height:"100%",objectFit:"cover"}}):e.preview?ve(tt,{recipe:e.preview}):null}),k]}),ye("button",{type:"button","data-taste-details":!0,"aria-label":`View ${e.name} details`,disabled:!l,onClick:()=>l?.(e),style:{width:"100%",padding:0,border:0,borderRadius:2,background:"transparent",font:"inherit",textAlign:"left",cursor:l?"pointer":"default",display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,minWidth:0,letterSpacing:".12px"},children:[ye("span",{style:{display:"inline-flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[ve("span",{"data-taste-name":!0,title:e.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,minWidth:0},children:e.name}),l&&ve("span",{"data-taste-detail-chevron":!0,"aria-hidden":"true",children:ve(y,{size:13,strokeWidth:2})})]}),e.metadata&&ve("span",{"data-taste-metadata":!0,title:e.metadata.label,"aria-label":e.metadata.label,style:{flexShrink:0,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:e.metadata.value})]})]})}function ht({theme:e,publicEntries:t,privateEntries:r,onClose:n,onRefresh:a,refreshDisabled:i=!1,refreshing:o=!1,onAdd:s,onRemove:c,activeEntryId:u=null,activeEntry:p,onOpenDetails:h,onPrefetchDetails:g,notice:f,action:v,headerAction:y,privateEmptyMessage:w,style:x}){let k=A[e],[S,C]=oe(!1),$=ie(null),R=ie(null),E=ie(null),T=ie(null),I=ie([]),N=ie(new Map),L=ie([]),z=ie(null),[D,j]=oe(null),P=ie(null),M=ie(null),[O,W]=oe(),[F,B]=oe(null),q=ie(null);de(()=>()=>{for(let e of q.current?.timers??[])clearTimeout(e);q.current?.cleanup();for(let e of I.current)e.cancel();for(let e of L.current)e.cancel();q.current=null},[]);let H=u?p?.id===u?p:[...t,...r].find(e=>e.id===u):null,U=F?.entry??H,V=U?.id??null,K=!!u&&D===u,Y="collapse"===F?.phase,J=t.filter(e=>e.id!==V||Y),X=r.filter(e=>e.id!==V||Y);se(()=>{let e=T.current;if(!e||"collapse"!==F?.phase||(T.current=null,window.matchMedia?.("(prefers-reduced-motion: reduce)").matches))return;let t=E.current,r=$.current,n=r?r.getBoundingClientRect().width/(r.offsetWidth||1):1;ut(t,e.positions,n,dt,I.current);for(let r of t?.querySelectorAll("[data-taste-tile]")??[])if(r.dataset.tasteEntryId===e.returningId&&r.animate){I.current.push(r.animate([{opacity:0},{opacity:1}],{duration:dt,easing:"ease-out"}));break}},[F?.phase]),se(()=>{let e=E.current;if(!e)return;let t=N.current;if(!K||z.current===u)return;z.current=u;let r=P.current,n=M.current,a=R.current,i=a?.querySelector("[data-taste-collections]");if(!r||!n||!a||!i||!r.animate||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void j(null);for(let e of L.current)e.cancel();L.current=[];let o={duration:220,easing:"ease-in-out"},l={delay:120,duration:160,easing:"ease-out",fill:"backwards"},s=r.offsetHeight,d=n.offsetHeight,c=r.animate([{height:"0px"},{height:`${s}px`}],o);L.current.push(c),L.current.push(r.animate([{opacity:0},{opacity:1}],l),n.animate([{height:"0px"},{height:`${d}px`}],o),n.animate([{opacity:0},{opacity:1}],l),a.animate([{gap:"0px"},{gap:"24px"}],o),i.animate([{gap:"0px"},{gap:"16px"}],o));let p=$.current;ut(e,t,p?p.getBoundingClientRect().width/(p.offsetWidth||1):1,220,L.current),c.onfinish=()=>{z.current===u&&(z.current=null,j(null))}},[K,u]),se(()=>{N.current=ct(E.current)});let _=e=>{s&&(!V&&!F&&(z.current=null,j(e.id)),s(e))};return ye("div",{ref:$,role:"region","aria-label":"Taste collection","aria-busy":o,"data-popmelt-taste":!0,"data-popmelt-font":"sans","data-popmelt-theme":e,style:{width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:16,padding:"16px 16px 0",border:`1px solid ${k.border}`,borderRadius:20,background:k.surface,backdropFilter:"blur(59.5px)",WebkitBackdropFilter:"blur(59.5px)",color:k.secondary,fontFamily:l,fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden",...x,...o&&O?{height:O}:{}},children:[ve("style",{children:`\n [data-popmelt-taste] [data-taste-thumbnail] { background: ${k.control}; }\n [data-popmelt-taste] [data-taste-preview-art] { transition: opacity 120ms ease; }\n [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-preview-art] { opacity: .2; }\n [data-popmelt-taste] [data-taste-name] { color: ${k.secondary}; transition: color 120ms ease; }\n [data-popmelt-taste] [data-taste-metadata] { color: ${k.muted}; transition: color 120ms ease; }\n [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-name] { color: ${k.primary}; }\n [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-metadata] { color: ${k.secondary}; }\n [data-popmelt-taste] [data-taste-detail-chevron] { display: inline-flex; width: 0; flex: 0 0 auto; overflow: hidden; opacity: 0; color: ${k.primary}; transform: translateX(-6px); transition: width 160ms ease, opacity 120ms ease, transform 160ms ease; }\n [data-popmelt-taste] [data-taste-details]:is(:hover, :focus-visible) [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: translateX(0); }\n [data-popmelt-taste] [data-taste-add] { background: ${k.actionSurface}; color: ${k.actionForeground}; opacity: 0; pointer-events: none; transition: opacity 120ms ease, background-color 120ms ease; }\n [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-add] { opacity: 1; }\n [data-popmelt-taste] [data-taste-thumbnail]:hover [data-taste-add] { background: ${k.actionHover}; }\n [data-popmelt-taste] button:focus-visible { outline: 2px solid ${k.primary}; outline-offset: 2px; }\n [data-popmelt-taste] button[data-taste-close]:hover { background: ${k.hoverSurface} !important; color: ${k.primary} !important; }\n [data-taste-refresh-icon] { opacity: 0; transform: translateX(-4px); transition: opacity 120ms ease, transform 160ms ease; }\n [data-taste-refresh]:not(:disabled):is(:hover, :focus-visible) [data-taste-refresh-icon] { opacity: 1; transform: translateX(0); }\n @media (hover: none) { [data-taste-refresh]:not(:disabled) [data-taste-refresh-icon] { opacity: 1; transform: none; } }\n @media (prefers-reduced-motion: reduce) { [data-taste-refresh-icon] { transition: none; transform: none; } }\n @media (hover: none) { [data-popmelt-taste] [data-taste-add] { opacity: 1; } }\n @media (hover: none) { [data-popmelt-taste] [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: none; } }\n @media (prefers-reduced-motion: reduce) { [data-popmelt-taste] :is([data-taste-name], [data-taste-metadata], [data-taste-add], [data-taste-detail-chevron]) { transition: none; } }\n `}),ye("div",{"data-taste-collection-header":!0,style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[ye("button",{type:"button","data-taste-refresh":!0,"aria-label":"Refresh taste collection",onClick:()=>{W($.current?.offsetHeight),a?.()},disabled:!a||i||o,style:{display:"inline-flex",alignItems:"center",gap:4,padding:0,border:0,borderRadius:4,background:"transparent",font:"inherit",cursor:a&&!i?"pointer":"default",color:k.primary,fontSize:14,fontWeight:600,letterSpacing:"-.14px"},children:[ve(m,{size:16,"aria-hidden":"true",style:{transform:"scaleY(-1)"}}),"Taste",ve(b,{"data-taste-refresh-icon":!0,size:12,"aria-hidden":"true",style:{marginLeft:2}})]}),ve("button",{type:"button","data-taste-close":!0,"aria-label":"Back to settings",onClick:n,style:{marginLeft:"auto",border:0,padding:0,width:20,height:20,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:4,background:"transparent",color:k.muted,cursor:"pointer"},children:ve(d,{size:16})})]}),ye("div",{"data-taste-scroll":!0,onScroll:e=>C(e.currentTarget.scrollTop>0),style:{display:"flex",flexDirection:"column",gap:24,minHeight:0,overflowY:"auto",scrollbarGutter:"stable",marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16,paddingBottom:20,flex:"1 1 auto",maskImage:S?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:S?"linear-gradient(to bottom, transparent, #000 16px)":void 0,overscrollBehavior:"contain"},children:[ye("div",{"data-taste-content":!0,ref:R,style:{display:"flex",flexDirection:"column",gap:U&&"collapse"!==F?.phase?24:0,transition:F?"gap 200ms ease-in-out":void 0},children:[y,U&&ye("section",{ref:P,"aria-label":"Active taste","data-taste-removal-phase":F?.phase,"aria-hidden":!!F,inert:!!F,style:{display:"flex",flexDirection:"column",gap:8,flexShrink:0,minHeight:0,height:F?"collapse"===F.phase?0:F.activeHeight:void 0,opacity:F?0:1,overflow:F||K?"hidden":void 0,pointerEvents:F?"none":void 0,transition:F?"opacity 100ms ease-out, height 200ms ease-in-out":void 0},children:[ve("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",color:k.secondary},children:"Active"}),ve("ul",{style:{listStyle:"none",padding:0,margin:0},children:ve(pt,{entry:U,active:!0,featured:!0,previewBackground:k.control,onRemove:K?void 0:e=>{if(!c||q.current)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void c(e);let t={id:e.id,timers:[],cleanup:()=>{}};for(let e of I.current)e.cancel();I.current=[],q.current=t,B({entry:e,phase:"fade",activeHeight:P.current?.offsetHeight??0,headingHeight:M.current?.offsetHeight??0});let r=!1,n=!1,a=!1,i=()=>{if(r&&n&&q.current===t){for(let e of t.timers)clearTimeout(e);t.cleanup(),q.current=null,B(null)}},o=R.current,l=e=>{!a||e.target!==o||"gap"!==e.propertyName||(r=!0,i())};o?.addEventListener("transitionend",l),t.cleanup=()=>o?.removeEventListener("transitionend",l),t.timers.push(setTimeout(()=>{q.current===t&&(a=!0,T.current={returningId:e.id,positions:ct(E.current)},B(t=>t?.entry.id===e.id?{...t,phase:"collapse"}:t))},100)),t.timers.push(setTimeout(()=>{r=!0,i()},600));try{Promise.resolve(c(e)).then(()=>{n=!0,i()},()=>{n=!0,i()})}catch{n=!0,i()}},onOpenDetails:h,onPrefetchDetails:g})})]}),ye("div",{"data-taste-collections":!0,style:{display:"flex",flexDirection:"column",gap:U&&"collapse"!==F?.phase?16:0,transition:F?"gap 200ms ease-in-out":void 0},children:[U&&ve("h3",{ref:M,"data-taste-collections-heading":!0,style:{margin:0,font:"inherit",fontWeight:600,lineHeight:"12px",color:"light"===e?"#555555":"#aaaaaa",flexShrink:0,height:F?"collapse"===F.phase?0:F.headingHeight:void 0,opacity:"collapse"===F?.phase?0:1,overflow:F||K?"hidden":void 0,transition:F?"height 200ms ease-in-out, opacity 100ms ease-out":void 0},children:"Collections"}),ve("div",{"data-taste-catalogs":!0,ref:E,style:{display:"flex",flexDirection:"column",gap:24},children:[{label:"Private",entries:X},{label:"Public",entries:J}].map(({label:e,entries:t})=>ye("section",{"aria-label":`${e} tastes`,style:{display:"flex",flexDirection:"column",gap:8},children:[ye("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px"},children:[ve("span",{children:e})," ",ve("span",{"data-taste-count":!0,style:{color:k.muted},children:t.length})]}),t.length?ve("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8},children:t.map(e=>ve(pt,{entry:e,onAdd:F||!s?void 0:_,onRemove:c,active:!1,hasActiveTaste:!!V&&!Y,onOpenDetails:h,onPrefetchDetails:g},e.id))}):ve("span",{style:{color:k.muted},children:"Private"===e&&w?w:`No ${e.toLowerCase()} results found.`})]},e))})]})]}),f&&ve("span",{role:"status",children:f}),v]})]})}function gt({entry:e,theme:t,active:r,onBack:n,onToggle:a,notice:i,style:o,facts:s,summaryNotice:u,drilldown:p,onOpenFact:h}){let g=A[t],[f,b]=oe(!1),w=ie(null),x=pe(p)?p.key:null;return de(()=>{w.current&&(w.current.scrollTop=0),b(!1)},[e.id,x]),ye("div",{role:"region","aria-label":`${e.name} taste details`,"data-taste-detail":!0,"data-popmelt-font":"sans","data-popmelt-theme":t,style:{display:"flex",flexDirection:"column",gap:16,padding:"20px 16px 0",borderRadius:20,border:`1px solid ${g.border}`,background:g.surface,color:g.primary,fontFamily:l,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,boxSizing:"border-box",overflow:"hidden",...o},children:[ve("style",{children:`\n [data-taste-detail] > div { flex-shrink: 0; }\n [data-taste-detail] [data-taste-detail-body] { flex-shrink: 1; }\n [data-taste-detail-body] > * { flex-shrink: 0; }\n [data-taste-detail] button:focus-visible { outline: 2px solid ${g.primary}; outline-offset: 3px; }\n [data-taste-detail] [data-detail-back]:hover { color: ${g.primary} !important; }\n [data-taste-detail] [data-detail-cta]:enabled:hover { background: ${g.actionHover} !important; }\n [data-taste-fact]:hover dt, [data-taste-fact]:focus-within dt { color: ${g.primary} !important; }\n [data-taste-fact]:hover button, [data-taste-fact] button:focus-visible { background: ${g.control} !important; }\n [data-taste-fact] button::after { content: ''; position: absolute; inset: 0; }\n [data-taste-fact] button svg { opacity: 0; width: 0; transition: opacity 120ms, width 120ms; }\n [data-taste-fact]:hover button svg, [data-taste-fact] button:focus-visible svg { opacity: 1; width: 14px; }\n `}),ye("div",{"data-taste-detail-header":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[ye("button",{type:"button","data-detail-back":!0,"aria-label":"Back to taste collection",onClick:n,style:{display:"flex",alignItems:"center",gap:2,alignSelf:"flex-start",padding:0,border:0,background:"transparent",color:g.secondary,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,cursor:"pointer"},children:[ve(c,{size:16,color:g.primary}),ve(m,{size:14,style:{transform:"scaleY(-1)"}}),e.name]}),ve("button",{type:"button","data-detail-cta":!0,"aria-label":`${r?"Remove":"Add"} ${e.name}`,"aria-pressed":r,disabled:!a,onClick:a,style:{display:"flex",alignItems:"center",gap:3,padding:r?"4px 9px 4px 10px":"4px 10px 4px 6px",border:0,borderRadius:8,background:g.actionSurface,color:g.actionForeground,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,opacity:a?1:.5,cursor:a?"pointer":"default"},children:ye(be,r?{children:["Remove",ve(d,{size:12})]}:{children:[ve(v,{size:12}),"Add"]})})]}),ve("div",{"data-taste-detail-body":!0,ref:w,onScroll:e=>b(e.currentTarget.scrollTop>0),style:{display:"flex",flexDirection:"column",gap:12,flex:"1 1 auto",minHeight:0,overflowY:"auto",marginLeft:-16,marginRight:-16,padding:"0 16px 16px",overscrollBehavior:"contain",maskImage:f?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:f?"linear-gradient(to bottom, transparent, #000 16px)":void 0},children:p??ye(be,{children:[ve("div",{style:{display:"flex",flexDirection:"column",gap:8},children:ve(st,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,background:g.control},e.id)}),ve("dl",{style:{display:"flex",flexDirection:"column",gap:0,padding:"0 4px",margin:"-4px 0"},children:[...e.metadata?[{key:"version",label:"Version",value:e.metadata.value}]:[],...(s??[]).filter(e=>"version"!==e.key)].map(({key:e,label:t,value:r})=>ye("div",{"data-taste-fact":!0,style:{position:"relative",display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,padding:"4px 0"},children:[ve("dt",{style:{color:g.secondary},children:t}),ve("dd",{"aria-label":`${t}: ${r}`,style:{margin:0,fontSize:14,fontWeight:500,fontVariantNumeric:"tabular-nums"},children:h?ye("button",{type:"button","aria-label":`View ${t}`,onClick:()=>h(e),style:{display:"flex",alignItems:"center",gap:2,border:0,padding:"2px 4px 2px 8px",borderRadius:8,color:"inherit",background:"transparent",font:"inherit",cursor:"pointer"},children:[r,ve(y,{size:14})]}):r})]},e))}),u&&ve("div",{role:"status",style:{color:g.secondary,padding:"0 4px"},children:u}),i&&ve("div",{role:"status",style:{color:g.secondary,padding:"0 4px"},children:i})]})})]})}var ft={position:"relative",margin:0,font:"inherit",fontWeight:"inherit",fontSize:12,display:"flex",alignItems:"center",padding:"4px 4px"};function mt({last:e,color:t,left:r=4}){return ye("span",{"aria-hidden":"true","data-taste-nested-branch":!0,style:{position:"absolute",left:r,top:0,bottom:0,pointerEvents:"none",color:t},children:[!e&&ve("span",{"data-taste-nested-trunk":!0,style:{position:"absolute",top:0,bottom:0,borderLeft:"1px solid currentColor"}}),ve("span",{"data-taste-nested-elbow":!0,style:{position:"absolute",top:0,bottom:"calc(50% - 0.5px)",width:8,borderLeft:"1px solid currentColor",borderBottom:"1px solid currentColor",borderBottomLeftRadius:6,boxSizing:"border-box"}})]})}var vt=e=>{let t=e.replace(/([a-z])([A-Z])/g,"$1 $2");return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()};function yt(e,t,r=!1,n=!1,a=!1){let i=new Map;for(let a of e){let e=a.path.slice(1).filter(e=>"$value"!==e);n&&(e=e.slice(1).filter(e=>"$children"!==e)),t&&"copy"===e[0]&&(e=e.slice(1)),t&&"slots"===e[0]&&(e=e.slice(1));let o=e.length-1;if(r&&(o=Math.min(1,o)),t){let t=e.findIndex(e=>["budget","rules","template"].includes(e));t>=0&&(o=t)}let l=e.slice(0,o),s=e.slice(o);t&&"budget"===s[0]&&s.shift();let d=s.map(e=>/^\d+$/.test(e)?String(Number(e)+1):vt(e)).join(" · "),c=JSON.stringify(l),u=i.get(c)??{heading:l.map(e=>t||r?vt(e):e).join(" → "),rows:[]};u.rows.push({...a,label:d}),i.set(c,u)}let o=[...i.values()];if(n){let e=["default","hover","active","disabled"],t=new Map,r=r=>{let n=r.split(" → "),a=n.pop()??"",i=n.join(" → ");t.has(i)||t.set(i,t.size);let o=e.indexOf(a);return[t.get(i),o<0?e.length:o]},n=new Map(o.map(e=>[e,r(e.heading)]));o.sort((e,t)=>{let[r=0,a=0]=n.get(e),[i=0,o=0]=n.get(t);return r-i||a-o})}return o.map(e=>e.rows.length>1||(n||a)&&e.heading?e:{heading:"",rows:e.rows.map(t=>({...t,label:[e.heading,t.label].filter(Boolean).join(" · ")}))})}var bt=["Palette","Semantic colors","Typography","Spacing & layout","Radii & borders","Shadows & effects","Motion","Other"],wt=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{},xt=(e,t)=>e.localeCompare(t,"en",{numeric:!0,sensitivity:"base"}),kt=new Map([["none",0],["xs",1],["sm",2],["base",3],["md",4],["lg",5],["xl",6]]),St=new Map([["xs",0],["sm",1],["base",2],["lg",3],["xl",4]]);function Ct(e){return/^(text|space|spacing|radius|radii|shadow)(?:-|$)/i.exec(e)?.[1]?.toLowerCase()??null}function $t(e,t){let r=e.toLowerCase().slice(t.length).replace(/^-/,"");if("space"===t||"spacing"===t)return"px"===r?.25:/^\d+(?:\.\d+)?$/.test(r)?Number(r):null;if("full"===r&&("radius"===t||"radii"===t))return 100;if(!r)return"text"===t?null:3;let n=/^(\d+)xs$/.exec(r),a=/^(\d+)xl$/.exec(r)??/^(x{2,})l$/.exec(r);return"text"===t?n?1-Number(n[1]):"xxs"===r?-1:a?3+(/^x/.test(a[1])?a[1].length:Number(a[1])):St.get(r)??null:n?2-Number(n[1]):"xxs"===r?0:a?5+(/^x/.test(a[1])?a[1].length:Number(a[1])):kt.get(r)??null}function Rt(e,t,r){let n=wt(t),a=String(n.$type??"").toLowerCase(),i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=n.$value??t,l=wt(o),s=/^(?:background|foreground|primary|secondary|accent|muted|card|popover|sidebar|input|ring|border|destructive|success|warning|info|surface|text|chart)(?:-|$)/.test(i);return"color"===a||O(o,r)?s?1:0:/^(typography|fontfamily|fontweight|fontstyle)$/.test(a)?2:/^(shadow|gradient|filter)$/.test(a)?5:/^(duration|cubicbezier|transition)$/.test(a)?6:/^(border|radius)$/.test(a)?4:/^(spacing|layout)$/.test(a)?3:a&&!["dimension","number","string","composite"].includes(a)?7:/^(font|text|heading|body|line-height|letter-spacing|typography)(?:-|$)/.test(i)||"fontFamily"in l||"fontSize"in l?2:/^(space|spacing|gap|padding|margin|layout|container|width|height|size|breakpoint)(?:-|$)/.test(i)||"maxWidth"in l?3:/^(radius|radii|border|stroke)(?:-|$)/.test(i)?4:/^(shadow|elevation|blur|opacity|gradient|filter)(?:-|$)/.test(i)?5:/^(transition|duration|easing|animation|motion)(?:-|$)/.test(i)?6:7}function Et({taste:e,style:t,onClick:r,children:n}){let a=rt(e?.states?.button,!0,320);return ve("button",{type:"button",...a.handlers,onClick:r,style:{...Pe(je(t)),...Oe(e?.detail?.button,320),...a.style},children:n})}var Tt={textfield:"input","text-field":"input","radio-group":"radio","toggle-group":"toggle","alert-dialog":"dialog",drawer:"sheet","hover-card":"popover","context-menu":"dropdown-menu","navigation-menu":"menubar","data-table":"table","input-otp":"otp","scroll-area":"scroll","date-picker":"calendar",collapsible:"accordion"},It=["button","card","input","textarea","badge","avatar","label","separator","checkbox","radio","switch","toggle","slider","progress","skeleton","tabs","accordion","select","combobox","dropdown-menu","menubar","dialog","sheet","popover","tooltip","alert","toast","table","breadcrumb","pagination","calendar","command","form","otp","scroll","chart"];function Nt(e){let t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Tt[t]??t;return It.includes(r)?r:void 0}var At=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{};function Lt(e,t){let r=(e,n=0)=>{if(n>12)return;if(e&&"object"==typeof e)return r(At(e).$value??At(e).ref,n+1);if("string"!=typeof e)return e;let a=e.trim();return Object.hasOwn(t,a)?r(t[a],n+1):a.replace(/var\(\s*(?:--|principles\.)([\w-]+)\s*\)|\{(?:principles\.)?([\w-]+)\}/g,(e,a,i)=>String(r(t[a??i],n+1)??""))},n=Object.fromEntries(Object.entries(At(e)).slice(0,80).map(([e,t])=>[e,r(t)])),a=Oe(Me({card:n})?.card,320);return["flex","inline-flex","grid","block","inline-block"].includes(String(n.display))&&(a.display=n.display),["row","column","row-reverse","column-reverse"].includes(String(n.flexDirection))&&(a.flexDirection=n.flexDirection),a}function zt({kind:e,style:t,handlers:r,definition:n,tokens:a,taste:i}){let o=he(),[l,c]=oe(0),[u,p]=oe(!1),[h,g]=oe(!0),[f,m]=oe(60),[v,b]=oe(""),w=At(At(n).$value),x=At(w.$children??At(n).$children),R=(e,t)=>{let r=At(x[e]),n=At(r.$value??r);return{...Lt(n.default,a),...Lt(t?n[t]:void 0,a)}},E=e=>e?Lt(w.checked??w.selected??w.active,a):{},T={boxSizing:"border-box",maxWidth:"86%",font:"inherit",...Oe(i?.detail?.body,320),...t},I={padding:"5cqw",...T,width:"82%"},N={font:"inherit",color:"inherit",background:"transparent",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:"1.5cqw 3cqw",cursor:"pointer"},A={display:"flex",flexDirection:"column",gap:"3cqw"},L={size:"1em","aria-hidden":!0},z=(e,t,r={})=>ve(Et,{taste:i,onClick:t,style:{...N,...r},children:e},e),D=ve("strong",{style:{...Oe(i?.detail?.heading,320),...R("title")},children:"A little space"}),j=ve("span",{style:{fontSize:"0.85em",...Oe(i?.detail?.body,320),...R("description")},children:"Make something your own."}),P={...r,"data-specimen-kind":e};switch(e){case"button":return ve("button",{...P,type:"button",style:{...T,cursor:"pointer"},children:"Button"});case"input":return ve("input",{...P,"aria-label":"Preview input",defaultValue:"A fresh start",style:{...T,width:"76%",outline:"none"}});case"textarea":return ve("textarea",{...P,"aria-label":"Preview textarea",defaultValue:"A little space for your ideas.",rows:3,style:{...T,width:"76%",resize:"none",outline:"none"}});case"card":return ye("div",{...P,style:{...I,...A},children:[D,j,z("Get started",()=>g(!h),R("button"))]});case"badge":return ve("span",{...P,style:T,children:"New"});case"avatar":return ve("div",{...P,"aria-label":"Preview avatar",style:{...T,width:"18cqw",height:"18cqw",display:"grid",placeItems:"center"},children:ve($,{...L})});case"label":return ve("label",{...P,style:T,children:"Project name"});case"separator":return ve("div",{...P,role:"separator",style:{...T,width:"76%",padding:0,...R("separator")}});case"checkbox":return ye("label",{...P,style:{...T,display:"flex",gap:"3cqw",alignItems:"center"},children:[ve("input",{type:"checkbox",checked:h,onChange:e=>g(e.target.checked),style:{width:"5cqw",height:"5cqw",...R("indicator",h?"checked":void 0)}}),"Stay inspired"]});case"radio":return ve("div",{...P,role:"radiogroup","aria-label":"Preview options",style:{...T,...A},children:["Personal","Team"].map((e,t)=>ye("label",{style:{display:"flex",gap:"3cqw",...R("item",l===t?"checked":void 0)},children:[ve("input",{name:o,type:"radio",checked:l===t,onChange:()=>c(t)}),e]},e))});case"switch":return ve("button",{...P,type:"button",role:"switch","aria-label":"Preview switch","aria-checked":h,onClick:()=>g(!h),style:{...T,width:"18cqw",padding:"1.5cqw",cursor:"pointer",...E(h)},children:ve("span",{style:{display:"block",width:"6cqw",height:"6cqw",marginLeft:h?"auto":0,...R("thumb",h?"checked":void 0)}})});case"toggle":return ye("button",{...P,type:"button","aria-pressed":h,onClick:()=>g(!h),style:{...T,cursor:"pointer",...E(h)},children:["Bold ",h&&ve(C,{...L})]});case"slider":return ve("input",{...P,type:"range","aria-label":"Preview slider",value:f,onChange:e=>m(Number(e.target.value)),style:{...T,width:"76%"}});case"progress":return ve("div",{...P,role:"progressbar","aria-label":"Preview progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":60,style:{...T,width:"76%",height:"4cqw",padding:0,overflow:"hidden"},children:ve("div",{style:{width:"60%",height:"100%",...R("indicator")}})});case"skeleton":return ve("div",{...P,"aria-label":"Preview loading placeholder",style:{...T,width:"76%",height:"22cqw"}});case"tabs":return ye("div",{...P,style:I,children:[ve("div",{role:"tablist","aria-label":"Preview tabs",style:{display:"flex",gap:"2cqw",...R("list")},children:["Overview","Activity"].map((e,t)=>ve("button",{type:"button",role:"tab","aria-selected":l===t,onClick:()=>c(t),onKeyDown:e=>{("ArrowLeft"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),c(1-l))},style:{...N,...R("trigger",l===t?"active":void 0)},children:e},e))}),ve("div",{role:"tabpanel",style:{paddingTop:"4cqw",...R("content")},children:0===l?"Your next big idea starts here.":"All caught up."})]});case"accordion":return ve("div",{...P,style:I,children:["What is included?","Can I make it mine?"].map((e,t)=>ye("div",{style:R("item"),children:[ye("button",{type:"button","aria-expanded":u&&l===t,onClick:()=>{c(t),p(!(u&&l===t))},style:{...N,width:"100%",display:"flex",justifyContent:"space-between",...Oe(i?.detail?.heading,320),...R("trigger")},children:[e,ve(S,{...L})]}),u&&l===t&&ve("div",{style:{padding:"3cqw",...Oe(i?.detail?.body,320),...R("content")},children:"Everything you need to get started."})]},e))});case"select":return ve("select",{...P,"aria-label":"Preview select",value:l,onChange:e=>c(Number(e.target.value)),style:T,children:["Choose a project","Personal","Team"].map((e,t)=>ve("option",{value:t,children:e},e))});case"combobox":case"command":return ye("div",{...P,style:{...I,...A},children:[ye("label",{style:{display:"flex",alignItems:"center",gap:"2cqw"},children:[ve(s,{...L}),ve("input",{"aria-label":"Search preview options",value:v,onChange:e=>b(e.target.value),placeholder:"Search projects…",style:{...N,minWidth:0,width:"100%",...R("input")}})]}),["Personal","Team","Archive"].filter(e=>e.toLowerCase().includes(v.toLowerCase())).map(e=>z(e,()=>b(e),R("item"))),!["Personal","Team","Archive"].some(e=>e.toLowerCase().includes(v.toLowerCase()))&&ve("span",{children:"No results"})]});case"dropdown-menu":case"menubar":return ye("div",{...P,style:{...I,...A},children:[z("Options ▾",()=>p(!u),R("trigger")),u&&ve("div",{style:{...A,...R("content")},children:["New project","Duplicate","Archive"].map((e,t)=>z(`${l===t?"✓ ":""}${e}`,()=>{c(t),p(!1)},R("item")))})]});case"dialog":case"sheet":return ve("div",{...P,style:{...I,...A,..."sheet"===e?{marginLeft:"auto",maxWidth:"65%",minHeight:"42cqw"}:{},...R("content")},children:ye(be,u?{children:[D,j,z("Done",()=>p(!1),R("button"))]}:{children:[D,j,z("Open preview",()=>p(!0),R("trigger"))]})});case"popover":case"tooltip":return ye("div",{...P,style:{...T,...A},children:[ve("button",{type:"button",onClick:()=>p(!u),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),onFocus:()=>p(!0),onBlur:()=>p(!1),style:{...N,...R("trigger")},children:"Learn more"}),u&&ve("span",{role:"tooltip",style:R("content"),children:"A little room for your ideas."})]});case"alert":case"toast":return ye("div",{...P,role:"status",style:{...I,display:"flex",gap:"3cqw",alignItems:"center"},children:[ve(k,{...L}),ye("div",{style:A,children:[ve("strong",{style:R("title"),children:h?"Changes saved":"Ready when you are"}),ve("span",{style:R("description"),children:"Your project is up to date."})]}),"toast"===e&&ve("button",{type:"button","aria-label":"Dismiss preview toast",onClick:()=>g(!h),style:N,children:ve(d,{...L})})]});case"table":return ve("div",{...P,style:{...I,padding:0,overflow:"hidden",textAlign:"left"},children:ye("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,font:"inherit",color:"inherit"},children:[ve("thead",{style:R("header"),children:ve("tr",{children:["Project","Status"].map(e=>ve("th",{style:{padding:"2cqw",...R("head")},children:e},e))})}),ve("tbody",{children:["Personal","Team"].map(e=>ye("tr",{style:R("row"),children:[ve("td",{style:{padding:"2cqw",...R("cell")},children:e}),ve("td",{style:{padding:"2cqw",...R("cell")},children:"Active"})]},e))})]})});case"breadcrumb":return ye("nav",{...P,"aria-label":"Preview breadcrumb",style:{...T,display:"flex",gap:"2cqw",alignItems:"center"},children:[z("Home",()=>c(0),R("link")),ve(y,{...L}),ve("span",{"aria-current":"page",style:R("page"),children:l?"Settings":"Projects"})]});case"pagination":return ve("nav",{...P,"aria-label":"Preview pagination",style:{...T,display:"flex",gap:"2cqw"},children:[0,1,2].map(e=>ve("button",{type:"button","aria-current":l===e?"page":void 0,onClick:()=>c(e),style:{...N,...R("item",l===e?"active":void 0)},children:e+1},e))});case"calendar":return ye("div",{...P,style:{...I,padding:"2cqw",fontSize:"3.5cqw"},children:[ve("div",{style:{textAlign:"center",...R("caption")},children:"September 2026"}),ye("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.5cqw"},children:[["M","T","W","T","F","S","S"].map((e,t)=>ve("span",{style:{textAlign:"center",...R("head")},children:e},t)),ve("span",{"aria-hidden":"true"}),Array.from({length:30},(e,t)=>ve("button",{type:"button","aria-label":`September ${t+1}`,"aria-pressed":l===t,onClick:()=>c(t),style:{...N,border:0,padding:0,...R("day",l===t?"selected":void 0)},children:t+1},t))]})]});case"form":return ye("form",{...P,onSubmit:e=>{e.preventDefault(),p(!0)},style:{...I,...A},children:[ve("label",{htmlFor:o,style:R("label"),children:"Project name"}),ve("input",{id:o,required:!0,placeholder:"A fresh start",style:{...N,...R("input")}}),ve("button",{type:"submit",style:{...N,...R("button")},children:"Create project"}),u&&ve("span",{role:"status",children:"Project created (preview)"})]});case"otp":return ve("div",{...P,style:{...T,display:"flex",gap:"1cqw"},children:[0,1,2,3].map(e=>ve("input",{"aria-label":`Preview digit ${e+1}`,inputMode:"numeric",maxLength:1,pattern:"[0-9]",style:{...N,width:"8cqw",padding:"2cqw 0",textAlign:"center",...R("slot")}},e))});case"scroll":return ve("div",{...P,tabIndex:0,"aria-label":"Preview scroll area",style:{...I,maxHeight:"35cqw",overflow:"auto",overscrollBehavior:"contain"},children:Array.from({length:12},(e,t)=>ye("div",{style:{padding:"2cqw",...R("item")},children:["Project ",t+1]},t))});case"chart":return ye("figure",{...P,"aria-label":"Preview project activity chart",style:{...I,margin:0},children:[ve("figcaption",{style:R("title"),children:"Activity"}),ve("div",{style:{display:"flex",alignItems:"end",gap:"3cqw",height:"25cqw"},children:[35,60,45,85,70].map((e,t)=>ve("div",{title:`${e} projects`,style:{flex:1,height:`${e}%`,...R("bar")}},t))})]});default:return null}}var Dt=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{};function jt(e,t,r){return!!r&&!!Nt(e)&&!!Object.keys(Dt(Dt(Dt(t).$value).default)).length}function Pt(e,t,r=[]){if(t.length>12||r.length>=500)return r;if(t.includes("$value")&&["string","number","boolean"].includes(typeof e))r.push({path:t,value:e});else if(e&&"object"==typeof e)for(let[n,a]of Object.entries(e))["__proto__","constructor","prototype","$type"].includes(n)||Pt(a,[...t,n],r);return r}function Mt({bridgeUrl:e,id:t,collection:r,section:n,theme:a,onPreview:i,onReconnect:o,cache:l,query:s=""}){let d=A[a],[c,u]=oe(),[p,h]=oe(""),[g,f]=oe(!1),[m,v]=oe(!1),[b,w]=oe(null),x=ie(null),k=`${e??""}/cloud-taste/definition?id=${encodeURIComponent(t)}&collection=${encodeURIComponent(r)}`;async function S(e,t,r=!1){if(!c||m)return;let n=x.current;if(n&&!n.signal.aborted){v(!0),h("");try{let a=await L(k,{signal:n.signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,value:t,reset:r,sourceHash:c.hash,expectedRevision:c.revision})});if(!a.ok)throw new Error("Save failed. Your remote taste is unchanged. Reopen this section to reload before trying again.");let o=await a.json();if(n.signal.aborted)return;l?.put(k,o),u(o);let s=et(o.preview);s&&i(s)}catch(e){l?.invalidate(k),n.signal.aborted||h(e.message)}finally{n.signal.aborted||v(!1)}}}de(()=>{let e=new AbortController;return x.current=e,u(void 0),h(""),f(!1),w(null),(l?l.read(k):L(k,{signal:e.signal})).then(async t=>{if(!t.ok){let r=await t.json().catch(()=>null),n=function(e,t){return"reconnect_required"===t?{message:"Reconnect to grant read-only taste inspection access.",reconnect:!0}:404===e?{message:"Taste inspection is not available on the running backend yet. The bridge and staging rollout need to be updated; reconnecting will not fix this.",reconnect:!1}:401===e||403===e?{message:"This browser does not have permission to inspect tastes through the local bridge. Check the project connection.",reconnect:!1}:{message:"Taste definitions are temporarily unavailable. Please try again after the backend is ready.",reconnect:!1}}(t.status,r?.error);return void(e.signal.aborted||(h(n.message),f(n.reconnect)))}let r=await t.json();if(!r.sections||!Array.isArray(r.overrides))throw new Error("Invalid taste definition");if(!e.signal.aborted){u(r);let e=et(r.preview);e&&i(e)}}).catch(t=>{e.signal.aborted||h(t instanceof TypeError?"Could not reach the local bridge. Check that the project is running, then try again.":"The backend returned an invalid taste definition. Please try again after the backend is updated.")}),()=>e.abort()},[k,i,l]);let C="tokens"===n||"principles"===n?"principles":"visual-directions"===n?"assets":"copy-guidance"===n?"content":n,$=s.trim().toLocaleLowerCase(),R=e=>!$||String(e).toLocaleLowerCase().includes($),E=Object.entries(Dt(c?.sections[C])),T="principles"===C,I=new Map(E.map(([e,t])=>[e,T?Rt(e,t,Dt(c?.sections.principles)):7]));if(T&&E.sort(([e],[t])=>I.get(e)-I.get(t)||function(e,t){let r=Ct(e),n=Ct(t);if(!r||r!==n)return xt(e,t);let a=$t(e,r),i=$t(t,n);return null!==a&&null!==i?a-i||xt(e,t):null!==a?-1:null!==i?1:xt(e,t)}(e,t)),"components"===C){let e=(e,t)=>jt(e,t,et(c?.componentPreviews?.[e]));E.sort(([t,r],[n,a])=>Number(e(n,a))-Number(e(t,r))||t.localeCompare(n,void 0,{sensitivity:"base",numeric:!0}))}let N=E.filter(([e,t])=>R(e)||R(JSON.stringify(t))),z=c?.versions?.filter(e=>R(`${e.version} ${e.saved_at??"Not recorded"} ${e.saved_at?new Date(e.saved_at).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}`));return"version"===n?ve("div",{"data-taste-versions":!0,children:p?ye("div",{role:"alert",children:[p,g&&ve("div",{style:{marginTop:8},children:ve("button",{type:"button",onClick:o,children:"Reconnect"})})]}):c?"public"===r?ve("div",{children:"Public version history is not available yet."}):c.versions?ye("dl",{style:{margin:0},children:[z?.map(e=>ye("div",{style:{display:"flex",justifyContent:"space-between",gap:16,padding:"8px 4px"},children:[ve("dt",{children:e.version}),ve("dd",{style:{margin:0,color:d.secondary},children:e.saved_at?ve("time",{dateTime:e.saved_at,title:new Date(e.saved_at).toLocaleString(),children:new Date(e.saved_at).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):"Not recorded"})]},e.version)),!c.versions.length&&ve("div",{children:"No version history recorded."}),!!c.versions.length&&!z?.length&&ve("div",{role:"status",children:"No matching versions."})]}):ve("div",{role:"status",children:"Version history is currently unavailable."}):ve("div",{role:"status",children:"Loading versions…"})}):ye("div",{"data-taste-drilldown":!0,style:{display:"flex",flexDirection:"column",gap:0,fontVariantNumeric:"tabular-nums"},children:[ve("style",{children:`\n [data-preview-zoom] + [data-taste-component-header] { margin-top: -4px; }\n [data-taste-component-header]:hover:not(:disabled), [data-taste-component-header]:focus-visible { color: ${d.primary} !important; }\n [data-taste-component-header]:hover:not(:disabled) svg { background: ${d.control}; }\n [data-taste-value-row]:hover, [data-taste-value-row]:focus-within { color: ${d.primary} !important; }\n [data-taste-token-group]:has(> [data-taste-token-child] [data-taste-value-row]:hover) > [data-taste-token-parent],\n [data-taste-token-parent]:hover,\n [data-taste-token-parent]:hover ~ [data-taste-token-child] [data-taste-value-row] > label { color: ${d.primary} !important; }\n [data-taste-value-row]:hover input, [data-taste-value-row] input:focus { background: ${d.control} !important; }\n [data-taste-value-row]:hover input, [data-taste-value-row]:focus-within input { color: ${d.primary} !important; }\n [data-taste-value-row] input:focus-visible { outline: 1px solid ${d.secondary}; }\n [data-taste-value-row] input { cursor: inherit; }\n [data-taste-value-row] input:not([type="checkbox"]):focus { cursor: text; text-overflow: clip !important; }\n `}),!c&&!p&&ve("div",{role:"status",children:"Loading definitions…"}),p&&ye("div",{role:"alert",style:{color:d.secondary},children:[p,!c&&g&&ve("button",{type:"button",onClick:o,style:{display:"block",marginTop:8},children:"Reconnect"})]}),!!c?.conflicts.length&&ve("div",{role:"status",children:"Some source values changed remotely. Conflicting overrides are not applied; reset or edit them to resolve."}),c&&!N.length&&ve("div",{role:"status",children:$&&E.length?"No matching definitions.":"No definitions in this section."}),N.map(([e,t],r)=>{let a=Pt(t,[C,e]).filter(t=>R(e)||R(t.path.join(" "))||R(JSON.stringify(t.value))),i="components"===C;return T&&a.sort((e,t)=>function(e,t){let r=["fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","color"],n=e=>{let t=r.indexOf(e.at(-1)??"");return t<0?r.length:t};return n(e)-n(t)||xt(e.join("."),t.join("."))}(e.path,t.path)),ye("div",{"data-taste-group-path":JSON.stringify([C,e]),style:{display:"flex",flexDirection:"column",gap:i?8:0,marginBottom:i?8:0},children:[T&&(0===r||I.get(N[r-1][0])!==I.get(e))&&ve("h2",{"data-taste-token-section":!0,style:{font:"inherit",fontWeight:500,color:d.primary,margin:0===r?"0 4px 8px":"16px 4px 8px"},children:bt[I.get(e)]}),i&&ve(Ot,{name:e,definition:t,taste:et(c?.preview),tokens:Dt(c?.sections.principles),recipe:et(c?.componentPreviews?.[e])}),i&&ye("button",{type:"button","data-taste-component-header":!0,disabled:!a.length,onClick:()=>w(b===e?null:e),"aria-expanded":a.length?b===e||!!$:void 0,style:{display:"flex",justifyContent:"space-between",alignItems:"center",border:0,padding:"6px 4px",font:"inherit",background:"transparent",borderRadius:8,color:d.secondary,cursor:a.length?"pointer":"default"},children:[ve("span",{children:e}),!!a.length&&ve(y,{size:14,style:{boxSizing:"content-box",padding:"2px 4px",borderRadius:8,transform:b===e||$?"rotate(90deg)":void 0,transition:"transform 120ms"}})]}),(!i||b===e||!!$)&&yt(a,"copy-guidance"===n,"visual-directions"===n,i,T).map((e,t,r)=>ye("div",{"data-taste-state-group":i?"":void 0,"data-taste-token-group":T&&e.heading?"":void 0,style:{position:"relative",display:"flex",flexDirection:"column",gap:0,paddingLeft:i?12:0},children:[i&&e.heading&&t<r.length-1&&ve("span",{"aria-hidden":"true","data-taste-state-trunk":!0,style:{position:"absolute",left:4,top:-8,bottom:0,borderLeft:"1px solid currentColor",pointerEvents:"none",color:`color-mix(in srgb, ${d.secondary} 40%, ${d.surface})`}}),e.heading&&ye("h3",{"data-taste-token-parent":T?"":void 0,style:{position:"relative",margin:T?0:i?"2px 4px 0":"12px 4px 0",font:"inherit",fontWeight:T?"inherit":500,fontSize:T?12:void 0,color:T?d.secondary:d.primary,display:T?"flex":void 0,alignItems:T?"center":void 0,padding:T?"4px 4px":void 0,...T?ft:{}},children:[i&&ve("span",{"aria-hidden":"true","data-taste-state-connector":!0,style:{position:"absolute",left:-12,top:-10,bottom:"calc(50% - 0.5px)",width:8,borderLeft:"1px solid currentColor",borderBottom:"1px solid currentColor",borderBottomLeftRadius:6,boxSizing:"border-box",pointerEvents:"none",color:`color-mix(in srgb, ${d.secondary} 40%, ${d.surface})`}}),e.heading,T&&ve("span",{"aria-hidden":"true",style:{visibility:"hidden",fontSize:14,padding:"2px 0"},children:" "})]}),e.rows.map((t,r)=>{let n=JSON.stringify(t.path),a=c.overrides.some(e=>JSON.stringify(e.path)===n),o=ve(Wt,{path:t.path,label:t.label,value:t.value,disabled:m,overridden:a,colors:d,componentValue:i,colorTokens:"principles"===C||"components"===C?Dt(c?.sections.principles):void 0,onSave:e=>{S(t.path,e)},onReset:()=>{S(t.path,t.value,!0)}},n);return T&&e.heading?ye("div",{"data-taste-token-child":!0,style:{position:"relative",paddingLeft:12},children:[ve(mt,{last:r===e.rows.length-1,color:`color-mix(in srgb, ${d.secondary} 40%, ${d.surface})`}),o]},n):o})]},t)),!i&&!a.length&&ye("div",{style:{color:d.secondary,padding:"0 4px",overflowWrap:"anywhere"},children:[e,": ",JSON.stringify(t)]})]},e)})]})}function Ot({name:t,definition:r,recipe:n,tokens:a,taste:i}){let o=Nt(t),l=/button/i.test(t)?"button":/input|text.?field|textarea/i.test(t)?"input":"card",s=rt(n?.states?.[l],!0,320);if(!n||!o||!jt(t,r,n))return null;let d={backgroundColor:"transparent",backgroundImage:"none",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:"button"===l?"3cqw 5cqw":16,fontSize:"4.6cqw",lineHeight:"button"===l?1.2:void 0,color:n.foreground,...Oe(i?.detail?.body,320),...Lt(Dt(Dt(r).$value).default,a),...s.style};return ve(e,{children:ve("div",{"aria-label":`${t} style preview`,style:{aspectRatio:"16 / 9",borderRadius:8,background:n.background,display:"grid",placeItems:"center",overflow:"hidden",containerType:"inline-size"},children:ve(zt,{kind:o,style:d,handlers:s.handlers,definition:r,tokens:a,accent:n.accent,taste:i})})})}function Wt({path:e,label:t,value:r,disabled:n,overridden:a,colors:i,onSave:o,onReset:l,colorTokens:s,componentValue:d=!1}){let c=d&&"string"==typeof r?/^var\(principles\.([^,)]+)\)$/.exec(r.trim())?.[1]:void 0,u=c&&s&&Object.hasOwn(s,c)?c:String(r),[p,h]=oe(u),g=ie(null),f=ie(!1),m=s&&"string"==typeof r?O(p,s):void 0;return de(()=>h(u),[u]),ye("div",{"data-taste-value-row":!0,"data-taste-path":JSON.stringify(e),onClick:e=>{n||e.target instanceof Element&&e.target.closest("input, button")||(g.current?.focus({preventScroll:!0}),"boolean"==typeof r&&g.current?.click())},style:{display:"flex",alignItems:"center",gap:8,color:i.secondary,padding:"4px 4px",cursor:n?"default":"pointer"},children:[ve("label",{style:{flex:1,minWidth:0,overflowWrap:"anywhere",fontSize:12},children:t}),"boolean"==typeof r?ve("input",{ref:g,"aria-label":t,type:"checkbox",checked:r,disabled:n,onChange:e=>o(e.target.checked)}):ye("span",{"data-taste-value-field":!0,style:{position:"relative",display:"inline-grid",maxWidth:"52%",marginRight:m?0:-8,minWidth:0},children:[ve("span",{"aria-hidden":"true",style:{visibility:"hidden",whiteSpace:"pre",overflow:"hidden",font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14,padding:"2px 8px"},children:p||" "}),ve("input",{ref:g,"data-taste-value-input":!0,"aria-label":t,value:p,title:p,disabled:n,onChange:e=>h(e.target.value),onBlur:()=>{f.current?f.current=!1:function(){let e="number"==typeof r?Number(p):d&&s&&Object.hasOwn(s,p.trim())?`var(principles.${p.trim()})`:p;("number"!=typeof e||p.trim()&&Number.isFinite(e))&&e!==r&&p!==u?o(e):h(u)}()},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(f.current=!0,h(u),e.preventDefault(),e.stopPropagation(),e.currentTarget.blur())},style:{position:"absolute",inset:0,boxSizing:"border-box",width:"100%",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",border:0,background:"transparent",borderRadius:8,padding:"2px 8px",textAlign:"right",color:`color-mix(in srgb, ${i.primary} 50%, ${i.secondary})`,font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14}})]}),m&&ve("span",{"data-taste-color-swatch":!0,title:m,"aria-label":`Color preview: ${m}`,style:{width:14,height:14,flex:"0 0 14px",borderRadius:3,overflow:"hidden",background:"repeating-conic-gradient(#aaa 0% 25%, #fff 0% 50%) 0 / 6px 6px",boxShadow:`0 0 0 1px ${i.border}`},children:ve("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:m}})}),a&&ve("button",{type:"button",disabled:n,onClick:l,"aria-label":`Reset ${t}`,style:{border:0,background:"transparent",color:i.secondary,padding:0},children:ve(w,{size:12})})]})}var Ft=["display","paddingTop","paddingRight","paddingBottom","paddingLeft","rowGap","columnGap","borderTopLeftRadius","fontFamily","fontSize","lineHeight","fontWeight","letterSpacing","color","backgroundColor","borderTopColor","borderTopWidth","boxShadow"];var Bt=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:px|rem|em|vw|vh|vmin|vmax|ch)?$/i;function qt(e,t){let r,n=q(e,t),a=[],i=[],o=0,l=[],s=!1,d=()=>!(l.length<2||l.length>4)&&(l.forEach((e,t)=>a.push({...e,layer:o,dimension:["x","y","blur","spread"][t]})),r&&i.push(r),l=[],r=void 0,s=!1,o++,!0);for(let a=0;a<e.length;){if(/\s/.test(e[a])){a++;continue}if(","===e[a]){if(!d())return null;a++;continue}let i=a,o=n.findIndex(e=>e.start===a),c=n[o];if(c)a=c.end;else{let t=0;do{if("("===e[a])t++;else if(")"===e[a]){if(!t)return null;t--}a++}while(a<e.length&&(t||!/[\s,]/.test(e[a])));if(t)return null}let u=e.slice(i,a),p={start:i,end:a,text:u,...c?{referenceIndex:o}:{}},h=c&&t.find(e=>e.name.toLowerCase()===c.name.toLowerCase()),g=/^calc\(/i.test(u)?_(u,t):null;if("inset"===u.toLowerCase()){if(s)return null;s=!0}else if("color"===h?.kind||!c&&O(u,{})){if(r)return null;r=p}else{if("layout"!==h?.kind&&(c||!Bt.test(u))&&"length"!==g?.kind)return null;if(g&&(g.css.includes("%")||2===l.length&&void 0!==g.value&&g.value<0)||void 0!==c?.opacity||l.length>=4||2===l.length&&!c&&parseFloat(u)<0)return null;l.push(p)}}return d()?{dimensions:a,colors:i,references:n}:null}function Ht(e,t){let r=te(e,t);if(null===r)return null;let n=qt(e=r,t);if(!n)return null;let a=e,i=[];for(let e of n.dimensions)void 0===e.referenceIndex&&/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(e.text)&&0!==Number(e.text)&&i.push({...e,value:`${e.text}px`});for(let r of n.references){let a=Z(t,e.slice(r.start,r.end));if(!a)return null;let o=n.dimensions.find(e=>e.start===r.start);if(o&&("layout"!==a.kind||"%"===a.unit||"blur"===o.dimension&&a.value<0))return null;let l="layout"===a.kind?`${Math.round(a.value)}${a.unit||"px"}`:P(a);i.push({...r,value:l})}for(let e of i.sort((e,t)=>t.start-e.start))a=a.slice(0,e.start)+e.value+a.slice(e.end);return a}function Ut(e,t,r,n,a){let i=qt(e,r);if(void 0!==a){let n=i?.dimensions[a];return n&&"layout"===t.kind?void 0!==n.referenceIndex?X(e,t,r,n.referenceIndex):e.slice(0,n.start)+`@${t.name}`+e.slice(n.end):null}if(i&&void 0!==n){let e=i.references[n];if(!e)return null;let r=i.dimensions.some(t=>t.referenceIndex===n||e.start>=t.start&&e.end<=t.end);if("layout"===t.kind!==r)return null}return X(e,t,r,n)}function Vt(e,t){try{if(Object.entries(t.root.styles).some(([t,r])=>null===Le(e,r,t)))return!1;for(let t of["basis","padding","gap","body-family","body-size","body-height","body-weight"]){let r=j(e.constraints,t);if("layout"===r.kind&&(r.value<0||["basis","body-size","body-height","body-weight"].includes(t)&&0===r.value))return!1}for(let r of["fontFamily","fontSize","lineHeight","fontWeight","color","backgroundColor"]){let n=t.root.styles[r],a=n&&Le(e,n,r);if(!a||("color"===r||"backgroundColor"===r)&&!O(a,{}))return!1}return!0}catch{return!1}}function Kt(e,t,r=0){try{return j(e,t,r)}catch{return null}}function Yt(e,t){let r=A[t],n=t=>Kt(e.constraints,t),a=(e,t)=>{let r=n(e);return"layout"!==r?.kind?t:"rem"===r.unit||"em"===r.unit?16*r.value:""===r.unit||"px"===r.unit?r.value:t},i=(e,t)=>{let r=n(e);return"layout"===r?.kind?`${r.value}${r.unit||"px"}`:`${t}px`},o=(t,r)=>{let n=e.tokens.find(e=>t.includes(e.name)),a=n&&M(n.value,e.constraints);return a&&O(a,{})?a:r},l=n("primary"),s="color"===l?.kind?P(l):r.primary,d=e=>{let t=n(e);return"font"===t?.kind?t.value:"system-ui, sans-serif"},c=(e,t)=>{let r=n(e);return"layout"===r?.kind?r.value:t};return{background:o(["page-surface","background"],r.control),surface:o(["card-surface","surface"],r.surface),foreground:o(["body-text","text"],r.primary),muted:o(["muted-text"],r.secondary),accent:s,border:r.border,radius:a("radii",8),spacing:a("gap",12),detail:{body:{fontFamily:d("body-family"),fontSize:i("body-size",16),lineHeight:i("body-height",22),fontWeight:c("body-weight",400)},heading:{fontFamily:d("heading-family"),fontSize:i("heading-size",24),lineHeight:i("heading-height",26),fontWeight:c("heading-weight",600),color:o(["heading-text"],r.primary)},card:{padding:i("padding",0),borderRadius:i("radii",8),gap:i("gap",12)},button:{backgroundColor:s,color:"color"===l?.kind?l.l>.6?"#111":"#fff":r.surface,borderRadius:i("radii",8)}}}}function Jt({recipe:e,styles:t}){let r=ie(null),n=ie(null),[a,i]=oe({scale:.5,width:640,height:320});return se(()=>{let e=r.current,t=n.current;if(!e||!t)return;let a=()=>{let r=Math.max(640,t.scrollWidth),n=Math.max(1,t.scrollHeight),a=Math.min(1,e.clientWidth/r,e.clientHeight/n);a>0&&i(e=>e.scale===a&&e.width===r&&e.height===n?e:{scale:a,width:r,height:n})};a();let o=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return o?.observe(e),o?.observe(t),()=>o?.disconnect()},[e,t]),ve("div",{ref:r,className:"tc-preview-demo",style:{backgroundColor:t.page?.backgroundColor??e.background},inert:!0,children:ve("div",{style:{position:"absolute",left:"50%",top:"50%",width:a.width*a.scale,height:a.height*a.scale,transform:"translate(-50%, -50%)"},children:ve("div",{ref:n,"data-taste-preview-canvas":!0,style:{width:640,transform:`scale(${a.scale})`,transformOrigin:"top left"},children:ve(nt,{recipe:e,usageStyles:t})})})})}function Xt({draft:e,dimensionId:t,theme:r,preferPageComponent:n=!1,waitForPageFoundations:a=!1}){let i=ue(()=>Yt(e,r),[e,r]),o=ue(()=>F(e),[e]),l=e.fragments?.find(t=>t.id===e.featuredComponentId),s=e.constraints.find(e=>e.id===t),d=s&&Kt(e.constraints,s.id),c=s&&d&&"font"!==d.kind?[-2,-1,0,1,2].map(t=>({step:t,value:Kt(e.constraints,s.id,t)})):[],u=Math.max(1,...c.map(({value:e})=>"layout"===e?.kind?e.value:0)),p=e.constraints.filter(t=>Kt(e.constraints,t.id)).length,h="increment"===s?.scaleMode,g=s?.name.endsWith("size"),f=s?.name.endsWith("height"),m="radii"===s?.id,v=s?`${s.name} preview`:"Taste demonstration preview";return ye("div",{className:"tc-dimension-preview","data-taste-constraint-preview":!0,"data-preview-dimension":s?.id,role:"group","aria-label":v,children:[ve("style",{children:"\n [data-taste-editor] .tc-dimension-preview { position: sticky; top: 16px; z-index: 3; flex: 0 0 176px; height: 176px; min-width: 0; overflow: hidden; isolation: isolate; border-radius: 12px; background: var(--tc-control); box-shadow: 0 -16px 0 var(--tc-surface), 0 0 0 4px var(--tc-surface); }\n [data-taste-editor] .tc-preview-demo { position: relative; height: 100%; pointer-events: none; }\n [data-taste-editor] .tc-preview-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 8px 10px 10px; height: 100%; }\n [data-taste-editor] .tc-preview-step { display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-width: 0; padding: 6px 2px; border-radius: 8px; font-size: 10px; }\n [data-taste-editor] .tc-preview-step[data-base=true] { background: var(--tc-surface); color: var(--tc-primary); }\n [data-taste-editor] .tc-preview-sample { width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--tc-primary); }\n [data-taste-editor] .tc-preview-step-label { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }\n [data-taste-editor] .tc-preview-empty { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 12px; }\n [data-taste-editor] .tc-preview-family { padding: 18px 16px 16px; overflow: hidden; }\n "}),s?d?"font"===d.kind?ye("div",{className:"tc-preview-family",style:{fontFamily:d.value},children:[ve("div",{style:{fontSize:32,lineHeight:1.4,color:"var(--tc-primary)"},children:"Aa Bb Cc"}),ve("div",{style:{fontSize:13,lineHeight:1.5},children:"The quick brown fox jumps."}),ve("div",{className:"tc-preview-step-label",title:d.value,style:{marginTop:8,fontSize:10},children:d.value})]}):ve("div",{className:"tc-preview-steps","aria-label":`${s.name} steps`,children:c.map(({step:e,value:t})=>{let r=t&&P(t),n="color"===t?.kind?`${Number((100*t.l).toFixed(1))}% L`:r,a={};return"color"===t?.kind?a={width:32,height:44,borderRadius:5,background:r,boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--tc-primary) 18%, transparent)"}:"layout"===t?.kind&&(a=m?{width:34,height:34,border:"1px solid currentColor",borderRadius:Math.min(17,t.value*("rem"===t.unit||"em"===t.unit?16:1))}:h?{fontSize:24,fontWeight:Math.max(1,Math.min(1e3,t.value))}:g?{fontSize:Math.max(6,t.value/u*30),lineHeight:1}:f?{fontSize:10,lineHeight:`${Math.max(6,t.value/u*24)}px`,whiteSpace:"pre",background:"repeating-linear-gradient(transparent 0 48%, color-mix(in srgb, var(--tc-primary) 12%, transparent) 48% 52%, transparent 52% 100%)"}:{height:Math.max(1,t.value/u*46),width:18,borderRadius:3,background:"var(--tc-secondary)"}),ye("div",{className:"tc-preview-step","data-base":0===e,"aria-label":`Step ${e}: ${r??"unresolved"}`,title:r??void 0,children:[ve("span",{children:e>0?`+${e}`:0===e?"Base":e}),ve("span",{className:"tc-preview-sample","aria-hidden":"true",children:ve("span",{style:a,children:h||g?"Aa":f?"Ab\nAb":""})}),ve("span",{className:"tc-preview-step-label",children:n??"—"})]},e)})}):ve("div",{className:"tc-preview-empty",children:s.value||s.parentId?"This dimension does not resolve yet.":"Waiting for this dimension…"}):!l||a&&!Vt(e,l)?p&&!n?ve(Jt,{recipe:i,styles:o}):ve("div",{className:"tc-preview-empty",children:ve("span",{className:"tc-proposal-status","data-state":"in-progress",children:"tracing stylenet"})}):ve(it,{fragment:l,draft:e,height:176})]})}var _t=new Map;function Gt(e,t){if(!e||typeof CanvasRenderingContext2D>"u")return;let r=`${t}|${e}`;if(_t.has(r))return _t.get(r);let n=T();if(!n)return;let a=function(e,t){if(!(I(e,t)>=1.6))return N(t)<.179?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.18)"}(n(e,"#d5d5d5"),n(t,"#fff"));return _t.size>=256&&_t.clear(),_t.set(r,a),a}function Zt(e){let t=[],r=/url\([^)]*\)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|#[\w-]+|@[\w-]+|[a-z_][\w-]*|[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:[a-z]+|%)?/gi;for(let n of e.matchAll(r))/^[+\-.\d]/.test(n[0])&&t.push({start:n.index,end:n.index+n[0].length,text:n[0]});return t}var Qt=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z]+|%)?$/i;function er({value:e,spec:t,preview:r,commit:n,cancel:a}){let i=ie(null),o=ie(0),l=ie(!1),s=ie(!1),[d,c]=oe(null);de(()=>()=>i.current?.(),[]);let u=t?(e.trim()||(void 0===t.defaultValue?"":String(t.defaultValue))).match(Qt):null,p=!!u&&Number.isFinite(Number(u[1]))||!!t?.compound&&Zt(e).length>0;return{enabled:p,dragging:l,consumedClick:s,start:d=>{if(s.current=!1,!p||!t||0!==d.button||"touch"===d.pointerType)return;let h=t.compound?u?{start:e.indexOf(e.trim()),end:e.indexOf(e.trim())+e.trim().length,text:e.trim()}:function(e,t,r){let n=e.ownerDocument,a=n.defaultView.getComputedStyle(e),i=n.createElement("span");Object.assign(i.style,{position:"fixed",visibility:"hidden",whiteSpace:"pre",font:a.font,letterSpacing:a.letterSpacing}),i.textContent=t,n.body.append(i);try{let o=e.getBoundingClientRect(),l=i.getBoundingClientRect().width,s=parseFloat(a.paddingLeft)||0,d=parseFloat(a.paddingRight)||0,c=o.width-s-d,u="right"===a.textAlign||"end"===a.textAlign?Math.max(0,c-l):"center"===a.textAlign?Math.max(0,(c-l)/2):0,p=r-o.left-s-u+e.scrollLeft,h=i.getBoundingClientRect().left;return Zt(t).find(e=>{let t=n.createRange();t.setStart(i.firstChild,e.start),t.setEnd(i.firstChild,e.end);let r=t.getBoundingClientRect();return p>=r.left-h&&p<=r.right-h})}finally{i.remove()}}(d.currentTarget,e,d.clientX):null,g=h?h.text.match(Qt):u;if(!g)return;let f=h?function(e,t,r){let n,a,i=e.slice(0,t).match(/(rgba?|hsla?|oklch|oklab|lch|lab|color)\(([^()]*)$/i),o=r.match(/[a-z%]+$/i)?.[0]?.toLowerCase(),l="rem"===o||"em"===o?.01:1;if(i){let e=Zt(i[2]).length,t=i[1].toLowerCase();i[2].includes("/")||["rgba","hsla"].includes(t)&&3===e?(l="%"===o?1:.01,n=0,a="%"===o?100:1):t.startsWith("rgb")?(n=0,a="%"===o?100:255):"%"===o?(n=0,a=100):t.startsWith("ok")&&e<2?(l=.01,n=0===e||"oklch"===t?0:void 0,a=0===e?1:void 0):"color"===t&&(l=.01,n=0,a=1)}else!o&&r.includes(".")&&(l=10**-Math.min(4,r.split(".")[1].length));return{step:l,shiftStep:5*l,min:n,max:a}}(e,h.start,h.text):t;d.preventDefault(),d.stopPropagation(),i.current?.();let m=++o.current,v=d.currentTarget,y=v.ownerDocument,b=y.defaultView,w=v.getRootNode(),x=()=>w.pointerLockElement===v||y.pointerLockElement===v,k=Number(g[1]),S=g[2]??"",C=/^(rem|em)$/i.test(S)&&1===f.step?.01:f.step,$=!1,R=!1,E=!1,T=d.clientX,I=T,N=0,A=0,L=e,z=d.clientY,D=()=>{x()&&y.exitPointerLock()},j=()=>{R=!0,l.current=!1,b.removeEventListener("pointermove",M,!0),b.removeEventListener("pointerup",O,!0),b.removeEventListener("pointercancel",W,!0),b.removeEventListener("keydown",F,!0),b.removeEventListener("keyup",F,!0),b.removeEventListener("blur",W),y.removeEventListener("pointerlockchange",B),v.hasPointerCapture?.(d.pointerId)&&v.releasePointerCapture(d.pointerId),D(),c(null),i.current=null},P=t=>{let n=k+Math.round(N/4)*C,a=f.shiftStep??.05,i=Math.min(f.max??1/0,Math.max(f.min??-1/0,t?Math.round(n/a)*a:n));if(!Number.isFinite(i))return;let o=`${Number(i.toFixed(4))}${S}`;L=h?e.slice(0,h.start)+o+e.slice(h.end):o,r(L)},M=e=>{let t=x(),r=t?e.movementX:e.clientX-T;T=e.clientX,A+=r,N+=r,I=t?((I+r)%b.innerWidth+b.innerWidth)%b.innerWidth:e.clientX,t&&c({x:I,y:z,doc:y}),($||!(Math.abs(A)<4))&&(e.preventDefault(),e.stopImmediatePropagation(),$||($=!0,l.current=!0),P(e.shiftKey))},O=e=>{e.preventDefault(),e.stopImmediatePropagation(),j(),s.current=$,$?n(L):(v.focus(),v instanceof b.HTMLInputElement&&v.select())},W=()=>{j(),a()},F=e=>{"Shift"!==e.key?"keydown"===e.type&&"Escape"===e.key&&(e.preventDefault(),e.stopImmediatePropagation(),W()):$&&P("keydown"===e.type)},B=()=>{R?D():x()?(E=!0,c({x:I,y:z,doc:y})):E&&W()};v.setPointerCapture?.(d.pointerId),b.addEventListener("pointermove",M,{capture:!0,passive:!1}),b.addEventListener("pointerup",O,!0),b.addEventListener("pointercancel",W,!0),b.addEventListener("keydown",F,!0),b.addEventListener("keyup",F,!0),b.addEventListener("blur",W),y.addEventListener("pointerlockchange",B),i.current=j,(()=>{if(!v.requestPointerLock)return;let e=()=>{y.removeEventListener("pointerlockchange",t),y.removeEventListener("pointerlockerror",e),R&&m===o.current&&D()},t=()=>{x()&&e()};y.addEventListener("pointerlockchange",t),y.addEventListener("pointerlockerror",e);try{let t=v.requestPointerLock();t&&t.then(e,e)}catch{e()}})()},cursor:d&&we(ve("div",{"data-taste-scrub-cursor":!0,"aria-hidden":"true",style:{position:"fixed",left:d.x,top:d.y,transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:2147483647,color:"white",filter:"drop-shadow(0 1px 2px black)"},children:ve(x,{size:18})}),d.doc.body)}}var tr=ae(()=>!1);function rr(e,t,r){let n=e.findIndex(e=>r?t>e.start&&t<=e.end:t>=e.start&&t<e.end),a=e.findIndex(e=>r?e.start===t:e.end===t),i=n>=0?n:a,o=i>=0?e[i+(r?-1:1)]:r?[...e].reverse().find(e=>e.end<t):e.find(e=>e.start>t);return o?r?o.start:o.end:r?0:e.at(-1)?.end??t}function nr({label:e,onCommit:t,onSelectionStart:r,children:n,...a}){let i=ie(null),o=ie(null),[l,s]=oe(null),[d,c]=oe(""),[u,p]=oe(""),h=ie(!1);se(()=>{!l||!o.current||(o.current.focus({preventScroll:!0}),o.current.setSelectionRange(Math.min(l.anchor,l.focus),Math.max(l.anchor,l.focus),l.focus<l.anchor?"backward":"forward"))},[l]);return ve(tr.Provider,{value:(e,t,n)=>{if(!i.current)return!1;let{value:a,fields:o}=function(e){let t="",r=new Map,n=e=>{if(e.nodeType!==Node.TEXT_NODE){if(e instanceof HTMLElement&&!e.matches("[data-token-preview], .tc-swatch, .tc-available")){if(e.matches(".tc-field")){let n=e.querySelector("input");if(n){let e=t.length;t+=n.value,r.set(n,{start:e,end:t.length})}return}if(void 0!==e.dataset.valueText)return void(t+=e.dataset.valueText);for(let t of e.childNodes)n(t)}}else t+=e.textContent??""};for(let t of e.childNodes)n(t);return{value:t.replace(/\u00a0/g," "),fields:r}}(i.current),l=o.get(e);if(!l||o.size<2)return!1;let d="backward"===e.selectionDirection,u=l.start+((d?e.selectionEnd:e.selectionStart)??0),h=l.start+((d?e.selectionStart:e.selectionEnd)??0),g=[...o.values()],f=n?rr(g,h,t):Math.max(0,Math.min(a.length,h+(t?-1:1)));return f!==h&&(c(a),s({value:a,ranges:g,anchor:u,focus:f,dirty:[...o.keys()].some(e=>e.hasAttribute("data-taste-field-dirty"))}),p(""),r?.(),!0)},children:ve("div",{...a,ref:i,children:l?ye("span",{className:"tc-field tc-fit",style:{flex:"1 1 auto",minWidth:0},children:[ve("span",{className:"tc-measure","aria-hidden":"true",children:d||""}),ve("input",{ref:o,"aria-label":e,"aria-invalid":!!u,"data-taste-value-input":!0,"data-taste-field-dirty":l.dirty||d!==l.value||void 0,value:d,onChange:e=>{c(e.target.value),p("")},onBlur:()=>{if(h.current)h.current=!1;else try{(l.dirty||d!==l.value)&&t(d.trim()),s(null)}catch(e){p(e instanceof Error?e.message:"Check this value")}},onKeyDown:e=>{if(e.stopPropagation(),"Escape"===e.key)e.preventDefault(),h.current=!0,e.currentTarget.blur(),s(null);else if("Enter"===e.key)e.preventDefault(),e.currentTarget.blur();else if(e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing&&d===l.value&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){let t=e.currentTarget,r="backward"===t.selectionDirection,n=(r?t.selectionEnd:t.selectionStart)??0,a=(r?t.selectionStart:t.selectionEnd)??0,i=rr(l.ranges,a,"ArrowLeft"===e.key);e.preventDefault(),t.setSelectionRange(Math.min(n,i),Math.max(n,i),i<n?"backward":"forward")}}}),u&&ve("span",{role:"alert",className:"tc-field-error",children:u})]}):n})})}function ar(e,t){let r=t,n=(e.x+t.x)/2;if(t.blockedLeft){let{top:a,bottom:i,width:o}=t.blockedLeft,l=e.y<=t.y,s=Math.min(8,o/2,(i-a)/2)*(1-Math.SQRT1_2);r={x:t.x+s,y:l?a+s:i-s};let d=Math.min(64,Math.abs(r.y-e.y)/2),c=r.y+(l?-1:1)*Math.min(24,d);return{from:e,to:r,path:`M ${e.x} ${e.y} C ${n} ${e.y}, ${r.x-d} ${c}, ${r.x} ${r.y}`}}return{from:e,to:r,path:`M ${e.x} ${e.y} C ${n} ${e.y}, ${n} ${r.y}, ${r.x} ${r.y}`}}var ir=({parent:e,child:t})=>JSON.stringify([e,t]),or=128;function lr(e){let t=e.getBoundingClientRect(),r=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1,a=new Map;e.querySelectorAll("[data-constraint-id], [data-token-id], [data-connection-id]").forEach(e=>{let t=e.dataset.connectionId??e.dataset.constraintId??`token:${e.dataset.tokenId}`;a.has(t)||a.set(t,e)});let i=new Map;return(o,l)=>{let s=`${l}:${o}`;if(i.has(s))return i.get(s);let d=a.get(o),c=d?.matches(".tc-reference")?d:d?.querySelector("source"===l?".tc-name":".tc-reference");if(!c)return i.set(s,null),null;let u=c.getBoundingClientRect(),p="target"===l&&c.parentElement?.classList.contains("tc-compound")&&Array.from(c.parentElement.children).some(e=>{if(e===c)return!1;let t=e.getBoundingClientRect();return t.width>0&&t.right<=u.left+1&&t.right>u.left-8&&t.bottom>u.top&&t.top<u.bottom}),h={x:(("source"===l?u.right:u.left)-t.left)/r-e.clientLeft,y:(u.top+u.height/2-t.top)/n-e.clientTop,...p?{blockedLeft:{top:(u.top-t.top)/n-e.clientTop,bottom:(u.bottom-t.top)/n-e.clientTop,width:u.width/r}}:{}};return i.set(s,h),h}}function sr({pane:e,edges:t,visible:r,revision:n,suspended:a,color:i}){let[o,l]=oe(new Map),s=new Set(r.map(ir)),d=JSON.stringify(t),c=JSON.stringify(r),u=ie(null),p=ie(r);return p.current=r,de(()=>{let t=e.current;if(!t)return;let r,n=JSON.parse(d),a=n.length>or,i=new Set,o=!1,s=()=>{if(o)return;let e=lr(t),r=p.current.length<=or?new Set(p.current.map(ir)):new Set,s=a?n.filter(e=>i.has(e.child)||r.has(ir(e))):n,d=new Map;for(let t of s){let r=e(t.parent,"source"),n=e(t.child,"target");r&&n&&d.set(ir(t),ar(r,n))}l(e=>e.size===d.size&&[...d].every(([t,r])=>e.get(t)?.path===r.path)?e:d)},c=()=>{void 0===r&&(r=requestAnimationFrame(()=>{r=void 0,s()}))};u.current=s;let h=typeof ResizeObserver>"u"?null:new ResizeObserver(c);h?.observe(t),t.querySelectorAll(".tc-scroll, .tc-row, .tc-reference, .tc-literal").forEach(e=>h?.observe(e));let g=new Map;t.querySelectorAll("[data-connection-id]").forEach(e=>g.set(e,e.dataset.connectionId)),t.querySelectorAll("[data-constraint-id] .tc-reference").forEach(e=>g.set(e,e.closest("[data-constraint-id]").dataset.constraintId));let f=a&&typeof IntersectionObserver<"u"?new IntersectionObserver(e=>{for(let t of e){let e=g.get(t.target);e&&(t.isIntersecting?i.add(e):i.delete(e))}c()},{root:t.querySelector(".tc-scroll"),rootMargin:"160px 0px"}):null;return g.forEach((e,t)=>f?.observe(t)),a&&!f&&n.slice(0,or).forEach(e=>i.add(e.child)),s(),t.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{o=!0,u.current=null,void 0!==r&&cancelAnimationFrame(r),h?.disconnect(),f?.disconnect(),t.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[e,d,n]),se(()=>{!a&&p.current.length<=or&&p.current.some(e=>!o.has(ir(e)))&&u.current?.()},[c,a,o]),ve("svg",{"data-taste-connection-layer":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[...o].map(([e,{from:t,to:r,path:n}])=>{let o=!a&&s.has(e);return ye("g",{"data-taste-cached-connection":e,"data-taste-connection":o?"":void 0,style:{visibility:o?"visible":"hidden"},children:[ve("path",{d:n,fill:"none",stroke:i,strokeWidth:1}),ve("circle",{cx:t.x,cy:t.y,r:3,fill:i}),ve("circle",{cx:r.x,cy:r.y,r:3,fill:i})]},e)})})}function dr({value:e,label:t,className:r,onEdit:n,onCommit:a,onPreview:i}){let o=er({value:e,spec:{step:1,compound:!0},preview:i,commit:e=>{a(e),i(null)},cancel:()=>i(null)});return ye(be,{children:[ve("button",{className:r,"aria-label":t,"data-scrubbable":o.enabled||void 0,onPointerDown:o.start,onClick:()=>{o.consumedClick.current||n()},children:e}),o.cursor]})}function cr({label:e,value:t,onCommit:r,onDraftChange:n,onCancel:a,arrowNavigation:i=!1,compact:o=!1,decimal:l=!1,scrub:s,clearable:d=!1,onScrubPreview:c,onDelete:u,sourceSuggestions:p,bareSource:h=!1,...g}){let f=me(tr),[m,v]=oe(null),[y,b]=oe(""),w=ie(!1),x=he(),k=m??t,[S,C]=oe(!1),[$,R]=oe(!0),[E,T]=oe(!1),I=h?k.match(/^@?([\w-]+)$/)?.[1]:k.match(/(?:^|\s)@([\w-]+)$/)?.[1],N=(S&&null!==m&&$&&!E&&I&&!p?.some(e=>e.toLowerCase()===I.toLowerCase())?p?.find(e=>e.length>I.length&&e.toLowerCase().startsWith(I.toLowerCase())):void 0)?.slice(I.length)??"",A=ie(null),[L,z]=oe(0);se(()=>{z(A.current?.getBoundingClientRect().width??0)},[N]);let D=e=>{try{r(e.trim()),c?.(null),v(null),b("")}catch(e){b(e instanceof Error?e.message:"Check this value")}},j=er({value:k,spec:s,preview:e=>{v(e),b(""),c?.(e)},commit:D,cancel:()=>{v(null),b(""),c?.(null),a?.()}}),P="number"==typeof l?l:2,M=3-P,O=l?k.match(/^(-?)(\d*)(\.?)(\d*)$/):null,W=O?`${O[3]?"":"."}${"0".repeat(Math.max(0,P-O[4].length))}`:"",F=O?"0".repeat(Math.max(0,M-O[2].length)):"",B=ie(null),[q,H]=oe(0);return se(()=>{let e=B.current;if(!e)return;let t=()=>H(e.getBoundingClientRect().width);if(t(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[W]),ye("span",{className:`tc-field${o?" tc-fit":""}${l?" tc-decimal":""}`,children:[o&&ve("span",{className:"tc-measure","aria-hidden":"true",children:l?`${"0".repeat(Math.max(4,t.length,O?`${O[1]}${F}${O[2]}${O[3]}${O[4]}${W}`.length:k.length)-P-1)}.${"0".repeat(P)}`:k+N||g.placeholder||""}),N&&ye("span",{className:"tc-source-completion","aria-hidden":"true",children:[ve("span",{style:{visibility:"hidden"},children:k}),ve("span",{ref:A,children:N})]}),l&&O&&ye("span",{className:"tc-decimal-display","aria-hidden":"true",children:[O[1],ve("span",{className:"tc-digit-placeholder",children:F}),O[2],O[3],O[4],ve("span",{ref:B,className:"tc-digit-placeholder",children:W})]}),ve("input",{...g,autoComplete:p?"off":void 0,"aria-autocomplete":p?"inline":void 0,onFocus:()=>{C(!0),w.current=!1},onSelect:e=>{let t=e.currentTarget;R(t.selectionStart===t.value.length&&t.selectionEnd===t.value.length)},onCompositionStart:()=>T(!0),onCompositionEnd:()=>T(!1),"data-scrubbable":j.enabled||void 0,onPointerDown:j.start,onContextMenu:d||u?e=>{e.preventDefault(),e.stopPropagation(),u?u():D("")}:void 0,placeholder:l?`${"0".repeat(M)}.${"0".repeat(P)}`:g.placeholder,inputMode:l?"decimal":void 0,style:l&&O?{color:"transparent",caretColor:"var(--tc-primary)",paddingRight:6+q}:N?{paddingRight:`calc(var(--tc-field-inline-padding, 6px) + ${L}px)`}:void 0,"data-taste-value-input":!0,"data-value-arrow-navigation":i||void 0,"data-taste-field-dirty":null!==m||void 0,"aria-label":e,"aria-invalid":!!y,"aria-describedby":y?x:void 0,value:m??t,onChange:e=>{if(R(e.target.selectionStart===e.target.value.length&&e.target.selectionEnd===e.target.value.length),n?.(e.target.value))return w.current=!0,v(null),void b("");l&&!new RegExp(`^-?\\d*(?:\\.\\d{0,${P}})?$`).test(e.target.value)||(v(e.target.value),b(""))},onBlur:e=>{if(C(!1),!j.dragging.current){if(w.current)return void(w.current=!1);if(null===m)return void((!i||!e.currentTarget.closest(".tc-reference")?.contains(e.relatedTarget))&&a?.());D(m)}},onKeyDown:e=>{if(e.stopPropagation(),N&&!e.nativeEvent.isComposing&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey&&("Enter"===e.key||"Tab"===e.key))return e.preventDefault(),v(k+N),void b("");if(i&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){let t=e.currentTarget,r="backward"===t.selectionDirection?t.selectionStart:t.selectionEnd;if((e.altKey||r===("ArrowLeft"===e.key?0:t.value.length))&&f(e.currentTarget,"ArrowLeft"===e.key,e.altKey))return w.current=!0,void e.preventDefault()}if(i&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){let t=e.currentTarget,r="ArrowLeft"===e.key,n=r?0:t.value.length;if(e.altKey||t.selectionStart===n&&t.selectionEnd===n){let n=Array.from(t.closest(".tc-value")?.querySelectorAll("input[data-value-arrow-navigation]")??[]),a=n[n.indexOf(t)+(r?-1:1)];if(a){e.preventDefault(),a.focus({preventScroll:!0});let t=e.altKey?r?0:a.value.length:r?a.value.length:0;a.setSelectionRange(t,t)}}}"Enter"===e.key&&(e.preventDefault(),e.currentTarget.blur()),"Escape"===e.key&&(e.preventDefault(),v(null),b(""),w.current=!0,e.currentTarget.blur(),a?.())}}),j.cursor,y&&ve("span",{id:x,role:"alert",className:"tc-field-error",children:y})]})}function ur({color:e,background:t}){let r=Gt(e,t);return ve("span",{"aria-hidden":"true",className:"tc-swatch","data-color-value":e??"",style:{boxShadow:r?`0 0 0 1px ${r}`:"none",background:e?"repeating-conic-gradient(#aaa 0% 25%, #fff 0% 50%) 0 / 6px 6px":void 0},children:ve("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:e}})})}function pr({value:e,constraints:t,name:r,background:n}){let a=Ht(e,t),i=Z(t,e),o=/\bcalc\(/i.test(e)?M(e,t):null,l="layout"===i?.kind?`${Math.round(i.value)}${i.unit}`:i?P(i):o??void 0,s=Q(e,t);return a||i||o||s.length?ye("span",{className:"tc-token-preview","data-token-preview":!0,"aria-label":`${r} resolves to ${a??l??s.join(", ")}`,children:[ve("span",{className:"tc-separator","aria-hidden":"true",children:ve(R,{size:12})}),a?ve("span",{className:"tc-resolved-value",children:ve("span",{className:"tc-shadow-preview","data-shadow-value":a,"aria-hidden":"true",children:ve("span",{style:{boxShadow:a}})})}):s.length?s.map((e,t)=>ve("span",{className:"tc-resolved-value",children:ve(ur,{color:e,background:n})},`${t}:${e}`)):ve("span",{className:"tc-resolved-value",children:l})]}):null}function hr({row:e,constraints:t,background:r}){if("color"===e.kind){let n;try{n=P(j(t,e.id))}catch{}return n?ve("span",{className:"tc-resolved-value",children:ve(ur,{color:n,background:r})}):null}return null}var gr=e=>e.dataset.connectionId??e.dataset.constraintId??`token:${e.dataset.tokenId}`,fr=e=>{let t=e.match(/^(token:.*):(ref|dim):(\d+)$/);return{row:t?.[1]??e,index:"ref"===t?.[2]?Number(t[3]):void 0,dimensionIndex:"dim"===t?.[2]?Number(t[3]):void 0}};function mr({drag:e,pane:t,color:r}){let[n,a]=oe(null);if(se(()=>{let r=t.current;if(!r)return;let n=()=>{let t=lr(r),n=t(e.id,e.port);if(!n)return;let i=(e.target&&e.validTarget?t(e.target,"source"===e.port?"target":"source"):null)??{x:e.toX-r.clientLeft,y:e.toY-r.clientTop};a("source"===e.port?ar(n,i):ar(i,n))};n(),r.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let i=typeof ResizeObserver>"u"?null:new ResizeObserver(n);return r.querySelectorAll(".tc-row, .tc-reference, .tc-literal").forEach(e=>i?.observe(e)),()=>{r.removeEventListener("scroll",n,!0),window.removeEventListener("resize",n),i?.disconnect()}},[e,t]),!n)return null;let{from:i,to:o,path:l}=n;return ye("svg",{"data-taste-connection":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[ve("path",{d:l,fill:"none",stroke:r,strokeWidth:1}),ve("circle",{cx:i.x,cy:i.y,r:3,fill:r}),ve("circle",{cx:o.x,cy:o.y,r:3,fill:r})]})}function vr({draft:e,onChange:r,history:n,theme:a,onBack:s,style:u,proposalState:p,preferPageComponent:h,proposalRecovery:g,fragments:f,detail:y,onSave:b,saving:w,saveNotice:k,saveAction:S}){let C=B(e),$="running"===p,R=A[a],E=ie(null),T=ie(null);!function(e,t,r){let n=ie(!1),a=ie(0),i=ie(t);se(()=>{let r=e.current;if(!r||"running"!==t)return;n.current=!1,a.current=r.scrollTop;let i=()=>{n.current=!0},o=()=>{Math.abs(r.scrollTop-a.current)>1&&i()},l=e=>{e.target.closest("input, textarea, [contenteditable]")||["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&i()};return r.addEventListener("wheel",i,{passive:!0}),r.addEventListener("touchmove",i,{passive:!0}),r.addEventListener("keydown",l),r.addEventListener("scroll",o,{passive:!0}),()=>{r.removeEventListener("wheel",i),r.removeEventListener("touchmove",i),r.removeEventListener("keydown",l),r.removeEventListener("scroll",o)}},[e,t]),se(()=>{let r="running"===i.current;i.current=t;let o=e.current;if(!o||n.current||"error"===t||"running"!==t&&!r)return;let l=()=>{if(n.current)return;let e=o.querySelectorAll('[data-proposal-status="done"], [data-token-id]'),t=e[e.length-1];if(!t)return;let r=t.getBoundingClientRect().bottom,i=o.getBoundingClientRect().top+o.clientHeight;r+16>i&&(o.scrollTop+=r+16-i,a.current=o.scrollTop)};if(l(),"running"!==t)return;let s=typeof ResizeObserver>"u"?null:new ResizeObserver(l);s?.observe(o);for(let e of o.children)s?.observe(e);return()=>s?.disconnect()},[e,t,r])}(T,p,e);let I=ie({past:[],future:[]}),N=n??I,L=e=>{$||JSON.stringify(e)!==JSON.stringify(C)&&(N.current.past=[...N.current.past.slice(-99),C],N.current.future=[],r(e))},z=ie(null),[D,j]=oe(null),[M,O]=oe(null),[W,F]=oe(null),[X,Q]=oe(null),[ee,te]=oe(null),[re,ne]=oe(null),[ae,le]=oe(null),ce=C.constraints.flatMap(e=>e.parentId?[{parent:e.parentId,child:e.id}]:[]);for(let e of C.tokens)q(e.value,C.constraints).forEach((t,r)=>{let n=t&&C.constraints.find(e=>e.name.toLowerCase()===t.name.toLowerCase());n&&ce.push({parent:n.id,child:H(e.value)?`token:${e.id}`:`token:${e.id}:ref:${r}`})});let pe=ce.filter(({parent:e,child:t})=>"source"===W?.port?e===W.id:t===W?.id||fr(t).row===W?.id).map(({parent:e,child:t})=>({id:e,target:t,port:"source",active:!0,validTarget:!0,x:0,y:0,toX:0,toY:0})),fe=new Set("source"===W?.port?pe.map(({target:e})=>fr(e).row):[]),me=D?[D]:M?[M]:pe,we=ie(!1),[xe,ke]=oe(""),[Se,Ce]=oe(null),[$e,Re]=oe(null),Ee=Se?C.constraints.map(e=>e.id===Se.id?{...e,...Se.patch}:e):C.constraints,Te=ue(()=>({...C,constraints:Ee,tokens:$e?C.tokens.map(e=>e.id===$e.id?{...e,value:$e.value}:e):C.tokens}),[C,Ee,$e]),[Ie,Ne]=oe(null);de(()=>{let e=E.current?.ownerDocument;if(!e)return;let t=e=>{let t=e.key.toLowerCase();if(!e.metaKey&&!e.ctrlKey||e.altKey||"z"!==t&&"y"!==t)return;let n=e.composedPath()[0],a=n instanceof Node&&E.current?.contains(n);if(o(e)&&(!a||n instanceof Element&&n.hasAttribute("data-taste-field-dirty"))||(e.preventDefault(),e.stopImmediatePropagation(),Se||$e||z.current))return;let i="y"===t||e.shiftKey,l=(i?N.current.future:N.current.past).pop();l&&((i?N.current.past:N.current.future).push(C),O(null),ke(""),r(l))};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[C,N,r,Se,$e]),de(()=>{if(!Ie)return;let e=setTimeout(()=>Ne(null),220);return()=>clearTimeout(e)},[Ie]);let Ae=he(),Le=ie(0),ze=(e,t)=>{O(null),L({...C,constraints:C.constraints.map(r=>r.id===e?{...r,...t}:r)}),ke("")},De=(e,t)=>L({...C,tokens:C.tokens.map(r=>r.id===e?{...r,value:t}:r)}),je=(e,t)=>{if(e.startsWith("token:")){let r=C.constraints.find(e=>e.id===t),n=fr(e),a=C.tokens.find(e=>`token:${e.id}`===n.row);return r&&a&&null!==Ut(a.value,r,C.constraints,n.index,n.dimensionIndex)?null:"Choose a compatible, unambiguous value"}return U(C.constraints,e,t)},Pe=(e,t,r=!1)=>{let n=je(e,t);if(n)throw Error(n);if(e.startsWith("token:")){let r=fr(e),n=C.tokens.find(e=>`token:${e.id}`===r.row),a=C.constraints.find(e=>e.id===t);return void De(n.id,Ut(n.value,a,C.constraints,r.index,r.dimensionIndex))}ze(e,{parentId:t,...r?{derivative:V(C.constraints,e,t)}:{}})},Me=(e,t)=>{let r=E.current,n=r.getBoundingClientRect();return{x:(e-n.left)/(n.width/r.offsetWidth||1),y:(t-n.top)/(n.height/r.offsetHeight||1)}},Oe=(e,t,r)=>{if(0!==e.button)return;Ne(null),F(null),O(null),we.current=!1;let n=Me(e.clientX,e.clientY);z.current={id:t,port:r,...n,toX:n.x,toY:n.y,active:!1,target:null,validTarget:!1},e.currentTarget.setPointerCapture(e.pointerId)},We=e=>{if(!e||!Number.isFinite(Number(e)))throw Error("Enter a finite number");return Number(e)};return ye("div",{ref:E,role:"region","aria-label":y?`${y.name} uses`:"New taste","data-taste-editor":!0,"data-popmelt-font":"sans","data-popmelt-theme":a,onMouseOver:y?e=>{let t=e.target.closest("[data-token-id], [data-constraint-id]"),r=t?.getAttribute("data-token-id"),n=t?.getAttribute("data-constraint-id");y.onHover?.(r?{kind:"token",id:r}:n?{kind:"dimension",id:n}:null)}:void 0,onMouseLeave:y?()=>y.onHover?.(null):void 0,onPointerMove:e=>{let t=z.current;if(!t&&!M)return;let r=E.current.getRootNode().elementFromPoint(e.clientX,e.clientY);if(!t){let e=E.current.contains(r)?r?.closest(".tc-row"):null;return void(e&&gr(e)!==fr(M.target??"").row&&O(null))}let n=Me(e.clientX,e.clientY),a=t.active||Math.hypot(n.x-t.x,n.y-t.y)>5,i=E.current.contains(r)?r?.closest("[data-connection-id], [data-constraint-id], [data-token-id]"):null,o=i?gr(i):null,l=t.landing;if(l&&t.validTarget&&E.current.contains(l.row)){let r=l.row.getBoundingClientRect(),n=e.clientX-r.left,a=e.clientY-r.top,i=6;n>=l.left-i&&n<=l.right+i&&a>=l.top-i&&a<=l.bottom+i&&a>=-i&&a<=r.height+i&&(o=t.target)}let s=!!o&&!je("source"===t.port?o:t.id,"source"===t.port?t.id:o);if(o!==t.target&&(l=void 0),!l&&s&&"source"===t.port&&o?.startsWith("token:")&&i){let e=i.closest("[data-token-id]"),t=r?.closest(".tc-shadow-dimension, .tc-reference, .tc-value")??i;if(e){let r=e.getBoundingClientRect(),n=t.getBoundingClientRect();n.width>0&&n.height>0&&(l={row:e,left:n.left-r.left,right:n.right-r.left,top:n.top-r.top,bottom:n.bottom-r.top})}}z.current={...t,active:a,toX:n.x,toY:n.y,target:o,validTarget:s,landing:l},a&&(we.current=!0,j(z.current))},onPointerUp:()=>{let e=z.current;if(z.current=null,j(null),e?.active&&e.target)try{Pe("source"===e.port?e.target:e.id,"source"===e.port?e.id:e.target,!0),O({...e})}catch{ke(""),Ne("source"===e.port?e.id:e.target)}},onPointerCancel:()=>{z.current=null,j(null)},onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),z.current||M?(z.current=null,j(null),O(null)):s())},style:{...u,width:"min(360px, 100%)",marginInline:"auto",boxSizing:"border-box",position:"relative",display:"flex",flexDirection:"column",maxHeight:u?.maxHeight??"calc(100dvh - 80px)",border:`1px solid ${R.border}`,borderRadius:20,background:R.surface,color:R.secondary,fontFamily:l,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden","--tc-primary":R.primary,"--tc-muted":R.muted,"--tc-control":R.control,"--tc-secondary":R.secondary,"--tc-border":R.border,"--tc-surface":R.surface},children:[ve("style",{children:`\n [data-taste-editor] { --tc-row-height: 22px; --tc-row-slop: 3px; --tc-value-font-size: 14px; }\n [data-taste-editor] * { box-sizing: border-box; }\n [data-taste-editor] button, [data-taste-editor] input { font: inherit; font-variant-numeric: tabular-nums; color: inherit; letter-spacing: inherit; }\n [data-taste-editor] button { border: 0; background: transparent; cursor: pointer; border-radius: 8px; padding: 2px 6px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }\n [data-taste-editor] button:hover { color: var(--tc-primary); background: var(--tc-control); }\n [data-taste-editor] button:focus-visible { outline: 1px solid var(--tc-secondary); outline-offset: 1px; }\n [data-taste-editor] input:focus-visible { outline: none; box-shadow: none; }\n [data-taste-editor] input { width: 100%; min-width: 0; border: 0; background: transparent; border-radius: 8px; padding: 2px 6px; text-align: right; text-overflow: ellipsis; }\n [data-taste-editor] input:hover, [data-taste-editor] input:focus { background: var(--tc-control); color: var(--tc-primary); }\n [data-taste-editor] input[data-scrubbable] { cursor: ew-resize; touch-action: none; }\n [data-taste-editor] button[data-scrubbable] { cursor: ew-resize; touch-action: none; }\n [data-taste-editor] input[data-scrubbable]:focus { cursor: text; }\n [data-taste-editor] input::placeholder { color: var(--tc-secondary); opacity: 1; }\n [data-taste-editor] .tc-field { position: relative; display: grid; min-width: 0; }\n [data-taste-editor] .tc-fit > input, [data-taste-editor] .tc-measure { grid-area: 1 / 1; }\n [data-taste-editor] .tc-fit > input { position: absolute; inset: 0; width: 100%; min-width: 1px; }\n [data-taste-editor] .tc-measure { visibility: hidden; white-space: pre; padding: 2px 6px; overflow: hidden; }\n [data-taste-editor] .tc-source-completion { position: absolute; inset: 0; padding: 2px 6px; text-align: right; white-space: pre; pointer-events: none; color: var(--tc-secondary); overflow: hidden; z-index: 1; }\n [data-taste-editor] .tc-decimal { flex: 0 0 auto; }\n [data-taste-editor] .tc-decimal-display { position: absolute; inset: 0; padding: 2px 6px; text-align: right; white-space: pre; pointer-events: none; z-index: 1; overflow: hidden; }\n [data-taste-editor] .tc-decimal:focus-within .tc-decimal-display { color: var(--tc-primary); }\n [data-taste-editor] .tc-digit-placeholder { display: inline-block; color: var(--tc-secondary); }\n [data-taste-editor] .tc-decimal input::placeholder { color: transparent; }\n [data-taste-editor] .tc-field-error { position: absolute; top: 100%; right: 0; z-index: 2; width: max-content; max-width: 280px; border-radius: 8px; background: ${"dark"===a?"#302024":"#f9e9ec"}; color: ${"dark"===a?"#f08a95":"#c4253d"}; font-size: 11px; padding: 6px 8px; text-align: center; }\n [data-taste-editor] .tc-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 0 15px 16px; scroll-padding-top: 208px; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; }\n [data-taste-editor] .tc-scroll > header { margin-top: 19px; }\n [data-taste-editor] header { display: flex; align-items: center; gap: 2px; flex-shrink: 0; height: 16px; }\n [data-taste-editor] header button { padding: 0; color: var(--tc-primary); }\n [data-taste-editor] header > svg { flex-shrink: 0; transform: scaleY(-1); }\n [data-taste-editor] header .tc-field { flex: 0 1 auto; font-weight: 600; }\n [data-taste-editor] header .tc-measure { padding: 0; }\n [data-taste-editor] input.tc-title { padding: 0; text-align: left; }\n [data-taste-editor] section { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }\n [data-taste-editor] h3 { font-size: 12px; line-height: 1.3; font-weight: 500; color: var(--tc-primary); margin: 0; }\n [data-taste-editor] .tc-type-role { color: var(--tc-secondary); letter-spacing: normal; height: 30.2px; flex-shrink: 0; }\n [data-taste-editor] .tc-type-role[data-typography-role="body"]:has(~ .tc-row[data-typography-role="body"]:is(:hover, :focus-within)),\n [data-taste-editor] .tc-type-role[data-typography-role="heading"]:has(~ .tc-row[data-typography-role="heading"]:is(:hover, :focus-within)) { color: var(--tc-primary); }\n [data-taste-editor] .tc-row[data-typography-role] { --tc-row-height: 30.2px; --tc-row-slop: 0px; margin-left: 12px; margin-top: -6px; letter-spacing: normal; }\n [data-taste-editor] .tc-row[data-typography-role] .tc-name { padding-inline: 4px; letter-spacing: normal; }\n [data-taste-editor] .tc-row { display: flex; align-items: center; justify-content: space-between; height: var(--tc-row-height); min-width: 0; border-radius: 8px; }\n [data-taste-editor] .tc-row { position: relative; isolation: isolate; }\n [data-taste-editor] .tc-row::before { content: ''; position: absolute; inset: calc(-1 * var(--tc-row-slop)) 0; z-index: -1; }\n [data-taste-editor] .tc-row:hover, [data-taste-editor] .tc-row:focus-within { color: var(--tc-primary); }\n [data-taste-editor] .tc-row:hover input { background: var(--tc-control); color: var(--tc-primary); }\n [data-taste-editor] [data-connection-active=true] { background: var(--tc-control); color: var(--tc-primary); }\n [data-taste-editor] .tc-name { height: 22px; justify-content: flex-start; min-width: 0; touch-action: none; user-select: none; text-align: left; letter-spacing: .12px; flex-shrink: 1; gap: 4px; }\n [data-taste-editor] .tc-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n [data-taste-editor] .tc-row[data-proposal-status=pending] .tc-name { color: var(--tc-muted); }\n [data-taste-editor] .tc-proposal-status { font-size: var(--tc-value-font-size); font-weight: 400; padding: 2px 6px; color: var(--tc-muted); white-space: nowrap; }\n [data-taste-editor] .tc-proposal-recovery { flex-shrink: 0; padding: 12px 15px 15px; border-top: 1px solid var(--tc-border); }\n [data-taste-editor] .tc-proposal-recovery p { margin: 0 0 10px; color: var(--tc-secondary); }\n [data-taste-editor] .tc-proposal-recovery nav { display: flex; gap: 8px; }\n [data-taste-editor] .tc-proposal-recovery button { padding: 6px 10px; background: var(--tc-control); color: var(--tc-primary); }\n ${t("[data-taste-editor] .tc-proposal-status[data-state=in-progress]","var(--tc-muted)","var(--tc-primary)")}\n [data-taste-editor] .tc-name:disabled { cursor: default; background: transparent; }\n [data-taste-editor] .tc-swatch { width: 14px; height: 14px; flex: 0 0 14px; margin-left: 8px; border-radius: 3px; overflow: hidden; pointer-events: none; box-shadow: 0 0 0 1px var(--tc-border); }\n @keyframes tc-rejection-shake { ${i} }\n [data-taste-editor] .tc-name[data-connection-rejected=true] { animation: tc-rejection-shake 220ms ease-out; background: var(--tc-control); color: var(--tc-primary); }\n @media (prefers-reduced-motion: reduce) { [data-taste-editor] .tc-name[data-connection-rejected=true] { animation: none; } }\n [data-taste-editor] .tc-row:focus-within .tc-name, [data-taste-editor] .tc-row:focus-within > .tc-field { color: var(--tc-primary); }\n [data-taste-editor] .tc-row > .tc-field { flex: 1; letter-spacing: .12px; }\n [data-taste-editor] .tc-row > .tc-field.tc-fit { flex: 0 1 auto; max-width: 50%; }\n [data-taste-editor] .tc-row > .tc-field input { text-align: left; }\n [data-taste-editor] input.tc-derived-name-active { color: var(--tc-primary); }\n [data-taste-editor] .tc-value { display: flex; align-items: center; justify-content: flex-end; min-width: 0; max-width: 78%; font-size: var(--tc-value-font-size); font-weight: 500; letter-spacing: -.14px; font-variant-numeric: lining-nums tabular-nums; }\n [data-taste-editor] .tc-token-preview { display: inline-flex; align-items: center; flex: 0 0 auto; }\n [data-taste-editor] .tc-resolved-value { display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; border-radius: 8px; white-space: nowrap; }\n [data-taste-editor] .tc-resolved-value .tc-swatch { width: 16px; height: 16px; flex-basis: 16px; margin-left: 0; border-radius: 4px; box-shadow: none; }\n [data-taste-editor] .tc-shadow-preview { position: relative; width: 16px; height: 16px; border-radius: 4px; background: #ededed; overflow: hidden; }\n [data-taste-editor] .tc-shadow-preview > span { position: absolute; width: 10px; height: 12px; left: 2px; top: 2px; border-radius: 1px; background: white; }\n [data-taste-editor] .tc-shadow-dimension { display: inline-flex; align-items: center; flex-shrink: 0; }\n [data-taste-editor] .tc-separator { flex: 0 0 16px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }\n [data-taste-editor] .tc-reference { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 8px; padding: 2px 6px; }\n /* Only extend above/below the visible badge: never cover its port or scrub fields. */\n [data-taste-editor] .tc-reference:not(:has(.tc-reference))::before,\n [data-taste-editor] .tc-reference:not(:has(.tc-reference))::after { content: ''; position: absolute; left: 0; right: 0; }\n [data-taste-editor] .tc-reference:not(:has(.tc-reference))::before { top: calc((100% - var(--tc-row-height)) / 2 - var(--tc-row-slop)); bottom: 100%; }\n [data-taste-editor] .tc-reference:not(:has(.tc-reference))::after { top: 100%; bottom: calc((100% - var(--tc-row-height)) / 2 - var(--tc-row-slop)); }\n [data-taste-editor] .tc-compound { display: flex; align-items: center; min-width: 0; }\n [data-taste-editor] .tc-compound > .tc-reference { flex: 0 0 auto; }\n [data-taste-editor] .tc-opacity-separator { white-space: pre; }\n [data-taste-editor] .tc-reference > .tc-port,\n [data-taste-editor] .tc-reference > span:not(.tc-field),\n [data-taste-editor] .tc-reference > .tc-field:has(.tc-token-step),\n [data-taste-editor] .tc-reference > .tc-field:has(.tc-token-opacity) { flex-shrink: 0; }\n [data-taste-editor] .tc-literal { white-space: pre; overflow: hidden; text-overflow: ellipsis; display: block; min-width: 0; padding: 2px 0; }\n [data-taste-editor] .tc-literal-prefix { flex-shrink: 0; }\n [data-taste-editor] .tc-available { background: var(--tc-control); flex-shrink: 0; }\n [data-taste-editor] .tc-row:hover .tc-reference, [data-taste-editor] .tc-reference:hover, [data-taste-editor] .tc-reference:focus-within { background: var(--tc-control); color: var(--tc-primary); }\n [data-taste-editor] .tc-row .tc-reference input { background: transparent; }\n [data-taste-editor] .tc-reference input, [data-taste-editor] .tc-reference .tc-measure { padding: 0; }\n [data-taste-editor] .tc-reference .tc-field { --tc-field-inline-padding: 0px; }\n [data-taste-editor] .tc-reference .tc-source-completion { padding: 0; }\n [data-taste-editor] .tc-port { padding: 0; touch-action: none; user-select: none; }\n [data-taste-editor] .tc-port:hover { background: transparent; }\n [data-taste-editor] .tc-add-token { align-self: flex-start; height: 22px; background: var(--tc-control); font-weight: 500; }\n [data-taste-editor] .tc-save { flex-shrink: 0; margin: 0 15px 15px; height: 32px; border-radius: 10px; background: ${R.actionSurface}; color: ${R.actionForeground}; font-weight: 500; }\n [data-taste-editor] .tc-save:hover { background: ${R.actionHover}; color: ${R.actionForeground}; }\n `}),ye("div",{ref:T,className:"tc-scroll",style:{overflowAnchor:"none"},tabIndex:$?0:void 0,children:[ye("header",{children:[ve("button",{"aria-label":y?"Back to taste":"Back to taste collection",onClick:s,children:ve(c,{size:16})}),ve(m,{size:14}),y?ve("span",{className:"tc-title",children:y.name}):ve(cr,{label:"Taste name",readOnly:$,compact:!0,value:C.name,placeholder:"Name this taste",className:"tc-title",onCommit:e=>L({...C,name:e})})]}),y?y.preview(Te):ve(Xt,{draft:Te,preferPageComponent:h,waitForPageFoundations:$&&h,dimensionId:X??ee,theme:a}),y&&ve("h3",{children:"Uses"}),["layout","typography","color"].map(e=>{let t="color"===e?"color":"layout",r=t=>(!y||y.constraintIds.includes(t.id))&&(t.group??("text"===t.id?"typography":t.kind))===e;return y&&!C.constraints.some(r)?null:ye("section",{"aria-label":"typography"===e?"Typography constraints":"layout"===t?"Layout constraints":"Color constraints",children:[ve("h3",{children:"typography"===e?"Typography":"layout"===t?"Layout":"Color"}),ve("datalist",{id:`${Ae}-${e}`,children:C.constraints.filter(e=>e.kind===t).map(e=>ve("option",{value:e.name},e.id))}),C.constraints.filter(r).map((e,t,r)=>{let n=e.kind,a=C.constraints.filter(t=>!U(C.constraints,e.id,t.id)).map(e=>e.name),i=C.constraints.find(t=>t.id===e.parentId),o=!!e.parentId,l=me.some(t=>!!t.active&&("source"===t.port&&t.id===e.id||"target"===t.port&&t.validTarget&&t.target===e.id)),s=me.some(t=>!!t.active&&("target"===t.port&&t.id===e.id||"source"===t.port&&t.validTarget&&t.target===e.id)),c=D?.active&&D.validTarget?"source"===D.port&&D.target===e.id?D.id:"target"===D.port&&D.id===e.id?D.target:null:null,u=C.constraints.find(e=>e.id===c)?.name,h=!(!D?.active||"source"!==D.port||o||s||U(C.constraints,e.id,D.id)),g=c?V(C.constraints,e.id,c):e.derivative,f=o||s||!!e.value,m=ve(hr,{row:e,background:R.surface,constraints:c?Ee.map(t=>t.id===e.id?{...t,parentId:c,derivative:g}:t):Ee}),v=t=>{if(!t)return O(null),void(e.parentId?L({...C,constraints:J(C.constraints,e.id)}):ze(e.id,{value:""}));let r=C.constraints.find(e=>e.name.toLowerCase()===t.replace(/^@/,"").toLowerCase());if(!r)throw Error("Choose an existing constraint");Pe(e.id,r.id)};return ye(ge,{children:[e.typographyRole&&r[t-1]?.typographyRole!==e.typographyRole&&ve("h4",{className:"tc-type-role","data-typography-role":e.typographyRole,style:ft,children:"body"===e.typographyRole?"Body":"Heading"}),ye("div",{"data-typography-role":e.typographyRole,className:"tc-row","data-constraint-id":e.id,onPointerEnter:()=>Q(e.id),onPointerLeave:()=>Q(null),onFocusCapture:()=>te(e.id),onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||te(null)},"data-proposal-status":p?e.value||e.parentId?"done":"pending":void 0,children:[e.typographyRole&&ve(mt,{left:-8,color:`color-mix(in srgb, ${R.secondary} 40%, ${R.surface})`,last:r[t+1]?.typographyRole!==e.typographyRole}),ve("button",{type:"button",disabled:$,className:"tc-name","data-connection-active":l,"data-connection-rejected":Ie===e.id,"aria-label":`Drag ${e.name} to connect`,onPointerDown:t=>Oe(t,e.id,"source"),onPointerEnter:()=>F({id:e.id,port:"source"}),onPointerLeave:()=>F(null),children:ve("span",{style:"source"===W?.port&&e.parentId===W.id?{color:"var(--tc-primary)"}:void 0,children:e.typographyRole?e.name.replace(`${e.typographyRole}-`,""):e.name})}),!$&&"error"!==p||e.value||e.parentId?ve("div",{inert:$,style:{display:"contents"},children:ye(nr,{className:"tc-value",label:`${e.name} expression`,onCommit:t=>{let[r="",a,...i]=t.split("⇆");if(i.length)throw Error("Use one scale value");let[o="",l,...s]=r.split("×");if(s.length)throw Error("Use one multiplier or rotation");let d={};if(o.trim().startsWith("@")){let t=o.trim().slice(1).trim(),r=C.constraints.find(e=>e.name.toLowerCase()===t.toLowerCase());if(!r)throw Error("Choose an existing constraint");let a=U(C.constraints,e.id,r.id);if(a)throw Error(a);if(d.parentId=r.id,d.derivative=void 0===l?e.derivative:We(l.trim().replace(/deg$/,"")),"layout"===n&&d.derivative<0)throw Error("Use zero or a positive multiplier")}else{if(void 0!==l)throw Error("A multiplier needs a source reference");o.trim()&&K(n,o.trim()),d.value=o.trim(),d.parentId=null}if(void 0!==a&&(d.scale=We(a.trim())/("color"===n?100:1),"layout"===n&&("increment"===e.scaleMode?d.scale<=0:d.scale<0)))throw Error("Use a nonnegative growth rate or a positive weight increment");ze(e.id,d)},onPointerEnter:()=>F({id:e.id,port:"target"}),onPointerLeave:()=>F(null),children:[o||s?ye("span",{className:"tc-reference","data-connection-active":s,onContextMenu:t=>{e.parentId&&(t.preventDefault(),t.stopPropagation(),v(""))},children:[ve("button",{className:"tc-port","aria-label":`Connect ${e.name} to parent`,onPointerDown:t=>Oe(t,e.id,"target"),onClick:e=>{we.current||e.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),ve(cr,{compact:!0,label:`${e.name} parent reference`,sourceSuggestions:a,bareSource:!0,arrowNavigation:!0,value:u??(o?i?.name??"":""),onCommit:v})]}):ye(be,{children:[h&&ve("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"}),(!h||!!e.value)&&ve(cr,{compact:!0,label:`${e.name} base value`,sourceSuggestions:a,arrowNavigation:!0,value:e.value,onScrubPreview:t=>Ce(null===t?null:{id:e.id,patch:{value:t}}),placeholder:"–",scrub:"layout"===n?{step:1,min:0}:"color"===n?{step:1,compound:!0}:void 0,clearable:!0,onCommit:t=>{t.startsWith("@")?v(t):(t&&K(n,t),ze(e.id,{value:t}))}})]}),"font"!==n&&(o||s)&&ye(be,{children:[ve("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" × ",children:ve(d,{size:12})}),ve(cr,{compact:!0,label:`${e.name} derivative`,arrowNavigation:!0,onScrubPreview:t=>Ce(null===t?null:{id:e.id,patch:{derivative:Number(t.replace(/deg$/,""))}}),decimal:"layout"===n,scrub:"color"===n?{step:1,shiftStep:5}:{step:.01,min:0},value:"color"===n?`${g}deg`:g.toFixed(2),onCommit:t=>{let r=We("color"===n?t.replace(/deg$/,""):t);if("layout"===n&&r<0)throw Error("Use zero or a positive multiplier");ze(e.id,{derivative:r})}})]}),"font"!==n&&f&&ye(be,{children:[ve("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" ⇆ ",children:ve(x,{size:12})}),ve(cr,{compact:!0,label:`${e.name} scaling`,title:"color"===n?"OKLCH lightness points per step":"increment"===e.scaleMode?"Weight units per step":"Growth per step: 0.75 means +75%; stepped results round to the nearest whole number",arrowNavigation:!0,onScrubPreview:t=>Ce(null===t?null:{id:e.id,patch:{scale:Number(t)/("color"===n?100:1)}}),decimal:"color"===n?1:"increment"!==e.scaleMode,scrub:"increment"===e.scaleMode?{step:1,min:1,shiftStep:5}:"color"===n?{step:.1,shiftStep:.5}:{step:.01,min:0},value:"layout"===n&&"increment"!==e.scaleMode?e.scale.toFixed(4).replace(/0{1,2}$/,""):(e.scale*("color"===n?100:1)).toFixed("color"===n?1:"increment"===e.scaleMode?0:2),onCommit:t=>{let r=We(t)/("color"===n?100:1);if("layout"===n&&("increment"===e.scaleMode?r<=0:r<0))throw Error("Use a nonnegative growth rate or a positive weight increment");ze(e.id,{scale:r})}})]}),"color"===n&&m]})}):ve("span",{className:"tc-proposal-status",role:"status","data-state":"pending","aria-label":`${e.name}: ${"error"===p?"Not returned":"Pending"}`,children:"error"===p?"Not returned":"Pending"})]},e.id)]},e.id)})]},e)}),ye("section",{"aria-label":"Ad-hoc tokens",inert:$,children:[ve("h3",{children:"Tokens"}),C.tokens.filter(e=>!y||y.tokenIds.includes(e.id)).map(e=>{let t=`token:${e.id}`,r=q(e.value,C.constraints),n="source"===D?.port?D.target:D?.id,a=D?.active&&D.validTarget&&n&&fr(n).row===t?"source"===D.port?D.id:D.target:null,i=C.constraints.find(e=>e.id===a),o=i?Ut(e.value,i,C.constraints,fr(n).index,fr(n).dimensionIndex)??e.value:$e?.id===e.id?$e.value:e.value,l=q(o,C.constraints),s=!!H(o),d=qt(o,C.constraints),c=e=>me.some(t=>t.active&&("target"===t.port?t.id===e:t.validTarget&&t.target===e)),u=D?.active&&"source"===D.port&&"layout"===C.constraints.find(e=>e.id===D.id)?.kind?(d?.dimensions??[]).flatMap((e,t)=>void 0!==e.referenceIndex||l.some(t=>t.start>=e.start&&t.end<=e.end)?[]:[{...e,index:t}]):[],p=D?.active&&"source"===D.port&&!c(t)&&!je(t,D.id),h=p?Y(o,C.constraints).find(e=>!e.reference):void 0,g=h&&(h.start>0||h.end<o.length)?h:void 0,f=ve("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"},"available"),m=(t,n)=>{let a=r[t];return a?e.value.slice(0,a.start)+n+e.value.slice(a.end):n},v=(e,t)=>{let n={...r[e]??l[e],...t};return m(e,`@${n.name}${null===n.step||0===n.step?"":`: ${n.step}`}${void 0===n.opacity?"":` / ${n.opacity}`}`)},b=[],w=(r,n)=>{if(n<=r)return;let a=r,i=[...g?[{...g,index:-1,dimension:"color"}]:[],...u].filter(e=>e.start>=r&&e.start<n).sort((e,t)=>e.start-t.start);for(let r of i)x(a,r.start),-1===r.index?(b.push(f),a=r.start):(b.push(ye("span",{className:"tc-shadow-dimension","data-connection-id":`${t}:dim:${r.index}`,"data-shadow-dimension":r.dimension,children:[f,ve("button",{className:"tc-literal","aria-label":`Edit ${e.name} ${r.dimension}`,onClick:()=>ne(e.id),children:o.slice(r.start,r.end)})]},`dimension-${r.index}`)),a=r.end);x(a,n)},x=(t,r)=>{if(r<=t)return;let n=e=>o.slice(0,t)+e+o.slice(r);b.push(ve(dr,{className:"tc-literal"+(r===g?.start?" tc-literal-prefix":""),label:`Edit ${e.name} value`,onEdit:()=>ne(e.id),value:o.slice(t,r),onPreview:t=>Re(null===t?null:{id:e.id,value:n(t)}),onCommit:t=>De(e.id,n(t))},`text-${t}`))},k=0;return l.forEach((a,o)=>{w(k,a.start),b.push(((a,o)=>{let l=d?.dimensions.findIndex((e,r)=>e.start===a.start&&c(`${t}:dim:${r}`)),u="color"===i?.kind&&n===t&&Y(e.value,C.constraints)[0]?.start===a.start?t:void 0!==l&&l>=0?`${t}:dim:${l}`:s?t:`${t}:ref:${o}`,p=s?e.name:`${e.name} mention ${o+1}`,h=C.constraints.find(e=>e.name.toLowerCase()===a.name.toLowerCase()),g=c(u)||c(t),f=ae?.id===e.id&&ae.index===o?ae:null,y=!!f||null!==a.step&&0!==a.step||$e?.id===e.id&&null!=r[o]?.step&&0!==r[o]?.step;return ye("span",{className:"tc-reference","data-connection-id":u,"data-connection-active":g,onBlur:e=>{f&&!e.currentTarget.contains(e.relatedTarget)&&le(null)},onPointerEnter:()=>F({id:u,port:"target"}),onPointerLeave:()=>F(null),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),O(null);let n=r[o],a=n&&Z(C.constraints,e.value.slice(n.start,n.end));De(e.id,m(o,n?.math?_(`calc(${e.value.slice(n.start,n.end)})`,C.constraints)?.css??"":a?P(a):""))},children:[ve("button",{className:"tc-port","aria-label":`Connect ${p} to constraint`,onPointerDown:e=>Oe(e,u,"target"),onClick:e=>{we.current||e.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),ve(cr,{compact:!0,label:`${p} reference`,sourceSuggestions:C.constraints.filter(e=>!je(u,e.id)).sort((e,t)=>+(t.kind===h?.kind)-+(e.kind===h?.kind)).map(e=>e.name),bareSource:!0,arrowNavigation:!0,value:f?.name??a.name,onDraftChange:t=>{if(y||!t.endsWith(":"))return!1;let r=t.slice(0,-1).trim().replace(/^@/,"");return!!H(`@${r}`)&&(le({id:e.id,index:o,name:r}),!0)},onCommit:t=>{if(!t)return void De(e.id,m(o,""));let r=H(t.startsWith("@")?t:`@${t}`);if(!r)throw new Error("Use a source name with an optional : step");De(e.id,v(o,{name:r.name,...t.includes(":")?{step:r.step}:{},...t.includes("/")?{opacity:r.opacity}:{}}))}}),y&&ye(be,{children:[ye("span",{"aria-hidden":"true",children:[":"," "]}),ve(cr,{compact:!0,className:"tc-token-step",label:`${p} step`,arrowNavigation:!0,value:f||null===a.step?"":String(a.step),placeholder:"step",autoFocus:!!f,onCancel:()=>le(null),scrub:{step:1,defaultValue:0},onScrubPreview:t=>Re(null===t?null:{id:e.id,value:v(o,{...f?{name:f.name}:{},step:We(t)})}),onCommit:t=>{De(e.id,v(o,{...f?{name:f.name}:{},step:t?We(t):null})),le(null)}})]}),("color"===h?.kind||void 0!==a.opacity)&&ye(be,{children:[ye("span",{className:"tc-opacity-separator","aria-hidden":"true",children:[" ","/"," "]}),ve(cr,{compact:!0,label:`${p} opacity`,arrowNavigation:!0,className:"tc-token-opacity",value:a.opacity??"1",scrub:{step:a.opacity?.endsWith("%")?1:.01,min:0,max:a.opacity?.endsWith("%")?100:1,shiftStep:a.opacity?.endsWith("%")?5:.05},onScrubPreview:t=>Re(null===t?null:{id:e.id,value:v(o,{opacity:t})}),onCommit:t=>{if(t&&null===G(t))throw Error("Use opacity from 0 to 1, or 0% to 100%");De(e.id,v(o,{opacity:t||void 0}))}})]})]},o)})(a,o)),k=a.end}),w(k,o.length),ye("div",{className:"tc-row","data-token-id":e.id,"data-token-value":o,children:[ve(cr,{label:`${e.name} name`,className:fe.has(t)?"tc-derived-name-active":void 0,compact:!0,value:e.name,onDelete:y?void 0:()=>{O(null),L({...C,tokens:C.tokens.filter(t=>t.id!==e.id)})},onCommit:t=>{if(!t)throw Error("Give this token a name");L({...C,tokens:C.tokens.map(r=>r.id===e.id?{...r,name:t}:r)})}}),ye(nr,{className:"tc-value",label:`${e.name} expression`,onSelectionStart:()=>le(null),onCommit:t=>De(e.id,t),onPointerEnter:()=>F({id:t,port:"target"}),onPointerLeave:()=>F(null),children:[(l.length>0||g||u.length>0)&&re!==e.id?ve("span",{className:"tc-compound",onDoubleClick:t=>{t.target.closest("input, .tc-port")||ne(e.id)},children:b}):ye("span",{className:c(t)?"tc-reference":"tc-compound","data-connection-active":c(t),children:[p&&!g&&f,ve(cr,{compact:!0,label:`${e.name} value`,sourceSuggestions:C.constraints.map(e=>e.name),scrub:{step:1,shiftStep:5,compound:!0},onScrubPreview:t=>Re(null===t?null:{id:e.id,value:t}),clearable:!0,autoFocus:re===e.id,value:o,placeholder:"–",onCommit:t=>{De(e.id,t),ne(null)}})]}),ve(pr,{value:o,background:R.surface,constraints:Ee,name:e.name})]})]},e.id)}),!y&&ye("button",{className:"tc-add-token","aria-label":"Add token",onClick:()=>L({...C,tokens:[...C.tokens,{id:`${Ae}-${++Le.current}`,name:`Token ${C.tokens.length+1}`,value:""}]}),children:[ve(v,{size:12}),"Add token"]})]}),f,(k||xe)&&ve("p",{role:"status",style:{margin:0,padding:10,borderRadius:8,background:R.control,textAlign:"center"},children:k||xe})]}),S,g?ye("div",{className:"tc-proposal-recovery",children:[ye("p",{role:"alert",children:[g.message," Values already received are kept above."]}),ye("nav",{"aria-label":"Proposal recovery",children:[ve("button",{type:"button",onClick:g.onRetry,children:"Retry"}),ve("button",{type:"button",onClick:g.onTemplate,children:"Use template"})]})]}):y?null:ve("button",{className:"tc-save",disabled:w,onClick:()=>$?s():b?b(C):ke("Prototype only — your taste has not been saved"),children:$?"Cancel proposal":w?"Saving…":"Save this taste"}),ve(sr,{pane:E,edges:ce,visible:pe.map(e=>({parent:e.id,child:e.target})),suspended:!!D||!!M,revision:JSON.stringify([C,Se,$e,re,D?.id,D?.target,D?.validTarget]),color:R.primary}),(D?[D]:M?[M]:[]).filter(e=>e.active).map(e=>ve(mr,{drag:e,pane:E,color:R.primary},`${e.id}:${e.target}`))]})}function yr({root:e,session:t,visible:r=!0}){let n=le(t.subscribeLook,t.getLookSnapshot,t.getLookSnapshot),[i,o]=oe(null);return se(()=>{let t=e.current;if(!r||!t||!n||n.expiresAt<=Date.now())return void o(null);let a,i=t.ownerDocument.defaultView,l=()=>{if(n.expiresAt<=Date.now())return void o(null);let e=function(e,t){if(!t)return e.querySelector("[data-taste-editor] header");let r="dimension"===t.kind?"data-constraint-id":"data-token-id";return[...e.querySelectorAll(`[${r}]`)].find(e=>e.getAttribute(r)===t.id)??null}(t,n.target),r=e&&function(e,t){let r=e.ownerDocument.defaultView;if(!r||!t.isConnected)return!1;let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0||n.top<0||n.bottom>r.innerHeight||n.left<0||n.right>r.innerWidth)return!1;for(let a=t;a;a=a.parentElement){let i=r.getComputedStyle(a);if("none"===i.display||"hidden"===i.visibility||"collapse"===i.visibility)return!1;if(a!==t){let e=a.getBoundingClientRect();if(/(auto|scroll|hidden|clip)/.test(i.overflowY)&&(n.top<e.top||n.bottom>e.bottom)||/(auto|scroll|hidden|clip)/.test(i.overflowX)&&(n.left<e.left||n.right>e.right))return!1}if(a===e)break}let a=e.querySelector(".tc-dimension-preview");if(a){let e=a.getBoundingClientRect();if(e.width>0&&e.height>0&&n.bottom>e.top-16&&n.top<e.bottom+4&&n.right>e.left-4&&n.left<e.right+4)return!1}return!0}(t,e)?e:null;r instanceof HTMLElement&&ne(r,r),o(e=>e?.lookId===n.id&&e.element===r?e:{lookId:n.id,element:r}),a=i.requestAnimationFrame(l)};return l(),()=>i.cancelAnimationFrame(a)},[e,n,r]),!r||!n||i?.lookId!==n.id||!i.element||n.expiresAt<=Date.now()?null:ve(a,{element:i.element,engaged:!1,label:n.target?`AI is looking at this ${n.target.kind}`:"AI is looking at this Taste",inverse:!0},n.id)}function br(e,t){t=Ce(t,e);let r=new Map,n=e=>{let r=t.constraints.find(t=>t.id===e);return r?r.parentId?`@${t.constraints.find(e=>e.id===r.parentId)?.name??r.parentId}${"font"===r.kind?"":"color"===r.kind?` · hue ${r.derivative}°`:` × ${r.derivative}`}`:r.value:"Missing dimension"},a=e=>{let i=e.children.filter(e=>"string"==typeof e).join(" ").trim();for(let[a,o]of Object.entries(e.styles)){let l=`${o.kind}:${o.id}:${o.step??0}`,s=r.get(l);if(!s){let e="token"===o.kind?t.tokens.find(e=>e.id===o.id):void 0,a="dimension"===o.kind?t.constraints.find(e=>e.id===o.id):void 0,i=[],d=new Set("dimension"===o.kind?[o.id]:[]),c=e=>{if(d.has(e))return;d.add(e);let r=t.constraints.find(t=>t.id===e);if(!r)return;let a="Unresolved";try{a=P(j(t.constraints,e))}catch{}i.push({id:e,name:r.name,expression:n(e),value:a}),r.parentId&&c(r.parentId)};e&&q(e.value,t.constraints).forEach(e=>{let r=t.constraints.find(t=>t.name===e.name);r&&c(r.id)}),a?.parentId&&c(a.parentId),s={key:l,source:o,name:e?.name??a?.name??o.id,expression:e?.value??n(o.id),derived:i.length>0,dependencies:i,values:[],targets:[]},r.set(l,s)}let d=Le(t,o,a)??"Unresolved";s.values.includes(d)||s.values.push(d),s.targets.push({nodeId:e.id,label:i.slice(0,64)||`${e.tag} · ${e.id}`,property:a})}e.children.forEach(e=>{"string"!=typeof e&&a(e)})};return a(e.root),[...r.values()]}function wr({fragment:e,draft:t,theme:r,onBack:n,onChange:a}){let i=ie(null),[o,l]=oe(null),s=br(e,t),d=[...new Set(s.flatMap(e=>[..."dimension"===e.source.kind?[e.source.id]:[],...e.dependencies.map(e=>e.id)]))],c=s.filter(e=>"token"===e.source.kind).map(e=>e.source.id),u=s.filter(e=>o&&(e.source.kind===o.kind&&e.source.id===o.id||"dimension"===o.kind&&e.dependencies.some(e=>e.id===o.id))).flatMap(e=>e.targets.map(e=>e.nodeId)),p=[],h=e=>{let t=Object.entries(e.localStyles??{});t.length&&p.push({id:e.id,entries:t}),e.children.forEach(e=>{"string"!=typeof e&&h(e)})};h(e.root),de(()=>{i.current?.querySelector("button")?.focus()},[e.id]);let g=A[r];return ve("section",{ref:i,"aria-label":`${e.name} details`,"data-fragment-detail":!0,"data-popmelt-panel":!0,style:{position:"absolute",inset:0,display:"flex"},children:ve(vr,{draft:Ce(t,e),theme:r,onBack:n,style:{flex:1,minHeight:0,border:0,maxHeight:"100%"},onChange:r=>{let n=new Set((e.tokens??[]).map(e=>e.id));a({...t,constraints:r.constraints,tokens:r.tokens.filter(e=>!n.has(e.id)),fragments:t.fragments?.map(t=>t.id===e.id?{...t,tokens:r.tokens.filter(e=>n.has(e.id))}:t)})},detail:{name:e.name,constraintIds:d,tokenIds:c,onHover:l,preview:t=>ve("div",{style:{position:"sticky",top:16,zIndex:1,flexShrink:0,borderRadius:8,background:g.control},children:ve(it,{fragment:{...e,tokens:[]},draft:t,height:240,highlightedNodes:u})})},fragments:ye(be,{children:[ve("button",{type:"button","aria-pressed":t.featuredComponentId===e.id,onClick:()=>a({...t,featuredComponentId:e.id}),children:t.featuredComponentId===e.id?"Featured preview":"Use as preview"}),ye("details",{children:[ve("summary",{children:"Affected parts"}),s.map(e=>ye("details",{"data-fragment-use":e.key,children:[ye("summary",{children:[e.name,e.source.step?`: ${e.source.step}`:""," ·"," ",new Set(e.targets.map(e=>e.nodeId)).size," ","parts"]}),e.targets.map(e=>ye("div",{children:[e.label," · ",e.property]},`${e.nodeId}:${e.property}`))]},e.key))]}),p.length>0&&ye("details",{children:[ve("summary",{children:"Local structure"}),p.map(e=>ye("section",{children:[ve("h3",{children:e.id}),e.entries.map(([e,t])=>ye("div",{className:"tc-row",children:[ve("span",{className:"tc-name",children:e}),ve("span",{className:"tc-value",children:t})]},e))]},e.id))]})]})})})}function xr(e){let t=ie(null),[r,n]=oe(null),a=ie(null),[i]=oe(()=>{let t=D(e.draft);return e.draft||t.create("extract"),t}),o=e.session??i,s=le(o.subscribe,o.getSnapshot,o.getSnapshot),{draft:d,state:c,message:u,runId:p}=s,h=d?.fragments?.find(e=>e.id===r);se(()=>{h||a.current?.isConnected&&(a.current.focus({preventScroll:!0}),a.current=null)},[h]);let g=ie(e.onDraft),f=ie(null);g.current=e.onDraft,de(()=>{if("running"!==o.getSnapshot().state)return;let t=Symbol();f.current=t;let r,n=e=>o.stream(p,{draft:e}),a=e=>o.stream(p,{state:e}),i=e=>o.stream(p,{message:e}),l=new AbortController,s=setTimeout(()=>{i("This is taking longer than expected. Please try again or use the template."),a("error"),l.abort()},19e4),d=!1;return(async()=>{try{if(await Promise.resolve(),l.signal.aborted)return;if(!e.bridgeUrl)throw Error("Connect the local bridge to propose a taste.");let t=function(e=document){let t=e.defaultView;if(!t||!e.body)throw Error("The current page is not ready.");let r=new URL(e.URL);r.search="",r.hash="",r.username="",r.password="";let n=new Map,a=new Map,i=[],o=new Map,l=new Map,s=e.createTreeWalker(e.body,1),d=0;for(;s.nextNode()&&d++<4e3;){let e=s.currentNode;if(e.closest('script, style, template, noscript, [hidden], [aria-hidden="true"], [contenteditable], [data-popmelt], [data-popmelt-toolbar], [data-taste-editor], [data-taste-navigation]'))continue;let r=e.getBoundingClientRect();if(!r.width||!r.height)continue;let d=t.getComputedStyle(e);if("none"===d.display||"visible"!==d.visibility||"0"===d.opacity)continue;let c={};for(let e of Ft)c[e]=d[e].slice(0,160);let u=e.tagName.toLowerCase(),p=JSON.stringify([u,c]),h=n.get(p),g=(/^(input|textarea|select|option)$/.test(u)?"":[...e.childNodes].filter(e=>3===e.nodeType).map(e=>e.textContent??"").join(" ").replace(/\s+/g," ").trim())||/^(main|nav|aside|header|footer|section|article|form|button|input)$/.test(u)||/^(flex|grid)$/.test(d.display);if(i.length<40&&g&&r.bottom>0&&r.right>0&&r.top<t.innerHeight&&r.left<t.innerWidth&&(h||n.size<160)){let s=e.parentElement;for(;s&&!o.has(s);)s=s.parentElement;let d=s?o.get(s):null,c=`${d}:${u}`,h=l.get(c)??0;if(h<3){l.set(c,h+1);let s=i.length;i.push({id:s,parent:d,sample:a.get(p)??n.size,box:[r.left/t.innerWidth,r.top/t.innerHeight,r.width/t.innerWidth,r.height/t.innerHeight].map(e=>Math.round(100*e))}),o.set(e,s)}}if(h){h.count++;continue}if(n.size>=160)continue;let f=/^(input|textarea|select|option)$/.test(u)?"":[...e.childNodes].filter(e=>3===e.nodeType).map(e=>e.textContent??"").join(" ").replace(/\s+/g," ").trim().slice(0,160);a.set(p,n.size),n.set(p,{tag:u,text:f,count:1,styles:c})}return{url:r.href,title:e.title.slice(0,160),viewport:{width:t.innerWidth,height:t.innerHeight},samples:[...n.values()],...i.length?{outline:i}:{}}}(),o=await L(`${e.bridgeUrl}/cloud-taste/propose`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:l.signal});if(!o.ok)throw Error((await o.json().catch(()=>null))?.error||`Taste proposal unavailable (${o.status}).`);if(!o.body)throw Error("The bridge returned no proposal stream.");let s=o.body.getReader(),c=new TextDecoder,u="",p=e=>{if(!e.trim()||l.signal.aborted)return;let t=JSON.parse(e);if("status"===t.type&&i(t.message),"error"===t.type)throw r=t.message,Error(t.message);"progress"===t.type?n(t.draft):"complete"===t.type&&(d=!0,n(t.draft),g.current(t.draft),a("complete"))};try{for(;;){let e,{value:t,done:r}=await s.read();if(r)break;if(u+=c.decode(t,{stream:!0}),u.length>256e3)throw Error("The proposal stream is too large.");for(;-1!==(e=u.indexOf("\n"));)p(u.slice(0,e)),u=u.slice(e+1)}p(u+c.decode())}finally{s.releaseLock()}if(!d&&!l.signal.aborted)throw Error("The proposal ended before all dimensions were returned.")}catch(e){l.signal.aborted||(i(r??(e instanceof Error&&/template|dimensions were returned/.test(e.message)?e.message:"We couldn’t finish the proposal. Please try again or use the template.")),a("error"),l.abort())}finally{clearTimeout(s)}})(),()=>{clearTimeout(s),l.abort(),Promise.resolve().then(()=>{f.current===t&&o.stream(p,{state:"error",message:"Extraction stopped. Retry or continue editing the partial draft."})})}},[e.bridgeUrl,p,o]);let m=A[e.theme];return ye("div",{ref:t,style:{...e.style,display:"flex",flexDirection:"column",background:m.surface,color:m.primary,fontFamily:l,borderRadius:20,overflow:"hidden",position:"relative",minHeight:0},children:[ve("div",{inert:!!h||e.saving,style:{display:"flex",flex:1,minHeight:0,visibility:h?"hidden":void 0,opacity:h?0:void 0},children:ve(vr,{history:o.history,theme:e.theme,draft:d??W(),onChange:t=>{o.edit(t),e.onDraft(t)},onBack:e.onBack,onSave:e.onSave,saving:e.saving,saveNotice:e.saveNotice,saveAction:e.saveAction,proposalState:"idle"===c?"complete":c,preferPageComponent:"extract"===s.mode,fragments:ve(ot,{draft:d??W(),session:o,bridgeUrl:e.bridgeUrl,theme:e.theme,visible:!1!==e.visible&&!e.saving,onDraft:e.onDraft,onInspect:e=>{a.current=document.activeElement instanceof HTMLElement?document.activeElement:null,n(e)}},p),proposalRecovery:"error"===c?{message:u,onRetry:()=>{o.create("extract")},onTemplate:e.onTemplate}:void 0,style:{flex:1,minHeight:0,border:0}},p)}),h&&d&&ve(wr,{fragment:h,draft:d,theme:e.theme,onBack:()=>n(null),onChange:t=>{o.edit(t),e.onDraft(t)}},h.id),ve(yr,{root:t,session:o,visible:e.visible})]})}var kr="popmelt:taste-recovery:v1:",Sr=e=>"string"==typeof e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e);function Cr(e){if(Sr(e.accountId)&&["production","staging"].includes(String(e.environment))&&"string"==typeof e.projectKey&&e.projectKey&&!(e.projectKey.length>256))return JSON.stringify([e.environment,e.accountId,e.projectKey])}function $r(e,t){if(!e||"object"!=typeof e)return;let r=e;return 1===r.version&&r.scope===t&&Sr(r.key)&&Sr(r.id)&&(e=>Number.isSafeInteger(e)&&Number(e)>=0)(r.revision)&&Number.isFinite(r.updatedAt)&&Ze(r.document)&&(null===r.pending||r.pending&&r.pending.id===r.id&&r.pending.expectedRevision===r.revision&&Sr(r.pending.requestId)&&Ze(r.pending.document))?r:void 0}function Rr(e,t=localStorage){let r=[];for(let n=0;n<t.length;n++){let a=t.key(n);if(!a?.startsWith(kr))continue;let i=t.getItem(a);if(i&&!(i.length>45e5))try{let t=$r(JSON.parse(i),e);t&&a===kr+t.key&&r.push(t)}catch{}}return r.sort((e,t)=>t.updatedAt-e.updatedAt)}function Er(e,t=localStorage){if(!$r(e,e.scope))throw Error("Invalid recovery record");let r=JSON.stringify(e);if(r.length>45e5)throw Error("Recovery record too large");t.setItem(kr+e.key,r)}function Tr(e,t=localStorage){if(!Sr(e))throw Error("Invalid recovery key");t.removeItem(kr+e)}function Ir({theme:e,records:t,onResume:r}){let n=A[e];return t.length?ye("section",{"aria-label":"Unsaved tastes","data-taste-recovery":!0,style:{display:"flex",flexDirection:"column",gap:8,marginBottom:24,color:n.secondary},children:[ve("style",{children:`\n [data-taste-recovery] button:focus-visible {\n outline: 2px solid ${n.primary};\n outline-offset: 4px;\n }\n [data-taste-recovery] button:hover [data-recovery-name],\n [data-taste-recovery] button:focus-visible [data-recovery-name] {\n color: ${n.primary};\n }\n `}),ve("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",letterSpacing:"-.12px"},children:"Unsaved"}),ve("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:16},children:t.map(e=>{let t=e.name||"Untitled Taste",a=e.preview?.savedDocument?.document;return ye("li",{style:{minWidth:0,position:"relative"},children:[ve("div",{"aria-hidden":"true",inert:!0,style:{position:"relative",height:104,overflow:"hidden",borderRadius:8,background:n.control},children:a?.draft.featuredComponentId?ve(lt,{document:a}):e.preview?ve(nt,{recipe:e.preview}):null}),ye("button",{type:"button","aria-label":`View ${t} details`,title:`Resume ${t}`,onClick:()=>r(e.key),style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:16,width:"100%",marginTop:-104,padding:"108px 0 0",position:"relative",border:0,borderRadius:8,background:"transparent",color:"inherit",font:"inherit",lineHeight:1.3,letterSpacing:".12px",textAlign:"left",cursor:"pointer"},children:[ve("span",{"data-recovery-name":!0,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:t}),ve("span",{style:{flexShrink:0,color:n.muted},children:e.pending?"Save unconfirmed":"Draft"})]})]},e.key)})})]}):null}function Nr({theme:e,pending:t,disabled:r=!1,onDiscard:n}){let a=A[e];return ye("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"8px 16px",fontSize:12},children:[ve("p",{style:{margin:0,color:a.secondary,lineHeight:1.4},children:t?"Save unconfirmed. Discard removes this browser draft; any remote save is unchanged.":"Unsaved work on this browser. Discard removes this draft."}),ve("button",{type:"button",disabled:r,onClick:n,style:{font:"inherit",color:a.primary,background:a.control,padding:8,border:0,borderRadius:8,cursor:r?"default":"pointer",opacity:r?.5:1},children:"Discard draft"})]})}var Ar=new WeakMap;function Lr(e){let[t,r]=oe(!1),[n,a]=oe(null),[i,o]=oe(!1),[l,s]=oe(!1),[d,c]=oe(null),[u,p]=oe(null),h=ie({}),g=A[e.theme],f=ie(!1),m=()=>{let t=e.session??h.current,r=e.session?.getSnapshot().runId??"",n=Ar.get(t);return(!n||n.runId!==r)&&(n={runId:r,recoveryKey:e.recovery?.key??crypto.randomUUID(),id:e.recovery?.id??e.saved?.id??crypto.randomUUID(),revision:e.recovery?.revision??e.saved?.revision??0,pending:e.recovery?.pending??null,recoveryScope:e.recovery?.scope??e.recoveryScope},Ar.set(t,n)),n},v=(t,r)=>{t.recoveryScope&&(Er({version:1,key:t.recoveryKey,scope:t.recoveryScope,updatedAt:Date.now(),id:t.id,revision:t.revision,document:r,pending:t.pending}),e.onRecoveryChange?.())},y=t=>{t.recoveryScope&&(Tr(t.recoveryKey),e.onRecoveryChange?.())},b=ie(()=>{});b.current=()=>{if(!e.recoveryScope)return;let t,r=e.session?.getSnapshot(),n=r?.draft??e.draft;if(n&&"running"!==r?.state){try{t=Qe(n)}catch{return}try{let r=m();if(r.recoveryScope&&r.recoveryScope!==e.recoveryScope)return;r.recoveryScope=e.recoveryScope,r.pending||e.recovery||!e.saved||Ge(t)!==Ge(e.saved.document)?v(r,t):y(r),p(null)}catch{p("Browser recovery storage is unavailable. Keep this tab open until a remote save is confirmed.")}}},de(()=>(b.current(),e.session?.subscribe(()=>b.current())),[e.session,e.recoveryScope,e.draft]);let w={font:"inherit",color:g.primary,background:g.control,padding:8,border:0,borderRadius:8,cursor:"pointer"};return ve(xr,{...e,onSave:t=>{l||(async t=>{if(!f.current&&e.bridgeUrl){f.current=!0,r(!0),a(null);try{let r=Qe(t),n=m(),i=await L(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"});if(!i.ok)throw Error("Could not check the remote connection. Your draft is kept.");let l=await i.json(),d=Cr(l);if(n.recoveryScope&&d!==n.recoveryScope)throw Error("The connected account, project, or environment changed. Reconnect the original account to save this draft.");if(!0!==l.canSave)throw o(!0),Error("Enable remote saving to save this private Taste to your Popmelt account.");o(!1);let c=JSON.stringify([e.bridgeUrl,l.environment,l.accountId]);if(n.identity&&n.identity!==c)throw Error("The connected account or environment changed. Your draft and pending save are kept; reconnect the original account before retrying.");n.identity=c,n.recoveryScope??(n.recoveryScope=d);for(let t=0;t<2;t++){let t=n.pending??{id:n.id,expectedRevision:n.revision,requestId:crypto.randomUUID(),document:r};n.pending=t;try{v(n,r)}catch{throw Error("Could not protect this save in browser recovery storage. No remote request was sent. Keep this tab open and free browser storage before retrying.")}let i=await L(`${e.bridgeUrl}/cloud-taste/document`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await i.json();if(!i.ok){"revision_conflict"===l.error&&s(!0),"reconnect_required"===l.error&&o(!0);let e={create_not_allowed:"Your account cannot save Tastes right now. Check your subscription or account access on Popmelt, then retry. Your draft is kept.",quota_exceeded:"Your account has reached its Taste limit. Remove an unused Taste in Popmelt, then retry. Your draft is kept.",reconnect_required:"Reconnect your Popmelt account and enable remote saving, then retry. Your draft is kept.",invalid_document:"Popmelt could not validate this Taste. Your draft is kept. Update Popmelt and try again; if it still fails, contact support.",request_conflict:"This save request conflicts with an earlier request. Your draft is kept. Contact support before retrying; do not create a duplicate Taste.",revision_conflict:"This Taste changed remotely. Your draft is kept. The remote revision must be reviewed and reconciled before these edits can be saved."};throw Error(Object.hasOwn(e,l.error)?e[l.error]:"Remote save failed. Your draft is kept; retry safely.")}if(l.id!==t.id||l.revision!==t.expectedRevision+1||!Ze(l.document)||Ge(l.document)!==Ge(t.document))throw Error("Could not confirm the saved Taste. Your draft is kept; retry safely.");if(n.revision=l.revision,n.pending=null,v(n,r),Ge(t.document)===Ge(r))return a("Saved privately to Popmelt. Not applied."),y(n),s(!1),void e.onSaved(l)}}catch(e){a(e instanceof Error?e.message:"Remote save failed. Your draft is kept.")}finally{f.current=!1,r(!1)}}})(t)},saving:t,saveNotice:n??u,saveAction:ye(be,{children:[e.recovery&&ve(Nr,{theme:e.theme,pending:!!m().pending,disabled:t,onDiscard:()=>{if(!f.current)try{y(m()),e.onBack()}catch{a("Could not discard browser recovery. Your draft is kept.")}}}),l?ye("div",{style:{padding:12,color:g.primary},children:[ve("p",{children:"Your draft is retained. Review the saved version before choosing what to keep."}),ve("button",{style:w,onClick:()=>{(async()=>{try{let t=await L(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"}),r=await t.json(),n=m();if(!t.ok||n.recoveryScope&&Cr(r)!==n.recoveryScope)throw Error("Reconnect the original account to review this Taste.");let a=await L(`${e.bridgeUrl}/cloud-taste/document?id=${encodeURIComponent(n.id)}`,{cache:"no-store"}),i=await a.json();if(!a.ok||i.id!==n.id||!Number.isSafeInteger(i.revision)||i.revision<1||!Ze(i.document))throw Error("Could not load the saved version. Your draft is kept.");c(i)}catch(e){a(e instanceof Error?e.message:"Could not review the saved version.")}})()},children:"Review saved version"}),d&&ye(be,{children:[ye("p",{children:["Saved revision ",d.revision," ·"," ",d.document.draft.name]}),ve(Xt,{draft:d.document.draft,theme:e.theme,preferPageComponent:!0}),ve("button",{style:w,onClick:()=>{try{let t=m();t.id=d.id,t.revision=d.revision,t.pending=null,e.session?.edit(d.document.draft),y(t),s(!1),c(null),e.onSaved(d)}catch{a("Could not discard the recovery record. Your draft is kept.")}},children:"Discard my edits and load saved version"}),ve("button",{style:w,onClick:()=>{(async()=>{try{let t=await L(`${e.bridgeUrl}/cloud-taste/creation-eligibility`,{cache:"no-store"});if(!t.ok||!0!==(await t.json()).activeSubscription)throw Error("An active subscription is required to save a new Taste.");let r=m(),n={...r,id:crypto.randomUUID(),revision:0,pending:null},i=e.session?.getSnapshot().draft??e.draft;if(!i)return;v(n,Qe(i)),Object.assign(r,n),s(!1),c(null),a("Your draft is now a new, unsaved Taste. Save explicitly to create the remote copy.")}catch(e){a(e instanceof Error?e.message:"Could not prepare a copy.")}})()},children:"Keep my draft as a new Taste"})]})]}):i?ve("button",{type:"button",onClick:e.onEnableSaving,style:{font:"inherit",color:g.primary,background:g.control,padding:8,border:0,borderRadius:8,cursor:"pointer"},children:"Enable remote saving"}):void 0]})})}var zr=class{constructor(){this.entries=new Map}clear(){for(let e of this.entries.values())e.abort.abort();this.entries.clear()}invalidate(e){this.entries.get(e)?.abort.abort(),this.entries.delete(e)}put(e,t){this.invalidate(e),this.entries.set(e,{response:new Response(JSON.stringify(t)),expires:Date.now()+6e4,abort:new AbortController})}async read(e){let t=this.entries.get(e);if(t?.response&&t.expires>Date.now())return t.response.clone();if(t?.pending)return(await t.pending).clone();this.invalidate(e),this.entries.size>=12&&this.invalidate(this.entries.keys().next().value);let r={expires:0,abort:new AbortController};return this.entries.set(e,r),r.pending=L(e,{signal:r.abort.signal}).then(async t=>{if(t.ok){let n=await t.clone().json();if(!n.sections||!Array.isArray(n.overrides))throw new Error("Invalid taste definition");this.entries.get(e)===r&&(r.response=t.clone(),r.expires=Date.now()+6e4)}else this.entries.get(e)===r&&this.entries.delete(e);return t}).catch(t=>{throw this.entries.get(e)===r&&this.entries.delete(e),t}).finally(()=>{r.pending=void 0}),(await r.pending).clone()}},Dr={principles:"tokens",components:"components",assets:"visual-directions",content:"copy-guidance"};var jr=e=>"string"==typeof e&&e.length>0&&e.length<=200&&!["__proto__","prototype","constructor"].includes(e);var Pr=(e,t)=>`${e}:${t}`;function Mr(e){let t=ie(e.onDirectionChange);t.current=e.onDirectionChange;let[r,i]=oe([]),o=ie(null),y=ie(null),[b,w]=oe(0),[x,k]=oe(!1),[S,C]=oe(null),[$,R]=oe(!1),[E,T]=oe(!1),I=le(z.subscribe,z.getSnapshot,z.getSnapshot),N=I.open,[j,P]=oe(null),M=ie(new Map),{onEditorVisibilityPinChange:O,visible:W}=e;se(()=>(O?.((N||!!j)&&!1!==W),()=>O?.(!1)),[N,j,W,O]);let F=ie(null),[B,q]=oe(null),[H,U]=oe(null),[V,K]=oe(),Y=()=>{let e=F.current?.offsetHeight;e&&K(e),T(!0)},[J,X]=oe(!1),_=ie(null),G=ie(null),Z=ie(!1);de(()=>{E?_.current?.focus({preventScroll:!0}):Z.current&&G.current?.focus({preventScroll:!0}),Z.current=E},[E]);let Q=()=>{T(!1),te("")},[ee,te]=oe(""),re=ie(void 0);de(()=>()=>clearTimeout(re.current),[]);let[ne,ae]=oe(),[pe,he]=oe(!1),[ge,fe]=oe(null),me=ie(void 0),we=t=>{clearTimeout(me.current),fe(!1===e.visible?null:t),me.current=setTimeout(()=>fe(null),200)};de(()=>{!1===e.visible&&(clearTimeout(me.current),fe(null))},[e.visible]),de(()=>()=>clearTimeout(me.current),[]);let xe=ie(void 0);de(()=>()=>clearTimeout(xe.current),[]);let[ke,Se]=oe(null),Ce=!!ke&&x,[$e,Re]=oe(!1),[Ee,Te]=oe(null),[Ie,Ne]=oe(),Ae=void 0!==Ie?Ie:Ee?.direction,Le=Ae?Pr(Ae.sourceCollection,Ae.sourceModelId):null,[ze,De]=oe(!1),[je,Pe]=oe(!1),[Me,Oe]=oe(!1),We=ie(null);de(()=>()=>We.current?.abort(),[]);let[Fe,Be]=oe(!1),[qe,He]=oe(!0),[Ue,Ve]=oe("Loading collection…"),[Ke,Ye]=oe(0),[Je,Xe]=oe(0),[_e,Ge]=oe(),[Qe,tt]=oe([]),rt=ce(()=>{try{tt(_e?Rr(_e):[])}catch{tt([])}},[_e]);de(()=>{rt();let e=()=>rt();return window.addEventListener("storage",e),window.addEventListener("focus",e),()=>{window.removeEventListener("storage",e),window.removeEventListener("focus",e)}},[rt]),de(()=>{j&&j.record.scope!==_e&&P(null)},[j,_e]);let nt=e.bridgeUrl;de(()=>{let e=new AbortController;return Oe(!1),z.setCreationAllowed(!1),nt&&L(`${nt}/cloud-taste/creation-eligibility`,{signal:e.signal,cache:"no-store"}).then(async t=>{let r=t.ok?await t.json():null;if(e.signal.aborted)return;let n=!0===r?.activeSubscription;Oe(n),z.setCreationAllowed(n)}).catch(()=>{}),()=>{e.abort(),z.setCreationAllowed(!1)}},[nt,Ke,Je]);let at=async(e,t=!1)=>{let r=ft.current;try{let n=await L(`${nt}/cloud-taste/creation-eligibility`,{cache:"no-store"}),a=n.ok?await n.json():null;if(r!==ft.current)return;let i=!0===a?.activeSubscription;if(Oe(i),z.setCreationAllowed(i),!i)return;Q(),z.create(e,t)}catch{if(r!==ft.current)return;Oe(!1),z.setCreationAllowed(!1)}},it=ie(0),ot=ie(!1),lt=ie(""),st=ie([]),dt=ie(void 0),ct=ie(void 0),ut=ie(!1),pt=ie(0),ft=ie(0);de(()=>{if(!nt||!1===e.visible)return void q(null);let t=!0,r=!1,n=async()=>{if(!r){r=!0;try{let e=await L(`${nt}/cloud-taste/agent-look`,{cache:"no-store"}),r=await e.json();t&&q(e.ok&&"looking"===r.status&&r.expiresAt>Date.now()?function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid Taste looking target");let t=e;if("search"===t.kind&&"string"==typeof t.query&&t.query.length<=200)return{kind:"search",query:t.query};if(("taste"===t.kind||"path"===t.kind)&&("public"===t.collection||"private"===t.collection)&&jr(t.id)){let e={collection:t.collection,id:t.id};if("taste"===t.kind)return{kind:"taste",...e};if(Array.isArray(t.path)&&t.path.length>=1&&t.path.length<=12&&t.path.every(jr)&&["principles","components","assets","content"].includes(t.path[0]??""))return{kind:"path",...e,path:[...t.path]}}throw new Error("Invalid Taste looking target")}(r.target):null)}catch{t&&q(null)}finally{r=!1}}};n();let a=setInterval(()=>{n()},750);return()=>{t=!1,clearInterval(a)}},[nt,e.visible]);let mt=ue(()=>({bridgeUrl:nt,revision:Ke,cache:new zr}),[nt,Ke]).cache;de(()=>{let t=F.current;if(!t||!B||!1===e.visible)return void U(null);let r=()=>{let e=function(e,t,r){if("search"===t.kind)return e.querySelector(r.searchOpen?"[data-taste-search] input":"[data-taste-search-trigger]");let n=`${t.collection}:${t.id}`;if(!r.showingDetail)return[...e.querySelectorAll("[data-taste-entry-id]")].find(e=>e.getAttribute("data-taste-entry-id")===n)??null;if(r.detailEntryId!==n)return null;if("path"===t.kind&&r.drilldownVisible&&Dr[t.path[0]??""]===r.drilldown){let r=e.querySelector('[data-taste-layer="drilldown"]'),n=[...r?.querySelectorAll("[data-taste-path]")??[]].find(e=>e.getAttribute("data-taste-path")===JSON.stringify(t.path));if(n)return n;if(t.path.length>=2){let e=[...r?.querySelectorAll("[data-taste-group-path]")??[]].find(e=>e.getAttribute("data-taste-group-path")===JSON.stringify(t.path.slice(0,2)));if(e)return e}}return e.querySelector("[data-taste-nav-title]")}(t,B,{searchOpen:E,showingDetail:Ce,detailEntryId:ke?.id??null,drilldown:S,drilldownVisible:$});U(t=>t===e?t:e)};r();let n=new MutationObserver(r);return n.observe(t,{childList:!0,subtree:!0}),()=>n.disconnect()},[B,ke,S,$,e.visible,E,Ce]),de(()=>()=>mt.clear(),[mt]);let[,vt]=oe(0),yt=ue(()=>({bridgeUrl:nt,revision:Ke,requests:new Map}),[nt,Ke]).requests;de(()=>()=>{for(let e of yt.values())e.abort.abort();yt.clear()},[yt]);let bt=ce(e=>{let t=yt.get(e.id);if(t&&(void 0===t.fetchedAt||Date.now()-t.fetchedAt<3e4))return t.promise;let r=new AbortController,[n="",a=""]=e.id.split(":"),i={preview:t?.preview,facts:t?.facts,abort:r,promise:Promise.resolve([])};return i.promise=(async()=>{if(!nt)throw Error("Connection unavailable.");if(e.documentRevision){let e=await L(`${nt}/cloud-taste/document?${new URLSearchParams({id:a})}`,{signal:r.signal,cache:"no-store"});if(!e.ok)throw Error("Saved Taste unavailable.");let t=await e.json();if(t.id!==a||!Number.isSafeInteger(t.revision)||t.revision<1||!Ze(t.document))throw Error("Invalid saved Taste.");return r.signal.aborted||(i.facts=[],i.fetchedAt=Date.now(),i.preview={...Yt(t.document.draft,"dark"),savedDocument:t,contentRevision:String(t.revision)},vt(e=>e+1)),[]}let t=await L(`${nt}/cloud-taste/summary?${new URLSearchParams({id:a,collection:n})}`,{signal:r.signal,cache:"no-store"});if(!t.ok)throw Error("Summary unavailable.");let o=await t.json();if(!Array.isArray(o.facts))throw Error("Summary unavailable.");if(!r.signal.aborted){i.facts=o.facts,i.fetchedAt=Date.now();let t=et(o.preview),r=st.current.find(t=>t.id===e.id)?.preview;i.preview=r&&r!==e.preview||r&&(r.recipeRevision??0)>(t?.recipeRevision??0)?r:t,vt(e=>e+1)}return o.facts})(),yt.set(e.id,i),i.promise.catch(()=>{yt.get(e.id)===i&&(t?.preview||t?.facts?yt.set(e.id,t):yt.delete(e.id))}),i.promise},[nt,yt]),[wt,xt]=oe(null);async function kt(e){if(!nt||!Ee||!ze||ut.current)return;let n=e?r.find(t=>t.id===e.id):void 0;if(e&&!n)return void Ve("Reload the collection before choosing this taste.");ut.current=!0,pt.current+=1,Ne(n?{sourceModelId:n.sourceModelId,sourceCollection:n.sourceCollection,name:n.name,sourceVersion:n.metadata?.value??null}:null),n&&!n.preview&&!yt.get(n.id)?.preview&&bt(n).catch(()=>{}),Be(!0),Ve("Saving taste…");let a=ft.current;try{let e=await L(`${nt}/cloud-taste/direction`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedGeneration:Ee.generation,...n?{sourceModelId:n.sourceModelId,sourceCollection:n.sourceCollection}:{}})});if(!e.ok)throw Error("The change could not be confirmed. Reload the collection before trying again.");let r=await e.json();if(a!==ft.current)return;Te(r),Ne(void 0),"string"==typeof dt.current&&t.current?.({accountId:dt.current,environment:ct.current,name:r.direction?.name??null,generation:r.generation}),Ve(null)}catch(e){a===ft.current&&(Te(null),Ne(void 0),t.current?.(null),Ve(e instanceof Error?e.message:"Could not save taste. Reload to check its state."))}finally{ut.current=!1,a===ft.current&&Be(!1)}}async function St(e=!1){if(!nt||ut.current)return;let t=window.open("about:blank","_blank");if(t){t.opener=null,ut.current=!0,Be(!0);try{let r=await L(`${nt}/cloud-taste/${e?"enable-saving":"enable-activation"}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!r.ok)throw Error("Could not start sign-in. Retry in Settings.");let a=await r.json(),i=n(a.authorizationUrl);t.location.replace(i.href),Ye(e=>e+1)}catch(e){t.close(),Ve(e instanceof Error?e.message:"Could not start sign-in.")}finally{ut.current=!1,Be(!1)}}else Ve("Allow popups, then try again.")}de(()=>{let e=r.find(e=>e.id===Le),t=[...e?[e]:[],...["private","public"].flatMap(e=>r.filter(t=>t.sourceCollection===e&&t.id!==Le))].slice(0,20);for(let e of t)e.preview||bt(e).catch(()=>{})},[Le,r,bt]),de(()=>{if(!ke||!nt)return;let e=!0;return xt({id:ke.id,cache:yt,notice:"Loading details…"}),(async()=>{try{let t=await bt(ke);e&&xt({id:ke.id,cache:yt,facts:t})}catch{e&&xt({id:ke.id,cache:yt,notice:"Summary unavailable. Reopen this taste to retry."})}})(),()=>{e=!1}},[ke,nt,bt,yt]),de(()=>{let t=()=>{it.current>0&&!ot.current&&!ut.current&&Date.now()-it.current>=3e4&&Xe(e=>e+1)};if(t(),!1===e.visible)return;let r=setInterval(t,3e4);return window.addEventListener("focus",t),()=>{clearInterval(r),window.removeEventListener("focus",t)}},[e.visible,e.prefetchSignal]),de(()=>{let e,r=++ft.current,n=pt.current,a=new AbortController;ot.current=!0;let o=`${nt}:${Ke}`,l=lt.current===o&&st.current.length>0;return lt.current=o,l||(He(!0),Te(null),Ne(void 0),De(!1),Re(!1),i([]),st.current=[]),async function o(){try{if(!nt)throw Error("Connection unavailable.");let s=await L(`${nt}/cloud-taste/status`,{signal:a.signal,cache:"no-store"});if(!s.ok)throw Error("Connection unavailable.");let d=await s.json();if(r!==ft.current)return;if(d.pending)return Ve("Complete sign-in in the browser."),void(e=setTimeout(o,1e3));if("signed_in"!==d.state){Ge(void 0),M.current.clear(),t.current?.(null),mt.clear(),i([]),st.current=[],Se(null);for(let e of yt.values())e.abort.abort();throw yt.clear(),Error("Sign in to activate a taste.")}if(void 0!==dt.current&&(dt.current!==d.accountId||ct.current!==d.environment)){mt.clear(),M.current.clear(),We.current?.abort(),ae(void 0);for(let e of yt.values())e.abort.abort();yt.clear(),st.current=[],i([]),Se(null)}dt.current=d.accountId,ct.current=d.environment,Ge(Cr(d)),d.canInspect||mt.clear();let[c,u,p]=await Promise.all([L(`${nt}/cloud-taste/catalog`,{signal:a.signal,cache:"no-store"}),L(`${nt}/cloud-taste/direction`,{signal:a.signal,cache:"no-store"}),!0===d.canBrowsePrivate?L(`${nt}/cloud-taste/private-catalog`,{signal:a.signal,cache:"no-store"}):null]);if(!c.ok||!u.ok||p&&!p.ok)throw Error("Could not load tastes. Please retry or reconnect in Settings.");let h=await c.json(),g=p?await p.json():{items:[]},f=await u.json();if(r!==ft.current)return;let m=["private","public"].flatMap(e=>("private"===e?g.items:h.items).map(t=>({id:Pr(e,t.id),sourceModelId:t.id,sourceCollection:e,thumbnailUrl:t.thumbnailUrl,preview:et(t.preview),name:t.name,documentRevision:t.documentRevision,...t.version?{metadata:{value:t.version,label:`Version ${t.version}`}}:{}}))).sort((e,t)=>e.name.localeCompare(t.name));for(let e of m){let t=yt.get(e.id);t?.preview?.savedDocument&&t.preview.savedDocument.revision!==e.documentRevision?(t.abort.abort(),yt.delete(e.id)):t&&e.preview&&(t.preview?.recipeRevision!==e.preview.recipeRevision||t.preview?.contentRevision!==e.preview.contentRevision)&&(t.abort.abort(),yt.delete(e.id))}st.current=m,i(m),l&&Se(e=>e?m.find(t=>t.id===e.id)??null:null),it.current=Date.now(),n===pt.current&&(Te(f),"string"==typeof d.accountId&&t.current?.({accountId:d.accountId,environment:d.environment,name:f.direction?.name??null,generation:f.generation})),De(!0===d.canWrite),Pe(!0===d.canInspect),Re(!0===d.canBrowsePrivate),Ve(null)}catch(e){r===ft.current&&Ve(e instanceof Error?e.message:"Connection unavailable.")}finally{r===ft.current&&(He(!1),ot.current=!1,it.current=Date.now())}}(),()=>{ft.current=r+1,a.abort(),clearTimeout(e)}},[nt,Ke,Je,yt,mt]);let Ct=r.find(e=>e.id===Le),$t=Ae&&Le?Ct?{...Ct,preview:yt.get(Ct.id)?.preview??Ct.preview}:{id:Le,name:Ae.name,sourceModelId:Ae.sourceModelId,sourceCollection:Ae.sourceCollection,...Ae.sourceVersion?{metadata:{value:Ae.sourceVersion,label:`Version ${Ae.sourceVersion}`}}:{}}:null,Rt=e=>r.filter(t=>t.sourceCollection===e).map(e=>({...e,preview:yt.get(e.id)?.preview??e.preview})),Et=!(!Ee||ze&&$e),Tt=ke?yt.get(ke.id)?.facts:void 0,It=wt?.id===ke?.id&&wt?.cache===yt?wt:null,Nt=A[e.theme],At=!Ce||$,Lt=E&&At,zt=$&&S?"components"===S?u:"copy-guidance"===S?p:"version"===S?h:"visual-directions"===S?g:f:m;de(()=>{Ce&&y.current?.focus({preventScroll:!0})},[Ce]);let Dt=()=>{if(X(!1),clearTimeout(me.current),fe(null),T(!1),te(""),$)return R(!1),clearTimeout(re.current),void(re.current=setTimeout(()=>C(null),220));k(!1),clearTimeout(xe.current),xe.current=setTimeout(()=>Se(null),220)};de(()=>{if(!1===e.visible||N)return;let t=t=>{if("Tab"===t.key&&X(!0),t.defaultPrevented||t.isComposing||t.metaKey||t.ctrlKey||t.altKey)return;let r=t.composedPath().some(e=>e instanceof HTMLElement&&(e.matches('input, textarea, select, [role="textbox"], [role="combobox"]')||e.isContentEditable));if("Escape"!==t.key||!t.composedPath().some(e=>e instanceof HTMLElement&&e.matches("[data-taste-value-input]")))if(" "===t.key&&At&&!r)X(!1),t.preventDefault(),t.stopImmediatePropagation(),t.repeat||Y();else if("Escape"===t.key){if(X(!1),t.preventDefault(),t.stopImmediatePropagation(),t.repeat)return;Lt?Q():Ce?Dt():e.onClose()}};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)});let jt=(ne??yt.get(ke?.id??"")?.preview??ke?.preview)?.savedDocument,Pt=t=>{P(null),rt();let r=M.current.get(t.id);r&&(r.saved=t);let n={id:Pr("private",t.id),sourceModelId:t.id,sourceCollection:"private",name:t.document.draft.name,documentRevision:t.revision,preview:{...Yt(t.document.draft,e.theme),savedDocument:t,contentRevision:String(t.revision)}};yt.get(n.id)?.abort.abort(),yt.delete(n.id),i(e=>[...e.filter(e=>e.id!==n.id),n]),Se(n),ae(n.preview),k(!0),z.close(),Ye(e=>e+1)};if(j&&j.record.scope===_e)return ve(Lr,{session:j.session,draft:j.record.document.draft,recovery:j.record,recoveryScope:_e,onRecoveryChange:rt,theme:e.theme,style:e.style,bridgeUrl:nt,visible:e.visible,onDraft:()=>{},onBack:()=>{P(null),rt()},onTemplate:()=>{},onSaved:Pt,onEnableSaving:()=>{St(!0)}},j.record.key);if(!N&&Ce&&jt){let t=M.current.get(jt.id);return t||(t={saved:jt,session:D(jt.document.draft)},M.current.set(jt.id,t)),ve(Lr,{saved:t.saved,recoveryScope:_e,onRecoveryChange:rt,session:t.session,draft:t.saved.document.draft,theme:e.theme,style:e.style,bridgeUrl:nt,visible:e.visible,onDraft:()=>{},onBack:Dt,onTemplate:()=>{},onSaved:Pt,onEnableSaving:()=>{St(!0)}},jt.id)}return N?ve(Lr,{visible:e.visible,session:z,recoveryScope:_e,onRecoveryChange:rt,theme:e.theme,style:e.style,bridgeUrl:e.bridgeUrl,draft:I.draft,onDraft:()=>{},onBack:()=>z.close(),onTemplate:()=>{at("template",!0)},onSaved:Pt,onEnableSaving:()=>{St(!0)}}):ye("div",{"data-popmelt-font":"sans",ref:F,"data-taste-keyboard-focus":J,onPointerDownCapture:()=>X(!1),"data-taste-navigation":Ce?"detail":"collection","data-taste-animated":pe||void 0,"data-taste-entering":!1===e.visible?void 0:ge??void 0,"data-taste-depth":$?"drilldown":"overview",style:{position:"relative",height:Lt?V:e.style?.height,maxHeight:e.style?.maxHeight,overflow:"hidden",borderRadius:20,background:Nt.surface,fontFamily:l},children:[ve("style",{children:`\n [data-taste-navigation] { user-select: none; -webkit-user-select: none; }\n [data-taste-navigation] input, [data-taste-navigation] textarea, [data-taste-navigation] [contenteditable="true"] { user-select: text; -webkit-user-select: text; }\n [data-taste-keyboard-focus="false"] [data-taste-navigation-header] :focus { outline: none !important; box-shadow: none !important; }\n [data-taste-navigation] [data-taste-collection-header], [data-taste-navigation] [data-taste-detail-header] { display: none !important; }\n [data-taste-navigation] [data-popmelt-taste], [data-taste-navigation] [data-taste-detail] { padding-top: 60px !important; }\n [data-taste-navigation] [data-taste-detail] { position: absolute; inset: 0; z-index: 1; background: transparent !important; overflow: hidden !important; }\n [data-taste-navigation] [data-taste-detail-body] { min-height: 0; overflow-y: auto; flex-shrink: 1; }\n [data-taste-navigation] [data-taste-scroll], [data-taste-navigation] [data-taste-detail-body] { transition: transform 200ms cubic-bezier(.2,.8,.2,1), opacity 160ms ease; }\n [data-taste-navigation="detail"] [data-taste-scroll] { transform: translateX(-100%); opacity: 0; }\n [data-taste-navigation="collection"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }\n [data-taste-entering="overview"] [data-taste-layer="overview"] [data-taste-detail-body],\n [data-taste-entering="drilldown"] [data-taste-layer="drilldown"] [data-taste-detail-body] { animation: taste-detail-enter 200ms cubic-bezier(.2,.8,.2,1); }\n [data-taste-depth="drilldown"] [data-taste-layer="overview"] [data-taste-detail-body] { transform: translateX(-100%); opacity: 0; }\n [data-taste-depth="overview"] [data-taste-layer="drilldown"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }\n @keyframes taste-detail-enter { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n [data-taste-navigation] [data-taste-nav-title], [data-taste-navigation] [data-taste-nav-title] svg, [data-taste-navigation] [data-taste-nav-action] { transition: color 160ms ease, font-size 200ms ease, width 200ms ease, height 200ms ease, opacity 140ms ease, transform 200ms ease; }\n [data-taste-navigation] [data-taste-nav-title]:hover [data-taste-refresh-icon] { opacity: 1; transform: none; }\n [data-taste-navigation] [data-taste-nav-action]:enabled:hover { background: ${Nt.actionHover} !important; }\n [data-taste-navigation] [data-taste-search-trigger]:hover, [data-taste-navigation] [data-taste-search-trigger]:focus-visible { color: ${Nt.primary} !important; }\n [data-taste-navigation-header] > [data-taste-search], [data-taste-navigation-header] > [data-taste-header-default] { transition: opacity 160ms ease, transform 200ms cubic-bezier(.2,.8,.2,1), visibility 0s 200ms; }\n [data-taste-navigation-header] > [data-taste-search] { opacity: 0; transform: translateX(12px); visibility: hidden; pointer-events: none; }\n [data-taste-navigation-header][data-search-open="true"] > [data-taste-search] { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }\n [data-taste-navigation-header] > [data-taste-header-default] { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }\n [data-taste-navigation-header][data-search-open="true"] > [data-taste-header-default] { opacity: 0; transform: translateX(-12px); visibility: hidden; pointer-events: none; transition-delay: 0s, 0s, 200ms; }\n @media (prefers-reduced-motion: reduce) { [data-taste-navigation] *, [data-taste-navigation] [data-taste-detail-body] { animation: none !important; transition: none !important; } }\n `}),ye("div",{"data-taste-navigation-header":!0,"data-search-open":Lt,style:{position:"absolute",top:16,left:16,right:16,height:28,zIndex:2,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[ye("div",{"data-taste-search":!0,inert:!Lt,"aria-hidden":!Lt,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",gap:8,width:"100%",color:Nt.secondary},children:[ve(s,{size:16}),ve("input",{ref:_,"aria-label":Ce?"Search taste definitions":"Search tastes",placeholder:Ce?"Search keys and values…":"Search tastes…",value:ee,onChange:e=>te(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&Q()},style:{flex:1,minWidth:0,border:0,outline:"none",background:"transparent",color:Nt.primary,font:"inherit",fontSize:12}}),ve("button",{type:"button","aria-label":"Close search",onClick:Q,style:{border:0,padding:4,background:"transparent",color:Nt.secondary,cursor:"pointer"},children:ve(d,{size:16})})]}),ye("div",{"data-taste-header-default":!0,inert:Lt,"aria-hidden":Lt,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,width:"100%"},children:[ye("button",{ref:y,type:"button","data-taste-nav-title":!0,"aria-label":Ce?$?"Back to taste details":"Back to taste collection":"Back to settings",onClick:Ce?Dt:e.onClose,style:{display:"flex",alignItems:"center",gap:3,padding:0,border:0,background:"transparent",color:Ce?Nt.secondary:Nt.primary,fontFamily:"inherit",fontSize:Ce?12:14,fontWeight:600,letterSpacing:Ce?"-.12px":"-.14px",minWidth:0,cursor:"pointer"},children:[ve(c,{size:16,style:{width:16,color:Nt.primary}}),ve(zt,{"data-taste-nav-icon":!0,style:{width:Ce?14:16,height:Ce?14:16,transform:zt===m?"scaleY(-1)":void 0,transitionProperty:"color, width, height, opacity"}}),ve("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:Ce?ke.name:void 0,children:Ce?S&&$?{version:"Versions",tokens:"Tokens",components:"Components","visual-directions":"Visual directions","copy-guidance":"Copy guidance"}[S]??S:ke.name:"Taste"})]}),ye("div",{style:{position:"relative",height:28,width:Ce?80:Me?135:28,flexShrink:0},children:[!Ce&&Me&&ve("button",{type:"button","aria-label":"Open template taste",onClick:()=>{at("template",!0)},style:{position:"absolute",right:56,top:0,border:0,padding:6,background:"transparent",color:Nt.muted,font:"inherit",fontSize:12,cursor:"pointer"},children:"Template"}),!Ce&&Me&&ve("button",{type:"button","aria-label":"Create a taste","data-taste-create":!0,onClick:()=>{at("extract")},style:{position:"absolute",right:28,top:0,border:0,padding:6,background:"transparent",color:Nt.muted,cursor:"pointer"},children:ve(v,{size:16})}),At?ve("button",{type:"button","aria-label":Ce?"Search definitions":"Search tastes",ref:G,"data-taste-search-trigger":!0,onClick:()=>{X(!1),Y()},style:{position:"absolute",right:0,border:0,padding:6,background:"transparent",color:Nt.muted,transition:"color 160ms ease",cursor:"pointer"},children:ve(s,{size:16})}):ve(be,{children:ve("button",{type:"button","data-taste-nav-action":!0,"aria-label":`${ke?.id===Le?"Remove":"Add"} ${ke?.name??"taste"}`,"aria-pressed":!!ke&&ke.id===Le,inert:!Ce,disabled:!ze||!Ee||Fe,onClick:()=>{ke&&kt(ke.id===Le?void 0:ke)},style:{position:"absolute",right:0,top:0,display:"flex",alignItems:"center",gap:3,padding:ke?.id===Le?"4px 7px 4px 8px":"4px 8px",border:0,borderRadius:8,background:Nt.actionSurface,color:Nt.actionForeground,font:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",opacity:Ce?1:0,transform:Ce?"translateX(0)":"translateX(5px)",pointerEvents:Ce?"auto":"none"},children:ye(be,ke?.id===Le?{children:["Remove",ve(d,{size:12})]}:{children:[ve(v,{size:12}),"Add"]})})})]})]})]}),ke&&(S?["overview","drilldown"]:["overview"]).map(t=>ve("div",{"data-taste-layer":t,inert:!Ce||"drilldown"===t!==$,"aria-hidden":!Ce||"drilldown"===t!==$,children:ve(gt,{theme:e.theme,style:{...e.style,...b>0?{minHeight:`min(${b}px, ${"number"==typeof e.style?.maxHeight?`${e.style.maxHeight}px`:e.style?.maxHeight??"calc(100dvh - 64px)"})`}:{}},entry:{...ke,preview:ne??yt.get(ke.id)?.preview??ke.preview},facts:Tt??It?.facts,onOpenFact:e=>{X(!1),we("drilldown"),clearTimeout(re.current),T(!1),te(""),C(e),R(!0)},drilldown:"drilldown"===t&&S?ve(Mt,{cache:mt,bridgeUrl:e.bridgeUrl,id:ke.sourceModelId,collection:ke.sourceCollection,section:S,query:ee,theme:e.theme,onPreview:ae,onReconnect:()=>{St()}},`${ke.id}:${S}`):void 0,summaryNotice:Tt?void 0:It?.notice??"Loading details…",active:ke.id===Le,onBack:Dt,onToggle:ze&&Ee&&!Fe?()=>{kt(ke.id===Le?void 0:ke)}:void 0,notice:Ue},ke.id)},t)),ve("div",{ref:o,inert:Ce,"aria-hidden":Ce,style:{display:"contents"},children:ve(ht,{...e,style:{...e.style,...Lt&&V?{height:"100%"}:{}},publicEntries:Rt("public").filter(e=>Ce||`${e.name} ${e.metadata?.value??""}`.toLowerCase().includes(ee.trim().toLowerCase())),privateEntries:Rt("private").filter(e=>Ce||`${e.name} ${e.metadata?.value??""}`.toLowerCase().includes(ee.trim().toLowerCase())),activeEntryId:Le,activeEntry:$t,onRefresh:()=>{He(!0),Ye(e=>e+1)},refreshing:qe,refreshDisabled:Fe,onAdd:ze&&Ee&&!Fe?e=>{kt(e)}:void 0,onRemove:ze&&Ee&&!Fe?()=>kt():void 0,onOpenDetails:t=>{if(X(!1),we("overview"),clearTimeout(xe.current),he(!0),w(o.current?.firstElementChild?.offsetHeight??0),Se(t),C(null),R(!1),T(!1),te(""),ae(void 0),We.current?.abort(),je&&e.bridgeUrl&&!t.documentRevision){let r=new AbortController;We.current=r,mt.read(`${e.bridgeUrl}/cloud-taste/definition?id=${encodeURIComponent(t.sourceModelId)}&collection=${t.sourceCollection}`).then(async e=>{if(!e.ok)return;let t=et((await e.json()).preview);!r.signal.aborted&&t&&ae(t)}).catch(()=>{})}k(!0)},onPrefetchDetails:e=>{bt(e).catch(()=>{})},privateEmptyMessage:$e?"No private results found.":"Reconnect to browse your private tastes.",notice:Ue,headerAction:ye(be,{children:[ve(Ir,{theme:e.theme,records:Qe.map(t=>({key:t.key,name:t.document.draft.name,pending:!!t.pending,preview:{...Yt(t.document.draft,e.theme),savedDocument:t}})),onResume:e=>{let t=Qe.find(t=>t.key===e);if(t)try{let e=Rr(t.scope).find(e=>e.key===t.key);if(!e)return void rt();let r={...e,key:crypto.randomUUID(),updatedAt:Date.now()};Er(r),Tr(e.key),P({record:r,session:D(r.document.draft)}),rt()}catch{Ve("Could not resume browser recovery. The original record is kept.")}}}),Et?ve("button",{type:"button",disabled:Fe,onClick:()=>{St()},style:{border:0,borderRadius:8,padding:"6px 10px",cursor:"pointer",font:"inherit"},children:"Reconnect account"}):null]})})}),ve(a,{element:H,label:"AI is looking at this Taste",inverse:!0})]})}export{Mr as PopmeltTasteConnectedPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{b as r}from"./chunk-
|
|
1
|
+
"use client";import{b as r}from"./chunk-OAHYSDJ4.mjs";import"./chunk-G7JR5Z3P.mjs";import"./chunk-HU2XWUJC.mjs";import"./chunk-XT6PHPPG.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import"./chunk-WHJEKDNP.mjs";import{useRef as t,useEffect as e}from"react";function n({config:n,adapters:o}){let u=t(o);u.current=o;let c=t(new Set);return e(()=>{r({sourceId:n.projectId,revision:n.revision},{get:()=>u.current,subscribe:r=>(c.current.add(r),()=>{c.current.delete(r)})});let t=window.__POPMELT_CODE_PREVIEW__;return()=>t?.dispose()},[n]),e(()=>{for(let r of c.current)r()},[o]),null}export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{B as e,Ma as t,ja as n,Ia as i}from"./chunk-F45IVFS3.mjs";import{useState as a}from"react";import{jsxs as o,jsx as r,Fragment as d}from"react/jsx-runtime";function l({messages:e,renderMessage:t,onChange:n}){return e.length?o("section",{"aria-label":"Queued messages",style:{display:"flex",flexDirection:"column",gap:6,flexShrink:0,borderTop:"1px solid var(--popmelt-thread-hairline)",paddingTop:8},children:[r("style",{children:'\n [data-queued-reply-actions] {\n width: 0;\n margin-left: 0;\n opacity: 0;\n overflow: hidden;\n pointer-events: none;\n transition: width 100ms ease-out, margin-left 100ms ease-out, opacity 100ms ease-out;\n }\n [data-queued-reply]:hover [data-queued-reply-actions],\n [data-queued-reply]:focus-within [data-queued-reply-actions],\n [data-queued-reply][data-editing="true"] [data-queued-reply-actions] {\n width: 52px;\n margin-left: 5px;\n opacity: 1;\n pointer-events: auto;\n }\n [data-queued-reply-actions] button {\n color: var(--popmelt-thread-muted);\n transition: color 50ms ease-out;\n }\n [data-queued-reply-actions] button:not(:disabled):hover,\n [data-queued-reply-actions] button:not(:disabled):focus-visible {\n color: var(--popmelt-thread-action);\n }\n [data-queued-reply-actions] button:not(:disabled):active {\n color: var(--popmelt-thread-action-hover);\n }\n [data-queued-reply-actions] button:disabled {\n opacity: 0.4;\n cursor: default;\n }\n @media (hover: none), (pointer: coarse) {\n [data-queued-reply-actions] {\n width: 52px;\n margin-left: 5px;\n opacity: 1;\n pointer-events: auto;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n [data-queued-reply-actions],\n [data-queued-reply-actions] button { transition: none; }\n }\n '}),o("div",{style:{fontSize:12,fontWeight:600,marginBottom:4,color:"var(--popmelt-thread-muted)"},children:[e.length," queued"]}),e.map(e=>r(s,{message:e,renderMessage:t,onChange:n},e.lifecycle?.submissionIds[0]??`${e.jobId}-${e.timestamp}`))]}):null}function s({message:l,renderMessage:s,onChange:u}){let[c,p]=a(!1),[m,h]=a(l.replyToQuestion??""),[y,g]=a(!1),[b,f]=a(""),v=!(!u||!l.lifecycle?.submissionIds[0]||y),q=async e=>{if(v&&u&&""!==e){g(!0),f("");try{await u(l,e),p(!1)}catch(e){f(e instanceof Error?e.message:"Could not update queued message.")}finally{g(!1)}}},x={display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:0,cursor:"pointer",padding:5,width:26,height:28,flexShrink:0};return o("div",{"data-queued-reply":!0,"data-editing":c,style:{display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0,flexShrink:0},children:[o("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[r("div",{"data-queued-reply-preview":!0,style:{flex:1,minWidth:0},children:c&&u?r("textarea",{autoFocus:!0,"aria-label":"Edit queued message",value:m,disabled:y,onChange:e=>h(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),y||p(!1)),"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),q(m.trim()))},style:{width:"100%",boxSizing:"border-box",minHeight:90,resize:"vertical",font:"inherit",lineHeight:1.5,color:"inherit",background:"var(--popmelt-thread-raised)",border:"1px solid var(--popmelt-thread-hairline)",borderRadius:12,padding:12}}):s(l)}),u&&r("div",{"data-queued-reply-actions":!0,style:{display:"flex",flexShrink:0},children:o(d,c?{children:[r("button",{type:"button",title:"Save queued message","aria-label":"Save queued message",disabled:!v||!m.trim(),style:x,onClick:()=>{q(m.trim())},children:r(e,{size:14})}),r("button",{type:"button",title:"Cancel editing","aria-label":"Cancel editing",disabled:y,style:x,onClick:()=>p(!1),children:r(t,{size:14})})]}:{children:[r("button",{type:"button",title:"Edit queued message","aria-label":"Edit queued message",disabled:!v,style:x,onClick:()=>{h(l.replyToQuestion??""),f(""),p(!0)},children:r(n,{size:14})}),r("button",{type:"button",title:"Delete queued message","aria-label":"Delete queued message",disabled:!v,style:x,onClick:()=>{q(null)},children:r(i,{size:14})})]})})]}),b&&r("div",{role:"alert",style:{fontSize:12,color:"#dc2626"},children:b})]})}export{l as QueuedReplies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as e}from"./chunk-R3AJWOID.mjs";import{b as t,d as r,e as n}from"./chunk-ZSL57PQ7.mjs";import{a as i}from"./chunk-PQT5FYN5.mjs";import{C as o,la as l}from"./chunk-F45IVFS3.mjs";import"./chunk-APP5IYTE.mjs";import{useState as a}from"react";import{jsx as s,jsxs as p,Fragment as c}from"react/jsx-runtime";function d(e){return"string"==typeof e&&e.trim()?e:void 0}function h(t){if(!t||"object"!=typeof t||Array.isArray(t))return;let i=d(t.sourceURI),o=i&&/^https?:\/\//i.test(i)&&f(i),l=d(t.title)??(o?new URL(o).hostname:void 0),a=d(t.content)??"";if(!l||!a&&!o||null!=t.content&&"string"!=typeof t.content||null!=t.title&&"string"!=typeof t.title)return;let s=d(t.source),p=d(t.sourceIcon),c=d(t.sourceURI),h=t.kind===r;return{title:l,optionReference:e(t),content:h?n(a,t.selection):a,...h&&{isExploreOption:!0},...s&&{source:s},...p&&{sourceIcon:p},...c&&{sourceURI:c}}}function f(e,t){let r=e?.trim();if(!r||Array.from(r).some(e=>e.charCodeAt(0)<32))return;let n=/^[a-z]:[\\/]/i;try{if(!n.test(r)&&/^[a-z][a-z0-9+.-]*:/i.test(r)){let e=new URL(r);return e.username||e.password?void 0:/^https?:$/.test(e.protocol)||"obsidian:"===e.protocol&&"open"===e.host&&!e.pathname&&!e.hash&&[...e.searchParams.keys()].every(e=>["vault","file","path","paneType"].includes(e))?e.href:void 0}let e=r.replaceAll("\\","/");if(e.startsWith("//")||e.startsWith("~"))return;let i=[];for(let t of e.split("/"))if(".."===t){if(!i.length||1===i.length&&n.test(e))return;i.pop()}else t&&"."!==t&&i.push(t);let o=t?.replaceAll("\\","/").replace(/\/$/,""),l=e.startsWith("/")?"/"+i.join("/"):n.test(e)?i.join("/"):t&&o+"/"+i.join("/");return i.length&&l&&(l.startsWith("/")||n.test(l))&&!l.startsWith("//")?"vscode://file/"+l.split("/").filter(Boolean).map((e,t)=>0===t&&n.test(l)?e:encodeURIComponent(e)).join("/"):void 0}catch{return}}function u({note:e}){let t=function(e){if(e){if(/^data:image\/(?:png|svg\+xml|x-icon)(?:;[^,]*)?,/i.test(e))return e;try{let t=new URL(e,document.baseURI);if(t.origin===location.origin&&/^https?:$/.test(t.protocol)&&/\.(?:png|svg)$/i.test(t.pathname)&&!t.username&&!t.password)return t.href}catch{}}}(e?.sourceIcon),[r,n]=a();return e?.isExploreOption?s(i,{active:!1,"aria-hidden":"true",width:12,height:12,viewBox:"8 8 24 24",fill:"currentColor",style:{flexShrink:0}}):t&&t!==r?s("img",{src:t,alt:"",width:12,height:12,referrerPolicy:"no-referrer",style:{flexShrink:0,objectFit:"contain"},onError:()=>n(t)}):s(l,{size:12,"aria-hidden":"true",style:{flexShrink:0}})}function m(e,t){return p(c,{children:[e.source&&e.source+": ",t?s("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:e.title}):e.title]})}var g={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},y={display:"-webkit-box",marginTop:4,contain:"inline-size",WebkitLineClamp:2,whiteSpace:"pre-line",WebkitBoxOrient:"vertical",overflow:"hidden",color:"var(--popmelt-thread-primary)"};function x(e){let t=JSON.stringify(e);return t.length<2048?JSON.stringify(e,null,2):t}function v({meta:e,projectRoot:r}){let n=Object.entries(e),i=1===n.length?h(n[0][1]):void 0,l=i&&i.content.length>160?i.content.slice(0,159)+"…":void 0,d=!i||!!i.content||Object.keys(n[0][1]).some(e=>!(e in i)),[v,w]=a(!(!i||l)),b=d&&v;if(!n.length)return null;let k=i?(i.source?i.source+": ":"")+i.title:n.length>1?`Context (${n.length} entries)`:"Context",S=i&&f(i.sourceURI,r),j={...g,whiteSpace:b?"normal":"nowrap",fontWeight:550},R=s(o,{size:12,"aria-hidden":"true",style:{marginLeft:"auto",flexShrink:0,transform:b?"rotate(180deg)":void 0}}),I={type:"button","aria-expanded":b,onClick:()=>w(!b)},O={font:"inherit",color:"inherit",cursor:"pointer",background:"transparent",border:0,padding:0,textAlign:"left"};return p("div",{"data-supplied-context":"",style:{alignSelf:"flex-end",boxSizing:"border-box",minWidth:0,maxWidth:"100%",marginTop:-10,borderRadius:"16px 16px 8px 16px",color:"var(--popmelt-thread-secondary)",background:"var(--popmelt-thread-control)",fontSize:12,lineHeight:1.4,overflowWrap:"anywhere"},children:[p("div",{style:{padding:b?"12px 12px 4px":12},children:[S&&i?p("div",{style:{display:"flex",alignItems:"center",gap:4},children:[s(u,{note:i}),s("span",{style:j,children:m(i,S)}),d&&s("button",{...I,"aria-label":`${b?"Collapse":"Expand"} context: ${k}`,style:{...O,marginLeft:"auto",alignSelf:"stretch",display:"grid",placeItems:"center",minWidth:20},children:R})]}):p("button",{...I,style:{...O,display:"flex",width:"100%",alignItems:"center",gap:4},children:[s(u,{note:i}),s("span",{style:j,children:k}),R]}),!b&&l&&s("span",{style:y,children:l})]}),s("div",{"aria-hidden":!b,style:{padding:b?"0 12px 12px":"0 12px",maxHeight:b?240:0,overflowY:b?"auto":"hidden",visibility:b?"visible":"hidden",color:"var(--popmelt-thread-primary)",whiteSpace:"pre-wrap"},children:n.map(([e,n])=>{let o=h(n);return o?p("div",{style:{marginTop:i?0:4},children:[!i&&p("div",{style:{display:"flex",alignItems:"center",gap:4,fontWeight:550},children:[s(u,{note:o}),s("span",{children:m(o,f(o.sourceURI,r))})]}),o.content.split("\n").filter(e=>!o.optionReference||!e.startsWith("Option: ")).join("\n"),o.optionReference&&p(c,{children:["\n","Option:"," ",s(t,{reference:o.optionReference})," (v"+(o.optionReference.option+1)+")"]}),!o.isExploreOption&&Object.keys(n).some(e=>!Object.prototype.hasOwnProperty.call(o,e))&&p("details",{children:[s("summary",{children:"Original data"}),s("pre",{style:{whiteSpace:"pre-wrap",fontSize:11},children:x({[e]:n})})]})]},e):s("pre",{style:{fontSize:11,whiteSpace:"pre-wrap",margin:"4px 0"},children:x({[e]:n})},e)})})]})}export{v as default};
|