@popmelt.com/core 0.33.0 → 0.33.1

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.
Files changed (85) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/ExploreAttachment-VKCCEIM7.mjs +1 -0
  4. package/dist/ParticipantRuntime-YS5SIZUQ.mjs +1 -0
  5. package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +1 -215
  6. package/dist/PreviewRuntime-LFPK56NW.mjs +1 -2
  7. package/dist/QueuedReplies-ZYUDSTS2.mjs +1 -46
  8. package/dist/SuppliedContext-RWN6UR3K.mjs +1 -2
  9. package/dist/ThreadErrorCard-7J62GD5W.mjs +1 -2
  10. package/dist/ThreadPanel-KVNM67WO.mjs +1 -0
  11. package/dist/adapter-react-three-fiber.mjs +1 -2
  12. package/dist/bridge-entry.mjs +1 -1
  13. package/dist/bridge-recovery-3IQN3U6D.mjs +1 -2
  14. package/dist/bridgeSSEStream-NEYI73TC.mjs +1 -4
  15. package/dist/bridgeWebSocketStream-H3DCP4T3.mjs +1 -2
  16. package/dist/browser-runtime-AP35S5MK.mjs +1 -0
  17. package/dist/browser.mjs +1 -2
  18. package/dist/canvas-chat-note-NHYL3T6J.mjs +1 -2
  19. package/dist/checkFixture-MWBOYIM2.mjs +1 -0
  20. package/dist/chunk-27ADDVGC.mjs +1 -3
  21. package/dist/chunk-2IASPT6L.mjs +1 -2
  22. package/dist/chunk-2P2NUZW7.mjs +1 -2
  23. package/dist/chunk-2VCHBI7Y.mjs +1 -11
  24. package/dist/chunk-2ZJ4FBTG.mjs +1 -2
  25. package/dist/chunk-4LHTPRFY.mjs +1 -2
  26. package/dist/chunk-5K7SACPW.mjs +1 -2
  27. package/dist/chunk-6V2VCKPG.mjs +1 -53
  28. package/dist/chunk-6VXFTT5U.mjs +1 -2
  29. package/dist/chunk-75PQGTKX.mjs +1 -2
  30. package/dist/chunk-BVTLSUQT.mjs +1 -2
  31. package/dist/chunk-CPOYMGYY.mjs +1 -2
  32. package/dist/chunk-DNOKP3JS.mjs +1 -2
  33. package/dist/chunk-EAV2VV2V.mjs +1 -2
  34. package/dist/chunk-EX63NVDN.mjs +1 -2
  35. package/dist/chunk-F5XSNRGT.mjs +1 -2
  36. package/dist/chunk-GASEZICN.mjs +1 -2
  37. package/dist/chunk-H7XMDLGU.mjs +30 -0
  38. package/dist/{chunk-C5WXW6VL.mjs → chunk-HVD5ZG6W.mjs} +1 -1
  39. package/dist/chunk-J3UIBBU2.mjs +1 -2
  40. package/dist/chunk-J4WDYITA.mjs +1 -2
  41. package/dist/chunk-JMMP5JSP.mjs +1 -2
  42. package/dist/chunk-LVEMYZOA.mjs +1 -2
  43. package/dist/chunk-N2QUNHV6.mjs +1 -0
  44. package/dist/chunk-N2ZEZCHO.mjs +1 -2
  45. package/dist/{chunk-HNCV37XO.mjs → chunk-N6JTX4PD.mjs} +1 -1
  46. package/dist/chunk-O4HZP3RP.mjs +1 -2
  47. package/dist/chunk-ODIGT4YJ.mjs +1 -17
  48. package/dist/chunk-PQT5FYN5.mjs +1 -2
  49. package/dist/chunk-PSSHCTJ2.mjs +1 -8
  50. package/dist/chunk-RESPUCV7.mjs +1 -0
  51. package/dist/chunk-SHAIHRV2.mjs +1 -0
  52. package/dist/chunk-V2I7PSJW.mjs +1 -2
  53. package/dist/{chunk-H2UYAUX3.mjs → chunk-VPPVURBR.mjs} +1 -1
  54. package/dist/chunk-W5NIRROD.mjs +1 -7
  55. package/dist/chunk-WHJEKDNP.mjs +1 -2
  56. package/dist/chunk-XKD2ABCO.mjs +1 -7
  57. package/dist/chunk-XTOCFTVW.mjs +1 -2
  58. package/dist/chunk-YLKEDOII.mjs +31 -0
  59. package/dist/chunk-ZHJZPC7U.mjs +1 -2
  60. package/dist/cli.mjs +1 -1
  61. package/dist/codex-note-context-4JYQ437H.mjs +2 -0
  62. package/dist/{codex-project-7VYHYTWO.mjs → codex-project-FA4EK6VR.mjs} +1 -1
  63. package/dist/focus-inspection-VBS5656D.mjs +1 -2
  64. package/dist/index.mjs +1 -2
  65. package/dist/media.mjs +1 -2
  66. package/dist/{peer-client-MTWZG2FB.mjs → peer-client-KJCPXT76.mjs} +1 -1
  67. package/dist/plugin-astro.mjs +1 -1
  68. package/dist/plugin-nuxt.mjs +1 -1
  69. package/dist/plugin-vite.mjs +1 -1
  70. package/dist/server.mjs +1 -1
  71. package/dist/taste-proposal-session-XU4N7RUV.mjs +1 -2
  72. package/dist/workspace-snapshot-RTTXNNUX.mjs +1 -2
  73. package/package.json +1 -1
  74. package/dist/ExploreAttachment-CLFSAWKM.mjs +0 -260
  75. package/dist/ParticipantRuntime-HW3MOZI5.mjs +0 -139
  76. package/dist/ThreadPanel-RJIHV3P6.mjs +0 -197
  77. package/dist/browser-runtime-JJHSKIKD.mjs +0 -2
  78. package/dist/checkFixture-TJDFGPQI.mjs +0 -2
  79. package/dist/chunk-7IJGE5AK.mjs +0 -31
  80. package/dist/chunk-I63OQTCF.mjs +0 -347
  81. package/dist/chunk-J5SC3R5L.mjs +0 -2
  82. package/dist/chunk-PHKDIU3X.mjs +0 -30
  83. package/dist/chunk-XMKYGH62.mjs +0 -142
  84. package/dist/codex-note-context-YHKPQ4WP.mjs +0 -2
  85. /package/dist/{chunk-DMWB3IRD.mjs → chunk-QOJCTLQW.mjs} +0 -0
@@ -1,215 +1 @@
1
- "use client";
2
- import{c as Vr,f as Kn,e as Vn,d as Yn}from"./chunk-PSSHCTJ2.mjs";import"./chunk-F5XSNRGT.mjs";import{b as Jn}from"./chunk-JMMP5JSP.mjs";import{oa as Yr,pa as _n,ca as Gn,D as Zn,q as Jr}from"./chunk-6V2VCKPG.mjs";import"./chunk-4LHTPRFY.mjs";import"./chunk-2ZJ4FBTG.mjs";import"./chunk-DNOKP3JS.mjs";import"./chunk-2VCHBI7Y.mjs";import{e as Qe,a as Ft}from"./chunk-ODIGT4YJ.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import{b as Ie}from"./chunk-CPOYMGYY.mjs";import"./chunk-6VXFTT5U.mjs";import{x as Xe,w as vr,e as Tt,f as mt,r as yr,l as Wt,v as _r,t as Gr,b as Qn,p as qt,g as rr,d as nr,j as Zr,c as Qr,o as Xr,k as Xn,s as en,m as tn,h as ea,i as br,q as ta,a as ra,n as na,u as aa}from"./chunk-O4HZP3RP.mjs";import"./chunk-XTOCFTVW.mjs";import{a as ia}from"./chunk-LVEMYZOA.mjs";import"./chunk-WHJEKDNP.mjs";import{createContext as oa,useRef as D,useState as T,useSyncExternalStore as wr,useLayoutEffect as Pe,useEffect as se,useCallback as rn,useMemo as Ot,isValidElement as la,useId as xr,Fragment as sa,createElement as da,useContext as ca}from"react";import{Search as kr,X as Ct,ChevronLeft as Sr,Component as ua,PenLine as pa,History as ha,Eye as fa,Ruler as ga,Fingerprint as Ht,Plus as Ut,ChevronRight as Kt,RotateCw as ma,RotateCcw as va,ArrowLeftRight as nn,Info as ya,ChevronDown as ba,Check as wa,User as xa,ArrowRight as ka}from"lucide-react";import{jsx as i,jsxs as k,Fragment as Le}from"react/jsx-runtime";import{createPortal as an}from"react-dom";var ar=["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"],on=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function Sa(e,t){return Lt(t)?e==="flexGrow"||e==="flexShrink"?on.test(t)&&Number.isFinite(Number(t))&&Number(t)>=0:["display","boxSizing","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","textAlign","whiteSpace","overflow","strokeLinecap","strokeLinejoin","objectFit"].includes(e)?!on.test(t):/^(none|normal|auto|transparent|currentcolor)$/i.test(t)?!0:/^(?: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):e==="opacity"?t==="1":/^(?:backgroundColor|fill|stroke)$/.test(e)&&/^rgba\([^)]*,\s*0\)$/.test(t):!1}function Vt(e,t){return{...e,tokens:[...e.tokens,...t.tokens??[]]}}function Cr(e){return/^(width|height|marginTop|marginRight|marginBottom|marginLeft|gridTemplateColumns)$/.test(e)}var Rt=e=>{throw new aa(e)},Lt=e=>typeof e=="string"&&e.length>0&&e.length<=512&&!/[;{}\\]|\b(?:url|expression|var)\s*\(/i.test(e)&&![...e].some(t=>t.charCodeAt(0)<32),Rr=e=>typeof e=="string"&&/^[a-zA-Z0-9_-]{1,80}$/.test(e),Ca=new Set(["div","span","img","svg","path","circle","rect","line","polyline","polygon","ellipse","g"]),ln=e=>typeof e=="string"&&e.length<=2e4&&/^(https?:\/\/|blob:https?:\/\/|data:image\/(png|jpeg|webp|gif);base64,)/i.test(e),Ra=new Set(["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fillRule","clipRule"]);function Ea(e){(!e||typeof e!="object"||JSON.stringify(e).length>24e4)&&Rt("Invalid fragment capture.");let t=e,{evidence:r,draft:n}=t;(!r||!Rr(r.id)||![r.width,r.height].every(d=>Number.isFinite(d)&&d>0&&d<=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)&&Rt("This component is too large to capture. Try a smaller element.");let o=new Set;for(let d of r.values)(!d||!Rr(d.id)||o.has(d.id)||!ar.includes(d.property)||d.local!==void 0&&(d.local!==!0||!Cr(d.property))||!Lt(d.value))&&Rt("Unsupported captured style."),o.add(d.id);let s=0,l=new Set,a=(d,h)=>{(!d||!Rr(d.id)||l.has(d.id)||!Ca.has(d.tag)||++s>64||h>12||!Array.isArray(d.children)||d.children.length>128||!d.styles||typeof d.styles!="object")&&Rt("This component is too complex. Try a smaller element."),l.add(d.id);for(let[u,f]of Object.entries(d.styles))r.values.some(y=>y.id===f&&y.property===u)||Rt("Invalid captured style reference.");for(let[u,f]of Object.entries(d.attributes??{}))d.tag==="img"&&u==="src"&&ln(f)||(!Ra.has(u)||typeof f!="string"||f.length>12e3||!/^[\d\w\s.,+()-]*$/.test(f))&&Rt("Unsupported vector geometry.");for(let u of d.children)typeof u=="string"?u.length>2e3&&Rt("Too much captured text."):a(u,h+1)};return a(r.root,0),t}function Yt(e,t,r){try{let n=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(r),o;if(t.kind==="token"){let s=e.tokens.find(l=>l.id===t.id);o=s?yr(s.value,e.constraints,!n):null}else{let s=Tt(e.constraints,t.id,t.step??0);o=mt(s),s.kind==="layout"&&!s.unit&&!n&&(o+="px")}return Lt(o)?o:null}catch{return null}}function sn(e,t){let r=["div","span","img"].includes(t.tag)?{all:"initial"}:{};for(let[n,o]of Object.entries(t.localStyles??{}))ar.includes(n)&&(Sa(n,o)||Cr(n)&&Lt(o))&&(r[n]=["flexGrow","flexShrink","opacity","strokeWidth"].includes(n)&&Number.isFinite(Number(o))?Number(o):o);for(let[n,o]of Object.entries(t.styles)){if(!ar.includes(n))continue;let s=Yt(e,o,n);s!==null&&(r[n]=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(n)&&Number.isFinite(Number(s))?Number(s):s)}return r}function Et(e,t=!1){if(typeof e!="string"||!e||e.length>800||!/^[a-z\d\s.,%+#()\-/]+$/i.test(e))return!1;let r=0;for(let s of e)if(s==="("&&++r>8||s===")"&&--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)??[],o=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 s 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(" "))o.add(s);return n.every(s=>o.has(s.toLowerCase()))}function Mt(e){if(e.border===void 0)return e;let{border:t,...r}=e,n=String(t).match(/(?:[^\s(]+\([^)]*\)|[^\s]+)/g)??[],o=n.find(a=>/^(?:[\d.]+(?:[a-z%]+)?|thin|medium|thick)$/.test(a)),s=n.find(a=>/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/.test(a)),l=n.filter(a=>a!==o&&a!==s).join(" ");return{borderWidth:o??"medium",borderStyle:s??"none",borderColor:l||"currentColor",...r}}function vt(e){if(e.background===void 0)return e;let{background:t,...r}=e,n=String(t);if(typeof document<"u"){let o=document.createElement("span").style;if(o.background=n,o.background)return{backgroundColor:o.backgroundColor||"transparent",backgroundImage:o.backgroundImage||"none",...r}}return{backgroundColor:/gradient\(/i.test(n)||n==="none"?"transparent":n,backgroundImage:/gradient\(/i.test(n)?n:"none",...r}}function Er(e){if(!e||typeof e!="object")return;let t={};for(let r of["body","heading","card","button","input"]){let n=e[r];if(!n||typeof n!="object")continue;let o={};for(let[s,l]of Object.entries(n)){let a=String(l??"");s==="fontFamily"&&a.length<=200&&/^[a-zA-Z][a-zA-Z0-9 ,"'_-]*$/.test(a.replace(/^["']/,""))&&(o[s]=a),s==="color"&&Et(l)&&(o[s]=a),["background","backgroundColor","backgroundImage","border","borderColor","boxShadow","outline"].includes(s)&&Et(l,s.startsWith("background"))&&(o[s]=a),s==="opacity"&&typeof l=="number"&&Number.isFinite(l)&&(o[s]=Math.max(0,Math.min(1,l))),s==="transform"&&a.length<150&&/^(?:none|(?:\s*(?:translate(?:X|Y)?\(-?[\d.]+(?:px|rem|%)(?:,\s*-?[\d.]+(?:px|rem|%))?\)|scale\(\d*\.?\d+\))\s*){1,3})$/.test(a)&&(o[s]=a),s==="transition"&&a.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(a)&&(o[s]=a),s==="fontWeight"&&typeof l=="number"&&l>=100&&l<=900&&(o[s]=l),s==="fontStyle"&&["normal","italic"].includes(a)&&(o[s]=a),s==="textTransform"&&["none","uppercase","lowercase","capitalize"].includes(a)&&(o[s]=a),["fontSize","letterSpacing","lineHeight","padding","margin","marginTop","marginBottom","gap","borderRadius","borderWidth","outlineOffset"].includes(s)&&a.length<100&&/^-?\d*\.?\d+(?:px|rem|em|%)?(?:\s+-?\d*\.?\d+(?:px|rem|em|%)?){0,3}$/.test(a)&&(o[s]=a)}t[r]=o}return t}function Ge(e,t=640,r=!1){if(!e)return{};let n={...e};for(let[o,s]of Object.entries(n))o==="fontFamily"||o==="fontWeight"||!r&&typeof s=="string"&&(n[o]=s.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(l,a,d)=>`${Math.max(-12,Math.min(12,Number(a)*(d==="rem"?16:1)/(t/100)))}cqw`));if(e.fontFamily){let o=dn(e.fontFamily);/^Geist\s?Mono$/i.test(o)?n.fontFamily='"Popmelt Geist Mono", ui-monospace, monospace':/^Geist$/i.test(o)?n.fontFamily='"Popmelt Geist", system-ui, sans-serif':o&&!cn(o)&&(n.fontFamily=`"Popmelt Taste ${o}", ${e.fontFamily}`)}return vt(Mt(n))}var dn=e=>e.split(",")[0].trim().replace(/^["']|["']$/g,""),cn=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),$r=new Map;function $a(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 n=dn(r.fontFamily);if(cn(n)||/^Geist(?:\s?Mono)?$/i.test(n)||!/^[a-zA-Z][a-zA-Z0-9 _-]{0,79}$/.test(n))continue;let o=Number(r.fontWeight)||400,s=r.fontStyle==="italic";t.set(`${n}:${o}:${s}`,{family:n,weight:o,italic:s})}return Promise.all([...t.entries()].slice(0,5).map(([r,n])=>{let o=$r.get(r);if(o)return o;let s=(async()=>{let l=new AbortController,a=setTimeout(()=>l.abort(),8e3);try{let d=new URLSearchParams({family:`${n.family}:${n.italic?"ital,wght@1,":"wght@"}${n.weight}`,display:"swap"}),h=await fetch(`https://fonts.googleapis.com/css2?${d}`,{signal:l.signal,credentials:"omit",referrerPolicy:"no-referrer"});if(h.ok||(h=await fetch(`https://fonts.googleapis.com/css2?family=${encodeURIComponent(n.family)}&display=swap`,{signal:l.signal,credentials:"omit",referrerPolicy:"no-referrer"})),!h.ok)throw new Error("Font unavailable");if(![...(await h.text()).matchAll(/@font-face\s*\{([^}]+)\}/g)].slice(0,32).flatMap(u=>{let f=u[1],y=f.match(/url\((https:\/\/fonts\.gstatic\.com\/[^\s)"']+)\)/)?.[1];if(!y)return[];let g=new FontFace(`Popmelt Taste ${n.family}`,`url(${JSON.stringify(y)})`,{weight:f.match(/font-weight:\s*([^;]+);/)?.[1]??"400",style:f.match(/font-style:\s*([^;]+);/)?.[1]??"normal",unicodeRange:f.match(/unicode-range:\s*([^;]+);/)?.[1]??"U+0-10FFFF",display:"swap"});return document.fonts.add(g),[g]}).length)throw new Error("Font unavailable");await document.fonts.load(`${n.italic?"italic ":""}${n.weight} 16px "Popmelt Taste ${n.family}"`,"Your workspace A little space for big ideas. Create a project")}finally{clearTimeout(a)}})().catch(l=>{console.warn(`[Popmelt] Preview font ${n.family} unavailable; using its fallback.`,l instanceof Error?l.message:"Font request failed"),$r.delete(r)});return $r.set(r,s),s})).then(()=>{})}var et=e=>!!e&&typeof e=="object"&&!Array.isArray(e),At=(e,t=512)=>typeof e=="string"&&e.length<=t,zt=e=>At(e,100)&&/^[a-zA-Z0-9_-]+$/.test(e),Ir=e=>At(e,4096)&&![...e].some(t=>t.charCodeAt(0)<9)&&!/[;{}<>]|\b(?:url|expression|javascript)\s*[:(]/i.test(e),yt=(e,t)=>Object.keys(e).every(r=>t.includes(r)),Dt=(e,t)=>new Set(e.map(r=>r[t])).size===e.length,Nr=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(" ")),Ia=new Set("div span img svg path circle rect line polyline polygon ellipse g".split(" ")),Na=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 bt(e){return Array.isArray(e)?"["+e.map(bt).join(",")+"]":et(e)?"{"+Object.keys(e).sort().map(t=>JSON.stringify(t)+":"+bt(e[t])).join(",")+"}":JSON.stringify(e)}function Ta(e){try{if(!et(e)||!yt(e,["format","schemaVersion","draft"])||e.format!=="popmelt.taste.graph"||e.schemaVersion!==1||new TextEncoder().encode(JSON.stringify(e)).byteLength>512e3)return!1;let t=e.draft;if(!et(t)||!yt(t,["schemaVersion","name","constraints","tokens","usage","fragments","featuredComponentId"])||t.schemaVersion!==1||!At(t.name,80)||!t.name.trim()||!Array.isArray(t.constraints)||t.constraints.length<1||t.constraints.length>32||!t.constraints.every(a=>et(a)&&yt(a,["id","name","kind","group","typographyRole","scaleMode","value","parentId","derivative","scale"])&&zt(a.id)&&At(a.name,80)&&(a.group===void 0||a.group==="typography")&&(a.typographyRole===void 0||a.typographyRole==="body"||a.typographyRole==="heading")&&["layout","color","font"].includes(String(a.kind))&&Ir(a.value)&&(a.parentId===null||zt(a.parentId))&&Number.isFinite(a.derivative)&&Number.isFinite(a.scale)&&typeof a.scale=="number"&&a.scale>=0&&(a.scaleMode===void 0||a.scaleMode==="increment"))||!Dt(t.constraints,"id"))return!1;let r=new Map(t.constraints.map(a=>[String(a.id),a]));for(let a of t.constraints){let d=new Set,h=a;for(;h.parentId!==null;){if(d.has(h.id))return!1;d.add(h.id);let u=r.get(h.parentId);if(!u||u.kind!==h.kind)return!1;h=u}if(!h.value.trim())return!1}let n=a=>Array.isArray(a)&&a.length<=128&&a.every(d=>et(d)&&yt(d,["id","name","value"])&&zt(d.id)&&zt(d.name)&&Ir(d.value)&&d.value.trim()&&[...d.value.matchAll(/@([a-zA-Z0-9_-]+)/g)].every(h=>r.has(h[1])))&&Dt(a,"id")&&Dt(a,"name");if(!n(t.tokens))return!1;let o=t.tokens,s=(a,d)=>et(a)&&yt(a,["kind","id","step"])&&(a.kind==="dimension"?r.has(String(a.id)):a.kind==="token"&&d.some(h=>h.id===a.id))&&(a.step===void 0||typeof a.step=="number"&&Number.isInteger(a.step)&&Math.abs(a.step)<=100);if(t.usage!==void 0&&(!Array.isArray(t.usage)||t.usage.length>256||!t.usage.every(a=>et(a)&&yt(a,["target","property","source"])&&["page","heading","body","muted","card","button","input"].includes(String(a.target))&&Nr.has(String(a.property))&&s(a.source,o))))return!1;let l=t.fragments??[];if(!Array.isArray(l)||l.length>32||!Dt(l,"id"))return!1;for(let a of l){if(!et(a)||!yt(a,["id","name","width","height","root","tokens"])||!zt(a.id)||!At(a.name,80)||!a.name.trim()||![a.width,a.height].every(g=>typeof g=="number"&&Number.isFinite(g)&&g>0&&g<=2e4)||!n(a.tokens??[]))return!1;let d=a.tokens??[];if(!n(d))return!1;let h=[...o,...d];if(!Dt(h,"id")||!Dt(h,"name"))return!1;let u=new Set,f=0,y=(g,C)=>typeof g=="string"?g.length<=1e4:!et(g)||!yt(g,["id","tag","styles","localStyles","attributes","children"])||!zt(g.id)||u.has(g.id)||++f>256||C>16||!Ia.has(String(g.tag))||!et(g.styles)||!Array.isArray(g.children)||g.children.length>256||(u.add(g.id),!Object.entries(g.styles).every(([c,b])=>Nr.has(c)&&s(b,h)))||g.localStyles!==void 0&&(!et(g.localStyles)||!Object.entries(g.localStyles).every(([c,b])=>Nr.has(c)&&Ir(b)))||g.attributes!==void 0&&(!et(g.attributes)||!Object.entries(g.attributes).every(([c,b])=>Na.has(c)&&At(b,2e4)&&(c!=="src"||/^https:\/\//.test(b))))?!1:g.children.every(c=>y(c,C+1));if(!y(a.root,0))return!1}return t.featuredComponentId==null||l.some(a=>a.id===t.featuredComponentId)}catch{return!1}}function $t(e){if(!Ta(e))return;let t=e;try{for(let r of t.draft.constraints)Tt(t.draft.constraints,r.id);for(let r of t.draft.fragments??[]){let n=Vt(t.draft,r),o=s=>Object.entries(s.styles).every(([l,a])=>Yt(n,a,l)!==null)&&s.children.every(l=>typeof l=="string"||o(l));if(!o(r.root))return}return t}catch{return}}function Tr(e){let t={format:"popmelt.taste.graph",schemaVersion:1,draft:e};if(!$t(t))throw Error("This Taste has incomplete or invalid dimensions, tokens, or component bindings.");return t}function wt(e){if(!e||typeof e!="object")return;let t=e;for(let o of["background","surface","foreground","muted","accent","border"])if(!Et(t[o],!0))return;for(let o of["radius","spacing"])if(typeof t[o]!="number"||!Number.isFinite(t[o])||t[o]<0||t[o]>32)return;let r={...t};delete r.savedDocument;let n=t.savedDocument;if(n&&typeof n.id=="string"&&Number.isSafeInteger(n.revision)&&n.revision>0&&$t(n.document)&&(r.savedDocument=n),delete r.detail,t.detail!==void 0&&(r.detail=Er(t.detail)),delete r.states,t.states&&typeof t.states=="object"){r.states={};for(let o of["card","button","input"]){let s=t.states[o];if(!(!s||typeof s!="object")){r.states[o]={};for(let l of["hover","focus","active"])r.states[o][l]=Er({[o]:s[l]})?.[o]}}}if(delete r.parts,t.parts!==void 0){if(!t.parts||typeof t.parts!="object")return;let o={};for(let s of["card","button","content"]){let l=t.parts[s];if(!l||typeof l.radius!="number"||!Number.isFinite(l.radius)||l.radius<0||l.radius>999)return;let a=l.backdropFilter;o[s]={background:Et(l.background,!0)?l.background:r.surface,border:Et(l.border)?l.border:`1px solid ${r.border}`,radius:l.radius,shadow:Et(l.shadow)?l.shadow:"none",...l.backgroundImage!==void 0?{backgroundImage:Et(l.backgroundImage,!0)?l.backgroundImage:"none"}:{},...l.backgroundBlendMode!==void 0?{backgroundBlendMode:["normal","overlay","multiply","screen","soft-light","hard-light"].includes(l.backgroundBlendMode)?l.backgroundBlendMode:"normal"}:{},...a!==void 0?{backdropFilter:typeof a=="string"&&a.length<150&&/^(?:none|(?:\s*(?:blur\(\d*\.?\d+(?:px|rem)\)|saturate\(\d*\.?\d+%?\))\s*){1,3})$/.test(a)?a:"none"}:{},...l.opacity!==void 0?{opacity:Number.isFinite(l.opacity)?Math.max(0,Math.min(1,l.opacity)):1}:{}}}r.parts=o}return(!Number.isSafeInteger(r.recipeRevision)||r.recipeRevision<0)&&delete r.recipeRevision,(typeof r.contentRevision!="string"||!/^[a-f\d]{24}$/.test(r.contentRevision))&&delete r.contentRevision,r}function La({recipe:e}){let t=e.radius*.45,r=o=>o.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(s,l,a)=>`${Math.max(-32,Math.min(32,Number(l)*(a==="rem"?16:1)*.45))}px`),n=o=>o?{background:o.background,...o.backgroundImage&&o.backgroundImage!=="none"?{backgroundImage:o.backgroundImage}:{},backgroundBlendMode:o.backgroundBlendMode,backdropFilter:o.backdropFilter?r(o.backdropFilter).replace(/saturate\(([\d.]+)%\)/g,(s,l)=>`saturate(${Math.min(400,Number(l))}%)`):void 0,WebkitBackdropFilter:o.backdropFilter?r(o.backdropFilter):void 0,opacity:o.opacity,border:r(o.border),borderRadius:o.radius*.45,boxShadow:r(o.shadow)}:{};return i("span",{"data-taste-specimen":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,background:e.background,pointerEvents:"none",overflow:"hidden"},children:k("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:[i("span",{"data-specimen-title":!0,style:{position:"absolute",left:0,top:0,width:"100%",height:"18.18%",background:e.parts?"transparent":e.accent}}),i("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:t*.6,boxSizing:"border-box",...n(e.parts?.button)}}),i("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:t*.6,boxSizing:"border-box",...n(e.parts?.content)}})]})})}function Jt(e,t=!1,r=640){let[n,o]=T(!1),[s,l]=T(!1),[a,d]=T(!1);return{handlers:{onPointerEnter:()=>o(!0),onPointerLeave:()=>{o(!1),d(!1)},onPointerDown:()=>d(!0),onPointerUp:()=>d(!1),onPointerCancel:()=>d(!1),onKeyDown:h=>{t&&["Enter"," "].includes(h.key)&&d(!0)},onKeyUp:()=>d(!1),onFocus:()=>l(!0),onBlur:()=>{l(!1),d(!1)}},style:{...Ge(n?e?.hover:void 0,r),...Ge(s?e?.focus:void 0,r),...Ge(a?e?.active:void 0,r)}}}function Lr({recipe:e,usageStyles:t}){let r=t!==void 0,n=u=>Ge({...e.detail?.[u]??{},...t?.[u]},640,r),o=Jt(e.states?.button,!0),s=Jt(e.states?.input),l=Jt(e.states?.card),a=r?`${e.spacing}px`:`${e.spacing/6.4}cqw`;se(()=>{$a({...e.detail,...t})},[e.detail,t]);let d=u=>u.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(f,y,g)=>`${Math.max(-16,Math.min(16,Number(y)*(g==="rem"?16:1)/6.4))}cqw`),h=u=>u?{...vt({background:u.background}),...u.backgroundImage&&u.backgroundImage!=="none"?{backgroundImage:u.backgroundImage}:{},backgroundBlendMode:u.backgroundBlendMode,...Mt({border:d(u.border)}),borderRadius:`${u.radius/6.4}cqw`,boxShadow:d(u.shadow),backdropFilter:u.backdropFilter?d(u.backdropFilter):void 0,WebkitBackdropFilter:u.backdropFilter?d(u.backdropFilter):void 0,opacity:u.opacity}:{};return i("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",...vt({background:e.background}),color:e.foreground,fontSynthesis:"none",...n("body"),...n("page"),overflow:r?"visible":"hidden"},children:i("div",{"data-taste-component":"card",style:{position:r?"relative":"absolute",...r?{}:{inset:"9% 8%"},...vt({background:e.surface}),...Mt({border:`1px solid ${e.border}`}),borderRadius:e.radius,...h(e.parts?.card),padding:r?0:"5cqw",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:a,...n("card")},children:k("div",{style:{display:"grid",gridTemplateColumns:"1.35fr 1fr",gap:r?n("card").gap??a:`calc(${a} * 2)`,alignItems:"center",flex:1,minHeight:0},children:[k("div",{children:[k("h2",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",lineHeight:1.1,letterSpacing:"-0.03em",marginBottom:a,...n("heading"),...r?{}:{fontSize:`clamp(3.8cqw, ${Ge(e.detail?.heading).fontSize??"4.6cqw"}, 5.4cqw)`}},children:["A little space",i("br",{}),"for big ideas."]}),k("p",{"data-taste-component":"paragraph",style:{margin:0,fontSize:r?"inherit":"2.4cqw",lineHeight:1.5,marginBottom:a,...n("body"),...n("muted")},children:["Gather your thoughts.",i("br",{}),"Make something your own."]}),i("button",{"data-taste-component":"button",...o.handlers,type:"button",style:{fontFamily:"inherit",color:"inherit",display:"inline-block",...vt({background:e.accent}),...Mt({border:`1px solid ${e.border}`}),borderRadius:e.radius,...h(e.parts?.button),padding:r?0:"1.5cqw 2.5cqw",fontSize:r?"inherit":"2.3cqw",fontWeight:"inherit",lineHeight:1.2,...n("button"),cursor:"pointer",...o.style},children:"Create a project \u2197"})]}),k("div",{"data-taste-component":"card",...l.handlers,style:{...vt({background:e.surface}),...Mt({border:`1px solid ${e.border}`}),borderRadius:e.radius,...h(e.parts?.card),padding:r?0:"3cqw",fontSize:r?"inherit":"2.1cqw",lineHeight:1.5,...n("card"),...l.style},children:[i("h3",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",...n("heading"),...r?{}:{fontSize:"2.6cqw"},marginBottom:a},children:"In the works"}),i("input",{"data-taste-component":"input",...s.handlers,"aria-label":"Preview project name",defaultValue:"A fresh start",style:{appearance:"none",outline:"none",borderWidth:0,borderStyle:"none",borderColor:"transparent",...vt({background:"transparent"}),...h(e.parts?.content),font:"inherit",color:"inherit",padding:r?0:"1.5cqw",...n("input"),width:"100%",minWidth:0,boxSizing:"border-box",marginBottom:a,...s.style}}),i("div",{children:"02 \xA0 What comes next"})]})]})})})}function Ma(e){let t=e.ownerDocument.defaultView;if(!t||Jr(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:[]},o=new Map,s=0,l=(d,h)=>{if(d.matches("script,style,noscript,template,[hidden],[contenteditable]")||Jr(d))return null;let u=d.getBoundingClientRect(),f=t.getComputedStyle(d);if(!u.width||!u.height||u.bottom<=0||u.right<=0||u.top>=t.innerHeight||u.left>=t.innerWidth||f.display==="none"||f.visibility!=="visible"||f.opacity==="0")return null;if(++s>64||h>12)throw Error("This component is too complex. Click a smaller element.");if(d.matches("video,canvas,iframe,object,embed,use,foreignObject")||d.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(f.backgroundImage))throw Error("Image backgrounds are not supported by static capture yet.");let y=d.namespaceURI==="http://www.w3.org/2000/svg",g=y?d.localName:d.localName==="img"?"img":f.display==="inline"?"span":"div",C={id:`n${s}`,tag:g,children:[],styles:{}};if(d instanceof HTMLImageElement){if(!ln(d.currentSrc||d.src))throw Error("This image cannot be captured safely.");C.attributes={src:d.currentSrc||d.src}}if(y){C.attributes={};for(let c of["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fill-rule","clip-rule"]){let b=d.getAttribute(c);b!==null&&(C.attributes[c.replace(/-([a-z])/g,(m,p)=>p.toUpperCase())]=b)}}for(let c of ar){if(["gap","padding","paddingInline","paddingBlock","border","borderRadius","borderColor","borderWidth"].includes(c)||!y&&["fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin"].includes(c)||y&&g!=="svg"&&["width","height"].includes(c))continue;let b=f[c],m=!1;if(Cr(c)){let N=d.computedStyleMap?.().get(c.replace(/[A-Z]/g,M=>`-${M.toLowerCase()}`))?.toString();N&&Lt(N)&&(b=N),m=!N||/^(auto|min-content|max-content|fit-content|none)$/.test(N)||c==="gridTemplateColumns"}if(!b)continue;if(!Lt(b))throw Error("This component has an unsupported style. Try a smaller element.");let p=`${c}:${b}:${m}`,v=o.get(p);v||(v=`s${o.size}`,o.set(p,v),n.values.push({id:v,property:c,value:b,...m?{local:!0}:{}})),C.styles[c]=v}if(!d.matches("input,textarea,select,option")){for(let c of d.childNodes)if(c.nodeType===3)c.textContent&&C.children.push(c.textContent);else if(c instanceof Element){let b=l(c,h+1);b&&C.children.push(b)}}return C},a=l(e,0);if(!a)throw Error("Choose a visible element on the page.");return n.root=a,Ea({evidence:n,draft:ra()}),n}function ir({fragment:e,draft:t,height:r=160,highlightedNodes:n=[]}){let o=D(null),s=D(null),[l,a]=T(null),[d,h]=T({scale:1,width:e.width,height:e.height}),{scale:u}=d;Pe(()=>{o.current&&a(o.current.shadowRoot??o.current.attachShadow({mode:"open"}))},[]),Pe(()=>{let y=()=>{if(!o.current||!s.current)return;let C=s.current,c=Math.max(1,C.scrollWidth),b=Math.max(1,C.scrollHeight),m={width:c,height:b,scale:Math.min(1,o.current.clientWidth/c,r/b)};h(p=>p.width===m.width&&p.height===m.height&&p.scale===m.scale?p:m)};if(y(),typeof ResizeObserver>"u")return;let g=new ResizeObserver(y);return o.current&&g.observe(o.current),s.current&&g.observe(s.current),()=>g.disconnect()},[l,t,r]);let f=y=>{let g=sn(Vt(t,e),y);return da(y.tag,{...y.attributes,key:y.id,style:{...g,color:g.color??"inherit",fontFamily:g.fontFamily??"inherit",fontSize:g.fontSize??"inherit",lineHeight:g.lineHeight??"inherit",fontWeight:g.fontWeight??"inherit",...n.includes(y.id)?{outline:"2px solid #888",outlineOffset:"2px"}:{}},"data-fragment-node":y.id},...y.children.map(C=>typeof C=="string"?C:f(C)))};return i("div",{ref:o,role:"img","aria-label":`${e.name} static preview`,style:{height:r,width:"100%",overflow:"hidden",borderRadius:8,pointerEvents:"none",backgroundColor:sn(Vt(t,e),e.root).backgroundColor??Gr(t).page?.backgroundColor},children:l&&an(i("div",{style:{height:r,display:"grid",placeItems:"center",overflow:"hidden"},children:i("div",{style:{width:d.width*u,height:d.height*u},children:i("div",{ref:s,style:{width:e.width,transform:`scale(${u})`,transformOrigin:"top left"},children:f(e.root)})})}),l)})}function Aa(e){let{session:t,draft:r,visible:n,bridgeUrl:o}=e,[s,l]=T([]),a=D(null),d=D(new Map),h=D(null),u=D(null),f=D(e);f.current=e;let y=D(!1),g=t.getSnapshot().runId,C=t.getSnapshot().state,c=Qe[e.theme],b=m=>{if(t.getSnapshot().state==="running")return;let p=t.getSnapshot().draft;if(!p)return;let v={...p,featuredComponentId:m};t.history.current.past.push(p),t.history.current.future=[],t.edit(v),e.onDraft(v)};return Pe(()=>{let m=a.current?.closest(".tc-scroll");if(!m||!n)return;let p=()=>{h.current=null},v=N=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(N.key)&&p()};return m.addEventListener("wheel",p,{passive:!0}),m.addEventListener("touchmove",p,{passive:!0}),m.addEventListener("pointerdown",p,{passive:!0}),m.addEventListener("keydown",v),()=>{m.removeEventListener("wheel",p),m.removeEventListener("touchmove",p),m.removeEventListener("pointerdown",p),m.removeEventListener("keydown",v)}},[n]),Pe(()=>{let m=h.current;if(!m||!n)return;let p=d.current.get(m),v=p?.closest(".tc-scroll");if(!p||!v)return;let N=p.getBoundingClientRect(),M=v.getBoundingClientRect(),j=N.bottom+16-M.bottom;j>0&&v.scrollTo({top:v.scrollTop+j,behavior:"instant"})},[s,n,r]),se(()=>(y.current=!0,()=>{y.current=!1,u.current?.abort(),u.current=null}),[]),se(()=>{if(n)return Jn(m=>{let p;try{let v=Ma(m);p={id:v.id,evidence:v,state:"pending"}}catch(v){p={id:crypto.randomUUID(),state:"error",message:v instanceof Error?v.message:"Could not capture this element."}}l(v=>v.length+(f.current.draft.fragments?.length??0)>=16?v:(h.current=p.id,[...v,p]))})},[n]),se(()=>{if(!n||u.current||C==="running")return;let m=s.find(M=>M.state==="pending"&&M.evidence);if(!m)return;let p=new AbortController;u.current=p;let v=M=>{y.current&&!p.signal.aborted&&l(j=>j.map(q=>q.id===m.id?{...q,...M}:q))};v({state:"running"});let N=setTimeout(()=>{v({state:"error",message:"Capture took too long. Try again."}),p.abort()},19e4);(async()=>{try{if(await Promise.resolve(),p.signal.aborted)return;if(!o)throw Error("Connect the local bridge to capture a component.");let M=t.getSnapshot(),j=await Ie(`${o}/cloud-taste/fragment`,{method:"POST",headers:{"Content-Type":"application/json"},signal:p.signal,body:JSON.stringify({evidence:m.evidence,draft:{...M.draft,fragments:void 0}})});if(!j.ok||!j.body)throw Error("Component capture is unavailable. Retry when the bridge is ready.");let q=j.body.getReader(),x=new TextDecoder,P="",L,B=O=>{if(!O.trim())return;let A=JSON.parse(O);if(A.type==="error")throw Error(A.message);A.type==="status"&&v({message:A.message}),A.type==="progress"&&v({name:A.draft.fragment.name}),A.type==="complete"&&(L=A.draft)};try{for(;;){let O=await q.read();if(O.done)break;if(P+=x.decode(O.value,{stream:!0}),P.length>256e3)throw Error("Component response was too large.");let A;for(;(A=P.indexOf(`
3
- `))!==-1;)B(P.slice(0,A)),P=P.slice(A+1)}B(P+x.decode())}finally{q.releaseLock()}if(!L)throw Error("The component ended before its styles arrived. Retry capture.");!p.signal.aborted&&y.current&&(f.current.onDraft(t.addFragment(g,L)),l(O=>O.filter(A=>A.id!==m.id)))}catch(M){v({state:"error",message:M instanceof Error?M.message:"Capture failed. Please retry."})}finally{clearTimeout(N),u.current===p&&(u.current=null),y.current&&l(M=>[...M])}})()},[s,C,n,o,g,t]),k("section",{ref:a,"aria-label":"Components",style:{display:"flex",flexDirection:"column",gap:16},children:[i("h3",{style:{margin:0,fontSize:12,fontWeight:400,color:c.primary},children:"Components"}),!r.fragments?.length&&!s.length&&i("p",{style:{margin:0,fontSize:12,color:c.secondary},children:"Click an element on the page to capture a static component."}),r.fragments?.map(m=>k("div",{ref:p=>{p?d.current.set(m.id,p):d.current.delete(m.id)},style:{display:"flex",flexDirection:"column",gap:4},children:[i("button",{type:"button","aria-label":`Inspect ${m.name}`,onClick:()=>e.onInspect?.(m.id),style:{background:c.control,borderRadius:8,width:"100%",padding:0,display:"block"},children:i(ir,{draft:r,fragment:m})}),k("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 4px",color:c.secondary},children:[i("button",{type:"button",onClick:()=>e.onInspect?.(m.id),style:{flex:1,justifyContent:"flex-start",fontSize:12,letterSpacing:".12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.name}),i("button",{type:"button",onClick:()=>b(m.id),"aria-label":`Use ${m.name} as preview`,"aria-pressed":r.featuredComponentId===m.id,disabled:C==="running",style:{fontSize:12},children:r.featuredComponentId===m.id?"Preview":"Use as preview"}),i("button",{type:"button",onClick:()=>e.onInspect?.(m.id),"aria-label":`Uses for ${m.name}`,title:"Styles are linked to this Taste\u2019s dimensions and tokens",style:{fontSize:14,fontWeight:500,letterSpacing:"-.14px"},children:"uses"})]})]},m.id)),s.map(m=>k("div",{ref:p=>{p?d.current.set(m.id,p):d.current.delete(m.id)},"data-taste-fragment-capture":m.id,style:{borderRadius:8,background:c.control,minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:8,padding:12,boxSizing:"border-box"},children:[i("span",{role:m.state==="error"?"alert":"status",className:"tc-proposal-status","data-state":m.state==="running"?"in-progress":m.state,style:{whiteSpace:"normal",textAlign:"center"},children:m.state==="error"?m.message:m.state==="pending"?"Pending":m.message??`Tracing ${m.name??"component"}\u2026`}),m.state==="error"&&k("div",{style:{display:"flex",gap:12},children:[m.evidence&&i("button",{type:"button",onClick:()=>l(p=>p.map(v=>v.id===m.id?{...v,state:"pending",message:void 0}:v)),children:"Retry"}),i("button",{type:"button",onClick:()=>l(p=>p.filter(v=>v.id!==m.id)),children:"Dismiss"})]})]},m.id))]})}function Mr({document:e}){let t=D(null),[r,n]=T(160);Pe(()=>{let l=()=>n(t.current?.clientHeight||160);if(l(),typeof ResizeObserver>"u")return;let a=new ResizeObserver(l);return t.current&&a.observe(t.current),()=>a.disconnect()},[]);let o=e.draft,s=o.fragments?.find(l=>l.id===o.featuredComponentId);return i("div",{ref:t,"data-taste-document-preview":!0,style:{width:"100%",height:"100%"},children:s?i(ir,{fragment:s,draft:o,height:r}):null})}function un({preview:e,thumbnailUrl:t,zoom:r=!0,background:n}){let[o,s]=T(null),l=e?.savedDocument?.document.draft.featuredComponentId?i(Mr,{document:e.savedDocument.document}):e?i(Lr,{recipe:e}):t&&t!==o?i("img",{src:t,alt:"",referrerPolicy:"no-referrer",onError:()=>s(t),style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):null;return i("div",{"data-detail-preview":!0,style:{aspectRatio:"16 / 9",width:"100%",position:"relative",border:0,padding:0,borderRadius:8,overflow:"hidden",background:n,font:"inherit"},children:r?i(Vr,{children:l}):l})}var Ar=100,Pt=200,za=600,pn=220,Da=120,Pa=160;function zr(e){let t=new Map;if(!e)return t;let r=e.getBoundingClientRect();for(let n of e.querySelectorAll("[data-taste-tile]")){let o=n.dataset.tasteEntryId;if(!o)continue;let s=n.getBoundingClientRect();t.set(o,{x:s.x-r.x,y:s.y-r.y})}return t}function hn(e,t,r,n,o){if(!e)return;let s=zr(e);for(let l of e.querySelectorAll("[data-taste-tile]")){let a=l.dataset.tasteEntryId,d=a?t.get(a):null,h=a?s.get(a):null;if(!d||!h||!l.animate)continue;let u=(d.x-h.x)/(r||1),f=(d.y-h.y)/(r||1);Math.abs(u)<.5&&Math.abs(f)<.5||o.push(l.animate([{transform:`translate(${u}px, ${f}px)`},{transform:"translate(0, 0)"}],{duration:n,easing:"ease-in-out"}))}}function fn({entry:e,onAdd:t,onRemove:r,active:n,featured:o=!1,previewBackground:s,hasActiveTaste:l=!1,onOpenDetails:a,onPrefetchDetails:d}){let[h,u]=T(null),f=D(null),y=D(d);y.current=d;let g=D(e);g.current=e,se(()=>{if(!f.current||typeof IntersectionObserver>"u")return;let N=new IntersectionObserver(([M])=>{M?.isIntersecting&&(g.current.preview||y.current?.(g.current),N.disconnect())},{root:f.current.closest("[data-taste-scroll]"),rootMargin:"180px"});return N.observe(f.current),()=>N.disconnect()},[e.id]);let C=D(void 0),c=()=>clearTimeout(C.current);se(()=>()=>clearTimeout(C.current),[]);let b=!!e.documentRevision||!!e.preview?.savedDocument,m=n?r:b?a:t,p=n?"Remove":b?"View":l?"Switch":"Add",v=i("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:n?k(Le,{children:["Remove",i(Ct,{size:12,"aria-hidden":"true"})]}):k(Le,{children:[b?i(Kt,{size:12,"aria-hidden":"true"}):i(Ut,{size:12,"aria-hidden":"true"}),p]})});return k("li",{"data-taste-tile":!0,"data-taste-entry-id":e.id,"data-taste-featured":o||void 0,ref:f,onMouseEnter:()=>{c(),C.current=setTimeout(()=>d?.(e),100)},onMouseLeave:c,onFocus:()=>{c(),d?.(e)},style:{minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[o?k("div",{"data-taste-thumbnail":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:8,overflow:"hidden"},children:[i("div",{"data-taste-preview-art":!0,"aria-hidden":"true",inert:!0,children:i(un,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,zoom:!1,background:s??"transparent"},e.id)}),i("button",{type:"button","data-taste-featured-action":!0,"aria-label":`${p} ${e.name}`,"aria-pressed":n,disabled:!m,onClick:()=>m?.(e),style:{position:"absolute",inset:0,width:"100%",padding:0,border:0,background:"transparent",font:"inherit",cursor:m?"pointer":"default"},children:v})]}):k("button",{type:"button","data-taste-thumbnail":!0,"aria-label":`${p} ${e.name}`,"aria-pressed":n,disabled:!m,onClick:()=>m?.(e),style:{display:"block",padding:0,border:0,font:"inherit",cursor:m?"pointer":"default",aspectRatio:"1",width:"100%",borderRadius:8,overflow:"hidden",position:"relative"},children:[i("span",{"data-taste-preview-art":!0,style:{position:"absolute",inset:0},children:e.preview?.savedDocument?.document.draft.featuredComponentId?i(Mr,{document:e.preview.savedDocument.document}):e.thumbnailUrl&&e.thumbnailUrl!==h?i("img",{src:e.thumbnailUrl,alt:"",referrerPolicy:"no-referrer",onError:()=>u(e.thumbnailUrl??null),style:{display:"block",width:"100%",height:"100%",objectFit:"cover"}}):e.preview?i(La,{recipe:e.preview}):null}),v]}),k("button",{type:"button","data-taste-details":!0,"aria-label":`View ${e.name} details`,disabled:!a,onClick:()=>a?.(e),style:{width:"100%",padding:0,border:0,borderRadius:2,background:"transparent",font:"inherit",textAlign:"left",cursor:a?"pointer":"default",display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,minWidth:0,letterSpacing:".12px"},children:[k("span",{style:{display:"inline-flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[i("span",{"data-taste-name":!0,title:e.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,minWidth:0},children:e.name}),a&&i("span",{"data-taste-detail-chevron":!0,"aria-hidden":"true",children:i(Kt,{size:13,strokeWidth:2})})]}),e.metadata&&i("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 ja({theme:e,publicEntries:t,privateEntries:r,onClose:n,onRefresh:o,refreshDisabled:s=!1,refreshing:l=!1,onAdd:a,onRemove:d,activeEntryId:h=null,activeEntry:u,onOpenDetails:f,onPrefetchDetails:y,notice:g,action:C,headerAction:c,privateEmptyMessage:b,style:m}){let p=Qe[e],[v,N]=T(!1),M=D(null),j=D(null),q=D(null),x=D(null),P=D([]),L=D(new Map),B=D([]),O=D(null),[A,I]=T(null),E=D(null),K=D(null),[de,Q]=T(),[H,ae]=T(null),he=D(null);se(()=>()=>{for(let J of he.current?.timers??[])clearTimeout(J);he.current?.cleanup();for(let J of P.current)J.cancel();for(let J of B.current)J.cancel();he.current=null},[]);let ue=h?u?.id===h?u:[...t,...r].find(J=>J.id===h):null,me=H?.entry??ue,Fe=me?.id??null,ve=!!h&&A===h,Me=H?.phase==="collapse",Ye=t.filter(J=>J.id!==Fe||Me),$=r.filter(J=>J.id!==Fe||Me);Pe(()=>{let J=x.current;if(!J||H?.phase!=="collapse"||(x.current=null,window.matchMedia?.("(prefers-reduced-motion: reduce)").matches))return;let pe=q.current,V=M.current,xe=V?V.getBoundingClientRect().width/(V.offsetWidth||1):1;hn(pe,J.positions,xe,Pt,P.current);for(let X of pe?.querySelectorAll("[data-taste-tile]")??[])if(!(X.dataset.tasteEntryId!==J.returningId||!X.animate)){P.current.push(X.animate([{opacity:0},{opacity:1}],{duration:Pt,easing:"ease-out"}));break}},[H?.phase]),Pe(()=>{let J=q.current;if(!J)return;let pe=L.current;if(!ve||O.current===h)return;O.current=h;let V=E.current,xe=K.current,X=j.current,Ke=X?.querySelector("[data-taste-collections]");if(!V||!xe||!X||!Ke||!V.animate||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){I(null);return}for(let rt of B.current)rt.cancel();B.current=[];let Je={duration:pn,easing:"ease-in-out"},qe={delay:Da,duration:Pa,easing:"ease-out",fill:"backwards"},Ae=V.offsetHeight,tt=xe.offsetHeight,We=V.animate([{height:"0px"},{height:`${Ae}px`}],Je);B.current.push(We),B.current.push(V.animate([{opacity:0},{opacity:1}],qe),xe.animate([{height:"0px"},{height:`${tt}px`}],Je),xe.animate([{opacity:0},{opacity:1}],qe),X.animate([{gap:"0px"},{gap:"24px"}],Je),Ke.animate([{gap:"0px"},{gap:"16px"}],Je));let ze=M.current,De=ze?ze.getBoundingClientRect().width/(ze.offsetWidth||1):1;hn(J,pe,De,pn,B.current),We.onfinish=()=>{O.current===h&&(O.current=null,I(null))}},[ve,h]),Pe(()=>{L.current=zr(q.current)});let te=J=>{a&&(!Fe&&!H&&(O.current=null,I(J.id)),a(J))},ge=J=>{if(!d||he.current)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){d(J);return}let pe={id:J.id,timers:[],cleanup:()=>{}};for(let Ae of P.current)Ae.cancel();P.current=[],he.current=pe,ae({entry:J,phase:"fade",activeHeight:E.current?.offsetHeight??0,headingHeight:K.current?.offsetHeight??0});let V=!1,xe=!1,X=!1,Ke=()=>{if(!(!V||!xe||he.current!==pe)){for(let Ae of pe.timers)clearTimeout(Ae);pe.cleanup(),he.current=null,ae(null)}},Je=j.current,qe=Ae=>{!X||Ae.target!==Je||Ae.propertyName!=="gap"||(V=!0,Ke())};Je?.addEventListener("transitionend",qe),pe.cleanup=()=>Je?.removeEventListener("transitionend",qe),pe.timers.push(setTimeout(()=>{he.current===pe&&(X=!0,x.current={returningId:J.id,positions:zr(q.current)},ae(Ae=>Ae?.entry.id===J.id?{...Ae,phase:"collapse"}:Ae))},Ar)),pe.timers.push(setTimeout(()=>{V=!0,Ke()},za));try{Promise.resolve(d(J)).then(()=>{xe=!0,Ke()},()=>{xe=!0,Ke()})}catch{xe=!0,Ke()}};return k("div",{ref:M,role:"region","aria-label":"Taste collection","aria-busy":l,"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 ${p.border}`,borderRadius:20,background:p.surface,backdropFilter:"blur(59.5px)",WebkitBackdropFilter:"blur(59.5px)",color:p.secondary,fontFamily:Ft,fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden",...m,...l&&de?{height:de}:{}},children:[i("style",{children:`
4
- [data-popmelt-taste] [data-taste-thumbnail] { background: ${p.control}; }
5
- [data-popmelt-taste] [data-taste-preview-art] { transition: opacity 120ms ease; }
6
- [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-preview-art] { opacity: .2; }
7
- [data-popmelt-taste] [data-taste-name] { color: ${p.secondary}; transition: color 120ms ease; }
8
- [data-popmelt-taste] [data-taste-metadata] { color: ${p.muted}; transition: color 120ms ease; }
9
- [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-name] { color: ${p.primary}; }
10
- [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-metadata] { color: ${p.secondary}; }
11
- [data-popmelt-taste] [data-taste-detail-chevron] { display: inline-flex; width: 0; flex: 0 0 auto; overflow: hidden; opacity: 0; color: ${p.primary}; transform: translateX(-6px); transition: width 160ms ease, opacity 120ms ease, transform 160ms ease; }
12
- [data-popmelt-taste] [data-taste-details]:is(:hover, :focus-visible) [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: translateX(0); }
13
- [data-popmelt-taste] [data-taste-add] { background: ${p.actionSurface}; color: ${p.actionForeground}; opacity: 0; pointer-events: none; transition: opacity 120ms ease, background-color 120ms ease; }
14
- [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-add] { opacity: 1; }
15
- [data-popmelt-taste] [data-taste-thumbnail]:hover [data-taste-add] { background: ${p.actionHover}; }
16
- [data-popmelt-taste] button:focus-visible { outline: 2px solid ${p.primary}; outline-offset: 2px; }
17
- [data-popmelt-taste] button[data-taste-close]:hover { background: ${p.hoverSurface} !important; color: ${p.primary} !important; }
18
- [data-taste-refresh-icon] { opacity: 0; transform: translateX(-4px); transition: opacity 120ms ease, transform 160ms ease; }
19
- [data-taste-refresh]:not(:disabled):is(:hover, :focus-visible) [data-taste-refresh-icon] { opacity: 1; transform: translateX(0); }
20
- @media (hover: none) { [data-taste-refresh]:not(:disabled) [data-taste-refresh-icon] { opacity: 1; transform: none; } }
21
- @media (prefers-reduced-motion: reduce) { [data-taste-refresh-icon] { transition: none; transform: none; } }
22
- @media (hover: none) { [data-popmelt-taste] [data-taste-add] { opacity: 1; } }
23
- @media (hover: none) { [data-popmelt-taste] [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: none; } }
24
- @media (prefers-reduced-motion: reduce) { [data-popmelt-taste] :is([data-taste-name], [data-taste-metadata], [data-taste-add], [data-taste-detail-chevron]) { transition: none; } }
25
- `}),k("div",{"data-taste-collection-header":!0,style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[k("button",{type:"button","data-taste-refresh":!0,"aria-label":"Refresh taste collection",onClick:()=>{Q(M.current?.offsetHeight),o?.()},disabled:!o||s||l,style:{display:"inline-flex",alignItems:"center",gap:4,padding:0,border:0,borderRadius:4,background:"transparent",font:"inherit",cursor:o&&!s?"pointer":"default",color:p.primary,fontSize:14,fontWeight:600,letterSpacing:"-.14px"},children:[i(Ht,{size:16,"aria-hidden":"true",style:{transform:"scaleY(-1)"}}),"Taste",i(ma,{"data-taste-refresh-icon":!0,size:12,"aria-hidden":"true",style:{marginLeft:2}})]}),i("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:p.muted,cursor:"pointer"},children:i(Ct,{size:16})})]}),k("div",{"data-taste-scroll":!0,onScroll:J=>N(J.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:v?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:v?"linear-gradient(to bottom, transparent, #000 16px)":void 0,overscrollBehavior:"contain"},children:[k("div",{"data-taste-content":!0,ref:j,style:{display:"flex",flexDirection:"column",gap:me&&H?.phase!=="collapse"?24:0,transition:H?`gap ${Pt}ms ease-in-out`:void 0},children:[c,me&&k("section",{ref:E,"aria-label":"Active taste","data-taste-removal-phase":H?.phase,"aria-hidden":!!H,inert:!!H,style:{display:"flex",flexDirection:"column",gap:8,flexShrink:0,minHeight:0,height:H?H.phase==="collapse"?0:H.activeHeight:void 0,opacity:H?0:1,overflow:H||ve?"hidden":void 0,pointerEvents:H?"none":void 0,transition:H?`opacity ${Ar}ms ease-out, height ${Pt}ms ease-in-out`:void 0},children:[i("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",color:p.secondary},children:"Active"}),i("ul",{style:{listStyle:"none",padding:0,margin:0},children:i(fn,{entry:me,active:!0,featured:!0,previewBackground:p.control,onRemove:ve?void 0:ge,onOpenDetails:f,onPrefetchDetails:y})})]}),k("div",{"data-taste-collections":!0,style:{display:"flex",flexDirection:"column",gap:me&&H?.phase!=="collapse"?16:0,transition:H?`gap ${Pt}ms ease-in-out`:void 0},children:[me&&i("h3",{ref:K,"data-taste-collections-heading":!0,style:{margin:0,font:"inherit",fontWeight:600,lineHeight:"12px",color:e==="light"?"#555555":"#aaaaaa",flexShrink:0,height:H?H.phase==="collapse"?0:H.headingHeight:void 0,opacity:H?.phase==="collapse"?0:1,overflow:H||ve?"hidden":void 0,transition:H?`height ${Pt}ms ease-in-out, opacity ${Ar}ms ease-out`:void 0},children:"Collections"}),i("div",{"data-taste-catalogs":!0,ref:q,style:{display:"flex",flexDirection:"column",gap:24},children:[{label:"Private",entries:$},{label:"Public",entries:Ye}].map(({label:J,entries:pe})=>k("section",{"aria-label":`${J} tastes`,style:{display:"flex",flexDirection:"column",gap:8},children:[k("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px"},children:[i("span",{children:J})," ",i("span",{"data-taste-count":!0,style:{color:p.muted},children:pe.length})]}),pe.length?i("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8},children:pe.map(V=>i(fn,{entry:V,onAdd:H||!a?void 0:te,onRemove:d,active:!1,hasActiveTaste:!!Fe&&!Me,onOpenDetails:f,onPrefetchDetails:y},V.id))}):i("span",{style:{color:p.muted},children:J==="Private"&&b?b:`No ${J.toLowerCase()} results found.`})]},J))})]})]}),g&&i("span",{role:"status",children:g}),C]})]})}function Ba({entry:e,theme:t,active:r,onBack:n,onToggle:o,notice:s,style:l,facts:a,summaryNotice:d,drilldown:h,onOpenFact:u}){let f=Qe[t],[y,g]=T(!1),C=D(null),c=la(h)?h.key:null;return se(()=>{C.current&&(C.current.scrollTop=0),g(!1)},[e.id,c]),k("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 ${f.border}`,background:f.surface,color:f.primary,fontFamily:Ft,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,boxSizing:"border-box",overflow:"hidden",...l},children:[i("style",{children:`
26
- [data-taste-detail] > div { flex-shrink: 0; }
27
- [data-taste-detail] [data-taste-detail-body] { flex-shrink: 1; }
28
- [data-taste-detail-body] > * { flex-shrink: 0; }
29
- [data-taste-detail] button:focus-visible { outline: 2px solid ${f.primary}; outline-offset: 3px; }
30
- [data-taste-detail] [data-detail-back]:hover { color: ${f.primary} !important; }
31
- [data-taste-detail] [data-detail-cta]:enabled:hover { background: ${f.actionHover} !important; }
32
- [data-taste-fact]:hover dt, [data-taste-fact]:focus-within dt { color: ${f.primary} !important; }
33
- [data-taste-fact]:hover button, [data-taste-fact] button:focus-visible { background: ${f.control} !important; }
34
- [data-taste-fact] button::after { content: ''; position: absolute; inset: 0; }
35
- [data-taste-fact] button svg { opacity: 0; width: 0; transition: opacity 120ms, width 120ms; }
36
- [data-taste-fact]:hover button svg, [data-taste-fact] button:focus-visible svg { opacity: 1; width: 14px; }
37
- `}),k("div",{"data-taste-detail-header":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[k("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:f.secondary,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,cursor:"pointer"},children:[i(Sr,{size:16,color:f.primary}),i(Ht,{size:14,style:{transform:"scaleY(-1)"}}),e.name]}),i("button",{type:"button","data-detail-cta":!0,"aria-label":`${r?"Remove":"Add"} ${e.name}`,"aria-pressed":r,disabled:!o,onClick:o,style:{display:"flex",alignItems:"center",gap:3,padding:r?"4px 9px 4px 10px":"4px 10px 4px 6px",border:0,borderRadius:8,background:f.actionSurface,color:f.actionForeground,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,opacity:o?1:.5,cursor:o?"pointer":"default"},children:r?k(Le,{children:["Remove",i(Ct,{size:12})]}):k(Le,{children:[i(Ut,{size:12}),"Add"]})})]}),i("div",{"data-taste-detail-body":!0,ref:C,onScroll:b=>g(b.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:y?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:y?"linear-gradient(to bottom, transparent, #000 16px)":void 0},children:h??k(Le,{children:[i("div",{style:{display:"flex",flexDirection:"column",gap:8},children:i(un,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,background:f.control},e.id)}),i("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}]:[],...(a??[]).filter(b=>b.key!=="version")].map(({key:b,label:m,value:p})=>k("div",{"data-taste-fact":!0,style:{position:"relative",display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,padding:"4px 0"},children:[i("dt",{style:{color:f.secondary},children:m}),i("dd",{"aria-label":`${m}: ${p}`,style:{margin:0,fontSize:14,fontWeight:500,fontVariantNumeric:"tabular-nums"},children:u?k("button",{type:"button","aria-label":`View ${m}`,onClick:()=>u(b),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:[p,i(Kt,{size:14})]}):p})]},b))}),d&&i("div",{role:"status",style:{color:f.secondary,padding:"0 4px"},children:d}),s&&i("div",{role:"status",style:{color:f.secondary,padding:"0 4px"},children:s})]})})]})}function Fa(e,t){return t==="reconnect_required"?{message:"Reconnect to grant read-only taste inspection access.",reconnect:!0}:e===404?{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}:e===401||e===403?{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}}var gn={position:"relative",margin:0,font:"inherit",fontWeight:"inherit",fontSize:12,display:"flex",alignItems:"center",padding:"4px 4px"};function mn({last:e,color:t,left:r=4}){return k("span",{"aria-hidden":"true","data-taste-nested-branch":!0,style:{position:"absolute",left:r,top:0,bottom:0,pointerEvents:"none",color:t},children:[!e&&i("span",{"data-taste-nested-trunk":!0,style:{position:"absolute",top:0,bottom:0,borderLeft:"1px solid currentColor"}}),i("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 vn=e=>{let t=e.replace(/([a-z])([A-Z])/g,"$1 $2");return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()};function Wa(e,t,r=!1,n=!1,o=!1){let s=new Map;for(let a of e){let d=a.path.slice(1).filter(c=>c!=="$value");n&&(d=d.slice(1).filter(c=>c!=="$children")),t&&d[0]==="copy"&&(d=d.slice(1)),t&&d[0]==="slots"&&(d=d.slice(1));let h=d.length-1;if(r&&(h=Math.min(1,h)),t){let c=d.findIndex(b=>["budget","rules","template"].includes(b));c>=0&&(h=c)}let u=d.slice(0,h),f=d.slice(h);t&&f[0]==="budget"&&f.shift();let y=f.map(c=>/^\d+$/.test(c)?String(Number(c)+1):vn(c)).join(" \xB7 "),g=JSON.stringify(u),C=s.get(g)??{heading:u.map(c=>t||r?vn(c):c).join(" \u2192 "),rows:[]};C.rows.push({...a,label:y}),s.set(g,C)}let l=[...s.values()];if(n){let a=["default","hover","active","disabled"],d=new Map,h=f=>{let y=f.split(" \u2192 "),g=y.pop()??"",C=y.join(" \u2192 ");d.has(C)||d.set(C,d.size);let c=a.indexOf(g);return[d.get(C),c<0?a.length:c]},u=new Map(l.map(f=>[f,h(f.heading)]));l.sort((f,y)=>{let[g=0,C=0]=u.get(f),[c=0,b=0]=u.get(y);return g-c||C-b})}return l.map(a=>a.rows.length>1||(n||o)&&a.heading?a:{heading:"",rows:a.rows.map(d=>({...d,label:[a.heading,d.label].filter(Boolean).join(" \xB7 ")}))})}var qa=["Palette","Semantic colors","Typography","Spacing & layout","Radii & borders","Shadows & effects","Motion","Other"],yn=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},or=(e,t)=>e.localeCompare(t,"en",{numeric:!0,sensitivity:"base"}),Oa=new Map([["none",0],["xs",1],["sm",2],["base",3],["md",4],["lg",5],["xl",6]]),Ha=new Map([["xs",0],["sm",1],["base",2],["lg",3],["xl",4]]);function bn(e){return/^(text|space|spacing|radius|radii|shadow)(?:-|$)/i.exec(e)?.[1]?.toLowerCase()??null}function wn(e,t){let r=e.toLowerCase().slice(t.length).replace(/^-/,"");if(t==="space"||t==="spacing")return r==="px"?.25:/^\d+(?:\.\d+)?$/.test(r)?Number(r):null;if(r==="full"&&(t==="radius"||t==="radii"))return 100;if(!r)return t==="text"?null:3;let n=/^(\d+)xs$/.exec(r),o=/^(\d+)xl$/.exec(r)??/^(x{2,})l$/.exec(r);return t==="text"?n?1-Number(n[1]):r==="xxs"?-1:o?3+(/^x/.test(o[1])?o[1].length:Number(o[1])):Ha.get(r)??null:n?2-Number(n[1]):r==="xxs"?0:o?5+(/^x/.test(o[1])?o[1].length:Number(o[1])):Oa.get(r)??null}function Ua(e,t){let r=bn(e),n=bn(t);if(!r||r!==n)return or(e,t);let o=wn(e,r),s=wn(t,n);return o!==null&&s!==null?o-s||or(e,t):o!==null?-1:s!==null?1:or(e,t)}function Ka(e,t,r){let n=yn(t),o=String(n.$type??"").toLowerCase(),s=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),l=n.$value??t,a=yn(l),d=/^(?:background|foreground|primary|secondary|accent|muted|card|popover|sidebar|input|ring|border|destructive|success|warning|info|surface|text|chart)(?:-|$)/.test(s);return o==="color"||Wt(l,r)?d?1:0:/^(typography|fontfamily|fontweight|fontstyle)$/.test(o)?2:/^(shadow|gradient|filter)$/.test(o)?5:/^(duration|cubicbezier|transition)$/.test(o)?6:/^(border|radius)$/.test(o)?4:/^(spacing|layout)$/.test(o)?3:o&&!["dimension","number","string","composite"].includes(o)?7:/^(font|text|heading|body|line-height|letter-spacing|typography)(?:-|$)/.test(s)||"fontFamily"in a||"fontSize"in a?2:/^(space|spacing|gap|padding|margin|layout|container|width|height|size|breakpoint)(?:-|$)/.test(s)||"maxWidth"in a?3:/^(radius|radii|border|stroke)(?:-|$)/.test(s)?4:/^(shadow|elevation|blur|opacity|gradient|filter)(?:-|$)/.test(s)?5:/^(transition|duration|easing|animation|motion)(?:-|$)/.test(s)?6:7}function Va(e,t){let r=["fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","color"],n=o=>{let s=r.indexOf(o.at(-1)??"");return s<0?r.length:s};return n(e)-n(t)||or(e.join("."),t.join("."))}function Ya({taste:e,style:t,onClick:r,children:n}){let o=Jt(e?.states?.button,!0,320);return i("button",{type:"button",...o.handlers,onClick:r,style:{...vt(Mt(t)),...Ge(e?.detail?.button,320),...o.style},children:n})}var Ja={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"},_a=["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 xn(e){let t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Ja[t]??t;return _a.includes(r)?r:void 0}var pt=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function lr(e,t){let r=(s,l=0)=>{if(l>12)return;if(s&&typeof s=="object")return r(pt(s).$value??pt(s).ref,l+1);if(typeof s!="string")return s;let a=s.trim();return Object.hasOwn(t,a)?r(t[a],l+1):a.replace(/var\(\s*(?:--|principles\.)([\w-]+)\s*\)|\{(?:principles\.)?([\w-]+)\}/g,(d,h,u)=>String(r(t[h??u],l+1)??""))},n=Object.fromEntries(Object.entries(pt(e)).slice(0,80).map(([s,l])=>[s,r(l)])),o=Ge(Er({card:n})?.card,320);return["flex","inline-flex","grid","block","inline-block"].includes(String(n.display))&&(o.display=n.display),["row","column","row-reverse","column-reverse"].includes(String(n.flexDirection))&&(o.flexDirection=n.flexDirection),o}function Ga({kind:e,style:t,handlers:r,definition:n,tokens:o,taste:s}){let l=xr(),[a,d]=T(0),[h,u]=T(!1),[f,y]=T(!0),[g,C]=T(60),[c,b]=T(""),m=pt(pt(n).$value),p=pt(m.$children??pt(n).$children),v=(I,E)=>{let K=pt(p[I]),de=pt(K.$value??K);return{...lr(de.default,o),...lr(E?de[E]:void 0,o)}},N=I=>I?lr(m.checked??m.selected??m.active,o):{},M={boxSizing:"border-box",maxWidth:"86%",font:"inherit",...Ge(s?.detail?.body,320),...t},j={padding:"5cqw",...M,width:"82%"},q={font:"inherit",color:"inherit",background:"transparent",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:"1.5cqw 3cqw",cursor:"pointer"},x={display:"flex",flexDirection:"column",gap:"3cqw"},P={size:"1em","aria-hidden":!0},L=(I,E,K={})=>i(Ya,{taste:s,onClick:E,style:{...q,...K},children:I},I),B=i("strong",{style:{...Ge(s?.detail?.heading,320),...v("title")},children:"A little space"}),O=i("span",{style:{fontSize:"0.85em",...Ge(s?.detail?.body,320),...v("description")},children:"Make something your own."}),A={...r,"data-specimen-kind":e};switch(e){case"button":return i("button",{...A,type:"button",style:{...M,cursor:"pointer"},children:"Button"});case"input":return i("input",{...A,"aria-label":"Preview input",defaultValue:"A fresh start",style:{...M,width:"76%",outline:"none"}});case"textarea":return i("textarea",{...A,"aria-label":"Preview textarea",defaultValue:"A little space for your ideas.",rows:3,style:{...M,width:"76%",resize:"none",outline:"none"}});case"card":return k("div",{...A,style:{...j,...x},children:[B,O,L("Get started",()=>y(!f),v("button"))]});case"badge":return i("span",{...A,style:M,children:"New"});case"avatar":return i("div",{...A,"aria-label":"Preview avatar",style:{...M,width:"18cqw",height:"18cqw",display:"grid",placeItems:"center"},children:i(xa,{...P})});case"label":return i("label",{...A,style:M,children:"Project name"});case"separator":return i("div",{...A,role:"separator",style:{...M,width:"76%",padding:0,...v("separator")}});case"checkbox":return k("label",{...A,style:{...M,display:"flex",gap:"3cqw",alignItems:"center"},children:[i("input",{type:"checkbox",checked:f,onChange:I=>y(I.target.checked),style:{width:"5cqw",height:"5cqw",...v("indicator",f?"checked":void 0)}}),"Stay inspired"]});case"radio":return i("div",{...A,role:"radiogroup","aria-label":"Preview options",style:{...M,...x},children:["Personal","Team"].map((I,E)=>k("label",{style:{display:"flex",gap:"3cqw",...v("item",a===E?"checked":void 0)},children:[i("input",{name:l,type:"radio",checked:a===E,onChange:()=>d(E)}),I]},I))});case"switch":return i("button",{...A,type:"button",role:"switch","aria-label":"Preview switch","aria-checked":f,onClick:()=>y(!f),style:{...M,width:"18cqw",padding:"1.5cqw",cursor:"pointer",...N(f)},children:i("span",{style:{display:"block",width:"6cqw",height:"6cqw",marginLeft:f?"auto":0,...v("thumb",f?"checked":void 0)}})});case"toggle":return k("button",{...A,type:"button","aria-pressed":f,onClick:()=>y(!f),style:{...M,cursor:"pointer",...N(f)},children:["Bold ",f&&i(wa,{...P})]});case"slider":return i("input",{...A,type:"range","aria-label":"Preview slider",value:g,onChange:I=>C(Number(I.target.value)),style:{...M,width:"76%"}});case"progress":return i("div",{...A,role:"progressbar","aria-label":"Preview progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":60,style:{...M,width:"76%",height:"4cqw",padding:0,overflow:"hidden"},children:i("div",{style:{width:"60%",height:"100%",...v("indicator")}})});case"skeleton":return i("div",{...A,"aria-label":"Preview loading placeholder",style:{...M,width:"76%",height:"22cqw"}});case"tabs":return k("div",{...A,style:j,children:[i("div",{role:"tablist","aria-label":"Preview tabs",style:{display:"flex",gap:"2cqw",...v("list")},children:["Overview","Activity"].map((I,E)=>i("button",{type:"button",role:"tab","aria-selected":a===E,onClick:()=>d(E),onKeyDown:K=>{(K.key==="ArrowLeft"||K.key==="ArrowRight")&&(K.preventDefault(),d(1-a))},style:{...q,...v("trigger",a===E?"active":void 0)},children:I},I))}),i("div",{role:"tabpanel",style:{paddingTop:"4cqw",...v("content")},children:a===0?"Your next big idea starts here.":"All caught up."})]});case"accordion":return i("div",{...A,style:j,children:["What is included?","Can I make it mine?"].map((I,E)=>k("div",{style:v("item"),children:[k("button",{type:"button","aria-expanded":h&&a===E,onClick:()=>{d(E),u(!(h&&a===E))},style:{...q,width:"100%",display:"flex",justifyContent:"space-between",...Ge(s?.detail?.heading,320),...v("trigger")},children:[I,i(ba,{...P})]}),h&&a===E&&i("div",{style:{padding:"3cqw",...Ge(s?.detail?.body,320),...v("content")},children:"Everything you need to get started."})]},I))});case"select":return i("select",{...A,"aria-label":"Preview select",value:a,onChange:I=>d(Number(I.target.value)),style:M,children:["Choose a project","Personal","Team"].map((I,E)=>i("option",{value:E,children:I},I))});case"combobox":case"command":return k("div",{...A,style:{...j,...x},children:[k("label",{style:{display:"flex",alignItems:"center",gap:"2cqw"},children:[i(kr,{...P}),i("input",{"aria-label":"Search preview options",value:c,onChange:I=>b(I.target.value),placeholder:"Search projects\u2026",style:{...q,minWidth:0,width:"100%",...v("input")}})]}),["Personal","Team","Archive"].filter(I=>I.toLowerCase().includes(c.toLowerCase())).map(I=>L(I,()=>b(I),v("item"))),!["Personal","Team","Archive"].some(I=>I.toLowerCase().includes(c.toLowerCase()))&&i("span",{children:"No results"})]});case"dropdown-menu":case"menubar":return k("div",{...A,style:{...j,...x},children:[L("Options \u25BE",()=>u(!h),v("trigger")),h&&i("div",{style:{...x,...v("content")},children:["New project","Duplicate","Archive"].map((I,E)=>L(`${a===E?"\u2713 ":""}${I}`,()=>{d(E),u(!1)},v("item")))})]});case"dialog":case"sheet":return i("div",{...A,style:{...j,...x,...e==="sheet"?{marginLeft:"auto",maxWidth:"65%",minHeight:"42cqw"}:{},...v("content")},children:h?k(Le,{children:[B,O,L("Done",()=>u(!1),v("button"))]}):k(Le,{children:[B,O,L("Open preview",()=>u(!0),v("trigger"))]})});case"popover":case"tooltip":return k("div",{...A,style:{...M,...x},children:[i("button",{type:"button",onClick:()=>u(!h),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),style:{...q,...v("trigger")},children:"Learn more"}),h&&i("span",{role:"tooltip",style:v("content"),children:"A little room for your ideas."})]});case"alert":case"toast":return k("div",{...A,role:"status",style:{...j,display:"flex",gap:"3cqw",alignItems:"center"},children:[i(ya,{...P}),k("div",{style:x,children:[i("strong",{style:v("title"),children:f?"Changes saved":"Ready when you are"}),i("span",{style:v("description"),children:"Your project is up to date."})]}),e==="toast"&&i("button",{type:"button","aria-label":"Dismiss preview toast",onClick:()=>y(!f),style:q,children:i(Ct,{...P})})]});case"table":return i("div",{...A,style:{...j,padding:0,overflow:"hidden",textAlign:"left"},children:k("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,font:"inherit",color:"inherit"},children:[i("thead",{style:v("header"),children:i("tr",{children:["Project","Status"].map(I=>i("th",{style:{padding:"2cqw",...v("head")},children:I},I))})}),i("tbody",{children:["Personal","Team"].map(I=>k("tr",{style:v("row"),children:[i("td",{style:{padding:"2cqw",...v("cell")},children:I}),i("td",{style:{padding:"2cqw",...v("cell")},children:"Active"})]},I))})]})});case"breadcrumb":return k("nav",{...A,"aria-label":"Preview breadcrumb",style:{...M,display:"flex",gap:"2cqw",alignItems:"center"},children:[L("Home",()=>d(0),v("link")),i(Kt,{...P}),i("span",{"aria-current":"page",style:v("page"),children:a?"Settings":"Projects"})]});case"pagination":return i("nav",{...A,"aria-label":"Preview pagination",style:{...M,display:"flex",gap:"2cqw"},children:[0,1,2].map(I=>i("button",{type:"button","aria-current":a===I?"page":void 0,onClick:()=>d(I),style:{...q,...v("item",a===I?"active":void 0)},children:I+1},I))});case"calendar":return k("div",{...A,style:{...j,padding:"2cqw",fontSize:"3.5cqw"},children:[i("div",{style:{textAlign:"center",...v("caption")},children:"September 2026"}),k("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.5cqw"},children:[["M","T","W","T","F","S","S"].map((I,E)=>i("span",{style:{textAlign:"center",...v("head")},children:I},E)),i("span",{"aria-hidden":"true"}),Array.from({length:30},(I,E)=>i("button",{type:"button","aria-label":`September ${E+1}`,"aria-pressed":a===E,onClick:()=>d(E),style:{...q,border:0,padding:0,...v("day",a===E?"selected":void 0)},children:E+1},E))]})]});case"form":return k("form",{...A,onSubmit:I=>{I.preventDefault(),u(!0)},style:{...j,...x},children:[i("label",{htmlFor:l,style:v("label"),children:"Project name"}),i("input",{id:l,required:!0,placeholder:"A fresh start",style:{...q,...v("input")}}),i("button",{type:"submit",style:{...q,...v("button")},children:"Create project"}),h&&i("span",{role:"status",children:"Project created (preview)"})]});case"otp":return i("div",{...A,style:{...M,display:"flex",gap:"1cqw"},children:[0,1,2,3].map(I=>i("input",{"aria-label":`Preview digit ${I+1}`,inputMode:"numeric",maxLength:1,pattern:"[0-9]",style:{...q,width:"8cqw",padding:"2cqw 0",textAlign:"center",...v("slot")}},I))});case"scroll":return i("div",{...A,tabIndex:0,"aria-label":"Preview scroll area",style:{...j,maxHeight:"35cqw",overflow:"auto",overscrollBehavior:"contain"},children:Array.from({length:12},(I,E)=>k("div",{style:{padding:"2cqw",...v("item")},children:["Project ",E+1]},E))});case"chart":return k("figure",{...A,"aria-label":"Preview project activity chart",style:{...j,margin:0},children:[i("figcaption",{style:v("title"),children:"Activity"}),i("div",{style:{display:"flex",alignItems:"end",gap:"3cqw",height:"25cqw"},children:[35,60,45,85,70].map((I,E)=>i("div",{title:`${I} projects`,style:{flex:1,height:`${I}%`,...v("bar")}},E))})]});default:return null}}var ht=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function kn(e,t,r){return!!r&&!!xn(e)&&!!Object.keys(ht(ht(ht(t).$value).default)).length}function Sn(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&&typeof e=="object")for(let[n,o]of Object.entries(e))["__proto__","constructor","prototype","$type"].includes(n)||Sn(o,[...t,n],r);return r}function Za({bridgeUrl:e,id:t,collection:r,section:n,theme:o,onPreview:s,onReconnect:l,cache:a,query:d=""}){let h=Qe[o],[u,f]=T(),[y,g]=T(""),[C,c]=T(!1),[b,m]=T(!1),[p,v]=T(null),N=D(null),M=`${e??""}/cloud-taste/definition?id=${encodeURIComponent(t)}&collection=${encodeURIComponent(r)}`;se(()=>{let E=new AbortController;return N.current=E,f(void 0),g(""),c(!1),v(null),(a?a.read(M):Ie(M,{signal:E.signal})).then(async K=>{if(!K.ok){let Q=await K.json().catch(()=>null),H=Fa(K.status,Q?.error);E.signal.aborted||(g(H.message),c(H.reconnect));return}let de=await K.json();if(!de.sections||!Array.isArray(de.overrides))throw new Error("Invalid taste definition");if(!E.signal.aborted){f(de);let Q=wt(de.preview);Q&&s(Q)}}).catch(K=>{E.signal.aborted||g(K 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()},[M,s,a]);async function j(E,K,de=!1){if(!u||b)return;let Q=N.current;if(!(!Q||Q.signal.aborted)){m(!0),g("");try{let H=await Ie(M,{signal:Q.signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:E,value:K,reset:de,sourceHash:u.hash,expectedRevision:u.revision})});if(!H.ok)throw new Error("Save failed. Your remote taste is unchanged. Reopen this section to reload before trying again.");let ae=await H.json();if(Q.signal.aborted)return;a?.put(M,ae),f(ae);let he=wt(ae.preview);he&&s(he)}catch(H){a?.invalidate(M),Q.signal.aborted||g(H.message)}finally{Q.signal.aborted||m(!1)}}}let q=n==="tokens"||n==="principles"?"principles":n==="visual-directions"?"assets":n==="copy-guidance"?"content":n,x=d.trim().toLocaleLowerCase(),P=E=>!x||String(E).toLocaleLowerCase().includes(x),L=Object.entries(ht(u?.sections[q])),B=q==="principles",O=new Map(L.map(([E,K])=>[E,B?Ka(E,K,ht(u?.sections.principles)):7]));if(B&&L.sort(([E],[K])=>O.get(E)-O.get(K)||Ua(E,K)),q==="components"){let E=(K,de)=>kn(K,de,wt(u?.componentPreviews?.[K]));L.sort(([K,de],[Q,H])=>Number(E(Q,H))-Number(E(K,de))||K.localeCompare(Q,void 0,{sensitivity:"base",numeric:!0}))}let A=L.filter(([E,K])=>P(E)||P(JSON.stringify(K))),I=u?.versions?.filter(E=>P(`${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 n==="version"?i("div",{"data-taste-versions":!0,children:y?k("div",{role:"alert",children:[y,C&&i("div",{style:{marginTop:8},children:i("button",{type:"button",onClick:l,children:"Reconnect"})})]}):u?r==="public"?i("div",{children:"Public version history is not available yet."}):u.versions?k("dl",{style:{margin:0},children:[I?.map(E=>k("div",{style:{display:"flex",justifyContent:"space-between",gap:16,padding:"8px 4px"},children:[i("dt",{children:E.version}),i("dd",{style:{margin:0,color:h.secondary},children:E.saved_at?i("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)),!u.versions.length&&i("div",{children:"No version history recorded."}),!!u.versions.length&&!I?.length&&i("div",{role:"status",children:"No matching versions."})]}):i("div",{role:"status",children:"Version history is currently unavailable."}):i("div",{role:"status",children:"Loading versions\u2026"})}):k("div",{"data-taste-drilldown":!0,style:{display:"flex",flexDirection:"column",gap:0,fontVariantNumeric:"tabular-nums"},children:[i("style",{children:`
38
- [data-preview-zoom] + [data-taste-component-header] { margin-top: -4px; }
39
- [data-taste-component-header]:hover:not(:disabled), [data-taste-component-header]:focus-visible { color: ${h.primary} !important; }
40
- [data-taste-component-header]:hover:not(:disabled) svg { background: ${h.control}; }
41
- [data-taste-value-row]:hover, [data-taste-value-row]:focus-within { color: ${h.primary} !important; }
42
- [data-taste-token-group]:has(> [data-taste-token-child] [data-taste-value-row]:hover) > [data-taste-token-parent],
43
- [data-taste-token-parent]:hover,
44
- [data-taste-token-parent]:hover ~ [data-taste-token-child] [data-taste-value-row] > label { color: ${h.primary} !important; }
45
- [data-taste-value-row]:hover input, [data-taste-value-row] input:focus { background: ${h.control} !important; }
46
- [data-taste-value-row]:hover input, [data-taste-value-row]:focus-within input { color: ${h.primary} !important; }
47
- [data-taste-value-row] input:focus-visible { outline: 1px solid ${h.secondary}; }
48
- [data-taste-value-row] input { cursor: inherit; }
49
- [data-taste-value-row] input:not([type="checkbox"]):focus { cursor: text; text-overflow: clip !important; }
50
- `}),!u&&!y&&i("div",{role:"status",children:"Loading definitions\u2026"}),y&&k("div",{role:"alert",style:{color:h.secondary},children:[y,!u&&C&&i("button",{type:"button",onClick:l,style:{display:"block",marginTop:8},children:"Reconnect"})]}),!!u?.conflicts.length&&i("div",{role:"status",children:"Some source values changed remotely. Conflicting overrides are not applied; reset or edit them to resolve."}),u&&!A.length&&i("div",{role:"status",children:x&&L.length?"No matching definitions.":"No definitions in this section."}),A.map(([E,K],de)=>{let Q=Sn(K,[q,E]).filter(ae=>P(E)||P(ae.path.join(" "))||P(JSON.stringify(ae.value))),H=q==="components";return B&&Q.sort((ae,he)=>Va(ae.path,he.path)),k("div",{"data-taste-group-path":JSON.stringify([q,E]),style:{display:"flex",flexDirection:"column",gap:H?8:0,marginBottom:H?8:0},children:[B&&(de===0||O.get(A[de-1][0])!==O.get(E))&&i("h2",{"data-taste-token-section":!0,style:{font:"inherit",fontWeight:500,color:h.primary,margin:de===0?"0 4px 8px":"16px 4px 8px"},children:qa[O.get(E)]}),H&&i(Qa,{name:E,definition:K,taste:wt(u?.preview),tokens:ht(u?.sections.principles),recipe:wt(u?.componentPreviews?.[E])}),H&&k("button",{type:"button","data-taste-component-header":!0,disabled:!Q.length,onClick:()=>v(p===E?null:E),"aria-expanded":Q.length?p===E||!!x:void 0,style:{display:"flex",justifyContent:"space-between",alignItems:"center",border:0,padding:"6px 4px",font:"inherit",background:"transparent",borderRadius:8,color:h.secondary,cursor:Q.length?"pointer":"default"},children:[i("span",{children:E}),!!Q.length&&i(Kt,{size:14,style:{boxSizing:"content-box",padding:"2px 4px",borderRadius:8,transform:p===E||x?"rotate(90deg)":void 0,transition:"transform 120ms"}})]}),(!H||p===E||!!x)&&Wa(Q,n==="copy-guidance",n==="visual-directions",H,B).map((ae,he,ue)=>k("div",{"data-taste-state-group":H?"":void 0,"data-taste-token-group":B&&ae.heading?"":void 0,style:{position:"relative",display:"flex",flexDirection:"column",gap:0,paddingLeft:H?12:0},children:[H&&ae.heading&&he<ue.length-1&&i("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, ${h.secondary} 40%, ${h.surface})`}}),ae.heading&&k("h3",{"data-taste-token-parent":B?"":void 0,style:{position:"relative",margin:B?0:H?"2px 4px 0":"12px 4px 0",font:"inherit",fontWeight:B?"inherit":500,fontSize:B?12:void 0,color:B?h.secondary:h.primary,display:B?"flex":void 0,alignItems:B?"center":void 0,padding:B?"4px 4px":void 0,...B?gn:{}},children:[H&&i("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, ${h.secondary} 40%, ${h.surface})`}}),ae.heading,B&&i("span",{"aria-hidden":"true",style:{visibility:"hidden",fontSize:14,padding:"2px 0"},children:"\xA0"})]}),ae.rows.map((me,Fe)=>{let ve=JSON.stringify(me.path),Me=u.overrides.some($=>JSON.stringify($.path)===ve),Ye=i(Xa,{path:me.path,label:me.label,value:me.value,disabled:b,overridden:Me,colors:h,componentValue:H,colorTokens:q==="principles"||q==="components"?ht(u?.sections.principles):void 0,onSave:$=>{j(me.path,$)},onReset:()=>{j(me.path,me.value,!0)}},ve);return B&&ae.heading?k("div",{"data-taste-token-child":!0,style:{position:"relative",paddingLeft:12},children:[i(mn,{last:Fe===ae.rows.length-1,color:`color-mix(in srgb, ${h.secondary} 40%, ${h.surface})`}),Ye]},ve):Ye})]},he)),!H&&!Q.length&&k("div",{style:{color:h.secondary,padding:"0 4px",overflowWrap:"anywhere"},children:[E,": ",JSON.stringify(K)]})]},E)})]})}function Qa({name:e,definition:t,recipe:r,tokens:n,taste:o}){let s=xn(e),l=/button/i.test(e)?"button":/input|text.?field|textarea/i.test(e)?"input":"card",a=Jt(r?.states?.[l],!0,320);if(!r||!s||!kn(e,t,r))return null;let d={backgroundColor:"transparent",backgroundImage:"none",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:l==="button"?"3cqw 5cqw":16,fontSize:"4.6cqw",lineHeight:l==="button"?1.2:void 0,color:r.foreground,...Ge(o?.detail?.body,320),...lr(ht(ht(t).$value).default,n),...a.style};return i(Vr,{children:i("div",{"aria-label":`${e} style preview`,style:{aspectRatio:"16 / 9",borderRadius:8,background:r.background,display:"grid",placeItems:"center",overflow:"hidden",containerType:"inline-size"},children:i(Ga,{kind:s,style:d,handlers:a.handlers,definition:t,tokens:n,accent:r.accent,taste:o})})})}function Xa({path:e,label:t,value:r,disabled:n,overridden:o,colors:s,onSave:l,onReset:a,colorTokens:d,componentValue:h=!1}){let u=h&&typeof r=="string"?/^var\(principles\.([^,)]+)\)$/.exec(r.trim())?.[1]:void 0,f=u&&d&&Object.hasOwn(d,u)?u:String(r),[y,g]=T(f),C=D(null),c=D(!1),b=d&&typeof r=="string"?Wt(y,d):void 0;se(()=>g(f),[f]);function m(){let p=typeof r=="number"?Number(y):h&&d&&Object.hasOwn(d,y.trim())?`var(principles.${y.trim()})`:y;if(typeof p=="number"&&(!y.trim()||!Number.isFinite(p))||p===r||y===f){g(f);return}l(p)}return k("div",{"data-taste-value-row":!0,"data-taste-path":JSON.stringify(e),onClick:p=>{n||p.target instanceof Element&&p.target.closest("input, button")||(C.current?.focus({preventScroll:!0}),typeof r=="boolean"&&C.current?.click())},style:{display:"flex",alignItems:"center",gap:8,color:s.secondary,padding:"4px 4px",cursor:n?"default":"pointer"},children:[i("label",{style:{flex:1,minWidth:0,overflowWrap:"anywhere",fontSize:12},children:t}),typeof r=="boolean"?i("input",{ref:C,"aria-label":t,type:"checkbox",checked:r,disabled:n,onChange:p=>l(p.target.checked)}):k("span",{"data-taste-value-field":!0,style:{position:"relative",display:"inline-grid",maxWidth:"52%",marginRight:b?0:-8,minWidth:0},children:[i("span",{"aria-hidden":"true",style:{visibility:"hidden",whiteSpace:"pre",overflow:"hidden",font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14,padding:"2px 8px"},children:y||" "}),i("input",{ref:C,"data-taste-value-input":!0,"aria-label":t,value:y,title:y,disabled:n,onChange:p=>g(p.target.value),onBlur:()=>{if(c.current){c.current=!1;return}m()},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur(),p.key==="Escape"&&(c.current=!0,g(f),p.preventDefault(),p.stopPropagation(),p.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, ${s.primary} 50%, ${s.secondary})`,font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14}})]}),b&&i("span",{"data-taste-color-swatch":!0,title:b,"aria-label":`Color preview: ${b}`,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 ${s.border}`},children:i("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:b}})}),o&&i("button",{type:"button",disabled:n,onClick:a,"aria-label":`Reset ${t}`,style:{border:0,background:"transparent",color:s.secondary,padding:0},children:i(va,{size:12})})]})}var ei=["display","paddingTop","paddingRight","paddingBottom","paddingLeft","rowGap","columnGap","borderTopLeftRadius","fontFamily","fontSize","lineHeight","fontWeight","letterSpacing","color","backgroundColor","borderTopColor","borderTopWidth","boxShadow"];function ti(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,o=new Map,s=[],l=new Map,a=new Map,d=e.createTreeWalker(e.body,1),h=0;for(;d.nextNode()&&h++<4e3;){let u=d.currentNode;if(u.closest('script, style, template, noscript, [hidden], [aria-hidden="true"], [contenteditable], [data-popmelt], [data-popmelt-toolbar], [data-taste-editor], [data-taste-navigation]'))continue;let f=u.getBoundingClientRect();if(!f.width||!f.height)continue;let y=t.getComputedStyle(u);if(y.display==="none"||y.visibility!=="visible"||y.opacity==="0")continue;let g={};for(let v of ei)g[v]=y[v].slice(0,160);let C=u.tagName.toLowerCase(),c=JSON.stringify([C,g]),b=n.get(c),m=(/^(input|textarea|select|option)$/.test(C)?"":[...u.childNodes].filter(v=>v.nodeType===3).map(v=>v.textContent??"").join(" ").replace(/\s+/g," ").trim())||/^(main|nav|aside|header|footer|section|article|form|button|input)$/.test(C)||/^(flex|grid)$/.test(y.display);if(s.length<40&&m&&f.bottom>0&&f.right>0&&f.top<t.innerHeight&&f.left<t.innerWidth&&(b||n.size<160)){let v=u.parentElement;for(;v&&!l.has(v);)v=v.parentElement;let N=v?l.get(v):null,M=`${N}:${C}`,j=a.get(M)??0;if(j<3){a.set(M,j+1);let q=s.length;s.push({id:q,parent:N,sample:o.get(c)??n.size,box:[f.left/t.innerWidth,f.top/t.innerHeight,f.width/t.innerWidth,f.height/t.innerHeight].map(x=>Math.round(x*100))}),l.set(u,q)}}if(b){b.count++;continue}if(n.size>=160)continue;let p=/^(input|textarea|select|option)$/.test(C)?"":[...u.childNodes].filter(v=>v.nodeType===3).map(v=>v.textContent??"").join(" ").replace(/\s+/g," ").trim().slice(0,160);o.set(c,n.size),n.set(c,{tag:C,text:p,count:1,styles:g})}return{url:r.href,title:e.title.slice(0,160),viewport:{width:t.innerWidth,height:t.innerHeight},samples:[...n.values()],...s.length?{outline:s}:{}}}var ri=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:px|rem|em|vw|vh|vmin|vmax|ch)?$/i;function Dr(e,t){let r=qt(e,t),n=[],o=[],s=0,l=[],a,d=!1,h=()=>l.length<2||l.length>4?!1:(l.forEach((u,f)=>n.push({...u,layer:s,dimension:["x","y","blur","spread"][f]})),a&&o.push(a),l=[],a=void 0,d=!1,s++,!0);for(let u=0;u<e.length;){if(/\s/.test(e[u])){u++;continue}if(e[u]===","){if(!h())return null;u++;continue}let f=u,y=r.findIndex(p=>p.start===u),g=r[y];if(g)u=g.end;else{let p=0;do{if(e[u]==="(")p++;else if(e[u]===")"){if(!p)return null;p--}u++}while(u<e.length&&(p||!/[\s,]/.test(e[u])));if(p)return null}let C=e.slice(f,u),c={start:f,end:u,text:C,...g?{referenceIndex:y}:{}},b=g&&t.find(p=>p.name.toLowerCase()===g.name.toLowerCase()),m=/^calc\(/i.test(C)?tn(C,t):null;if(C.toLowerCase()==="inset"){if(d)return null;d=!0}else if(b?.kind==="color"||!g&&Wt(C,{})){if(a)return null;a=c}else if(b?.kind==="layout"||!g&&ri.test(C)||m?.kind==="length"){if(m&&(m.css.includes("%")||l.length===2&&m.value!==void 0&&m.value<0)||g?.opacity!==void 0||l.length>=4||l.length===2&&!g&&parseFloat(C)<0)return null;l.push(c)}else return null}return h()?{dimensions:n,colors:o,references:r}:null}function ni(e,t){let r=na(e,t);if(r===null)return null;e=r;let n=Dr(e,t);if(!n)return null;let o=e,s=[];for(let l of n.dimensions)l.referenceIndex===void 0&&/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(l.text)&&Number(l.text)!==0&&s.push({...l,value:`${l.text}px`});for(let l of n.references){let a=br(t,e.slice(l.start,l.end));if(!a)return null;let d=n.dimensions.find(u=>u.start===l.start);if(d&&(a.kind!=="layout"||a.unit==="%"||d.dimension==="blur"&&a.value<0))return null;let h=a.kind==="layout"?`${Math.round(a.value)}${a.unit||"px"}`:mt(a);s.push({...l,value:h})}for(let l of s.sort((a,d)=>d.start-a.start))o=o.slice(0,l.start)+l.value+o.slice(l.end);return o}function Pr(e,t,r,n,o){let s=Dr(e,r);if(o!==void 0){let l=s?.dimensions[o];return!l||t.kind!=="layout"?null:l.referenceIndex!==void 0?en(e,t,r,l.referenceIndex):e.slice(0,l.start)+`@${t.name}`+e.slice(l.end)}if(s&&n!==void 0){let l=s.references[n];if(!l)return null;let a=s.dimensions.some(d=>d.referenceIndex===n||l.start>=d.start&&l.end<=d.end);if(t.kind==="layout"!==a)return null}return en(e,t,r,n)}function ai(e,t){try{if(Object.entries(t.root.styles).some(([r,n])=>Yt(e,n,r)===null))return!1;for(let r of["basis","padding","gap","body-family","body-size","body-height","body-weight"]){let n=Tt(e.constraints,r);if(n.kind==="layout"&&(n.value<0||["basis","body-size","body-height","body-weight"].includes(r)&&n.value===0))return!1}for(let r of["fontFamily","fontSize","lineHeight","fontWeight","color","backgroundColor"]){let n=t.root.styles[r],o=n&&Yt(e,n,r);if(!o||(r==="color"||r==="backgroundColor")&&!Wt(o,{}))return!1}return!0}catch{return!1}}function sr(e,t,r=0){try{return Tt(e,t,r)}catch{return null}}function dr(e,t){let r=Qe[t],n=f=>sr(e.constraints,f),o=(f,y)=>{let g=n(f);return g?.kind!=="layout"?y:g.unit==="rem"||g.unit==="em"?g.value*16:g.unit===""||g.unit==="px"?g.value:y},s=(f,y)=>{let g=n(f);return g?.kind==="layout"?`${g.value}${g.unit||"px"}`:`${y}px`},l=(f,y)=>{let g=e.tokens.find(c=>f.includes(c.name)),C=g&&yr(g.value,e.constraints);return C&&Wt(C,{})?C:y},a=n("primary"),d=a?.kind==="color"?mt(a):r.primary,h=f=>{let y=n(f);return y?.kind==="font"?y.value:"system-ui, sans-serif"},u=(f,y)=>{let g=n(f);return g?.kind==="layout"?g.value:y};return{background:l(["page-surface","background"],r.control),surface:l(["card-surface","surface"],r.surface),foreground:l(["body-text","text"],r.primary),muted:l(["muted-text"],r.secondary),accent:d,border:r.border,radius:o("radii",8),spacing:o("gap",12),detail:{body:{fontFamily:h("body-family"),fontSize:s("body-size",16),lineHeight:s("body-height",22),fontWeight:u("body-weight",400)},heading:{fontFamily:h("heading-family"),fontSize:s("heading-size",24),lineHeight:s("heading-height",26),fontWeight:u("heading-weight",600),color:l(["heading-text"],r.primary)},card:{padding:s("padding",0),borderRadius:s("radii",8),gap:s("gap",12)},button:{backgroundColor:d,color:a?.kind==="color"?a.l>.6?"#111":"#fff":r.surface,borderRadius:s("radii",8)}}}}function ii({recipe:e,styles:t}){let r=D(null),n=D(null),[o,s]=T({scale:.5,width:640,height:320});return Pe(()=>{let l=r.current,a=n.current;if(!l||!a)return;let d=()=>{let u=Math.max(640,a.scrollWidth),f=Math.max(1,a.scrollHeight),y=Math.min(1,l.clientWidth/u,l.clientHeight/f);y>0&&s(g=>g.scale===y&&g.width===u&&g.height===f?g:{scale:y,width:u,height:f})};d();let h=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return h?.observe(l),h?.observe(a),()=>h?.disconnect()},[e,t]),i("div",{ref:r,className:"tc-preview-demo",style:{backgroundColor:t.page?.backgroundColor??e.background},inert:!0,children:i("div",{style:{position:"absolute",left:"50%",top:"50%",width:o.width*o.scale,height:o.height*o.scale,transform:"translate(-50%, -50%)"},children:i("div",{ref:n,"data-taste-preview-canvas":!0,style:{width:640,transform:`scale(${o.scale})`,transformOrigin:"top left"},children:i(Lr,{recipe:e,usageStyles:t})})})})}function Cn({draft:e,dimensionId:t,theme:r,preferPageComponent:n=!1,waitForPageFoundations:o=!1}){let s=Ot(()=>dr(e,r),[e,r]),l=Ot(()=>Gr(e),[e]),a=e.fragments?.find(p=>p.id===e.featuredComponentId),d=e.constraints.find(p=>p.id===t),h=d&&sr(e.constraints,d.id),u=d&&h&&h.kind!=="font"?[-2,-1,0,1,2].map(p=>({step:p,value:sr(e.constraints,d.id,p)})):[],f=Math.max(1,...u.map(({value:p})=>p?.kind==="layout"?p.value:0)),y=e.constraints.filter(p=>sr(e.constraints,p.id)).length,g=d?.scaleMode==="increment",C=d?.name.endsWith("size"),c=d?.name.endsWith("height"),b=d?.id==="radii",m=d?`${d.name} preview`:"Taste demonstration preview";return k("div",{className:"tc-dimension-preview","data-taste-constraint-preview":!0,"data-preview-dimension":d?.id,role:"group","aria-label":m,children:[i("style",{children:`
51
- [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); }
52
- [data-taste-editor] .tc-preview-demo { position: relative; height: 100%; pointer-events: none; }
53
- [data-taste-editor] .tc-preview-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 8px 10px 10px; height: 100%; }
54
- [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; }
55
- [data-taste-editor] .tc-preview-step[data-base=true] { background: var(--tc-surface); color: var(--tc-primary); }
56
- [data-taste-editor] .tc-preview-sample { width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--tc-primary); }
57
- [data-taste-editor] .tc-preview-step-label { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
58
- [data-taste-editor] .tc-preview-empty { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 12px; }
59
- [data-taste-editor] .tc-preview-family { padding: 18px 16px 16px; overflow: hidden; }
60
- `}),d?h?h.kind==="font"?k("div",{className:"tc-preview-family",style:{fontFamily:h.value},children:[i("div",{style:{fontSize:32,lineHeight:1.4,color:"var(--tc-primary)"},children:"Aa Bb Cc"}),i("div",{style:{fontSize:13,lineHeight:1.5},children:"The quick brown fox jumps."}),i("div",{className:"tc-preview-step-label",title:h.value,style:{marginTop:8,fontSize:10},children:h.value})]}):i("div",{className:"tc-preview-steps","aria-label":`${d.name} steps`,children:u.map(({step:p,value:v})=>{let N=v&&mt(v),M=v?.kind==="color"?`${Number((v.l*100).toFixed(1))}% L`:N,j={};return v?.kind==="color"?j={width:32,height:44,borderRadius:5,background:N,boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--tc-primary) 18%, transparent)"}:v?.kind==="layout"&&(b?j={width:34,height:34,border:"1px solid currentColor",borderRadius:Math.min(17,v.value*(v.unit==="rem"||v.unit==="em"?16:1))}:g?j={fontSize:24,fontWeight:Math.max(1,Math.min(1e3,v.value))}:C?j={fontSize:Math.max(6,v.value/f*30),lineHeight:1}:c?j={fontSize:10,lineHeight:`${Math.max(6,v.value/f*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%)"}:j={height:Math.max(1,v.value/f*46),width:18,borderRadius:3,background:"var(--tc-secondary)"}),k("div",{className:"tc-preview-step","data-base":p===0,"aria-label":`Step ${p}: ${N??"unresolved"}`,title:N??void 0,children:[i("span",{children:p>0?`+${p}`:p===0?"Base":p}),i("span",{className:"tc-preview-sample","aria-hidden":"true",children:i("span",{style:j,children:g||C?"Aa":c?`Ab
61
- Ab`:""})}),i("span",{className:"tc-preview-step-label",children:M??"\u2014"})]},p)})}):i("div",{className:"tc-preview-empty",children:d.value||d.parentId?"This dimension does not resolve yet.":"Waiting for this dimension\u2026"}):a&&(!o||ai(e,a))?i(ir,{fragment:a,draft:e,height:176}):y&&!n?i(ii,{recipe:s,styles:l}):i("div",{className:"tc-preview-empty",children:i("span",{className:"tc-proposal-status","data-state":"in-progress",children:"tracing stylenet"})})]})}function oi(e,t){if(!(Vn(e,t)>=1.6))return Yn(t)<.179?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.18)"}var _t=new Map;function li(e,t){if(!e||typeof CanvasRenderingContext2D>"u")return;let r=`${t}|${e}`;if(_t.has(r))return _t.get(r);let n=Kn();if(!n)return;let o=oi(n(e,"#d5d5d5"),n(t,"#fff"));return _t.size>=256&&_t.clear(),_t.set(r,o),o}function jr(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}function si(e,t,r){let n=e.slice(0,t).match(/(rgba?|hsla?|oklch|oklab|lch|lab|color)\(([^()]*)$/i),o=r.match(/[a-z%]+$/i)?.[0]?.toLowerCase(),s=o==="rem"||o==="em"?.01:1,l,a;if(n){let d=jr(n[2]).length,h=n[1].toLowerCase();n[2].includes("/")||["rgba","hsla"].includes(h)&&d===3?(s=o==="%"?1:.01,l=0,a=o==="%"?100:1):h.startsWith("rgb")?(l=0,a=o==="%"?100:255):o==="%"?(l=0,a=100):h.startsWith("ok")&&d<2?(s=.01,l=d===0||h==="oklch"?0:void 0,a=d===0?1:void 0):h==="color"&&(s=.01,l=0,a=1)}else!o&&r.includes(".")&&(s=10**-Math.min(4,r.split(".")[1].length));return{step:s,shiftStep:s*5,min:l,max:a}}var Rn=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z]+|%)?$/i;function di(e,t,r){let n=e.ownerDocument,o=n.defaultView.getComputedStyle(e),s=n.createElement("span");Object.assign(s.style,{position:"fixed",visibility:"hidden",whiteSpace:"pre",font:o.font,letterSpacing:o.letterSpacing}),s.textContent=t,n.body.append(s);try{let l=e.getBoundingClientRect(),a=s.getBoundingClientRect().width,d=parseFloat(o.paddingLeft)||0,h=parseFloat(o.paddingRight)||0,u=l.width-d-h,f=o.textAlign==="right"||o.textAlign==="end"?Math.max(0,u-a):o.textAlign==="center"?Math.max(0,(u-a)/2):0,y=r-l.left-d-f+e.scrollLeft,g=s.getBoundingClientRect().left;return jr(t).find(C=>{let c=n.createRange();c.setStart(s.firstChild,C.start),c.setEnd(s.firstChild,C.end);let b=c.getBoundingClientRect();return y>=b.left-g&&y<=b.right-g})}finally{s.remove()}}function En({value:e,spec:t,preview:r,commit:n,cancel:o}){let s=D(null),l=D(0),a=D(!1),d=D(!1),[h,u]=T(null);se(()=>()=>s.current?.(),[]);let f=t?(e.trim()||(t.defaultValue===void 0?"":String(t.defaultValue))).match(Rn):null,y=!!f&&Number.isFinite(Number(f[1]))||!!t?.compound&&jr(e).length>0;return{enabled:y,dragging:a,consumedClick:d,start:g=>{if(d.current=!1,!y||!t||g.button!==0||g.pointerType==="touch")return;let C=t.compound?f?{start:e.indexOf(e.trim()),end:e.indexOf(e.trim())+e.trim().length,text:e.trim()}:di(g.currentTarget,e,g.clientX):null,c=C?C.text.match(Rn):f;if(!c)return;let b=C?si(e,C.start,C.text):t;g.preventDefault(),g.stopPropagation(),s.current?.();let m=++l.current,p=g.currentTarget,v=p.ownerDocument,N=v.defaultView,M=p.getRootNode(),j=()=>M.pointerLockElement===p||v.pointerLockElement===p,q=Number(c[1]),x=c[2]??"",P=/^(rem|em)$/i.test(x)&&b.step===1?.01:b.step,L=!1,B=!1,O=!1,A=g.clientX,I=A,E=0,K=0,de=e,Q=g.clientY,H=()=>{j()&&v.exitPointerLock()},ae=()=>{B=!0,a.current=!1,N.removeEventListener("pointermove",me,!0),N.removeEventListener("pointerup",Fe,!0),N.removeEventListener("pointercancel",ve,!0),N.removeEventListener("keydown",Me,!0),N.removeEventListener("keyup",Me,!0),N.removeEventListener("blur",ve),v.removeEventListener("pointerlockchange",Ye),p.hasPointerCapture?.(g.pointerId)&&p.releasePointerCapture(g.pointerId),H(),u(null),s.current=null},he=()=>{if(!p.requestPointerLock)return;let $=()=>{v.removeEventListener("pointerlockchange",te),v.removeEventListener("pointerlockerror",$),B&&m===l.current&&H()},te=()=>{j()&&$()};v.addEventListener("pointerlockchange",te),v.addEventListener("pointerlockerror",$);try{let ge=p.requestPointerLock();ge&&ge.then($,$)}catch{$()}},ue=$=>{let te=q+Math.round(E/4)*P,ge=b.shiftStep??.05,J=Math.min(b.max??1/0,Math.max(b.min??-1/0,$?Math.round(te/ge)*ge:te));if(!Number.isFinite(J))return;let pe=`${Number(J.toFixed(4))}${x}`;de=C?e.slice(0,C.start)+pe+e.slice(C.end):pe,r(de)},me=$=>{let te=j(),ge=te?$.movementX:$.clientX-A;A=$.clientX,K+=ge,E+=ge,I=te?((I+ge)%N.innerWidth+N.innerWidth)%N.innerWidth:$.clientX,te&&u({x:I,y:Q,doc:v}),!(!L&&Math.abs(K)<4)&&($.preventDefault(),$.stopImmediatePropagation(),L||(L=!0,a.current=!0),ue($.shiftKey))},Fe=$=>{$.preventDefault(),$.stopImmediatePropagation(),ae(),d.current=L,L?n(de):(p.focus(),p instanceof N.HTMLInputElement&&p.select())},ve=()=>{ae(),o()},Me=$=>{if($.key==="Shift"){L&&ue($.type==="keydown");return}$.type==="keydown"&&$.key==="Escape"&&($.preventDefault(),$.stopImmediatePropagation(),ve())},Ye=()=>{if(B){H();return}j()?(O=!0,u({x:I,y:Q,doc:v})):O&&ve()};p.setPointerCapture?.(g.pointerId),N.addEventListener("pointermove",me,{capture:!0,passive:!1}),N.addEventListener("pointerup",Fe,!0),N.addEventListener("pointercancel",ve,!0),N.addEventListener("keydown",Me,!0),N.addEventListener("keyup",Me,!0),N.addEventListener("blur",ve),v.addEventListener("pointerlockchange",Ye),s.current=ae,he()},cursor:h&&an(i("div",{"data-taste-scrub-cursor":!0,"aria-hidden":"true",style:{position:"fixed",left:h.x,top:h.y,transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:2147483647,color:"white",filter:"drop-shadow(0 1px 2px black)"},children:i(nn,{size:18})}),h.doc.body)}}function ci(e,t,r){let n=D(!1),o=D(0),s=D(t);Pe(()=>{let l=e.current;if(!l||t!=="running")return;n.current=!1,o.current=l.scrollTop;let a=()=>{n.current=!0},d=()=>{Math.abs(l.scrollTop-o.current)>1&&a()},h=u=>{u.target.closest("input, textarea, [contenteditable]")||["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(u.key)&&a()};return l.addEventListener("wheel",a,{passive:!0}),l.addEventListener("touchmove",a,{passive:!0}),l.addEventListener("keydown",h),l.addEventListener("scroll",d,{passive:!0}),()=>{l.removeEventListener("wheel",a),l.removeEventListener("touchmove",a),l.removeEventListener("keydown",h),l.removeEventListener("scroll",d)}},[e,t]),Pe(()=>{let l=s.current==="running";s.current=t;let a=e.current;if(!a||n.current||t==="error"||t!=="running"&&!l)return;let d=()=>{if(n.current)return;let u=a.querySelectorAll('[data-proposal-status="done"], [data-token-id]'),f=u[u.length-1];if(!f)return;let y=f.getBoundingClientRect().bottom,g=a.getBoundingClientRect().top+a.clientHeight;y+16>g&&(a.scrollTop+=y+16-g,o.current=a.scrollTop)};if(d(),t!=="running")return;let h=typeof ResizeObserver>"u"?null:new ResizeObserver(d);h?.observe(a);for(let u of a.children)h?.observe(u);return()=>h?.disconnect()},[e,t,r])}var $n=oa(()=>!1),ui=()=>ca($n);function pi(e){let t="",r=new Map,n=o=>{if(o.nodeType===Node.TEXT_NODE){t+=o.textContent??"";return}if(o instanceof HTMLElement&&!o.matches("[data-token-preview], .tc-swatch, .tc-available")){if(o.matches(".tc-field")){let s=o.querySelector("input");if(s){let l=t.length;t+=s.value,r.set(s,{start:l,end:t.length})}return}if(o.dataset.valueText!==void 0){t+=o.dataset.valueText;return}for(let s of o.childNodes)n(s)}};for(let o of e.childNodes)n(o);return{value:t.replace(/\u00a0/g," "),fields:r}}function In(e,t,r){let n=e.findIndex(a=>r?t>a.start&&t<=a.end:t>=a.start&&t<a.end),o=e.findIndex(a=>r?a.start===t:a.end===t),s=n>=0?n:o,l=s>=0?e[s+(r?-1:1)]:r?[...e].reverse().find(a=>a.end<t):e.find(a=>a.start>t);return l?r?l.start:l.end:r?0:e.at(-1)?.end??t}function Nn({label:e,onCommit:t,onSelectionStart:r,children:n,...o}){let s=D(null),l=D(null),[a,d]=T(null),[h,u]=T(""),[f,y]=T(""),g=D(!1);Pe(()=>{!a||!l.current||(l.current.focus({preventScroll:!0}),l.current.setSelectionRange(Math.min(a.anchor,a.focus),Math.max(a.anchor,a.focus),a.focus<a.anchor?"backward":"forward"))},[a]);let C=(c,b,m)=>{if(!s.current)return!1;let{value:p,fields:v}=pi(s.current),N=v.get(c);if(!N||v.size<2)return!1;let M=c.selectionDirection==="backward",j=N.start+((M?c.selectionEnd:c.selectionStart)??0),q=N.start+((M?c.selectionStart:c.selectionEnd)??0),x=[...v.values()],P=m?In(x,q,b):Math.max(0,Math.min(p.length,q+(b?-1:1)));return P===q?!1:(u(p),d({value:p,ranges:x,anchor:j,focus:P,dirty:[...v.keys()].some(L=>L.hasAttribute("data-taste-field-dirty"))}),y(""),r?.(),!0)};return i($n.Provider,{value:C,children:i("div",{...o,ref:s,children:a?k("span",{className:"tc-field tc-fit",style:{flex:"1 1 auto",minWidth:0},children:[i("span",{className:"tc-measure","aria-hidden":"true",children:h||"\u200B"}),i("input",{ref:l,"aria-label":e,"aria-invalid":!!f,"data-taste-value-input":!0,"data-taste-field-dirty":a.dirty||h!==a.value||void 0,value:h,onChange:c=>{u(c.target.value),y("")},onBlur:()=>{if(g.current){g.current=!1;return}try{(a.dirty||h!==a.value)&&t(h.trim()),d(null)}catch(c){y(c instanceof Error?c.message:"Check this value")}},onKeyDown:c=>{if(c.stopPropagation(),c.key==="Escape")c.preventDefault(),g.current=!0,c.currentTarget.blur(),d(null);else if(c.key==="Enter")c.preventDefault(),c.currentTarget.blur();else if(c.altKey&&c.shiftKey&&!c.metaKey&&!c.ctrlKey&&!c.nativeEvent.isComposing&&h===a.value&&(c.key==="ArrowLeft"||c.key==="ArrowRight")){let b=c.currentTarget,m=b.selectionDirection==="backward",p=(m?b.selectionEnd:b.selectionStart)??0,v=(m?b.selectionStart:b.selectionEnd)??0,N=In(a.ranges,v,c.key==="ArrowLeft");c.preventDefault(),b.setSelectionRange(Math.min(p,N),Math.max(p,N),N<p?"backward":"forward")}}}),f&&i("span",{role:"alert",className:"tc-field-error",children:f})]}):n})})}function Br(e,t){let r=t,n=(e.x+t.x)/2;if(t.blockedLeft){let{top:o,bottom:s,width:l}=t.blockedLeft,a=e.y<=t.y,d=Math.min(8,l/2,(s-o)/2)*(1-Math.SQRT1_2);r={x:t.x+d,y:a?o+d:s-d};let h=Math.min(64,Math.abs(r.y-e.y)/2),u=r.y+(a?-1:1)*Math.min(24,h);return{from:e,to:r,path:`M ${e.x} ${e.y} C ${n} ${e.y}, ${r.x-h} ${u}, ${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 Gt=({parent:e,child:t})=>JSON.stringify([e,t]),cr=128;function Tn(e){let t=e.getBoundingClientRect(),r=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1,o=new Map;e.querySelectorAll("[data-constraint-id], [data-token-id], [data-connection-id]").forEach(l=>{let a=l.dataset.connectionId??l.dataset.constraintId??`token:${l.dataset.tokenId}`;o.has(a)||o.set(a,l)});let s=new Map;return(l,a)=>{let d=`${a}:${l}`;if(s.has(d))return s.get(d);let h=o.get(l),u=h?.matches(".tc-reference")?h:h?.querySelector(a==="source"?".tc-name":".tc-reference");if(!u)return s.set(d,null),null;let f=u.getBoundingClientRect(),y=a==="target"&&u.parentElement?.classList.contains("tc-compound")&&Array.from(u.parentElement.children).some(C=>{if(C===u)return!1;let c=C.getBoundingClientRect();return c.width>0&&c.right<=f.left+1&&c.right>f.left-8&&c.bottom>f.top&&c.top<f.bottom}),g={x:((a==="source"?f.right:f.left)-t.left)/r-e.clientLeft,y:(f.top+f.height/2-t.top)/n-e.clientTop,...y?{blockedLeft:{top:(f.top-t.top)/n-e.clientTop,bottom:(f.bottom-t.top)/n-e.clientTop,width:f.width/r}}:{}};return s.set(d,g),g}}function hi({pane:e,edges:t,visible:r,revision:n,suspended:o,color:s}){let[l,a]=T(new Map),d=new Set(r.map(Gt)),h=JSON.stringify(t),u=JSON.stringify(r),f=D(null),y=D(r);return y.current=r,se(()=>{let g=e.current;if(!g)return;let C=JSON.parse(h),c=C.length>cr,b=new Set,m,p=!1,v=()=>{if(p)return;let x=Tn(g),P=y.current.length<=cr?new Set(y.current.map(Gt)):new Set,L=c?C.filter(O=>b.has(O.child)||P.has(Gt(O))):C,B=new Map;for(let O of L){let A=x(O.parent,"source"),I=x(O.child,"target");A&&I&&B.set(Gt(O),Br(A,I))}a(O=>O.size===B.size&&[...B].every(([A,I])=>O.get(A)?.path===I.path)?O:B)},N=()=>{m===void 0&&(m=requestAnimationFrame(()=>{m=void 0,v()}))};f.current=v;let M=typeof ResizeObserver>"u"?null:new ResizeObserver(N);M?.observe(g),g.querySelectorAll(".tc-scroll, .tc-row, .tc-reference, .tc-literal").forEach(x=>M?.observe(x));let j=new Map;g.querySelectorAll("[data-connection-id]").forEach(x=>j.set(x,x.dataset.connectionId)),g.querySelectorAll("[data-constraint-id] .tc-reference").forEach(x=>j.set(x,x.closest("[data-constraint-id]").dataset.constraintId));let q=c&&typeof IntersectionObserver<"u"?new IntersectionObserver(x=>{for(let P of x){let L=j.get(P.target);L&&(P.isIntersecting?b.add(L):b.delete(L))}N()},{root:g.querySelector(".tc-scroll"),rootMargin:"160px 0px"}):null;return j.forEach((x,P)=>q?.observe(P)),c&&!q&&C.slice(0,cr).forEach(x=>b.add(x.child)),v(),g.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{p=!0,f.current=null,m!==void 0&&cancelAnimationFrame(m),M?.disconnect(),q?.disconnect(),g.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[e,h,n]),Pe(()=>{!o&&y.current.length<=cr&&y.current.some(g=>!l.has(Gt(g)))&&f.current?.()},[u,o,l]),i("svg",{"data-taste-connection-layer":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[...l].map(([g,{from:C,to:c,path:b}])=>{let m=!o&&d.has(g);return k("g",{"data-taste-cached-connection":g,"data-taste-connection":m?"":void 0,style:{visibility:m?"visible":"hidden"},children:[i("path",{d:b,fill:"none",stroke:s,strokeWidth:1}),i("circle",{cx:C.x,cy:C.y,r:3,fill:s}),i("circle",{cx:c.x,cy:c.y,r:3,fill:s})]},g)})})}function fi({value:e,label:t,className:r,onEdit:n,onCommit:o,onPreview:s}){let l=En({value:e,spec:{step:1,compound:!0},preview:s,commit:a=>{o(a),s(null)},cancel:()=>s(null)});return k(Le,{children:[i("button",{className:r,"aria-label":t,"data-scrubbable":l.enabled||void 0,onPointerDown:l.start,onClick:()=>{l.consumedClick.current||n()},children:e}),l.cursor]})}function st({label:e,value:t,onCommit:r,onDraftChange:n,onCancel:o,arrowNavigation:s=!1,compact:l=!1,decimal:a=!1,scrub:d,clearable:h=!1,onScrubPreview:u,onDelete:f,sourceSuggestions:y,bareSource:g=!1,...C}){let c=ui(),[b,m]=T(null),[p,v]=T(""),N=D(!1),M=xr(),j=b??t,[q,x]=T(!1),[P,L]=T(!0),[B,O]=T(!1),A=g?j.match(/^@?([\w-]+)$/)?.[1]:j.match(/(?:^|\s)@([\w-]+)$/)?.[1],I=(q&&b!==null&&P&&!B&&A&&!y?.some($=>$.toLowerCase()===A.toLowerCase())?y?.find($=>$.length>A.length&&$.toLowerCase().startsWith(A.toLowerCase())):void 0)?.slice(A.length)??"",E=D(null),[K,de]=T(0);Pe(()=>{de(E.current?.getBoundingClientRect().width??0)},[I]);let Q=$=>{try{r($.trim()),u?.(null),m(null),v("")}catch(te){v(te instanceof Error?te.message:"Check this value")}},H=En({value:j,spec:d,preview:$=>{m($),v(""),u?.($)},commit:Q,cancel:()=>{m(null),v(""),u?.(null),o?.()}}),ae=typeof a=="number"?a:2,he=3-ae,ue=a?j.match(/^(-?)(\d*)(\.?)(\d*)$/):null,me=ue?`${ue[3]?"":"."}${"0".repeat(Math.max(0,ae-ue[4].length))}`:"",Fe=ue?"0".repeat(Math.max(0,he-ue[2].length)):"",ve=D(null),[Me,Ye]=T(0);return Pe(()=>{let $=ve.current;if(!$)return;let te=()=>Ye($.getBoundingClientRect().width);if(te(),typeof ResizeObserver>"u")return;let ge=new ResizeObserver(te);return ge.observe($),()=>ge.disconnect()},[me]),k("span",{className:`tc-field${l?" tc-fit":""}${a?" tc-decimal":""}`,children:[l&&i("span",{className:"tc-measure","aria-hidden":"true",children:a?`${"0".repeat(Math.max(4,t.length,ue?`${ue[1]}${Fe}${ue[2]}${ue[3]}${ue[4]}${me}`.length:j.length)-ae-1)}.${"0".repeat(ae)}`:j+I||C.placeholder||"\u200B"}),I&&k("span",{className:"tc-source-completion","aria-hidden":"true",children:[i("span",{style:{visibility:"hidden"},children:j}),i("span",{ref:E,children:I})]}),a&&ue&&k("span",{className:"tc-decimal-display","aria-hidden":"true",children:[ue[1],i("span",{className:"tc-digit-placeholder",children:Fe}),ue[2],ue[3],ue[4],i("span",{ref:ve,className:"tc-digit-placeholder",children:me})]}),i("input",{...C,autoComplete:y?"off":void 0,"aria-autocomplete":y?"inline":void 0,onFocus:()=>{x(!0),N.current=!1},onSelect:$=>{let te=$.currentTarget;L(te.selectionStart===te.value.length&&te.selectionEnd===te.value.length)},onCompositionStart:()=>O(!0),onCompositionEnd:()=>O(!1),"data-scrubbable":H.enabled||void 0,onPointerDown:H.start,onContextMenu:h||f?$=>{$.preventDefault(),$.stopPropagation(),f?f():Q("")}:void 0,placeholder:a?`${"0".repeat(he)}.${"0".repeat(ae)}`:C.placeholder,inputMode:a?"decimal":void 0,style:a&&ue?{color:"transparent",caretColor:"var(--tc-primary)",paddingRight:6+Me}:I?{paddingRight:`calc(var(--tc-field-inline-padding, 6px) + ${K}px)`}:void 0,"data-taste-value-input":!0,"data-value-arrow-navigation":s||void 0,"data-taste-field-dirty":b!==null||void 0,"aria-label":e,"aria-invalid":!!p,"aria-describedby":p?M:void 0,value:b??t,onChange:$=>{if(L($.target.selectionStart===$.target.value.length&&$.target.selectionEnd===$.target.value.length),n?.($.target.value)){N.current=!0,m(null),v("");return}a&&!new RegExp(`^-?\\d*(?:\\.\\d{0,${ae}})?$`).test($.target.value)||(m($.target.value),v(""))},onBlur:$=>{if(x(!1),!H.dragging.current){if(N.current){N.current=!1;return}if(b===null){(!s||!$.currentTarget.closest(".tc-reference")?.contains($.relatedTarget))&&o?.();return}Q(b)}},onKeyDown:$=>{if($.stopPropagation(),I&&!$.nativeEvent.isComposing&&!$.shiftKey&&!$.altKey&&!$.metaKey&&!$.ctrlKey&&($.key==="Enter"||$.key==="Tab")){$.preventDefault(),m(j+I),v("");return}if(s&&$.shiftKey&&!$.metaKey&&!$.ctrlKey&&!$.nativeEvent.isComposing&&($.key==="ArrowLeft"||$.key==="ArrowRight")){let te=$.currentTarget,ge=te.selectionDirection==="backward"?te.selectionStart:te.selectionEnd;if(($.altKey||ge===($.key==="ArrowLeft"?0:te.value.length))&&c($.currentTarget,$.key==="ArrowLeft",$.altKey)){N.current=!0,$.preventDefault();return}}if(s&&!$.shiftKey&&!$.metaKey&&!$.ctrlKey&&!$.nativeEvent.isComposing&&($.key==="ArrowLeft"||$.key==="ArrowRight")){let te=$.currentTarget,ge=$.key==="ArrowLeft",J=ge?0:te.value.length;if($.altKey||te.selectionStart===J&&te.selectionEnd===J){let pe=Array.from(te.closest(".tc-value")?.querySelectorAll("input[data-value-arrow-navigation]")??[]),V=pe[pe.indexOf(te)+(ge?-1:1)];if(V){$.preventDefault(),V.focus({preventScroll:!0});let xe=$.altKey?ge?0:V.value.length:ge?V.value.length:0;V.setSelectionRange(xe,xe)}}}$.key==="Enter"&&($.preventDefault(),$.currentTarget.blur()),$.key==="Escape"&&($.preventDefault(),m(null),v(""),N.current=!0,$.currentTarget.blur(),o?.())}}),H.cursor,p&&i("span",{id:M,role:"alert",className:"tc-field-error",children:p})]})}function Ln({color:e,background:t}){let r=li(e,t);return i("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:i("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:e}})})}function gi({value:e,constraints:t,name:r,background:n}){let o=ni(e,t),s=br(t,e),l=/\bcalc\(/i.test(e)?yr(e,t):null,a=s?.kind==="layout"?`${Math.round(s.value)}${s.unit}`:s?mt(s):l??void 0,d=ta(e,t);return!o&&!s&&!l&&!d.length?null:k("span",{className:"tc-token-preview","data-token-preview":!0,"aria-label":`${r} resolves to ${o??a??d.join(", ")}`,children:[i("span",{className:"tc-separator","aria-hidden":"true",children:i(ka,{size:12})}),o?i("span",{className:"tc-resolved-value",children:i("span",{className:"tc-shadow-preview","data-shadow-value":o,"aria-hidden":"true",children:i("span",{style:{boxShadow:o}})})}):d.length?d.map((h,u)=>i("span",{className:"tc-resolved-value",children:i(Ln,{color:h,background:n})},`${u}:${h}`)):i("span",{className:"tc-resolved-value",children:a})]})}function mi({row:e,constraints:t,background:r}){if(e.kind==="color"){let n;try{n=mt(Tt(t,e.id))}catch{}return n?i("span",{className:"tc-resolved-value",children:i(Ln,{color:n,background:r})}):null}return null}var Mn=e=>e.dataset.connectionId??e.dataset.constraintId??`token:${e.dataset.tokenId}`,xt=e=>{let t=e.match(/^(token:.*):(ref|dim):(\d+)$/);return{row:t?.[1]??e,index:t?.[2]==="ref"?Number(t[3]):void 0,dimensionIndex:t?.[2]==="dim"?Number(t[3]):void 0}};function vi({drag:e,pane:t,color:r}){let[n,o]=T(null);if(Pe(()=>{let d=t.current;if(!d)return;let h=()=>{let f=Tn(d),y=f(e.id,e.port);if(!y)return;let g=(e.target&&e.validTarget?f(e.target,e.port==="source"?"target":"source"):null)??{x:e.toX-d.clientLeft,y:e.toY-d.clientTop};o(e.port==="source"?Br(y,g):Br(g,y))};h(),d.addEventListener("scroll",h,!0),window.addEventListener("resize",h);let u=typeof ResizeObserver>"u"?null:new ResizeObserver(h);return d.querySelectorAll(".tc-row, .tc-reference, .tc-literal").forEach(f=>u?.observe(f)),()=>{d.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h),u?.disconnect()}},[e,t]),!n)return null;let{from:s,to:l,path:a}=n;return k("svg",{"data-taste-connection":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[i("path",{d:a,fill:"none",stroke:r,strokeWidth:1}),i("circle",{cx:s.x,cy:s.y,r:3,fill:r}),i("circle",{cx:l.x,cy:l.y,r:3,fill:r})]})}function An({draft:e,onChange:t,history:r,theme:n,onBack:o,style:s,proposalState:l,preferPageComponent:a,proposalRecovery:d,fragments:h,detail:u,onSave:f,saving:y,saveNotice:g,saveAction:C}){let c=Qn(e),b=l==="running",m=Qe[n],p=D(null),v=D(null);ci(v,l,e);let N=D({past:[],future:[]}),M=r??N,j=w=>{b||JSON.stringify(w)!==JSON.stringify(c)&&(M.current.past=[...M.current.past.slice(-99),c],M.current.future=[],t(w))},q=D(null),[x,P]=T(null),[L,B]=T(null),[O,A]=T(null),[I,E]=T(null),[K,de]=T(null),[Q,H]=T(null),[ae,he]=T(null),ue=c.constraints.flatMap(w=>w.parentId?[{parent:w.parentId,child:w.id}]:[]);for(let w of c.tokens)qt(w.value,c.constraints).forEach((U,_)=>{let S=U&&c.constraints.find(Se=>Se.name.toLowerCase()===U.name.toLowerCase());S&&ue.push({parent:S.id,child:rr(w.value)?`token:${w.id}`:`token:${w.id}:ref:${_}`})});let me=ue.filter(({parent:w,child:U})=>O?.port==="source"?w===O.id:U===O?.id||xt(U).row===O?.id).map(({parent:w,child:U})=>({id:w,target:U,port:"source",active:!0,validTarget:!0,x:0,y:0,toX:0,toY:0})),Fe=new Set(O?.port==="source"?me.map(({target:w})=>xt(w).row):[]),ve=x?[x]:L?[L]:me,Me=D(!1),[Ye,$]=T(""),[te,ge]=T(null),[J,pe]=T(null),V=te?c.constraints.map(w=>w.id===te.id?{...w,...te.patch}:w):c.constraints,xe=Ot(()=>({...c,constraints:V,tokens:J?c.tokens.map(w=>w.id===J.id?{...w,value:J.value}:w):c.tokens}),[c,V,J]),[X,Ke]=T(null);se(()=>{let w=p.current?.ownerDocument;if(!w)return;let U=_=>{let S=_.key.toLowerCase();if(!(_.metaKey||_.ctrlKey)||_.altKey||S!=="z"&&S!=="y")return;let Se=_.composedPath()[0],we=Se instanceof Node&&p.current?.contains(Se);if(Zn(_)&&(!we||Se instanceof Element&&Se.hasAttribute("data-taste-field-dirty"))||(_.preventDefault(),_.stopImmediatePropagation(),te||J||q.current))return;let G=S==="y"||_.shiftKey,oe=(G?M.current.future:M.current.past).pop();oe&&((G?M.current.past:M.current.future).push(c),B(null),$(""),t(oe))};return w.addEventListener("keydown",U,!0),()=>w.removeEventListener("keydown",U,!0)},[c,M,t,te,J]),se(()=>{if(!X)return;let w=setTimeout(()=>Ke(null),220);return()=>clearTimeout(w)},[X]);let Je=xr(),qe=D(0),Ae=()=>`${Je}-${++qe.current}`,tt=(w,U)=>{B(null),j({...c,constraints:c.constraints.map(_=>_.id===w?{..._,...U}:_)}),$("")},We=(w,U)=>j({...c,tokens:c.tokens.map(_=>_.id===w?{..._,value:U}:_)}),ze=(w,U)=>{if(w.startsWith("token:")){let _=c.constraints.find(we=>we.id===U),S=xt(w),Se=c.tokens.find(we=>`token:${we.id}`===S.row);return _&&Se&&Pr(Se.value,_,c.constraints,S.index,S.dimensionIndex)!==null?null:"Choose a compatible, unambiguous value"}return nr(c.constraints,w,U)},De=(w,U,_=!1)=>{let S=ze(w,U);if(S)throw Error(S);if(w.startsWith("token:")){let Se=xt(w),we=c.tokens.find(oe=>`token:${oe.id}`===Se.row),G=c.constraints.find(oe=>oe.id===U);We(we.id,Pr(we.value,G,c.constraints,Se.index,Se.dimensionIndex));return}tt(w,{parentId:U,..._?{derivative:Zr(c.constraints,w,U)}:{}})},rt=(w,U)=>{let _=p.current,S=_.getBoundingClientRect();return{x:(w-S.left)/(S.width/_.offsetWidth||1),y:(U-S.top)/(S.height/_.offsetHeight||1)}},It=(w,U,_)=>{if(w.button!==0)return;Ke(null),A(null),B(null),Me.current=!1;let S=rt(w.clientX,w.clientY);q.current={id:U,port:_,...S,toX:S.x,toY:S.y,active:!1,target:null,validTarget:!1},w.currentTarget.setPointerCapture(w.pointerId)},pr=w=>{let U=q.current;if(!U&&!L)return;let _=p.current.getRootNode().elementFromPoint(w.clientX,w.clientY);if(!U){let Ce=p.current.contains(_)?_?.closest(".tc-row"):null;Ce&&Mn(Ce)!==xt(L.target??"").row&&B(null);return}let S=rt(w.clientX,w.clientY),Se=U.active||Math.hypot(S.x-U.x,S.y-U.y)>5,we=p.current.contains(_)?_?.closest("[data-connection-id], [data-constraint-id], [data-token-id]"):null,G=we?Mn(we):null,oe=U.landing;if(oe&&U.validTarget&&p.current.contains(oe.row)){let Ce=oe.row.getBoundingClientRect(),Oe=w.clientX-Ce.left,Ne=w.clientY-Ce.top,fe=6;Oe>=oe.left-fe&&Oe<=oe.right+fe&&Ne>=oe.top-fe&&Ne<=oe.bottom+fe&&Ne>=-fe&&Ne<=Ce.height+fe&&(G=U.target)}let Ve=!!G&&!ze(U.port==="source"?G:U.id,U.port==="source"?U.id:G);if(G!==U.target&&(oe=void 0),!oe&&Ve&&U.port==="source"&&G?.startsWith("token:")&&we){let Ce=we.closest("[data-token-id]"),Oe=_?.closest(".tc-shadow-dimension, .tc-reference, .tc-value")??we;if(Ce){let Ne=Ce.getBoundingClientRect(),fe=Oe.getBoundingClientRect();fe.width>0&&fe.height>0&&(oe={row:Ce,left:fe.left-Ne.left,right:fe.right-Ne.left,top:fe.top-Ne.top,bottom:fe.bottom-Ne.top})}}q.current={...U,active:Se,toX:S.x,toY:S.y,target:G,validTarget:Ve,landing:oe},Se&&(Me.current=!0,P(q.current))},hr=()=>{let w=q.current;if(q.current=null,P(null),!(!w?.active||!w.target))try{De(w.port==="source"?w.target:w.id,w.port==="source"?w.id:w.target,!0),B({...w})}catch{$(""),Ke(w.port==="source"?w.id:w.target)}},at=w=>{if(!w||!Number.isFinite(Number(w)))throw Error("Enter a finite number");return Number(w)};return k("div",{ref:p,role:"region","aria-label":u?`${u.name} uses`:"New taste","data-taste-editor":!0,"data-popmelt-font":"sans","data-popmelt-theme":n,onMouseOver:u?w=>{let U=w.target.closest("[data-token-id], [data-constraint-id]"),_=U?.getAttribute("data-token-id"),S=U?.getAttribute("data-constraint-id");u.onHover?.(_?{kind:"token",id:_}:S?{kind:"dimension",id:S}:null)}:void 0,onMouseLeave:u?()=>u.onHover?.(null):void 0,onPointerMove:pr,onPointerUp:hr,onPointerCancel:()=>{q.current=null,P(null)},onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),q.current||L?(q.current=null,P(null),B(null)):o())},style:{...s,width:"min(360px, 100%)",marginInline:"auto",boxSizing:"border-box",position:"relative",display:"flex",flexDirection:"column",maxHeight:s?.maxHeight??"calc(100dvh - 80px)",border:`1px solid ${m.border}`,borderRadius:20,background:m.surface,color:m.secondary,fontFamily:Ft,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden","--tc-primary":m.primary,"--tc-muted":m.muted,"--tc-control":m.control,"--tc-secondary":m.secondary,"--tc-border":m.border,"--tc-surface":m.surface},children:[i("style",{children:`
62
- [data-taste-editor] { --tc-row-height: 22px; --tc-row-slop: 3px; --tc-value-font-size: 14px; }
63
- [data-taste-editor] * { box-sizing: border-box; }
64
- [data-taste-editor] button, [data-taste-editor] input { font: inherit; font-variant-numeric: tabular-nums; color: inherit; letter-spacing: inherit; }
65
- [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; }
66
- [data-taste-editor] button:hover { color: var(--tc-primary); background: var(--tc-control); }
67
- [data-taste-editor] button:focus-visible { outline: 1px solid var(--tc-secondary); outline-offset: 1px; }
68
- [data-taste-editor] input:focus-visible { outline: none; box-shadow: none; }
69
- [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; }
70
- [data-taste-editor] input:hover, [data-taste-editor] input:focus { background: var(--tc-control); color: var(--tc-primary); }
71
- [data-taste-editor] input[data-scrubbable] { cursor: ew-resize; touch-action: none; }
72
- [data-taste-editor] button[data-scrubbable] { cursor: ew-resize; touch-action: none; }
73
- [data-taste-editor] input[data-scrubbable]:focus { cursor: text; }
74
- [data-taste-editor] input::placeholder { color: var(--tc-secondary); opacity: 1; }
75
- [data-taste-editor] .tc-field { position: relative; display: grid; min-width: 0; }
76
- [data-taste-editor] .tc-fit > input, [data-taste-editor] .tc-measure { grid-area: 1 / 1; }
77
- [data-taste-editor] .tc-fit > input { position: absolute; inset: 0; width: 100%; min-width: 1px; }
78
- [data-taste-editor] .tc-measure { visibility: hidden; white-space: pre; padding: 2px 6px; overflow: hidden; }
79
- [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; }
80
- [data-taste-editor] .tc-decimal { flex: 0 0 auto; }
81
- [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; }
82
- [data-taste-editor] .tc-decimal:focus-within .tc-decimal-display { color: var(--tc-primary); }
83
- [data-taste-editor] .tc-digit-placeholder { display: inline-block; color: var(--tc-secondary); }
84
- [data-taste-editor] .tc-decimal input::placeholder { color: transparent; }
85
- [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: ${n==="dark"?"#302024":"#f9e9ec"}; color: ${n==="dark"?"#f08a95":"#c4253d"}; font-size: 11px; padding: 6px 8px; text-align: center; }
86
- [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; }
87
- [data-taste-editor] .tc-scroll > header { margin-top: 19px; }
88
- [data-taste-editor] header { display: flex; align-items: center; gap: 2px; flex-shrink: 0; height: 16px; }
89
- [data-taste-editor] header button { padding: 0; color: var(--tc-primary); }
90
- [data-taste-editor] header > svg { flex-shrink: 0; transform: scaleY(-1); }
91
- [data-taste-editor] header .tc-field { flex: 0 1 auto; font-weight: 600; }
92
- [data-taste-editor] header .tc-measure { padding: 0; }
93
- [data-taste-editor] input.tc-title { padding: 0; text-align: left; }
94
- [data-taste-editor] section { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
95
- [data-taste-editor] h3 { font-size: 12px; line-height: 1.3; font-weight: 500; color: var(--tc-primary); margin: 0; }
96
- [data-taste-editor] .tc-type-role { color: var(--tc-secondary); letter-spacing: normal; height: 30.2px; flex-shrink: 0; }
97
- [data-taste-editor] .tc-type-role[data-typography-role="body"]:has(~ .tc-row[data-typography-role="body"]:is(:hover, :focus-within)),
98
- [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); }
99
- [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; }
100
- [data-taste-editor] .tc-row[data-typography-role] .tc-name { padding-inline: 4px; letter-spacing: normal; }
101
- [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; }
102
- [data-taste-editor] .tc-row { position: relative; isolation: isolate; }
103
- [data-taste-editor] .tc-row::before { content: ''; position: absolute; inset: calc(-1 * var(--tc-row-slop)) 0; z-index: -1; }
104
- [data-taste-editor] .tc-row:hover, [data-taste-editor] .tc-row:focus-within { color: var(--tc-primary); }
105
- [data-taste-editor] .tc-row:hover input { background: var(--tc-control); color: var(--tc-primary); }
106
- [data-taste-editor] [data-connection-active=true] { background: var(--tc-control); color: var(--tc-primary); }
107
- [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; }
108
- [data-taste-editor] .tc-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
109
- [data-taste-editor] .tc-row[data-proposal-status=pending] .tc-name { color: var(--tc-muted); }
110
- [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; }
111
- [data-taste-editor] .tc-proposal-recovery { flex-shrink: 0; padding: 12px 15px 15px; border-top: 1px solid var(--tc-border); }
112
- [data-taste-editor] .tc-proposal-recovery p { margin: 0 0 10px; color: var(--tc-secondary); }
113
- [data-taste-editor] .tc-proposal-recovery nav { display: flex; gap: 8px; }
114
- [data-taste-editor] .tc-proposal-recovery button { padding: 6px 10px; background: var(--tc-control); color: var(--tc-primary); }
115
- [data-taste-editor] .tc-proposal-status[data-state=in-progress] {
116
- color: var(--tc-primary);
117
- background: linear-gradient(100deg, var(--tc-muted) 35%, var(--tc-primary) 50%, var(--tc-muted) 65%);
118
- background-size: 250% 100%;
119
- background-clip: text;
120
- -webkit-background-clip: text;
121
- -webkit-text-fill-color: transparent;
122
- animation: tc-proposal-sweep 2.4s linear infinite;
123
- }
124
- @keyframes tc-proposal-sweep {
125
- 0% { background-position: 100% 0; }
126
- 80%, 100% { background-position: 0% 0; }
127
- }
128
- @media (prefers-reduced-motion: reduce) {
129
- [data-taste-editor] .tc-proposal-status[data-state=in-progress] {
130
- animation: none;
131
- background: none;
132
- -webkit-text-fill-color: currentColor;
133
- }
134
- }
135
- [data-taste-editor] .tc-name:disabled { cursor: default; background: transparent; }
136
- [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); }
137
- @keyframes tc-rejection-shake { ${Gn} }
138
- [data-taste-editor] .tc-name[data-connection-rejected=true] { animation: tc-rejection-shake 220ms ease-out; background: var(--tc-control); color: var(--tc-primary); }
139
- @media (prefers-reduced-motion: reduce) { [data-taste-editor] .tc-name[data-connection-rejected=true] { animation: none; } }
140
- [data-taste-editor] .tc-row:focus-within .tc-name, [data-taste-editor] .tc-row:focus-within > .tc-field { color: var(--tc-primary); }
141
- [data-taste-editor] .tc-row > .tc-field { flex: 1; letter-spacing: .12px; }
142
- [data-taste-editor] .tc-row > .tc-field.tc-fit { flex: 0 1 auto; max-width: 50%; }
143
- [data-taste-editor] .tc-row > .tc-field input { text-align: left; }
144
- [data-taste-editor] input.tc-derived-name-active { color: var(--tc-primary); }
145
- [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; }
146
- [data-taste-editor] .tc-token-preview { display: inline-flex; align-items: center; flex: 0 0 auto; }
147
- [data-taste-editor] .tc-resolved-value { display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; border-radius: 8px; white-space: nowrap; }
148
- [data-taste-editor] .tc-resolved-value .tc-swatch { width: 16px; height: 16px; flex-basis: 16px; margin-left: 0; border-radius: 4px; box-shadow: none; }
149
- [data-taste-editor] .tc-shadow-preview { position: relative; width: 16px; height: 16px; border-radius: 4px; background: #ededed; overflow: hidden; }
150
- [data-taste-editor] .tc-shadow-preview > span { position: absolute; width: 10px; height: 12px; left: 2px; top: 2px; border-radius: 1px; background: white; }
151
- [data-taste-editor] .tc-shadow-dimension { display: inline-flex; align-items: center; flex-shrink: 0; }
152
- [data-taste-editor] .tc-separator { flex: 0 0 16px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
153
- [data-taste-editor] .tc-reference { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 8px; padding: 2px 6px; }
154
- /* Only extend above/below the visible badge: never cover its port or scrub fields. */
155
- [data-taste-editor] .tc-reference:not(:has(.tc-reference))::before,
156
- [data-taste-editor] .tc-reference:not(:has(.tc-reference))::after { content: ''; position: absolute; left: 0; right: 0; }
157
- [data-taste-editor] .tc-reference:not(:has(.tc-reference))::before { top: calc((100% - var(--tc-row-height)) / 2 - var(--tc-row-slop)); bottom: 100%; }
158
- [data-taste-editor] .tc-reference:not(:has(.tc-reference))::after { top: 100%; bottom: calc((100% - var(--tc-row-height)) / 2 - var(--tc-row-slop)); }
159
- [data-taste-editor] .tc-compound { display: flex; align-items: center; min-width: 0; }
160
- [data-taste-editor] .tc-compound > .tc-reference { flex: 0 0 auto; }
161
- [data-taste-editor] .tc-opacity-separator { white-space: pre; }
162
- [data-taste-editor] .tc-reference > .tc-port,
163
- [data-taste-editor] .tc-reference > span:not(.tc-field),
164
- [data-taste-editor] .tc-reference > .tc-field:has(.tc-token-step),
165
- [data-taste-editor] .tc-reference > .tc-field:has(.tc-token-opacity) { flex-shrink: 0; }
166
- [data-taste-editor] .tc-literal { white-space: pre; overflow: hidden; text-overflow: ellipsis; display: block; min-width: 0; padding: 2px 0; }
167
- [data-taste-editor] .tc-literal-prefix { flex-shrink: 0; }
168
- [data-taste-editor] .tc-available { background: var(--tc-control); flex-shrink: 0; }
169
- [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); }
170
- [data-taste-editor] .tc-row .tc-reference input { background: transparent; }
171
- [data-taste-editor] .tc-reference input, [data-taste-editor] .tc-reference .tc-measure { padding: 0; }
172
- [data-taste-editor] .tc-reference .tc-field { --tc-field-inline-padding: 0px; }
173
- [data-taste-editor] .tc-reference .tc-source-completion { padding: 0; }
174
- [data-taste-editor] .tc-port { padding: 0; touch-action: none; user-select: none; }
175
- [data-taste-editor] .tc-port:hover { background: transparent; }
176
- [data-taste-editor] .tc-add-token { align-self: flex-start; height: 22px; background: var(--tc-control); font-weight: 500; }
177
- [data-taste-editor] .tc-save { flex-shrink: 0; margin: 0 15px 15px; height: 32px; border-radius: 10px; background: ${m.actionSurface}; color: ${m.actionForeground}; font-weight: 500; }
178
- [data-taste-editor] .tc-save:hover { background: ${m.actionHover}; color: ${m.actionForeground}; }
179
- `}),k("div",{ref:v,className:"tc-scroll",style:{overflowAnchor:"none"},tabIndex:b?0:void 0,children:[k("header",{children:[i("button",{"aria-label":u?"Back to taste":"Back to taste collection",onClick:o,children:i(Sr,{size:16})}),i(Ht,{size:14}),u?i("span",{className:"tc-title",children:u.name}):i(st,{label:"Taste name",readOnly:b,compact:!0,value:c.name,placeholder:"Name this taste",className:"tc-title",onCommit:w=>j({...c,name:w})})]}),u?u.preview(xe):i(Cn,{draft:xe,preferPageComponent:a,waitForPageFoundations:b&&a,dimensionId:I??K,theme:n}),u&&i("h3",{children:"Uses"}),["layout","typography","color"].map(w=>{let U=w==="color"?"color":"layout",_=S=>(!u||u.constraintIds.includes(S.id))&&(S.group??(S.id==="text"?"typography":S.kind))===w;return u&&!c.constraints.some(_)?null:k("section",{"aria-label":w==="typography"?"Typography constraints":U==="layout"?"Layout constraints":"Color constraints",children:[i("h3",{children:w==="typography"?"Typography":U==="layout"?"Layout":"Color"}),i("datalist",{id:`${Je}-${w}`,children:c.constraints.filter(S=>S.kind===U).map(S=>i("option",{value:S.name},S.id))}),c.constraints.filter(_).map((S,Se,we)=>{let G=S.kind,oe=c.constraints.filter(W=>!nr(c.constraints,S.id,W.id)).map(W=>W.name),Ve=c.constraints.find(W=>W.id===S.parentId),Ce=!!S.parentId,Oe=ve.some(W=>!!W.active&&(W.port==="source"&&W.id===S.id||W.port==="target"&&W.validTarget&&W.target===S.id)),Ne=ve.some(W=>!!W.active&&(W.port==="target"&&W.id===S.id||W.port==="source"&&W.validTarget&&W.target===S.id)),fe=x?.active&&x.validTarget?x.port==="source"&&x.target===S.id?x.id:x.port==="target"&&x.id===S.id?x.target:null:null,dt=c.constraints.find(W=>W.id===fe)?.name,nt=!!x?.active&&x.port==="source"&&!Ce&&!Ne&&!nr(c.constraints,S.id,x.id),it=fe?Zr(c.constraints,S.id,fe):S.derivative,He=Ce||Ne||!!S.value,ie=i(mi,{row:S,background:m.surface,constraints:fe?V.map(W=>W.id===S.id?{...W,parentId:fe,derivative:it}:W):V}),ct=W=>{if(!W){B(null),S.parentId?j({...c,constraints:Xn(c.constraints,S.id)}):tt(S.id,{value:""});return}let je=c.constraints.find(ot=>ot.name.toLowerCase()===W.replace(/^@/,"").toLowerCase());if(!je)throw Error("Choose an existing constraint");De(S.id,je.id)};return k(sa,{children:[S.typographyRole&&we[Se-1]?.typographyRole!==S.typographyRole&&i("h4",{className:"tc-type-role","data-typography-role":S.typographyRole,style:gn,children:S.typographyRole==="body"?"Body":"Heading"}),k("div",{"data-typography-role":S.typographyRole,className:"tc-row","data-constraint-id":S.id,onPointerEnter:()=>E(S.id),onPointerLeave:()=>E(null),onFocusCapture:()=>de(S.id),onBlurCapture:W=>{W.currentTarget.contains(W.relatedTarget)||de(null)},"data-proposal-status":l?S.value||S.parentId?"done":"pending":void 0,children:[S.typographyRole&&i(mn,{left:-8,color:`color-mix(in srgb, ${m.secondary} 40%, ${m.surface})`,last:we[Se+1]?.typographyRole!==S.typographyRole}),i("button",{type:"button",disabled:b,className:"tc-name","data-connection-active":Oe,"data-connection-rejected":X===S.id,"aria-label":`Drag ${S.name} to connect`,onPointerDown:W=>It(W,S.id,"source"),onPointerEnter:()=>A({id:S.id,port:"source"}),onPointerLeave:()=>A(null),children:i("span",{style:O?.port==="source"&&S.parentId===O.id?{color:"var(--tc-primary)"}:void 0,children:S.typographyRole?S.name.replace(`${S.typographyRole}-`,""):S.name})}),(b||l==="error")&&!S.value&&!S.parentId?i("span",{className:"tc-proposal-status",role:"status","data-state":"pending","aria-label":`${S.name}: ${l==="error"?"Not returned":"Pending"}`,children:l==="error"?"Not returned":"Pending"}):i("div",{inert:b,style:{display:"contents"},children:k(Nn,{className:"tc-value",label:`${S.name} expression`,onCommit:W=>{let[je="",ot,...Ze]=W.split("\u21C6");if(Ze.length)throw Error("Use one scale value");let[F="",Z,...ce]=je.split("\xD7");if(ce.length)throw Error("Use one multiplier or rotation");let ye={};if(F.trim().startsWith("@")){let le=F.trim().slice(1).trim(),Be=c.constraints.find(ne=>ne.name.toLowerCase()===le.toLowerCase());if(!Be)throw Error("Choose an existing constraint");let kt=nr(c.constraints,S.id,Be.id);if(kt)throw Error(kt);if(ye.parentId=Be.id,ye.derivative=Z===void 0?S.derivative:at(Z.trim().replace(/deg$/,"")),G==="layout"&&ye.derivative<0)throw Error("Use zero or a positive multiplier")}else{if(Z!==void 0)throw Error("A multiplier needs a source reference");F.trim()&&Qr(G,F.trim()),ye.value=F.trim(),ye.parentId=null}if(ot!==void 0&&(ye.scale=at(ot.trim())/(G==="color"?100:1),G==="layout"&&(S.scaleMode==="increment"?ye.scale<=0:ye.scale<0)))throw Error("Use a nonnegative growth rate or a positive weight increment");tt(S.id,ye)},onPointerEnter:()=>A({id:S.id,port:"target"}),onPointerLeave:()=>A(null),children:[Ce||Ne?k("span",{className:"tc-reference","data-connection-active":Ne,onContextMenu:W=>{S.parentId&&(W.preventDefault(),W.stopPropagation(),ct(""))},children:[i("button",{className:"tc-port","aria-label":`Connect ${S.name} to parent`,onPointerDown:W=>It(W,S.id,"target"),onClick:W=>{Me.current||W.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),i(st,{compact:!0,label:`${S.name} parent reference`,sourceSuggestions:oe,bareSource:!0,arrowNavigation:!0,value:dt??(Ce?Ve?.name??"":""),onCommit:ct})]}):k(Le,{children:[nt&&i("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"}),(!nt||!!S.value)&&i(st,{compact:!0,label:`${S.name} base value`,sourceSuggestions:oe,arrowNavigation:!0,value:S.value,onScrubPreview:W=>ge(W===null?null:{id:S.id,patch:{value:W}}),placeholder:"\u2013",scrub:G==="layout"?{step:1,min:0}:G==="color"?{step:1,compound:!0}:void 0,clearable:!0,onCommit:W=>{W.startsWith("@")?ct(W):(W&&Qr(G,W),tt(S.id,{value:W}))}})]}),G!=="font"&&(Ce||Ne)&&k(Le,{children:[i("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" \xD7 ",children:i(Ct,{size:12})}),i(st,{compact:!0,label:`${S.name} derivative`,arrowNavigation:!0,onScrubPreview:W=>ge(W===null?null:{id:S.id,patch:{derivative:Number(W.replace(/deg$/,""))}}),decimal:G==="layout",scrub:G==="color"?{step:1,shiftStep:5}:{step:.01,min:0},value:G==="color"?`${it}deg`:it.toFixed(2),onCommit:W=>{let je=at(G==="color"?W.replace(/deg$/,""):W);if(G==="layout"&&je<0)throw Error("Use zero or a positive multiplier");tt(S.id,{derivative:je})}})]}),G!=="font"&&He&&k(Le,{children:[i("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" \u21C6 ",children:i(nn,{size:12})}),i(st,{compact:!0,label:`${S.name} scaling`,title:G==="color"?"OKLCH lightness points per step":S.scaleMode==="increment"?"Weight units per step":"Growth per step: 0.75 means +75%; stepped results round to the nearest whole number",arrowNavigation:!0,onScrubPreview:W=>ge(W===null?null:{id:S.id,patch:{scale:Number(W)/(G==="color"?100:1)}}),decimal:G==="color"?1:S.scaleMode!=="increment",scrub:S.scaleMode==="increment"?{step:1,min:1,shiftStep:5}:G==="color"?{step:.1,shiftStep:.5}:{step:.01,min:0},value:G==="layout"&&S.scaleMode!=="increment"?S.scale.toFixed(4).replace(/0{1,2}$/,""):(S.scale*(G==="color"?100:1)).toFixed(G==="color"?1:S.scaleMode==="increment"?0:2),onCommit:W=>{let je=at(W)/(G==="color"?100:1);if(G==="layout"&&(S.scaleMode==="increment"?je<=0:je<0))throw Error("Use a nonnegative growth rate or a positive weight increment");tt(S.id,{scale:je})}})]}),G==="color"&&ie]})})]},S.id)]},S.id)})]},w)}),k("section",{"aria-label":"Ad-hoc tokens",inert:b,children:[i("h3",{children:"Tokens"}),c.tokens.filter(w=>!u||u.tokenIds.includes(w.id)).map(w=>{let U=`token:${w.id}`,_=qt(w.value,c.constraints),S=x?.port==="source"?x.target:x?.id,Se=x?.active&&x.validTarget&&S&&xt(S).row===U?x.port==="source"?x.id:x.target:null,we=c.constraints.find(F=>F.id===Se),G=we?Pr(w.value,we,c.constraints,xt(S).index,xt(S).dimensionIndex)??w.value:J?.id===w.id?J.value:w.value,oe=qt(G,c.constraints),Ve=!!rr(G),Ce=Dr(G,c.constraints),Oe=F=>ve.some(Z=>Z.active&&(Z.port==="target"?Z.id===F:Z.validTarget&&Z.target===F)),Ne=x?.active&&x.port==="source"&&c.constraints.find(F=>F.id===x.id)?.kind==="layout"?(Ce?.dimensions??[]).flatMap((F,Z)=>F.referenceIndex===void 0&&!oe.some(ce=>ce.start>=F.start&&ce.end<=F.end)?[{...F,index:Z}]:[]):[],fe=x?.active&&x.port==="source"&&!Oe(U)&&!ze(U,x.id),dt=fe?Xr(G,c.constraints).find(F=>!F.reference):void 0,nt=dt&&(dt.start>0||dt.end<G.length)?dt:void 0,it=i("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"},"available"),He=(F,Z)=>{let ce=_[F];return ce?w.value.slice(0,ce.start)+Z+w.value.slice(ce.end):Z},ie=(F,Z)=>{let ce={..._[F]??oe[F],...Z};return He(F,`@${ce.name}${ce.step===null||ce.step===0?"":`: ${ce.step}`}${ce.opacity===void 0?"":` / ${ce.opacity}`}`)},ct=(F,Z)=>{let ce=Ce?.dimensions.findIndex((ee,Re)=>ee.start===F.start&&Oe(`${U}:dim:${Re}`)),ye=we?.kind==="color"&&S===U&&Xr(w.value,c.constraints)[0]?.start===F.start?U:ce!==void 0&&ce>=0?`${U}:dim:${ce}`:Ve?U:`${U}:ref:${Z}`,le=Ve?w.name:`${w.name} mention ${Z+1}`,Be=c.constraints.find(ee=>ee.name.toLowerCase()===F.name.toLowerCase()),kt=Oe(ye)||Oe(U),ne=ae?.id===w.id&&ae.index===Z?ae:null,ut=!!ne||F.step!==null&&F.step!==0||J?.id===w.id&&_[Z]?.step!=null&&_[Z]?.step!==0;return k("span",{className:"tc-reference","data-connection-id":ye,"data-connection-active":kt,onBlur:ee=>{ne&&!ee.currentTarget.contains(ee.relatedTarget)&&he(null)},onPointerEnter:()=>A({id:ye,port:"target"}),onPointerLeave:()=>A(null),onContextMenu:ee=>{ee.preventDefault(),ee.stopPropagation(),B(null);let Re=_[Z],St=Re&&br(c.constraints,w.value.slice(Re.start,Re.end));We(w.id,He(Z,Re?.math?tn(`calc(${w.value.slice(Re.start,Re.end)})`,c.constraints)?.css??"":St?mt(St):""))},children:[i("button",{className:"tc-port","aria-label":`Connect ${le} to constraint`,onPointerDown:ee=>It(ee,ye,"target"),onClick:ee=>{Me.current||ee.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),i(st,{compact:!0,label:`${le} reference`,sourceSuggestions:c.constraints.filter(ee=>!ze(ye,ee.id)).sort((ee,Re)=>+(Re.kind===Be?.kind)-+(ee.kind===Be?.kind)).map(ee=>ee.name),bareSource:!0,arrowNavigation:!0,value:ne?.name??F.name,onDraftChange:ee=>{if(ut||!ee.endsWith(":"))return!1;let Re=ee.slice(0,-1).trim().replace(/^@/,"");return rr(`@${Re}`)?(he({id:w.id,index:Z,name:Re}),!0):!1},onCommit:ee=>{if(!ee){We(w.id,He(Z,""));return}let Re=rr(ee.startsWith("@")?ee:`@${ee}`);if(!Re)throw new Error("Use a source name with an optional : step");We(w.id,ie(Z,{name:Re.name,...ee.includes(":")?{step:Re.step}:{},...ee.includes("/")?{opacity:Re.opacity}:{}}))}}),ut&&k(Le,{children:[k("span",{"aria-hidden":"true",children:[":","\xA0"]}),i(st,{compact:!0,className:"tc-token-step",label:`${le} step`,arrowNavigation:!0,value:ne||F.step===null?"":String(F.step),placeholder:"step",autoFocus:!!ne,onCancel:()=>he(null),scrub:{step:1,defaultValue:0},onScrubPreview:ee=>pe(ee===null?null:{id:w.id,value:ie(Z,{...ne?{name:ne.name}:{},step:at(ee)})}),onCommit:ee=>{We(w.id,ie(Z,{...ne?{name:ne.name}:{},step:ee?at(ee):null})),he(null)}})]}),(Be?.kind==="color"||F.opacity!==void 0)&&k(Le,{children:[k("span",{className:"tc-opacity-separator","aria-hidden":"true",children:[" ","/"," "]}),i(st,{compact:!0,label:`${le} opacity`,arrowNavigation:!0,className:"tc-token-opacity",value:F.opacity??"1",scrub:{step:F.opacity?.endsWith("%")?1:.01,min:0,max:F.opacity?.endsWith("%")?100:1,shiftStep:F.opacity?.endsWith("%")?5:.05},onScrubPreview:ee=>pe(ee===null?null:{id:w.id,value:ie(Z,{opacity:ee})}),onCommit:ee=>{if(ee&&ea(ee)===null)throw Error("Use opacity from 0 to 1, or 0% to 100%");We(w.id,ie(Z,{opacity:ee||void 0}))}})]})]},Z)},W=[],je=(F,Z)=>{if(Z<=F)return;let ce=F,ye=[...nt?[{...nt,index:-1,dimension:"color"}]:[],...Ne].filter(le=>le.start>=F&&le.start<Z).sort((le,Be)=>le.start-Be.start);for(let le of ye)ot(ce,le.start),le.index===-1?(W.push(it),ce=le.start):(W.push(k("span",{className:"tc-shadow-dimension","data-connection-id":`${U}:dim:${le.index}`,"data-shadow-dimension":le.dimension,children:[it,i("button",{className:"tc-literal","aria-label":`Edit ${w.name} ${le.dimension}`,onClick:()=>H(w.id),children:G.slice(le.start,le.end)})]},`dimension-${le.index}`)),ce=le.end);ot(ce,Z)},ot=(F,Z)=>{if(Z<=F)return;let ce=ye=>G.slice(0,F)+ye+G.slice(Z);W.push(i(fi,{className:`tc-literal${Z===nt?.start?" tc-literal-prefix":""}`,label:`Edit ${w.name} value`,onEdit:()=>H(w.id),value:G.slice(F,Z),onPreview:ye=>pe(ye===null?null:{id:w.id,value:ce(ye)}),onCommit:ye=>We(w.id,ce(ye))},`text-${F}`))},Ze=0;return oe.forEach((F,Z)=>{je(Ze,F.start),W.push(ct(F,Z)),Ze=F.end}),je(Ze,G.length),k("div",{className:"tc-row","data-token-id":w.id,"data-token-value":G,children:[i(st,{label:`${w.name} name`,className:Fe.has(U)?"tc-derived-name-active":void 0,compact:!0,value:w.name,onDelete:u?void 0:()=>{B(null),j({...c,tokens:c.tokens.filter(F=>F.id!==w.id)})},onCommit:F=>{if(!F)throw Error("Give this token a name");j({...c,tokens:c.tokens.map(Z=>Z.id===w.id?{...Z,name:F}:Z)})}}),k(Nn,{className:"tc-value",label:`${w.name} expression`,onSelectionStart:()=>he(null),onCommit:F=>We(w.id,F),onPointerEnter:()=>A({id:U,port:"target"}),onPointerLeave:()=>A(null),children:[(oe.length>0||nt||Ne.length>0)&&Q!==w.id?i("span",{className:"tc-compound",onDoubleClick:F=>{F.target.closest("input, .tc-port")||H(w.id)},children:W}):k("span",{className:Oe(U)?"tc-reference":"tc-compound","data-connection-active":Oe(U),children:[fe&&!nt&&it,i(st,{compact:!0,label:`${w.name} value`,sourceSuggestions:c.constraints.map(F=>F.name),scrub:{step:1,shiftStep:5,compound:!0},onScrubPreview:F=>pe(F===null?null:{id:w.id,value:F}),clearable:!0,autoFocus:Q===w.id,value:G,placeholder:"\u2013",onCommit:F=>{We(w.id,F),H(null)}})]}),i(gi,{value:G,background:m.surface,constraints:V,name:w.name})]})]},w.id)}),!u&&k("button",{className:"tc-add-token","aria-label":"Add token",onClick:()=>j({...c,tokens:[...c.tokens,{id:Ae(),name:`Token ${c.tokens.length+1}`,value:""}]}),children:[i(Ut,{size:12}),"Add token"]})]}),h,(g||Ye)&&i("p",{role:"status",style:{margin:0,padding:10,borderRadius:8,background:m.control,textAlign:"center"},children:g||Ye})]}),C,d?k("div",{className:"tc-proposal-recovery",children:[k("p",{role:"alert",children:[d.message," Values already received are kept above."]}),k("nav",{"aria-label":"Proposal recovery",children:[i("button",{type:"button",onClick:d.onRetry,children:"Retry"}),i("button",{type:"button",onClick:d.onTemplate,children:"Use template"})]})]}):u?null:i("button",{className:"tc-save",disabled:y,onClick:()=>b?o():f?f(c):$("Prototype only \u2014 your taste has not been saved"),children:b?"Cancel proposal":y?"Saving\u2026":"Save this taste"}),i(hi,{pane:p,edges:ue,visible:me.map(w=>({parent:w.id,child:w.target})),suspended:!!x||!!L,revision:JSON.stringify([c,te,J,Q,x?.id,x?.target,x?.validTarget]),color:m.primary}),(x?[x]:L?[L]:[]).filter(w=>w.active).map(w=>i(vi,{drag:w,pane:p,color:m.primary},`${w.id}:${w.target}`))]})}function yi(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 s=t;s;s=s.parentElement){let l=r.getComputedStyle(s);if(l.display==="none"||l.visibility==="hidden"||l.visibility==="collapse")return!1;if(s!==t){let a=s.getBoundingClientRect();if(/(auto|scroll|hidden|clip)/.test(l.overflowY)&&(n.top<a.top||n.bottom>a.bottom)||/(auto|scroll|hidden|clip)/.test(l.overflowX)&&(n.left<a.left||n.right>a.right))return!1}if(s===e)break}let o=e.querySelector(".tc-dimension-preview");if(o){let s=o.getBoundingClientRect();if(s.width>0&&s.height>0&&n.bottom>s.top-16&&n.top<s.bottom+4&&n.right>s.left-4&&n.left<s.right+4)return!1}return!0}function bi(e,t){if(!t)return e.querySelector("[data-taste-editor] header");let r=t.kind==="dimension"?"data-constraint-id":"data-token-id";return[...e.querySelectorAll(`[${r}]`)].find(n=>n.getAttribute(r)===t.id)??null}function wi({root:e,session:t,visible:r=!0}){let n=wr(t.subscribeLook,t.getLookSnapshot,t.getLookSnapshot),[o,s]=T(null);return Pe(()=>{let l=e.current;if(!r||!l||!n||n.expiresAt<=Date.now()){s(null);return}let a=l.ownerDocument.defaultView,d,h=()=>{if(n.expiresAt<=Date.now()){s(null);return}let u=bi(l,n.target),f=u&&yi(l,u)?u:null;f instanceof HTMLElement&&ia(f,f),s(y=>y?.lookId===n.id&&y.element===f?y:{lookId:n.id,element:f}),d=a.requestAnimationFrame(h)};return h(),()=>a.cancelAnimationFrame(d)},[e,n,r]),!r||!n||o?.lookId!==n.id||!o.element||n.expiresAt<=Date.now()?null:i(Yr,{element:o.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 xi(e,t){t=Vt(t,e);let r=new Map,n=s=>{let l=t.constraints.find(a=>a.id===s);return l?l.parentId?`@${t.constraints.find(a=>a.id===l.parentId)?.name??l.parentId}${l.kind==="font"?"":l.kind==="color"?` \xB7 hue ${l.derivative}\xB0`:` \xD7 ${l.derivative}`}`:l.value:"Missing dimension"},o=s=>{let l=s.children.filter(a=>typeof a=="string").join(" ").trim();for(let[a,d]of Object.entries(s.styles)){let h=`${d.kind}:${d.id}:${d.step??0}`,u=r.get(h);if(!u){let y=d.kind==="token"?t.tokens.find(m=>m.id===d.id):void 0,g=d.kind==="dimension"?t.constraints.find(m=>m.id===d.id):void 0,C=[],c=new Set(d.kind==="dimension"?[d.id]:[]),b=m=>{if(c.has(m))return;c.add(m);let p=t.constraints.find(N=>N.id===m);if(!p)return;let v="Unresolved";try{v=mt(Tt(t.constraints,m))}catch{}C.push({id:m,name:p.name,expression:n(m),value:v}),p.parentId&&b(p.parentId)};y&&qt(y.value,t.constraints).forEach(m=>{let p=t.constraints.find(v=>v.name===m.name);p&&b(p.id)}),g?.parentId&&b(g.parentId),u={key:h,source:d,name:y?.name??g?.name??d.id,expression:y?.value??n(d.id),derived:C.length>0,dependencies:C,values:[],targets:[]},r.set(h,u)}let f=Yt(t,d,a)??"Unresolved";u.values.includes(f)||u.values.push(f),u.targets.push({nodeId:s.id,label:l.slice(0,64)||`${s.tag} \xB7 ${s.id}`,property:a})}s.children.forEach(a=>{typeof a!="string"&&o(a)})};return o(e.root),[...r.values()]}function ki({fragment:e,draft:t,theme:r,onBack:n,onChange:o}){let s=D(null),[l,a]=T(null),d=xi(e,t),h=[...new Set(d.flatMap(c=>[...c.source.kind==="dimension"?[c.source.id]:[],...c.dependencies.map(b=>b.id)]))],u=d.filter(c=>c.source.kind==="token").map(c=>c.source.id),f=d.filter(c=>l&&(c.source.kind===l.kind&&c.source.id===l.id||l.kind==="dimension"&&c.dependencies.some(b=>b.id===l.id))).flatMap(c=>c.targets.map(b=>b.nodeId)),y=[],g=c=>{let b=Object.entries(c.localStyles??{});b.length&&y.push({id:c.id,entries:b}),c.children.forEach(m=>{typeof m!="string"&&g(m)})};g(e.root),se(()=>{s.current?.querySelector("button")?.focus()},[e.id]);let C=Qe[r];return i("section",{ref:s,"aria-label":`${e.name} details`,"data-fragment-detail":!0,"data-popmelt-panel":!0,style:{position:"absolute",inset:0,display:"flex"},children:i(An,{draft:Vt(t,e),theme:r,onBack:n,style:{flex:1,minHeight:0,border:0,maxHeight:"100%"},onChange:c=>{let b=new Set((e.tokens??[]).map(m=>m.id));o({...t,constraints:c.constraints,tokens:c.tokens.filter(m=>!b.has(m.id)),fragments:t.fragments?.map(m=>m.id===e.id?{...m,tokens:c.tokens.filter(p=>b.has(p.id))}:m)})},detail:{name:e.name,constraintIds:h,tokenIds:u,onHover:a,preview:c=>i("div",{style:{position:"sticky",top:16,zIndex:1,flexShrink:0,borderRadius:8,background:C.control},children:i(ir,{fragment:{...e,tokens:[]},draft:c,height:240,highlightedNodes:f})})},fragments:k(Le,{children:[i("button",{type:"button","aria-pressed":t.featuredComponentId===e.id,onClick:()=>o({...t,featuredComponentId:e.id}),children:t.featuredComponentId===e.id?"Featured preview":"Use as preview"}),k("details",{children:[i("summary",{children:"Affected parts"}),d.map(c=>k("details",{"data-fragment-use":c.key,children:[k("summary",{children:[c.name,c.source.step?`: ${c.source.step}`:""," \xB7"," ",new Set(c.targets.map(b=>b.nodeId)).size," ","parts"]}),c.targets.map(b=>k("div",{children:[b.label," \xB7 ",b.property]},`${b.nodeId}:${b.property}`))]},c.key))]}),y.length>0&&k("details",{children:[i("summary",{children:"Local structure"}),y.map(c=>k("section",{children:[i("h3",{children:c.id}),c.entries.map(([b,m])=>k("div",{className:"tc-row",children:[i("span",{className:"tc-name",children:b}),i("span",{className:"tc-value",children:m})]},b))]},c.id))]})]})})})}function Si(e){let t=D(null),[r,n]=T(null),o=D(null),[s]=T(()=>{let b=vr(e.draft);return e.draft||b.create("extract"),b}),l=e.session??s,a=wr(l.subscribe,l.getSnapshot,l.getSnapshot),{draft:d,state:h,message:u,runId:f}=a,y=d?.fragments?.find(b=>b.id===r);Pe(()=>{y||o.current?.isConnected&&(o.current.focus({preventScroll:!0}),o.current=null)},[y]);let g=D(e.onDraft),C=D(null);g.current=e.onDraft,se(()=>{if(l.getSnapshot().state!=="running")return;let b=Symbol();C.current=b;let m=x=>l.stream(f,{draft:x}),p=x=>l.stream(f,{state:x}),v=x=>l.stream(f,{message:x}),N=new AbortController,M=setTimeout(()=>{v("This is taking longer than expected. Please try again or use the template."),p("error"),N.abort()},19e4),j=!1,q;return(async()=>{try{if(await Promise.resolve(),N.signal.aborted)return;if(!e.bridgeUrl)throw Error("Connect the local bridge to propose a taste.");let x=ti(),P=await Ie(`${e.bridgeUrl}/cloud-taste/propose`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:N.signal});if(!P.ok)throw Error((await P.json().catch(()=>null))?.error||`Taste proposal unavailable (${P.status}).`);if(!P.body)throw Error("The bridge returned no proposal stream.");let L=P.body.getReader(),B=new TextDecoder,O="",A=I=>{if(!I.trim()||N.signal.aborted)return;let E=JSON.parse(I);if(E.type==="status"&&v(E.message),E.type==="error")throw q=E.message,Error(E.message);E.type==="progress"?m(E.draft):E.type==="complete"&&(j=!0,m(E.draft),g.current(E.draft),p("complete"))};try{for(;;){let{value:I,done:E}=await L.read();if(E)break;if(O+=B.decode(I,{stream:!0}),O.length>256e3)throw Error("The proposal stream is too large.");let K;for(;(K=O.indexOf(`
180
- `))!==-1;)A(O.slice(0,K)),O=O.slice(K+1)}A(O+B.decode())}finally{L.releaseLock()}if(!j&&!N.signal.aborted)throw Error("The proposal ended before all dimensions were returned.")}catch(x){N.signal.aborted||(v(q??(x instanceof Error&&/template|dimensions were returned/.test(x.message)?x.message:"We couldn\u2019t finish the proposal. Please try again or use the template.")),p("error"),N.abort())}finally{clearTimeout(M)}})(),()=>{clearTimeout(M),N.abort(),Promise.resolve().then(()=>{C.current===b&&l.stream(f,{state:"error",message:"Extraction stopped. Retry or continue editing the partial draft."})})}},[e.bridgeUrl,f,l]);let c=Qe[e.theme];return k("div",{ref:t,style:{...e.style,display:"flex",flexDirection:"column",background:c.surface,color:c.primary,fontFamily:Ft,borderRadius:20,overflow:"hidden",position:"relative",minHeight:0},children:[i("div",{inert:!!y||e.saving,style:{display:"flex",flex:1,minHeight:0,visibility:y?"hidden":void 0,opacity:y?0:void 0},children:i(An,{history:l.history,theme:e.theme,draft:d??_r(),onChange:b=>{l.edit(b),e.onDraft(b)},onBack:e.onBack,onSave:e.onSave,saving:e.saving,saveNotice:e.saveNotice,saveAction:e.saveAction,proposalState:h==="idle"?"complete":h,preferPageComponent:a.mode==="extract",fragments:i(Aa,{draft:d??_r(),session:l,bridgeUrl:e.bridgeUrl,theme:e.theme,visible:e.visible!==!1&&!e.saving,onDraft:e.onDraft,onInspect:b=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,n(b)}},f),proposalRecovery:h==="error"?{message:u,onRetry:()=>{l.create("extract")},onTemplate:e.onTemplate}:void 0,style:{flex:1,minHeight:0,border:0}},f)}),y&&d&&i(ki,{fragment:y,draft:d,theme:e.theme,onBack:()=>n(null),onChange:b=>{l.edit(b),e.onDraft(b)}},y.id),i(wi,{root:t,session:l,visible:e.visible})]})}var ur="popmelt:taste-recovery:v1:",Zt=e=>typeof e=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),Ci=e=>Number.isSafeInteger(e)&&Number(e)>=0;function Fr(e){if(!(!Zt(e.accountId)||!["production","staging"].includes(String(e.environment))||typeof e.projectKey!="string"||!e.projectKey||e.projectKey.length>256))return JSON.stringify([e.environment,e.accountId,e.projectKey])}function zn(e,t){if(!e||typeof e!="object")return;let r=e;if(!(r.version!==1||r.scope!==t||!Zt(r.key)||!Zt(r.id)||!Ci(r.revision)||!Number.isFinite(r.updatedAt)||!$t(r.document))&&!(r.pending!==null&&(!r.pending||r.pending.id!==r.id||r.pending.expectedRevision!==r.revision||!Zt(r.pending.requestId)||!$t(r.pending.document))))return r}function Dn(e,t=localStorage){let r=[];for(let n=0;n<t.length;n++){let o=t.key(n);if(!o?.startsWith(ur))continue;let s=t.getItem(o);if(!(!s||s.length>45e5))try{let l=zn(JSON.parse(s),e);l&&o===ur+l.key&&r.push(l)}catch{}}return r.sort((n,o)=>o.updatedAt-n.updatedAt)}function Pn(e,t=localStorage){if(!zn(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(ur+e.key,r)}function jn(e,t=localStorage){if(!Zt(e))throw Error("Invalid recovery key");t.removeItem(ur+e)}function Ri({theme:e,records:t,onResume:r}){let n=Qe[e];return t.length?k("section",{"aria-label":"Unsaved tastes","data-taste-recovery":!0,style:{display:"flex",flexDirection:"column",gap:8,marginBottom:24,color:n.secondary},children:[i("style",{children:`
181
- [data-taste-recovery] button:focus-visible {
182
- outline: 2px solid ${n.primary};
183
- outline-offset: 4px;
184
- }
185
- [data-taste-recovery] button:hover [data-recovery-name],
186
- [data-taste-recovery] button:focus-visible [data-recovery-name] {
187
- color: ${n.primary};
188
- }
189
- `}),i("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",letterSpacing:"-.12px"},children:"Unsaved"}),i("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:16},children:t.map(o=>{let s=o.name||"Untitled Taste",l=o.preview?.savedDocument?.document;return k("li",{style:{minWidth:0,position:"relative"},children:[i("div",{"aria-hidden":"true",inert:!0,style:{position:"relative",height:104,overflow:"hidden",borderRadius:8,background:n.control},children:l?.draft.featuredComponentId?i(Mr,{document:l}):o.preview?i(Lr,{recipe:o.preview}):null}),k("button",{type:"button","aria-label":`View ${s} details`,title:`Resume ${s}`,onClick:()=>r(o.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:[i("span",{"data-recovery-name":!0,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:s}),i("span",{style:{flexShrink:0,color:n.muted},children:o.pending?"Save unconfirmed":"Draft"})]})]},o.key)})})]}):null}function Ei({theme:e,pending:t,disabled:r=!1,onDiscard:n}){let o=Qe[e];return k("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"8px 16px",fontSize:12},children:[i("p",{style:{margin:0,color:o.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."}),i("button",{type:"button",disabled:r,onClick:n,style:{font:"inherit",color:o.primary,background:o.control,padding:8,border:0,borderRadius:8,cursor:r?"default":"pointer",opacity:r?.5:1},children:"Discard draft"})]})}var Bn=new WeakMap;function Wr(e){let[t,r]=T(!1),[n,o]=T(null),[s,l]=T(!1),[a,d]=T(!1),[h,u]=T(null),[f,y]=T(null),g=D({}),C=Qe[e.theme],c=D(!1),b=()=>{let x=e.session??g.current,P=e.session?.getSnapshot().runId??"",L=Bn.get(x);return(!L||L.runId!==P)&&(L={runId:P,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},Bn.set(x,L)),L},m=(x,P)=>{x.recoveryScope&&(Pn({version:1,key:x.recoveryKey,scope:x.recoveryScope,updatedAt:Date.now(),id:x.id,revision:x.revision,document:P,pending:x.pending}),e.onRecoveryChange?.())},p=x=>{x.recoveryScope&&(jn(x.recoveryKey),e.onRecoveryChange?.())},v=D(()=>{});v.current=()=>{if(!e.recoveryScope)return;let x=e.session?.getSnapshot(),P=x?.draft??e.draft;if(!P||x?.state==="running")return;let L;try{L=Tr(P)}catch{return}try{let B=b();if(B.recoveryScope&&B.recoveryScope!==e.recoveryScope)return;B.recoveryScope=e.recoveryScope,!B.pending&&!e.recovery&&e.saved&&bt(L)===bt(e.saved.document)?p(B):m(B,L),y(null)}catch{y("Browser recovery storage is unavailable. Keep this tab open until a remote save is confirmed.")}},se(()=>(v.current(),e.session?.subscribe(()=>v.current())),[e.session,e.recoveryScope,e.draft]);let N=async x=>{if(!(c.current||!e.bridgeUrl)){c.current=!0,r(!0),o(null);try{let P=Tr(x),L=b(),B=await Ie(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"});if(!B.ok)throw Error("Could not check the remote connection. Your draft is kept.");let O=await B.json(),A=Fr(O);if(L.recoveryScope&&A!==L.recoveryScope)throw Error("The connected account, project, or environment changed. Reconnect the original account to save this draft.");if(O.canSave!==!0)throw l(!0),Error("Enable remote saving to save this private Taste to your Popmelt account.");l(!1);let I=JSON.stringify([e.bridgeUrl,O.environment,O.accountId]);if(L.identity&&L.identity!==I)throw Error("The connected account or environment changed. Your draft and pending save are kept; reconnect the original account before retrying.");L.identity=I,L.recoveryScope??(L.recoveryScope=A);for(let E=0;E<2;E++){let K=L.pending??{id:L.id,expectedRevision:L.revision,requestId:crypto.randomUUID(),document:P};L.pending=K;try{m(L,P)}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 de=await Ie(`${e.bridgeUrl}/cloud-taste/document`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)}),Q=await de.json();if(!de.ok){Q.error==="revision_conflict"&&d(!0),Q.error==="reconnect_required"&&l(!0);let H={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(H,Q.error)?H[Q.error]:"Remote save failed. Your draft is kept; retry safely.")}if(Q.id!==K.id||Q.revision!==K.expectedRevision+1||!$t(Q.document)||bt(Q.document)!==bt(K.document))throw Error("Could not confirm the saved Taste. Your draft is kept; retry safely.");if(L.revision=Q.revision,L.pending=null,m(L,P),bt(K.document)===bt(P)){o("Saved privately to Popmelt. Not applied."),p(L),d(!1),e.onSaved(Q);return}}}catch(P){o(P instanceof Error?P.message:"Remote save failed. Your draft is kept.")}finally{c.current=!1,r(!1)}}},M=async()=>{try{let x=await Ie(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"}),P=await x.json(),L=b();if(!x.ok||L.recoveryScope&&Fr(P)!==L.recoveryScope)throw Error("Reconnect the original account to review this Taste.");let B=await Ie(`${e.bridgeUrl}/cloud-taste/document?id=${encodeURIComponent(L.id)}`,{cache:"no-store"}),O=await B.json();if(!B.ok||O.id!==L.id||!Number.isSafeInteger(O.revision)||O.revision<1||!$t(O.document))throw Error("Could not load the saved version. Your draft is kept.");u(O)}catch(x){o(x instanceof Error?x.message:"Could not review the saved version.")}},j=async()=>{try{let x=await Ie(`${e.bridgeUrl}/cloud-taste/creation-eligibility`,{cache:"no-store"});if(!x.ok||(await x.json()).activeSubscription!==!0)throw Error("An active subscription is required to save a new Taste.");let P=b(),L={...P,id:crypto.randomUUID(),revision:0,pending:null},B=e.session?.getSnapshot().draft??e.draft;if(!B)return;m(L,Tr(B)),Object.assign(P,L),d(!1),u(null),o("Your draft is now a new, unsaved Taste. Save explicitly to create the remote copy.")}catch(x){o(x instanceof Error?x.message:"Could not prepare a copy.")}},q={font:"inherit",color:C.primary,background:C.control,padding:8,border:0,borderRadius:8,cursor:"pointer"};return i(Si,{...e,onSave:x=>{a||N(x)},saving:t,saveNotice:n??f,saveAction:k(Le,{children:[e.recovery&&i(Ei,{theme:e.theme,pending:!!b().pending,disabled:t,onDiscard:()=>{if(!c.current)try{p(b()),e.onBack()}catch{o("Could not discard browser recovery. Your draft is kept.")}}}),a?k("div",{style:{padding:12,color:C.primary},children:[i("p",{children:"Your draft is retained. Review the saved version before choosing what to keep."}),i("button",{style:q,onClick:()=>{M()},children:"Review saved version"}),h&&k(Le,{children:[k("p",{children:["Saved revision ",h.revision," \xB7"," ",h.document.draft.name]}),i(Cn,{draft:h.document.draft,theme:e.theme,preferPageComponent:!0}),i("button",{style:q,onClick:()=>{try{let x=b();x.id=h.id,x.revision=h.revision,x.pending=null,e.session?.edit(h.document.draft),p(x),d(!1),u(null),e.onSaved(h)}catch{o("Could not discard the recovery record. Your draft is kept.")}},children:"Discard my edits and load saved version"}),i("button",{style:q,onClick:()=>{j()},children:"Keep my draft as a new Taste"})]})]}):s?i("button",{type:"button",onClick:e.onEnableSaving,style:{font:"inherit",color:C.primary,background:C.control,padding:8,border:0,borderRadius:8,cursor:"pointer"},children:"Enable remote saving"}):void 0]})})}var $i=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=Ie(e,{signal:r.abort.signal}).then(async n=>{if(n.ok){let o=await n.clone().json();if(!o.sections||!Array.isArray(o.overrides))throw new Error("Invalid taste definition");this.entries.get(e)===r&&(r.response=n.clone(),r.expires=Date.now()+6e4)}else this.entries.get(e)===r&&this.entries.delete(e);return n}).catch(n=>{throw this.entries.get(e)===r&&this.entries.delete(e),n}).finally(()=>{r.pending=void 0}),(await r.pending).clone()}},Ii={principles:"tokens",components:"components",assets:"visual-directions",content:"copy-guidance"};function Ni(e,t,r){if(t.kind==="search")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(o=>o.getAttribute("data-taste-entry-id")===n)??null;if(r.detailEntryId!==n)return null;if(t.kind==="path"&&r.drilldownVisible&&Ii[t.path[0]??""]===r.drilldown){let o=e.querySelector('[data-taste-layer="drilldown"]'),s=[...o?.querySelectorAll("[data-taste-path]")??[]].find(l=>l.getAttribute("data-taste-path")===JSON.stringify(t.path));if(s)return s;if(t.path.length>=2){let l=[...o?.querySelectorAll("[data-taste-group-path]")??[]].find(a=>a.getAttribute("data-taste-group-path")===JSON.stringify(t.path.slice(0,2)));if(l)return l}}return e.querySelector("[data-taste-nav-title]")}var Fn=e=>typeof e=="string"&&e.length>0&&e.length<=200&&!["__proto__","prototype","constructor"].includes(e);function Ti(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid Taste looking target");let t=e;if(t.kind==="search"&&typeof t.query=="string"&&t.query.length<=200)return{kind:"search",query:t.query};if((t.kind==="taste"||t.kind==="path")&&(t.collection==="public"||t.collection==="private")&&Fn(t.id)){let r={collection:t.collection,id:t.id};if(t.kind==="taste")return{kind:"taste",...r};if(Array.isArray(t.path)&&t.path.length>=1&&t.path.length<=12&&t.path.every(Fn)&&["principles","components","assets","content"].includes(t.path[0]??""))return{kind:"path",...r,path:[...t.path]}}throw new Error("Invalid Taste looking target")}var qr=(e,t)=>`${e}:${t}`;function Li(e){let t=D(e.onDirectionChange);t.current=e.onDirectionChange;let[r,n]=T([]),o=D(null),s=D(null),[l,a]=T(0),[d,h]=T(!1),[u,f]=T(null),[y,g]=T(!1),[C,c]=T(!1),b=wr(Xe.subscribe,Xe.getSnapshot,Xe.getSnapshot),m=b.open,[p,v]=T(null),N=D(new Map),{onEditorVisibilityPinChange:M,visible:j}=e;Pe(()=>(M?.((m||!!p)&&j!==!1),()=>M?.(!1)),[m,p,j,M]);let q=D(null),[x,P]=T(null),[L,B]=T(null),[O,A]=T(),I=()=>{let R=q.current?.offsetHeight;R&&A(R),c(!0)},[E,K]=T(!1),de=D(null),Q=D(null),H=D(!1);se(()=>{C?de.current?.focus({preventScroll:!0}):H.current&&Q.current?.focus({preventScroll:!0}),H.current=C},[C]);let ae=()=>{c(!1),ue("")},[he,ue]=T(""),me=D(void 0);se(()=>()=>clearTimeout(me.current),[]);let[Fe,ve]=T(),[Me,Ye]=T(!1),[$,te]=T(null),ge=D(void 0),J=R=>{clearTimeout(ge.current),te(e.visible===!1?null:R),ge.current=setTimeout(()=>te(null),200)};se(()=>{e.visible===!1&&(clearTimeout(ge.current),te(null))},[e.visible]),se(()=>()=>clearTimeout(ge.current),[]);let pe=D(void 0);se(()=>()=>clearTimeout(pe.current),[]);let[V,xe]=T(null),X=!!V&&d,[Ke,Je]=T(!1),[qe,Ae]=T(null),[tt,We]=T(),ze=tt!==void 0?tt:qe?.direction,De=ze?qr(ze.sourceCollection,ze.sourceModelId):null,[rt,It]=T(!1),[pr,hr]=T(!1),[at,w]=T(!1),U=D(null);se(()=>()=>U.current?.abort(),[]);let[_,S]=T(!1),[Se,we]=T(!0),[G,oe]=T("Loading collection\u2026"),[Ve,Ce]=T(0),[Oe,Ne]=T(0),[fe,dt]=T(),[nt,it]=T([]),He=rn(()=>{try{it(fe?Dn(fe):[])}catch{it([])}},[fe]);se(()=>{He();let R=()=>He();return window.addEventListener("storage",R),window.addEventListener("focus",R),()=>{window.removeEventListener("storage",R),window.removeEventListener("focus",R)}},[He]),se(()=>{p&&p.record.scope!==fe&&v(null)},[p,fe]);let ie=e.bridgeUrl;se(()=>{let R=new AbortController;return w(!1),Xe.setCreationAllowed(!1),ie&&Ie(`${ie}/cloud-taste/creation-eligibility`,{signal:R.signal,cache:"no-store"}).then(async z=>{let Y=z.ok?await z.json():null;if(R.signal.aborted)return;let re=Y?.activeSubscription===!0;w(re),Xe.setCreationAllowed(re)}).catch(()=>{}),()=>{R.abort(),Xe.setCreationAllowed(!1)}},[ie,Ve,Oe]);let ct=async(R,z=!1)=>{let Y=le.current;try{let re=await Ie(`${ie}/cloud-taste/creation-eligibility`,{cache:"no-store"}),be=re.ok?await re.json():null;if(Y!==le.current)return;let ke=be?.activeSubscription===!0;if(w(ke),Xe.setCreationAllowed(ke),!ke)return;ae(),Xe.create(R,z)}catch{if(Y!==le.current)return;w(!1),Xe.setCreationAllowed(!1)}},W=D(0),je=D(!1),ot=D(""),Ze=D([]),F=D(void 0),Z=D(void 0),ce=D(!1),ye=D(0),le=D(0);se(()=>{if(!ie||e.visible===!1){P(null);return}let R=!0,z=!1,Y=async()=>{if(!z){z=!0;try{let be=await Ie(`${ie}/cloud-taste/agent-look`,{cache:"no-store"}),ke=await be.json();R&&P(be.ok&&ke.status==="looking"&&ke.expiresAt>Date.now()?Ti(ke.target):null)}catch{R&&P(null)}finally{z=!1}}};Y();let re=setInterval(()=>{Y()},750);return()=>{R=!1,clearInterval(re)}},[ie,e.visible]);let Be=Ot(()=>({bridgeUrl:ie,revision:Ve,cache:new $i}),[ie,Ve]).cache;se(()=>{let R=q.current;if(!R||!x||e.visible===!1){B(null);return}let z=()=>{let re=Ni(R,x,{searchOpen:C,showingDetail:X,detailEntryId:V?.id??null,drilldown:u,drilldownVisible:y});B(be=>be===re?be:re)};z();let Y=new MutationObserver(z);return Y.observe(R,{childList:!0,subtree:!0}),()=>Y.disconnect()},[x,V,u,y,e.visible,C,X]),se(()=>()=>Be.clear(),[Be]);let[,kt]=T(0),ne=Ot(()=>({bridgeUrl:ie,revision:Ve,requests:new Map}),[ie,Ve]).requests;se(()=>()=>{for(let R of ne.values())R.abort.abort();ne.clear()},[ne]);let ut=rn(R=>{let z=ne.get(R.id);if(z&&(z.fetchedAt===void 0||Date.now()-z.fetchedAt<3e4))return z.promise;let Y=new AbortController,[re="",be=""]=R.id.split(":"),ke={preview:z?.preview,facts:z?.facts,abort:Y,promise:Promise.resolve([])};return ke.promise=(async()=>{if(!ie)throw Error("Connection unavailable.");if(R.documentRevision){let Ee=await Ie(`${ie}/cloud-taste/document?${new URLSearchParams({id:be})}`,{signal:Y.signal,cache:"no-store"});if(!Ee.ok)throw Error("Saved Taste unavailable.");let Ue=await Ee.json();if(Ue.id!==be||!Number.isSafeInteger(Ue.revision)||Ue.revision<1||!$t(Ue.document))throw Error("Invalid saved Taste.");return Y.signal.aborted||(ke.facts=[],ke.fetchedAt=Date.now(),ke.preview={...dr(Ue.document.draft,"dark"),savedDocument:Ue,contentRevision:String(Ue.revision)},kt(gt=>gt+1)),[]}let Bt=await Ie(`${ie}/cloud-taste/summary?${new URLSearchParams({id:be,collection:re})}`,{signal:Y.signal,cache:"no-store"});if(!Bt.ok)throw Error("Summary unavailable.");let lt=await Bt.json();if(!Array.isArray(lt.facts))throw Error("Summary unavailable.");if(!Y.signal.aborted){ke.facts=lt.facts,ke.fetchedAt=Date.now();let Ee=wt(lt.preview),Ue=Ze.current.find(gt=>gt.id===R.id)?.preview;ke.preview=Ue&&Ue!==R.preview||Ue&&(Ue.recipeRevision??0)>(Ee?.recipeRevision??0)?Ue:Ee,kt(gt=>gt+1)}return lt.facts})(),ne.set(R.id,ke),ke.promise.catch(()=>{ne.get(R.id)===ke&&(z?.preview||z?.facts?ne.set(R.id,z):ne.delete(R.id))}),ke.promise},[ie,ne]),[ee,Re]=T(null);se(()=>{let R=r.find(Y=>Y.id===De),z=[...R?[R]:[],...["private","public"].flatMap(Y=>r.filter(re=>re.sourceCollection===Y&&re.id!==De))].slice(0,20);for(let Y of z)Y.preview||ut(Y).catch(()=>{})},[De,r,ut]),se(()=>{if(!V||!ie)return;let R=!0;return Re({id:V.id,cache:ne,notice:"Loading details\u2026"}),(async()=>{try{let z=await ut(V);R&&Re({id:V.id,cache:ne,facts:z})}catch{R&&Re({id:V.id,cache:ne,notice:"Summary unavailable. Reopen this taste to retry."})}})(),()=>{R=!1}},[V,ie,ut,ne]),se(()=>{let R=()=>{W.current>0&&!je.current&&!ce.current&&Date.now()-W.current>=3e4&&Ne(Y=>Y+1)};if(R(),e.visible===!1)return;let z=setInterval(R,3e4);return window.addEventListener("focus",R),()=>{clearInterval(z),window.removeEventListener("focus",R)}},[e.visible,e.prefetchSignal]),se(()=>{let R=++le.current,z=ye.current,Y=new AbortController,re;je.current=!0;let be=`${ie}:${Ve}`,ke=ot.current===be&&Ze.current.length>0;ot.current=be,ke||(we(!0),Ae(null),We(void 0),It(!1),Je(!1),n([]),Ze.current=[]);async function Bt(){try{if(!ie)throw Error("Connection unavailable.");let lt=await Ie(`${ie}/cloud-taste/status`,{signal:Y.signal,cache:"no-store"});if(!lt.ok)throw Error("Connection unavailable.");let Ee=await lt.json();if(R!==le.current)return;if(Ee.pending){oe("Complete sign-in in the browser."),re=setTimeout(Bt,1e3);return}if(Ee.state!=="signed_in"){dt(void 0),N.current.clear(),t.current?.(null),Be.clear(),n([]),Ze.current=[],xe(null);for(let Te of ne.values())Te.abort.abort();throw ne.clear(),Error("Sign in to activate a taste.")}if(F.current!==void 0&&(F.current!==Ee.accountId||Z.current!==Ee.environment)){Be.clear(),N.current.clear(),U.current?.abort(),ve(void 0);for(let Te of ne.values())Te.abort.abort();ne.clear(),Ze.current=[],n([]),xe(null)}F.current=Ee.accountId,Z.current=Ee.environment,dt(Fr(Ee)),Ee.canInspect||Be.clear();let[Ue,gt,er]=await Promise.all([Ie(`${ie}/cloud-taste/catalog`,{signal:Y.signal,cache:"no-store"}),Ie(`${ie}/cloud-taste/direction`,{signal:Y.signal,cache:"no-store"}),Ee.canBrowsePrivate===!0?Ie(`${ie}/cloud-taste/private-catalog`,{signal:Y.signal,cache:"no-store"}):null]);if(!Ue.ok||!gt.ok||er&&!er.ok)throw Error("Could not load tastes. Please retry or reconnect in Settings.");let Hn=await Ue.json(),Un=er?await er.json():{items:[]},mr=await gt.json();if(R!==le.current)return;let tr=["private","public"].flatMap(Te=>(Te==="private"?Un.items:Hn.items).map($e=>({id:qr(Te,$e.id),sourceModelId:$e.id,sourceCollection:Te,thumbnailUrl:$e.thumbnailUrl,preview:wt($e.preview),name:$e.name,documentRevision:$e.documentRevision,...$e.version?{metadata:{value:$e.version,label:`Version ${$e.version}`}}:{}}))).sort((Te,$e)=>Te.name.localeCompare($e.name));for(let Te of tr){let $e=ne.get(Te.id);if($e?.preview?.savedDocument&&$e.preview.savedDocument.revision!==Te.documentRevision){$e.abort.abort(),ne.delete(Te.id);continue}$e&&Te.preview&&($e.preview?.recipeRevision!==Te.preview.recipeRevision||$e.preview?.contentRevision!==Te.preview.contentRevision)&&($e.abort.abort(),ne.delete(Te.id))}Ze.current=tr,n(tr),ke&&xe(Te=>Te?tr.find($e=>$e.id===Te.id)??null:null),W.current=Date.now(),z===ye.current&&(Ae(mr),typeof Ee.accountId=="string"&&t.current?.({accountId:Ee.accountId,environment:Ee.environment,name:mr.direction?.name??null,generation:mr.generation})),It(Ee.canWrite===!0),hr(Ee.canInspect===!0),Je(Ee.canBrowsePrivate===!0),oe(null)}catch(lt){R===le.current&&oe(lt instanceof Error?lt.message:"Connection unavailable.")}finally{R===le.current&&(we(!1),je.current=!1,W.current=Date.now())}}return Bt(),()=>{le.current=R+1,Y.abort(),clearTimeout(re)}},[ie,Ve,Oe,ne,Be]);async function St(R){if(!ie||!qe||!rt||ce.current)return;let z=R?r.find(re=>re.id===R.id):void 0;if(R&&!z){oe("Reload the collection before choosing this taste.");return}ce.current=!0,ye.current+=1,We(z?{sourceModelId:z.sourceModelId,sourceCollection:z.sourceCollection,name:z.name,sourceVersion:z.metadata?.value??null}:null),z&&!z.preview&&!ne.get(z.id)?.preview&&ut(z).catch(()=>{}),S(!0),oe("Saving taste\u2026");let Y=le.current;try{let re=await Ie(`${ie}/cloud-taste/direction`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedGeneration:qe.generation,...z?{sourceModelId:z.sourceModelId,sourceCollection:z.sourceCollection}:{}})});if(!re.ok)throw Error("The change could not be confirmed. Reload the collection before trying again.");let be=await re.json();if(Y!==le.current)return;Ae(be),We(void 0),typeof F.current=="string"&&t.current?.({accountId:F.current,environment:Z.current,name:be.direction?.name??null,generation:be.generation}),oe(null)}catch(re){Y===le.current&&(Ae(null),We(void 0),t.current?.(null),oe(re instanceof Error?re.message:"Could not save taste. Reload to check its state."))}finally{ce.current=!1,Y===le.current&&S(!1)}}async function jt(R=!1){if(!ie||ce.current)return;let z=window.open("about:blank","_blank");if(!z){oe("Allow popups, then try again.");return}z.opener=null,ce.current=!0,S(!0);try{let Y=await Ie(`${ie}/cloud-taste/${R?"enable-saving":"enable-activation"}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!Y.ok)throw Error("Could not start sign-in. Retry in Settings.");let re=await Y.json(),be=_n(re.authorizationUrl);z.location.replace(be.href),Ce(ke=>ke+1)}catch(Y){z.close(),oe(Y instanceof Error?Y.message:"Could not start sign-in.")}finally{ce.current=!1,S(!1)}}let Qt=r.find(R=>R.id===De),Wn=ze&&De?Qt?{...Qt,preview:ne.get(Qt.id)?.preview??Qt.preview}:{id:De,name:ze.name,sourceModelId:ze.sourceModelId,sourceCollection:ze.sourceCollection,...ze.sourceVersion?{metadata:{value:ze.sourceVersion,label:`Version ${ze.sourceVersion}`}}:{}}:null,Or=R=>r.filter(z=>z.sourceCollection===R).map(z=>({...z,preview:ne.get(z.id)?.preview??z.preview})),qn=!!qe&&(!rt||!Ke),Hr=V?ne.get(V.id)?.facts:void 0,Ur=ee?.id===V?.id&&ee?.cache===ne?ee:null,_e=Qe[e.theme],fr=!X||y,ft=C&&fr,Kr=y&&u?u==="components"?ua:u==="copy-guidance"?pa:u==="version"?ha:u==="visual-directions"?fa:ga:Ht;se(()=>{X&&s.current?.focus({preventScroll:!0})},[X]);let Xt=()=>{if(K(!1),clearTimeout(ge.current),te(null),c(!1),ue(""),y){g(!1),clearTimeout(me.current),me.current=setTimeout(()=>f(null),220);return}h(!1),clearTimeout(pe.current),pe.current=setTimeout(()=>xe(null),220)},On=()=>{we(!0),Ce(R=>R+1)};se(()=>{if(e.visible===!1||m)return;let R=z=>{if(z.key==="Tab"&&K(!0),z.defaultPrevented||z.isComposing||z.metaKey||z.ctrlKey||z.altKey)return;let Y=z.composedPath().some(re=>re instanceof HTMLElement&&(re.matches('input, textarea, select, [role="textbox"], [role="combobox"]')||re.isContentEditable));if(!(z.key==="Escape"&&z.composedPath().some(re=>re instanceof HTMLElement&&re.matches("[data-taste-value-input]")))){if(z.key===" "&&fr&&!Y)K(!1),z.preventDefault(),z.stopImmediatePropagation(),z.repeat||I();else if(z.key==="Escape"){if(K(!1),z.preventDefault(),z.stopImmediatePropagation(),z.repeat)return;ft?ae():X?Xt():e.onClose()}}};return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)});let Nt=(Fe??ne.get(V?.id??"")?.preview??V?.preview)?.savedDocument,gr=R=>{v(null),He();let z=N.current.get(R.id);z&&(z.saved=R);let Y={id:qr("private",R.id),sourceModelId:R.id,sourceCollection:"private",name:R.document.draft.name,documentRevision:R.revision,preview:{...dr(R.document.draft,e.theme),savedDocument:R,contentRevision:String(R.revision)}};ne.get(Y.id)?.abort.abort(),ne.delete(Y.id),n(re=>[...re.filter(be=>be.id!==Y.id),Y]),xe(Y),ve(Y.preview),h(!0),Xe.close(),Ce(re=>re+1)};if(p&&p.record.scope===fe)return i(Wr,{session:p.session,draft:p.record.document.draft,recovery:p.record,recoveryScope:fe,onRecoveryChange:He,theme:e.theme,style:e.style,bridgeUrl:ie,visible:e.visible,onDraft:()=>{},onBack:()=>{v(null),He()},onTemplate:()=>{},onSaved:gr,onEnableSaving:()=>{jt(!0)}},p.record.key);if(!m&&X&&Nt){let R=N.current.get(Nt.id);return R||(R={saved:Nt,session:vr(Nt.document.draft)},N.current.set(Nt.id,R)),i(Wr,{saved:R.saved,recoveryScope:fe,onRecoveryChange:He,session:R.session,draft:R.saved.document.draft,theme:e.theme,style:e.style,bridgeUrl:ie,visible:e.visible,onDraft:()=>{},onBack:Xt,onTemplate:()=>{},onSaved:gr,onEnableSaving:()=>{jt(!0)}},Nt.id)}return m?i(Wr,{visible:e.visible,session:Xe,recoveryScope:fe,onRecoveryChange:He,theme:e.theme,style:e.style,bridgeUrl:e.bridgeUrl,draft:b.draft,onDraft:()=>{},onBack:()=>Xe.close(),onTemplate:()=>{ct("template",!0)},onSaved:gr,onEnableSaving:()=>{jt(!0)}}):k("div",{"data-popmelt-font":"sans",ref:q,"data-taste-keyboard-focus":E,onPointerDownCapture:()=>K(!1),"data-taste-navigation":X?"detail":"collection","data-taste-animated":Me||void 0,"data-taste-entering":e.visible===!1?void 0:$??void 0,"data-taste-depth":y?"drilldown":"overview",style:{position:"relative",height:ft?O:e.style?.height,maxHeight:e.style?.maxHeight,overflow:"hidden",borderRadius:20,background:_e.surface,fontFamily:Ft},children:[i("style",{children:`
190
- [data-taste-navigation] { user-select: none; -webkit-user-select: none; }
191
- [data-taste-navigation] input, [data-taste-navigation] textarea, [data-taste-navigation] [contenteditable="true"] { user-select: text; -webkit-user-select: text; }
192
- [data-taste-keyboard-focus="false"] [data-taste-navigation-header] :focus { outline: none !important; box-shadow: none !important; }
193
- [data-taste-navigation] [data-taste-collection-header], [data-taste-navigation] [data-taste-detail-header] { display: none !important; }
194
- [data-taste-navigation] [data-popmelt-taste], [data-taste-navigation] [data-taste-detail] { padding-top: 60px !important; }
195
- [data-taste-navigation] [data-taste-detail] { position: absolute; inset: 0; z-index: 1; background: transparent !important; overflow: hidden !important; }
196
- [data-taste-navigation] [data-taste-detail-body] { min-height: 0; overflow-y: auto; flex-shrink: 1; }
197
- [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; }
198
- [data-taste-navigation="detail"] [data-taste-scroll] { transform: translateX(-100%); opacity: 0; }
199
- [data-taste-navigation="collection"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }
200
- [data-taste-entering="overview"] [data-taste-layer="overview"] [data-taste-detail-body],
201
- [data-taste-entering="drilldown"] [data-taste-layer="drilldown"] [data-taste-detail-body] { animation: taste-detail-enter 200ms cubic-bezier(.2,.8,.2,1); }
202
- [data-taste-depth="drilldown"] [data-taste-layer="overview"] [data-taste-detail-body] { transform: translateX(-100%); opacity: 0; }
203
- [data-taste-depth="overview"] [data-taste-layer="drilldown"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }
204
- @keyframes taste-detail-enter { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
205
- [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; }
206
- [data-taste-navigation] [data-taste-nav-title]:hover [data-taste-refresh-icon] { opacity: 1; transform: none; }
207
- [data-taste-navigation] [data-taste-nav-action]:enabled:hover { background: ${_e.actionHover} !important; }
208
- [data-taste-navigation] [data-taste-search-trigger]:hover, [data-taste-navigation] [data-taste-search-trigger]:focus-visible { color: ${_e.primary} !important; }
209
- [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; }
210
- [data-taste-navigation-header] > [data-taste-search] { opacity: 0; transform: translateX(12px); visibility: hidden; pointer-events: none; }
211
- [data-taste-navigation-header][data-search-open="true"] > [data-taste-search] { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
212
- [data-taste-navigation-header] > [data-taste-header-default] { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
213
- [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; }
214
- @media (prefers-reduced-motion: reduce) { [data-taste-navigation] *, [data-taste-navigation] [data-taste-detail-body] { animation: none !important; transition: none !important; } }
215
- `}),k("div",{"data-taste-navigation-header":!0,"data-search-open":ft,style:{position:"absolute",top:16,left:16,right:16,height:28,zIndex:2,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[k("div",{"data-taste-search":!0,inert:!ft,"aria-hidden":!ft,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",gap:8,width:"100%",color:_e.secondary},children:[i(kr,{size:16}),i("input",{ref:de,"aria-label":X?"Search taste definitions":"Search tastes",placeholder:X?"Search keys and values\u2026":"Search tastes\u2026",value:he,onChange:R=>ue(R.target.value),onKeyDown:R=>{R.stopPropagation(),R.key==="Escape"&&ae()},style:{flex:1,minWidth:0,border:0,outline:"none",background:"transparent",color:_e.primary,font:"inherit",fontSize:12}}),i("button",{type:"button","aria-label":"Close search",onClick:ae,style:{border:0,padding:4,background:"transparent",color:_e.secondary,cursor:"pointer"},children:i(Ct,{size:16})})]}),k("div",{"data-taste-header-default":!0,inert:ft,"aria-hidden":ft,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,width:"100%"},children:[k("button",{ref:s,type:"button","data-taste-nav-title":!0,"aria-label":X?y?"Back to taste details":"Back to taste collection":"Back to settings",onClick:X?Xt:e.onClose,style:{display:"flex",alignItems:"center",gap:3,padding:0,border:0,background:"transparent",color:X?_e.secondary:_e.primary,fontFamily:"inherit",fontSize:X?12:14,fontWeight:600,letterSpacing:X?"-.12px":"-.14px",minWidth:0,cursor:"pointer"},children:[i(Sr,{size:16,style:{width:16,color:_e.primary}}),i(Kr,{"data-taste-nav-icon":!0,style:{width:X?14:16,height:X?14:16,transform:Kr===Ht?"scaleY(-1)":void 0,transitionProperty:"color, width, height, opacity"}}),i("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:X?V.name:void 0,children:X?u&&y?{version:"Versions",tokens:"Tokens",components:"Components","visual-directions":"Visual directions","copy-guidance":"Copy guidance"}[u]??u:V.name:"Taste"})]}),k("div",{style:{position:"relative",height:28,width:X?80:at?135:28,flexShrink:0},children:[!X&&at&&i("button",{type:"button","aria-label":"Open template taste",onClick:()=>{ct("template",!0)},style:{position:"absolute",right:56,top:0,border:0,padding:6,background:"transparent",color:_e.muted,font:"inherit",fontSize:12,cursor:"pointer"},children:"Template"}),!X&&at&&i("button",{type:"button","aria-label":"Create a taste","data-taste-create":!0,onClick:()=>{ct("extract")},style:{position:"absolute",right:28,top:0,border:0,padding:6,background:"transparent",color:_e.muted,cursor:"pointer"},children:i(Ut,{size:16})}),fr?i("button",{type:"button","aria-label":X?"Search definitions":"Search tastes",ref:Q,"data-taste-search-trigger":!0,onClick:()=>{K(!1),I()},style:{position:"absolute",right:0,border:0,padding:6,background:"transparent",color:_e.muted,transition:"color 160ms ease",cursor:"pointer"},children:i(kr,{size:16})}):i(Le,{children:i("button",{type:"button","data-taste-nav-action":!0,"aria-label":`${V?.id===De?"Remove":"Add"} ${V?.name??"taste"}`,"aria-pressed":!!V&&V.id===De,inert:!X,disabled:!rt||!qe||_,onClick:()=>{V&&St(V.id===De?void 0:V)},style:{position:"absolute",right:0,top:0,display:"flex",alignItems:"center",gap:3,padding:V?.id===De?"4px 7px 4px 8px":"4px 8px",border:0,borderRadius:8,background:_e.actionSurface,color:_e.actionForeground,font:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",opacity:X?1:0,transform:X?"translateX(0)":"translateX(5px)",pointerEvents:X?"auto":"none"},children:V?.id===De?k(Le,{children:["Remove",i(Ct,{size:12})]}):k(Le,{children:[i(Ut,{size:12}),"Add"]})})})]})]})]}),V&&(u?["overview","drilldown"]:["overview"]).map(R=>i("div",{"data-taste-layer":R,inert:!X||R==="drilldown"!==y,"aria-hidden":!X||R==="drilldown"!==y,children:i(Ba,{theme:e.theme,style:{...e.style,...l>0?{minHeight:`min(${l}px, ${typeof e.style?.maxHeight=="number"?`${e.style.maxHeight}px`:e.style?.maxHeight??"calc(100dvh - 64px)"})`}:{}},entry:{...V,preview:Fe??ne.get(V.id)?.preview??V.preview},facts:Hr??Ur?.facts,onOpenFact:z=>{K(!1),J("drilldown"),clearTimeout(me.current),c(!1),ue(""),f(z),g(!0)},drilldown:R==="drilldown"&&u?i(Za,{cache:Be,bridgeUrl:e.bridgeUrl,id:V.sourceModelId,collection:V.sourceCollection,section:u,query:he,theme:e.theme,onPreview:ve,onReconnect:()=>{jt()}},`${V.id}:${u}`):void 0,summaryNotice:Hr?void 0:Ur?.notice??"Loading details\u2026",active:V.id===De,onBack:Xt,onToggle:rt&&qe&&!_?()=>{St(V.id===De?void 0:V)}:void 0,notice:G},V.id)},R)),i("div",{ref:o,inert:X,"aria-hidden":X,style:{display:"contents"},children:i(ja,{...e,style:{...e.style,...ft&&O?{height:"100%"}:{}},publicEntries:Or("public").filter(R=>X||`${R.name} ${R.metadata?.value??""}`.toLowerCase().includes(he.trim().toLowerCase())),privateEntries:Or("private").filter(R=>X||`${R.name} ${R.metadata?.value??""}`.toLowerCase().includes(he.trim().toLowerCase())),activeEntryId:De,activeEntry:Wn,onRefresh:On,refreshing:Se,refreshDisabled:_,onAdd:rt&&qe&&!_?R=>{St(R)}:void 0,onRemove:rt&&qe&&!_?()=>St():void 0,onOpenDetails:R=>{if(K(!1),J("overview"),clearTimeout(pe.current),Ye(!0),a(o.current?.firstElementChild?.offsetHeight??0),xe(R),f(null),g(!1),c(!1),ue(""),ve(void 0),U.current?.abort(),pr&&e.bridgeUrl&&!R.documentRevision){let z=new AbortController;U.current=z,Be.read(`${e.bridgeUrl}/cloud-taste/definition?id=${encodeURIComponent(R.sourceModelId)}&collection=${R.sourceCollection}`).then(async Y=>{if(!Y.ok)return;let re=await Y.json(),be=wt(re.preview);!z.signal.aborted&&be&&ve(be)}).catch(()=>{})}h(!0)},onPrefetchDetails:R=>{ut(R).catch(()=>{})},privateEmptyMessage:Ke?"No private results found.":"Reconnect to browse your private tastes.",notice:G,headerAction:k(Le,{children:[i(Ri,{theme:e.theme,records:nt.map(R=>({key:R.key,name:R.document.draft.name,pending:!!R.pending,preview:{...dr(R.document.draft,e.theme),savedDocument:R}})),onResume:R=>{let z=nt.find(Y=>Y.key===R);if(z)try{let Y=Dn(z.scope).find(be=>be.key===z.key);if(!Y){He();return}let re={...Y,key:crypto.randomUUID(),updatedAt:Date.now()};Pn(re),jn(Y.key),v({record:re,session:vr(re.document.draft)}),He()}catch{oe("Could not resume browser recovery. The original record is kept.")}}}),qn?i("button",{type:"button",disabled:_,onClick:()=>{jt()},style:{border:0,borderRadius:8,padding:"6px 10px",cursor:"pointer",font:"inherit"},children:"Reconnect account"}):null]})})}),i(Yr,{element:L,label:"AI is looking at this Taste",inverse:!0})]})}export{Li as PopmeltTasteConnectedPane};
1
+ "use client";import{c as e,f as t,e as r,d as n}from"./chunk-PSSHCTJ2.mjs";import"./chunk-F5XSNRGT.mjs";import{b as a}from"./chunk-JMMP5JSP.mjs";import{oa as i,pa as o,ca as l,D as s,q as d}from"./chunk-6V2VCKPG.mjs";import"./chunk-4LHTPRFY.mjs";import"./chunk-2ZJ4FBTG.mjs";import"./chunk-DNOKP3JS.mjs";import"./chunk-2VCHBI7Y.mjs";import{e as c,a as u}from"./chunk-ODIGT4YJ.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import{b as p}from"./chunk-CPOYMGYY.mjs";import"./chunk-6VXFTT5U.mjs";import{x as h,w as g,e as f,f as m,r as v,l as y,v as b,t as w,b as x,p as k,g as S,d as C,j as $,c as R,o as E,k as T,s as I,m as N,h as A,i as L,q as z,a as P,n as D,u as j}from"./chunk-O4HZP3RP.mjs";import"./chunk-XTOCFTVW.mjs";import{a as M}from"./chunk-LVEMYZOA.mjs";import"./chunk-WHJEKDNP.mjs";import{createContext as O,useRef as W,useState as F,useSyncExternalStore as B,useLayoutEffect as q,useEffect as H,useCallback as U,useMemo as V,isValidElement as K,useId as Y,Fragment as J,createElement as _,useContext as X}from"react";import{Search as G,X as Z,ChevronLeft as Q,Component as ee,PenLine as te,History as re,Eye as ne,Ruler as ae,Fingerprint as ie,Plus as oe,ChevronRight as le,RotateCw as se,RotateCcw as de,ArrowLeftRight as ce,Info as ue,ChevronDown as pe,Check as he,User as ge,ArrowRight as fe}from"lucide-react";import{jsx as me,jsxs as ve,Fragment as ye}from"react/jsx-runtime";import{createPortal as be}from"react-dom";var we=["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"],xe=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function ke(e,t){return!!Re(t)&&("flexGrow"===e||"flexShrink"===e?xe.test(t)&&Number.isFinite(Number(t))&&Number(t)>=0:["display","boxSizing","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","textAlign","whiteSpace","overflow","strokeLinecap","strokeLinejoin","objectFit"].includes(e)?!xe.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 Se(e,t){return{...e,tokens:[...e.tokens,...t.tokens??[]]}}function Ce(e){return/^(width|height|marginTop|marginRight|marginBottom|marginLeft|gridTemplateColumns)$/.test(e)}var $e=e=>{throw new j(e)},Re=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),Ee=e=>"string"==typeof e&&/^[a-zA-Z0-9_-]{1,80}$/.test(e),Te=new Set(["div","span","img","svg","path","circle","rect","line","polyline","polygon","ellipse","g"]),Ie=e=>"string"==typeof e&&e.length<=2e4&&/^(https?:\/\/|blob:https?:\/\/|data:image\/(png|jpeg|webp|gif);base64,)/i.test(e),Ne=new Set(["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fillRule","clipRule"]);function Ae(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?v(r.value,e.constraints,!a):null}else{let r=f(e.constraints,t.id,t.step??0);n=m(r),"layout"===r.kind&&!r.unit&&!a&&(n+="px")}return Re(n)?n:null}catch{return null}}function Le(e,t){let r=["div","span","img"].includes(t.tag)?{all:"initial"}:{};for(let[e,n]of Object.entries(t.localStyles??{}))we.includes(e)&&(ke(e,n)||Ce(e)&&Re(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(!we.includes(n))continue;let t=Ae(e,a,n);null!==t&&(r[n]=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(n)&&Number.isFinite(Number(t))?Number(t):t)}return r}function ze(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 Pe(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 De(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 je(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&&ze(t)&&(a[e]=r),["background","backgroundColor","backgroundImage","border","borderColor","boxShadow","outline"].includes(e)&&ze(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 Me(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=Oe(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&&!We(t)&&(n.fontFamily=`"Popmelt Taste ${t}", ${e.fontFamily}`)}return De(Pe(n))}var Oe=e=>e.split(",")[0].trim().replace(/^["']|["']$/g,""),We=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),Fe=new Map;var Be=e=>!!e&&"object"==typeof e&&!Array.isArray(e),qe=(e,t=512)=>"string"==typeof e&&e.length<=t,He=e=>qe(e,100)&&/^[a-zA-Z0-9_-]+$/.test(e),Ue=e=>qe(e,4096)&&![...e].some(e=>e.charCodeAt(0)<9)&&!/[;{}<>]|\b(?:url|expression|javascript)\s*[:(]/i.test(e),Ve=(e,t)=>Object.keys(e).every(e=>t.includes(e)),Ke=(e,t)=>new Set(e.map(e=>e[t])).size===e.length,Ye=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(" ")),Je=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 Xe(e){return Array.isArray(e)?"["+e.map(Xe).join(",")+"]":Be(e)?"{"+Object.keys(e).sort().map(t=>JSON.stringify(t)+":"+Xe(e[t])).join(",")+"}":JSON.stringify(e)}function Ge(e){if(!function(e){try{if(!Be(e)||!Ve(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(!Be(t)||!Ve(t,["schemaVersion","name","constraints","tokens","usage","fragments","featuredComponentId"])||1!==t.schemaVersion||!qe(t.name,80)||!t.name.trim()||!Array.isArray(t.constraints)||t.constraints.length<1||t.constraints.length>32||!t.constraints.every(e=>Be(e)&&Ve(e,["id","name","kind","group","typographyRole","scaleMode","value","parentId","derivative","scale"])&&He(e.id)&&qe(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))&&Ue(e.value)&&(null===e.parentId||He(e.parentId))&&Number.isFinite(e.derivative)&&Number.isFinite(e.scale)&&"number"==typeof e.scale&&e.scale>=0&&(void 0===e.scaleMode||"increment"===e.scaleMode))||!Ke(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=>Be(e)&&Ve(e,["id","name","value"])&&He(e.id)&&He(e.name)&&Ue(e.value)&&e.value.trim()&&[...e.value.matchAll(/@([a-zA-Z0-9_-]+)/g)].every(e=>r.has(e[1])))&&Ke(e,"id")&&Ke(e,"name");if(!n(t.tokens))return!1;let a=t.tokens,i=(e,t)=>Be(e)&&Ve(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=>Be(e)&&Ve(e,["target","property","source"])&&["page","heading","body","muted","card","button","input"].includes(String(e.target))&&Ye.has(String(e.property))&&i(e.source,a))))return!1;let o=t.fragments??[];if(!Array.isArray(o)||o.length>32||!Ke(o,"id"))return!1;for(let e of o){if(!(Be(e)&&Ve(e,["id","name","width","height","root","tokens"])&&He(e.id)&&qe(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(!Ke(r,"id")||!Ke(r,"name"))return!1;let o=new Set,l=0,s=(e,t)=>"string"==typeof e?e.length<=1e4:!(!Be(e)||!Ve(e,["id","tag","styles","localStyles","attributes","children"])||!He(e.id)||o.has(e.id)||++l>256||t>16||!Je.has(String(e.tag))||!Be(e.styles)||!Array.isArray(e.children)||e.children.length>256||(o.add(e.id),!Object.entries(e.styles).every(([e,t])=>Ye.has(e)&&i(t,r)))||!(void 0===e.localStyles||Be(e.localStyles)&&Object.entries(e.localStyles).every(([e,t])=>Ye.has(e)&&Ue(t)))||!(void 0===e.attributes||Be(e.attributes)&&Object.entries(e.attributes).every(([e,t])=>_e.has(e)&&qe(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)f(t.draft.constraints,e.id);for(let e of t.draft.fragments??[]){let r=Se(t.draft,e),n=e=>Object.entries(e.styles).every(([e,t])=>null!==Ae(r,t,e))&&e.children.every(e=>"string"==typeof e||n(e));if(!n(e.root))return}return t}catch{return}}function Ze(e){let t={format:"popmelt.taste.graph",schemaVersion:1,draft:e};if(!Ge(t))throw Error("This Taste has incomplete or invalid dimensions, tokens, or component bindings.");return t}function Qe(e){if(!e||"object"!=typeof e)return;let t=e;for(let e of["background","surface","foreground","muted","accent","border"])if(!ze(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&&Ge(n.document)&&(r.savedDocument=n),delete r.detail,void 0!==t.detail&&(r.detail=je(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]=je({[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:ze(a.background,!0)?a.background:r.surface,border:ze(a.border)?a.border:`1px solid ${r.border}`,radius:a.radius,shadow:ze(a.shadow)?a.shadow:"none",...void 0!==a.backgroundImage?{backgroundImage:ze(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 et({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 me("span",{"data-taste-specimen":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,background:e.background,pointerEvents:"none",overflow:"hidden"},children:ve("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:[me("span",{"data-specimen-title":!0,style:{position:"absolute",left:0,top:0,width:"100%",height:"18.18%",background:e.parts?"transparent":e.accent}}),me("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)}}),me("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 tt(e,t=!1,r=640){let[n,a]=F(!1),[i,o]=F(!1),[l,s]=F(!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:{...Me(n?e?.hover:void 0,r),...Me(i?e?.focus:void 0,r),...Me(l?e?.active:void 0,r)}}}function rt({recipe:e,usageStyles:t}){let r=void 0!==t,n=n=>Me({...e.detail?.[n]??{},...t?.[n]},640,r),a=tt(e.states?.button,!0),i=tt(e.states?.input),o=tt(e.states?.card),l=r?`${e.spacing}px`:e.spacing/6.4+"cqw";H(()=>{!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=Oe(r.fontFamily);if(We(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=Fe.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"),Fe.delete(e)});return Fe.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?{...De({background:e.background}),...e.backgroundImage&&"none"!==e.backgroundImage?{backgroundImage:e.backgroundImage}:{},backgroundBlendMode:e.backgroundBlendMode,...Pe({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 me("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",...De({background:e.background}),color:e.foreground,fontSynthesis:"none",...n("body"),...n("page"),overflow:r?"visible":"hidden"},children:me("div",{"data-taste-component":"card",style:{position:r?"relative":"absolute",...r?{}:{inset:"9% 8%"},...De({background:e.surface}),...Pe({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:ve("div",{style:{display:"grid",gridTemplateColumns:"1.35fr 1fr",gap:r?n("card").gap??l:`calc(${l} * 2)`,alignItems:"center",flex:1,minHeight:0},children:[ve("div",{children:[ve("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, ${Me(e.detail?.heading).fontSize??"4.6cqw"}, 5.4cqw)`}},children:["A little space",me("br",{}),"for big ideas."]}),ve("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.",me("br",{}),"Make something your own."]}),me("button",{"data-taste-component":"button",...a.handlers,type:"button",style:{fontFamily:"inherit",color:"inherit",display:"inline-block",...De({background:e.accent}),...Pe({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 ↗"})]}),ve("div",{"data-taste-component":"card",...o.handlers,style:{...De({background:e.surface}),...Pe({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:[me("h3",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",...n("heading"),...r?{}:{fontSize:"2.6cqw"},marginBottom:l},children:"In the works"}),me("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",...De({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}}),me("div",{children:"02   What comes next"})]})]})})})}function nt(e){let t=e.ownerDocument.defaultView;if(!t||d(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]")||d(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 c="http://www.w3.org/2000/svg"===e.namespaceURI,u=c?e.localName:"img"===e.localName?"img":"inline"===s.display?"span":"div",p={id:`n${i}`,tag:u,children:[],styles:{}};if(e instanceof HTMLImageElement){if(!Ie(e.currentSrc||e.src))throw Error("This image cannot be captured safely.");p.attributes={src:e.currentSrc||e.src}}if(c){p.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&&(p.attributes[t.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())]=r)}}for(let t of we){if(["gap","padding","paddingInline","paddingBlock","border","borderRadius","borderColor","borderWidth"].includes(t)||!c&&["fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin"].includes(t)||c&&"svg"!==u&&["width","height"].includes(t))continue;let r=s[t],i=!1;if(Ce(t)){let n=e.computedStyleMap?.().get(t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`))?.toString();n&&Re(n)&&(r=n),i=!n||/^(auto|min-content|max-content|fit-content|none)$/.test(n)||"gridTemplateColumns"===t}if(!r)continue;if(!Re(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}:{}})),p.styles[t]=l}if(!e.matches("input,textarea,select,option"))for(let t of e.childNodes)if(3===t.nodeType)t.textContent&&p.children.push(t.textContent);else if(t instanceof Element){let e=o(t,r+1);e&&p.children.push(e)}return p},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)&&$e("Invalid fragment capture.");let t=e,{evidence:r,draft:n}=t;(!r||!Ee(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)&&$e("This component is too large to capture. Try a smaller element.");let a=new Set;for(let e of r.values)(!e||!Ee(e.id)||a.has(e.id)||!we.includes(e.property)||void 0!==e.local&&(!0!==e.local||!Ce(e.property))||!Re(e.value))&&$e("Unsupported captured style."),a.add(e.id);let i=0,o=new Set,l=(e,t)=>{(!e||!Ee(e.id)||o.has(e.id)||!Te.has(e.tag)||++i>64||t>12||!Array.isArray(e.children)||e.children.length>128||!e.styles||"object"!=typeof e.styles)&&$e("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)||$e("Invalid captured style reference.");for(let[t,r]of Object.entries(e.attributes??{}))"img"===e.tag&&"src"===t&&Ie(r)||(!Ne.has(t)||"string"!=typeof r||r.length>12e3||!/^[\d\w\s.,+()-]*$/.test(r))&&$e("Unsupported vector geometry.");for(let r of e.children)"string"==typeof r?r.length>2e3&&$e("Too much captured text."):l(r,t+1)};l(r.root,0)}({evidence:n,draft:P()}),n}function at({fragment:e,draft:t,height:r=160,highlightedNodes:n=[]}){let a=W(null),i=W(null),[o,l]=F(null),[s,d]=F({scale:1,width:e.width,height:e.height}),{scale:c}=s;q(()=>{a.current&&l(a.current.shadowRoot??a.current.attachShadow({mode:"open"}))},[]),q(()=>{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=Le(Se(t,e),r);return _(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 me("div",{ref:a,role:"img","aria-label":`${e.name} static preview`,style:{height:r,width:"100%",overflow:"hidden",borderRadius:8,pointerEvents:"none",backgroundColor:Le(Se(t,e),e.root).backgroundColor??w(t).page?.backgroundColor},children:o&&be(me("div",{style:{height:r,display:"grid",placeItems:"center",overflow:"hidden"},children:me("div",{style:{width:s.width*c,height:s.height*c},children:me("div",{ref:i,style:{width:e.width,transform:`scale(${c})`,transformOrigin:"top left"},children:u(e.root)})})}),o)})}function it(e){let{session:t,draft:r,visible:n,bridgeUrl:i}=e,[o,l]=F([]),s=W(null),d=W(new Map),u=W(null),h=W(null),g=W(e);g.current=e;let f=W(!1),m=t.getSnapshot().runId,v=t.getSnapshot().state,y=c[e.theme];return q(()=>{let e=s.current?.closest(".tc-scroll");if(!e||!n)return;let t=()=>{u.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)}},[n]),q(()=>{let e=u.current;if(!e||!n)return;let t=d.current.get(e),r=t?.closest(".tc-scroll");if(!t||!r)return;let a=t.getBoundingClientRect(),i=r.getBoundingClientRect(),o=a.bottom+16-i.bottom;o>0&&r.scrollTo({top:r.scrollTop+o,behavior:"instant"})},[o,n,r]),H(()=>(f.current=!0,()=>{f.current=!1,h.current?.abort(),h.current=null}),[]),H(()=>{if(n)return a(e=>{let t;try{let r=nt(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+(g.current.draft.fragments?.length??0)>=16?e:(u.current=t.id,[...e,t]))})},[n]),H(()=>{if(!n||h.current||"running"===v)return;let e=o.find(e=>"pending"===e.state&&e.evidence);if(!e)return;let r=new AbortController;h.current=r;let a=t=>{f.current&&!r.signal.aborted&&l(r=>r.map(r=>r.id===e.id?{...r,...t}:r))};a({state:"running"});let s=setTimeout(()=>{a({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 n=t.getSnapshot(),o=await p(`${i}/cloud-taste/fragment`,{method:"POST",headers:{"Content-Type":"application/json"},signal:r.signal,body:JSON.stringify({evidence:e.evidence,draft:{...n.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="",h=e=>{if(!e.trim())return;let t=JSON.parse(e);if("error"===t.type)throw Error(t.message);"status"===t.type&&a({message:t.message}),"progress"===t.type&&a({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"));)h(u.slice(0,e)),u=u.slice(e+1)}h(u+c.decode())}finally{d.releaseLock()}if(!s)throw Error("The component ended before its styles arrived. Retry capture.");!r.signal.aborted&&f.current&&(g.current.onDraft(t.addFragment(m,s)),l(t=>t.filter(t=>t.id!==e.id)))}catch(e){a({state:"error",message:e instanceof Error?e.message:"Capture failed. Please retry."})}finally{clearTimeout(s),h.current===r&&(h.current=null),f.current&&l(e=>[...e])}})()},[o,v,n,i,m,t]),ve("section",{ref:s,"aria-label":"Components",style:{display:"flex",flexDirection:"column",gap:16},children:[me("h3",{style:{margin:0,fontSize:12,fontWeight:400,color:y.primary},children:"Components"}),!r.fragments?.length&&!o.length&&me("p",{style:{margin:0,fontSize:12,color:y.secondary},children:"Click an element on the page to capture a static component."}),r.fragments?.map(n=>ve("div",{ref:e=>{e?d.current.set(n.id,e):d.current.delete(n.id)},style:{display:"flex",flexDirection:"column",gap:4},children:[me("button",{type:"button","aria-label":`Inspect ${n.name}`,onClick:()=>e.onInspect?.(n.id),style:{background:y.control,borderRadius:8,width:"100%",padding:0,display:"block"},children:me(at,{draft:r,fragment:n})}),ve("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 4px",color:y.secondary},children:[me("button",{type:"button",onClick:()=>e.onInspect?.(n.id),style:{flex:1,justifyContent:"flex-start",fontSize:12,letterSpacing:".12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.name}),me("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)})(n.id),"aria-label":`Use ${n.name} as preview`,"aria-pressed":r.featuredComponentId===n.id,disabled:"running"===v,style:{fontSize:12},children:r.featuredComponentId===n.id?"Preview":"Use as preview"}),me("button",{type:"button",onClick:()=>e.onInspect?.(n.id),"aria-label":`Uses for ${n.name}`,title:"Styles are linked to this Taste’s dimensions and tokens",style:{fontSize:14,fontWeight:500,letterSpacing:"-.14px"},children:"uses"})]})]},n.id)),o.map(e=>ve("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:y.control,minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:8,padding:12,boxSizing:"border-box"},children:[me("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&&ve("div",{style:{display:"flex",gap:12},children:[e.evidence&&me("button",{type:"button",onClick:()=>l(t=>t.map(t=>t.id===e.id?{...t,state:"pending",message:void 0}:t)),children:"Retry"}),me("button",{type:"button",onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),children:"Dismiss"})]})]},e.id))]})}function ot({document:e}){let t=W(null),[r,n]=F(160);q(()=>{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 me("div",{ref:t,"data-taste-document-preview":!0,style:{width:"100%",height:"100%"},children:i?me(at,{fragment:i,draft:a,height:r}):null})}function lt({preview:t,thumbnailUrl:r,zoom:n=!0,background:a}){let[i,o]=F(null),l=t?.savedDocument?.document.draft.featuredComponentId?me(ot,{document:t.savedDocument.document}):t?me(rt,{recipe:t}):r&&r!==i?me("img",{src:r,alt:"",referrerPolicy:"no-referrer",onError:()=>o(r),style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):null;return me("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?me(e,{children:l}):l})}var st=200;function dt(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 ct(e,t,r,n,a){if(!e)return;let i=dt(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 ut({entry:e,onAdd:t,onRemove:r,active:n,featured:a=!1,previewBackground:i,hasActiveTaste:o=!1,onOpenDetails:l,onPrefetchDetails:s}){let[d,c]=F(null),u=W(null),p=W(s);p.current=s;let h=W(e);h.current=e,H(()=>{if(!u.current||typeof IntersectionObserver>"u")return;let e=new IntersectionObserver(([t])=>{t?.isIntersecting&&(h.current.preview||p.current?.(h.current),e.disconnect())},{root:u.current.closest("[data-taste-scroll]"),rootMargin:"180px"});return e.observe(u.current),()=>e.disconnect()},[e.id]);let g=W(void 0),f=()=>clearTimeout(g.current);H(()=>()=>clearTimeout(g.current),[]);let m=!!e.documentRevision||!!e.preview?.savedDocument,v=n?r:m?l:t,y=n?"Remove":m?"View":o?"Switch":"Add",b=me("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:ve(ye,n?{children:["Remove",me(Z,{size:12,"aria-hidden":"true"})]}:{children:[me(m?le:oe,{size:12,"aria-hidden":"true"}),y]})});return ve("li",{"data-taste-tile":!0,"data-taste-entry-id":e.id,"data-taste-featured":a||void 0,ref:u,onMouseEnter:()=>{f(),g.current=setTimeout(()=>s?.(e),100)},onMouseLeave:f,onFocus:()=>{f(),s?.(e)},style:{minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[a?ve("div",{"data-taste-thumbnail":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:8,overflow:"hidden"},children:[me("div",{"data-taste-preview-art":!0,"aria-hidden":"true",inert:!0,children:me(lt,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,zoom:!1,background:i??"transparent"},e.id)}),me("button",{type:"button","data-taste-featured-action":!0,"aria-label":`${y} ${e.name}`,"aria-pressed":n,disabled:!v,onClick:()=>v?.(e),style:{position:"absolute",inset:0,width:"100%",padding:0,border:0,background:"transparent",font:"inherit",cursor:v?"pointer":"default"},children:b})]}):ve("button",{type:"button","data-taste-thumbnail":!0,"aria-label":`${y} ${e.name}`,"aria-pressed":n,disabled:!v,onClick:()=>v?.(e),style:{display:"block",padding:0,border:0,font:"inherit",cursor:v?"pointer":"default",aspectRatio:"1",width:"100%",borderRadius:8,overflow:"hidden",position:"relative"},children:[me("span",{"data-taste-preview-art":!0,style:{position:"absolute",inset:0},children:e.preview?.savedDocument?.document.draft.featuredComponentId?me(ot,{document:e.preview.savedDocument.document}):e.thumbnailUrl&&e.thumbnailUrl!==d?me("img",{src:e.thumbnailUrl,alt:"",referrerPolicy:"no-referrer",onError:()=>c(e.thumbnailUrl??null),style:{display:"block",width:"100%",height:"100%",objectFit:"cover"}}):e.preview?me(et,{recipe:e.preview}):null}),b]}),ve("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:[ve("span",{style:{display:"inline-flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[me("span",{"data-taste-name":!0,title:e.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,minWidth:0},children:e.name}),l&&me("span",{"data-taste-detail-chevron":!0,"aria-hidden":"true",children:me(le,{size:13,strokeWidth:2})})]}),e.metadata&&me("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 pt({theme:e,publicEntries:t,privateEntries:r,onClose:n,onRefresh:a,refreshDisabled:i=!1,refreshing:o=!1,onAdd:l,onRemove:s,activeEntryId:d=null,activeEntry:p,onOpenDetails:h,onPrefetchDetails:g,notice:f,action:m,headerAction:v,privateEmptyMessage:y,style:b}){let w=c[e],[x,k]=F(!1),S=W(null),C=W(null),$=W(null),R=W(null),E=W([]),T=W(new Map),I=W([]),N=W(null),[A,L]=F(null),z=W(null),P=W(null),[D,j]=F(),[M,O]=F(null),B=W(null);H(()=>()=>{for(let e of B.current?.timers??[])clearTimeout(e);B.current?.cleanup();for(let e of E.current)e.cancel();for(let e of I.current)e.cancel();B.current=null},[]);let U=d?p?.id===d?p:[...t,...r].find(e=>e.id===d):null,V=M?.entry??U,K=V?.id??null,Y=!!d&&A===d,J="collapse"===M?.phase,_=t.filter(e=>e.id!==K||J),X=r.filter(e=>e.id!==K||J);q(()=>{let e=R.current;if(!e||"collapse"!==M?.phase||(R.current=null,window.matchMedia?.("(prefers-reduced-motion: reduce)").matches))return;let t=$.current,r=S.current,n=r?r.getBoundingClientRect().width/(r.offsetWidth||1):1;ct(t,e.positions,n,st,E.current);for(let r of t?.querySelectorAll("[data-taste-tile]")??[])if(r.dataset.tasteEntryId===e.returningId&&r.animate){E.current.push(r.animate([{opacity:0},{opacity:1}],{duration:st,easing:"ease-out"}));break}},[M?.phase]),q(()=>{let e=$.current;if(!e)return;let t=T.current;if(!Y||N.current===d)return;N.current=d;let r=z.current,n=P.current,a=C.current,i=a?.querySelector("[data-taste-collections]");if(!r||!n||!a||!i||!r.animate||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void L(null);for(let e of I.current)e.cancel();I.current=[];let o={duration:220,easing:"ease-in-out"},l={delay:120,duration:160,easing:"ease-out",fill:"backwards"},s=r.offsetHeight,c=n.offsetHeight,u=r.animate([{height:"0px"},{height:`${s}px`}],o);I.current.push(u),I.current.push(r.animate([{opacity:0},{opacity:1}],l),n.animate([{height:"0px"},{height:`${c}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=S.current;ct(e,t,p?p.getBoundingClientRect().width/(p.offsetWidth||1):1,220,I.current),u.onfinish=()=>{N.current===d&&(N.current=null,L(null))}},[Y,d]),q(()=>{T.current=dt($.current)});let G=e=>{l&&(!K&&!M&&(N.current=null,L(e.id)),l(e))};return ve("div",{ref:S,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 ${w.border}`,borderRadius:20,background:w.surface,backdropFilter:"blur(59.5px)",WebkitBackdropFilter:"blur(59.5px)",color:w.secondary,fontFamily:u,fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden",...b,...o&&D?{height:D}:{}},children:[me("style",{children:`\n [data-popmelt-taste] [data-taste-thumbnail] { background: ${w.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: ${w.secondary}; transition: color 120ms ease; }\n [data-popmelt-taste] [data-taste-metadata] { color: ${w.muted}; transition: color 120ms ease; }\n [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-name] { color: ${w.primary}; }\n [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-metadata] { color: ${w.secondary}; }\n [data-popmelt-taste] [data-taste-detail-chevron] { display: inline-flex; width: 0; flex: 0 0 auto; overflow: hidden; opacity: 0; color: ${w.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: ${w.actionSurface}; color: ${w.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: ${w.actionHover}; }\n [data-popmelt-taste] button:focus-visible { outline: 2px solid ${w.primary}; outline-offset: 2px; }\n [data-popmelt-taste] button[data-taste-close]:hover { background: ${w.hoverSurface} !important; color: ${w.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 `}),ve("div",{"data-taste-collection-header":!0,style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[ve("button",{type:"button","data-taste-refresh":!0,"aria-label":"Refresh taste collection",onClick:()=>{j(S.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:w.primary,fontSize:14,fontWeight:600,letterSpacing:"-.14px"},children:[me(ie,{size:16,"aria-hidden":"true",style:{transform:"scaleY(-1)"}}),"Taste",me(se,{"data-taste-refresh-icon":!0,size:12,"aria-hidden":"true",style:{marginLeft:2}})]}),me("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:w.muted,cursor:"pointer"},children:me(Z,{size:16})})]}),ve("div",{"data-taste-scroll":!0,onScroll:e=>k(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:x?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:x?"linear-gradient(to bottom, transparent, #000 16px)":void 0,overscrollBehavior:"contain"},children:[ve("div",{"data-taste-content":!0,ref:C,style:{display:"flex",flexDirection:"column",gap:V&&"collapse"!==M?.phase?24:0,transition:M?"gap 200ms ease-in-out":void 0},children:[v,V&&ve("section",{ref:z,"aria-label":"Active taste","data-taste-removal-phase":M?.phase,"aria-hidden":!!M,inert:!!M,style:{display:"flex",flexDirection:"column",gap:8,flexShrink:0,minHeight:0,height:M?"collapse"===M.phase?0:M.activeHeight:void 0,opacity:M?0:1,overflow:M||Y?"hidden":void 0,pointerEvents:M?"none":void 0,transition:M?"opacity 100ms ease-out, height 200ms ease-in-out":void 0},children:[me("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",color:w.secondary},children:"Active"}),me("ul",{style:{listStyle:"none",padding:0,margin:0},children:me(ut,{entry:V,active:!0,featured:!0,previewBackground:w.control,onRemove:Y?void 0:e=>{if(!s||B.current)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void s(e);let t={id:e.id,timers:[],cleanup:()=>{}};for(let e of E.current)e.cancel();E.current=[],B.current=t,O({entry:e,phase:"fade",activeHeight:z.current?.offsetHeight??0,headingHeight:P.current?.offsetHeight??0});let r=!1,n=!1,a=!1,i=()=>{if(r&&n&&B.current===t){for(let e of t.timers)clearTimeout(e);t.cleanup(),B.current=null,O(null)}},o=C.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(()=>{B.current===t&&(a=!0,R.current={returningId:e.id,positions:dt($.current)},O(t=>t?.entry.id===e.id?{...t,phase:"collapse"}:t))},100)),t.timers.push(setTimeout(()=>{r=!0,i()},600));try{Promise.resolve(s(e)).then(()=>{n=!0,i()},()=>{n=!0,i()})}catch{n=!0,i()}},onOpenDetails:h,onPrefetchDetails:g})})]}),ve("div",{"data-taste-collections":!0,style:{display:"flex",flexDirection:"column",gap:V&&"collapse"!==M?.phase?16:0,transition:M?"gap 200ms ease-in-out":void 0},children:[V&&me("h3",{ref:P,"data-taste-collections-heading":!0,style:{margin:0,font:"inherit",fontWeight:600,lineHeight:"12px",color:"light"===e?"#555555":"#aaaaaa",flexShrink:0,height:M?"collapse"===M.phase?0:M.headingHeight:void 0,opacity:"collapse"===M?.phase?0:1,overflow:M||Y?"hidden":void 0,transition:M?"height 200ms ease-in-out, opacity 100ms ease-out":void 0},children:"Collections"}),me("div",{"data-taste-catalogs":!0,ref:$,style:{display:"flex",flexDirection:"column",gap:24},children:[{label:"Private",entries:X},{label:"Public",entries:_}].map(({label:e,entries:t})=>ve("section",{"aria-label":`${e} tastes`,style:{display:"flex",flexDirection:"column",gap:8},children:[ve("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px"},children:[me("span",{children:e})," ",me("span",{"data-taste-count":!0,style:{color:w.muted},children:t.length})]}),t.length?me("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8},children:t.map(e=>me(ut,{entry:e,onAdd:M||!l?void 0:G,onRemove:s,active:!1,hasActiveTaste:!!K&&!J,onOpenDetails:h,onPrefetchDetails:g},e.id))}):me("span",{style:{color:w.muted},children:"Private"===e&&y?y:`No ${e.toLowerCase()} results found.`})]},e))})]})]}),f&&me("span",{role:"status",children:f}),m]})]})}function ht({entry:e,theme:t,active:r,onBack:n,onToggle:a,notice:i,style:o,facts:l,summaryNotice:s,drilldown:d,onOpenFact:p}){let h=c[t],[g,f]=F(!1),m=W(null),v=K(d)?d.key:null;return H(()=>{m.current&&(m.current.scrollTop=0),f(!1)},[e.id,v]),ve("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 ${h.border}`,background:h.surface,color:h.primary,fontFamily:u,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,boxSizing:"border-box",overflow:"hidden",...o},children:[me("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 ${h.primary}; outline-offset: 3px; }\n [data-taste-detail] [data-detail-back]:hover { color: ${h.primary} !important; }\n [data-taste-detail] [data-detail-cta]:enabled:hover { background: ${h.actionHover} !important; }\n [data-taste-fact]:hover dt, [data-taste-fact]:focus-within dt { color: ${h.primary} !important; }\n [data-taste-fact]:hover button, [data-taste-fact] button:focus-visible { background: ${h.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 `}),ve("div",{"data-taste-detail-header":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[ve("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:h.secondary,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,cursor:"pointer"},children:[me(Q,{size:16,color:h.primary}),me(ie,{size:14,style:{transform:"scaleY(-1)"}}),e.name]}),me("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:h.actionSurface,color:h.actionForeground,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,opacity:a?1:.5,cursor:a?"pointer":"default"},children:ve(ye,r?{children:["Remove",me(Z,{size:12})]}:{children:[me(oe,{size:12}),"Add"]})})]}),me("div",{"data-taste-detail-body":!0,ref:m,onScroll:e=>f(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:g?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:g?"linear-gradient(to bottom, transparent, #000 16px)":void 0},children:d??ve(ye,{children:[me("div",{style:{display:"flex",flexDirection:"column",gap:8},children:me(lt,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,background:h.control},e.id)}),me("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}]:[],...(l??[]).filter(e=>"version"!==e.key)].map(({key:e,label:t,value:r})=>ve("div",{"data-taste-fact":!0,style:{position:"relative",display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,padding:"4px 0"},children:[me("dt",{style:{color:h.secondary},children:t}),me("dd",{"aria-label":`${t}: ${r}`,style:{margin:0,fontSize:14,fontWeight:500,fontVariantNumeric:"tabular-nums"},children:p?ve("button",{type:"button","aria-label":`View ${t}`,onClick:()=>p(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,me(le,{size:14})]}):r})]},e))}),s&&me("div",{role:"status",style:{color:h.secondary,padding:"0 4px"},children:s}),i&&me("div",{role:"status",style:{color:h.secondary,padding:"0 4px"},children:i})]})})]})}var gt={position:"relative",margin:0,font:"inherit",fontWeight:"inherit",fontSize:12,display:"flex",alignItems:"center",padding:"4px 4px"};function ft({last:e,color:t,left:r=4}){return ve("span",{"aria-hidden":"true","data-taste-nested-branch":!0,style:{position:"absolute",left:r,top:0,bottom:0,pointerEvents:"none",color:t},children:[!e&&me("span",{"data-taste-nested-trunk":!0,style:{position:"absolute",top:0,bottom:0,borderLeft:"1px solid currentColor"}}),me("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 mt=e=>{let t=e.replace(/([a-z])([A-Z])/g,"$1 $2");return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()};function vt(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):mt(e)).join(" · "),c=JSON.stringify(l),u=i.get(c)??{heading:l.map(e=>t||r?mt(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 yt=["Palette","Semantic colors","Typography","Spacing & layout","Radii & borders","Shadows & effects","Motion","Other"],bt=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{},wt=(e,t)=>e.localeCompare(t,"en",{numeric:!0,sensitivity:"base"}),xt=new Map([["none",0],["xs",1],["sm",2],["base",3],["md",4],["lg",5],["xl",6]]),kt=new Map([["xs",0],["sm",1],["base",2],["lg",3],["xl",4]]);function St(e){return/^(text|space|spacing|radius|radii|shadow)(?:-|$)/i.exec(e)?.[1]?.toLowerCase()??null}function Ct(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])):kt.get(r)??null:n?2-Number(n[1]):"xxs"===r?0:a?5+(/^x/.test(a[1])?a[1].length:Number(a[1])):xt.get(r)??null}function $t(e,t,r){let n=bt(t),a=String(n.$type??"").toLowerCase(),i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=n.$value??t,l=bt(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||y(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 Rt({taste:e,style:t,onClick:r,children:n}){let a=tt(e?.states?.button,!0,320);return me("button",{type:"button",...a.handlers,onClick:r,style:{...De(Pe(t)),...Me(e?.detail?.button,320),...a.style},children:n})}var Et={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"},Tt=["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 It(e){let t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Et[t]??t;return Tt.includes(r)?r:void 0}var Nt=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{};function At(e,t){let r=(e,n=0)=>{if(n>12)return;if(e&&"object"==typeof e)return r(Nt(e).$value??Nt(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(Nt(e)).slice(0,80).map(([e,t])=>[e,r(t)])),a=Me(je({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 Lt({kind:e,style:t,handlers:r,definition:n,tokens:a,taste:i}){let o=Y(),[l,s]=F(0),[d,c]=F(!1),[u,p]=F(!0),[h,g]=F(60),[f,m]=F(""),v=Nt(Nt(n).$value),y=Nt(v.$children??Nt(n).$children),b=(e,t)=>{let r=Nt(y[e]),n=Nt(r.$value??r);return{...At(n.default,a),...At(t?n[t]:void 0,a)}},w=e=>e?At(v.checked??v.selected??v.active,a):{},x={boxSizing:"border-box",maxWidth:"86%",font:"inherit",...Me(i?.detail?.body,320),...t},k={padding:"5cqw",...x,width:"82%"},S={font:"inherit",color:"inherit",background:"transparent",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:"1.5cqw 3cqw",cursor:"pointer"},C={display:"flex",flexDirection:"column",gap:"3cqw"},$={size:"1em","aria-hidden":!0},R=(e,t,r={})=>me(Rt,{taste:i,onClick:t,style:{...S,...r},children:e},e),E=me("strong",{style:{...Me(i?.detail?.heading,320),...b("title")},children:"A little space"}),T=me("span",{style:{fontSize:"0.85em",...Me(i?.detail?.body,320),...b("description")},children:"Make something your own."}),I={...r,"data-specimen-kind":e};switch(e){case"button":return me("button",{...I,type:"button",style:{...x,cursor:"pointer"},children:"Button"});case"input":return me("input",{...I,"aria-label":"Preview input",defaultValue:"A fresh start",style:{...x,width:"76%",outline:"none"}});case"textarea":return me("textarea",{...I,"aria-label":"Preview textarea",defaultValue:"A little space for your ideas.",rows:3,style:{...x,width:"76%",resize:"none",outline:"none"}});case"card":return ve("div",{...I,style:{...k,...C},children:[E,T,R("Get started",()=>p(!u),b("button"))]});case"badge":return me("span",{...I,style:x,children:"New"});case"avatar":return me("div",{...I,"aria-label":"Preview avatar",style:{...x,width:"18cqw",height:"18cqw",display:"grid",placeItems:"center"},children:me(ge,{...$})});case"label":return me("label",{...I,style:x,children:"Project name"});case"separator":return me("div",{...I,role:"separator",style:{...x,width:"76%",padding:0,...b("separator")}});case"checkbox":return ve("label",{...I,style:{...x,display:"flex",gap:"3cqw",alignItems:"center"},children:[me("input",{type:"checkbox",checked:u,onChange:e=>p(e.target.checked),style:{width:"5cqw",height:"5cqw",...b("indicator",u?"checked":void 0)}}),"Stay inspired"]});case"radio":return me("div",{...I,role:"radiogroup","aria-label":"Preview options",style:{...x,...C},children:["Personal","Team"].map((e,t)=>ve("label",{style:{display:"flex",gap:"3cqw",...b("item",l===t?"checked":void 0)},children:[me("input",{name:o,type:"radio",checked:l===t,onChange:()=>s(t)}),e]},e))});case"switch":return me("button",{...I,type:"button",role:"switch","aria-label":"Preview switch","aria-checked":u,onClick:()=>p(!u),style:{...x,width:"18cqw",padding:"1.5cqw",cursor:"pointer",...w(u)},children:me("span",{style:{display:"block",width:"6cqw",height:"6cqw",marginLeft:u?"auto":0,...b("thumb",u?"checked":void 0)}})});case"toggle":return ve("button",{...I,type:"button","aria-pressed":u,onClick:()=>p(!u),style:{...x,cursor:"pointer",...w(u)},children:["Bold ",u&&me(he,{...$})]});case"slider":return me("input",{...I,type:"range","aria-label":"Preview slider",value:h,onChange:e=>g(Number(e.target.value)),style:{...x,width:"76%"}});case"progress":return me("div",{...I,role:"progressbar","aria-label":"Preview progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":60,style:{...x,width:"76%",height:"4cqw",padding:0,overflow:"hidden"},children:me("div",{style:{width:"60%",height:"100%",...b("indicator")}})});case"skeleton":return me("div",{...I,"aria-label":"Preview loading placeholder",style:{...x,width:"76%",height:"22cqw"}});case"tabs":return ve("div",{...I,style:k,children:[me("div",{role:"tablist","aria-label":"Preview tabs",style:{display:"flex",gap:"2cqw",...b("list")},children:["Overview","Activity"].map((e,t)=>me("button",{type:"button",role:"tab","aria-selected":l===t,onClick:()=>s(t),onKeyDown:e=>{("ArrowLeft"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),s(1-l))},style:{...S,...b("trigger",l===t?"active":void 0)},children:e},e))}),me("div",{role:"tabpanel",style:{paddingTop:"4cqw",...b("content")},children:0===l?"Your next big idea starts here.":"All caught up."})]});case"accordion":return me("div",{...I,style:k,children:["What is included?","Can I make it mine?"].map((e,t)=>ve("div",{style:b("item"),children:[ve("button",{type:"button","aria-expanded":d&&l===t,onClick:()=>{s(t),c(!(d&&l===t))},style:{...S,width:"100%",display:"flex",justifyContent:"space-between",...Me(i?.detail?.heading,320),...b("trigger")},children:[e,me(pe,{...$})]}),d&&l===t&&me("div",{style:{padding:"3cqw",...Me(i?.detail?.body,320),...b("content")},children:"Everything you need to get started."})]},e))});case"select":return me("select",{...I,"aria-label":"Preview select",value:l,onChange:e=>s(Number(e.target.value)),style:x,children:["Choose a project","Personal","Team"].map((e,t)=>me("option",{value:t,children:e},e))});case"combobox":case"command":return ve("div",{...I,style:{...k,...C},children:[ve("label",{style:{display:"flex",alignItems:"center",gap:"2cqw"},children:[me(G,{...$}),me("input",{"aria-label":"Search preview options",value:f,onChange:e=>m(e.target.value),placeholder:"Search projects…",style:{...S,minWidth:0,width:"100%",...b("input")}})]}),["Personal","Team","Archive"].filter(e=>e.toLowerCase().includes(f.toLowerCase())).map(e=>R(e,()=>m(e),b("item"))),!["Personal","Team","Archive"].some(e=>e.toLowerCase().includes(f.toLowerCase()))&&me("span",{children:"No results"})]});case"dropdown-menu":case"menubar":return ve("div",{...I,style:{...k,...C},children:[R("Options ▾",()=>c(!d),b("trigger")),d&&me("div",{style:{...C,...b("content")},children:["New project","Duplicate","Archive"].map((e,t)=>R(`${l===t?"✓ ":""}${e}`,()=>{s(t),c(!1)},b("item")))})]});case"dialog":case"sheet":return me("div",{...I,style:{...k,...C,..."sheet"===e?{marginLeft:"auto",maxWidth:"65%",minHeight:"42cqw"}:{},...b("content")},children:ve(ye,d?{children:[E,T,R("Done",()=>c(!1),b("button"))]}:{children:[E,T,R("Open preview",()=>c(!0),b("trigger"))]})});case"popover":case"tooltip":return ve("div",{...I,style:{...x,...C},children:[me("button",{type:"button",onClick:()=>c(!d),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:()=>c(!1),style:{...S,...b("trigger")},children:"Learn more"}),d&&me("span",{role:"tooltip",style:b("content"),children:"A little room for your ideas."})]});case"alert":case"toast":return ve("div",{...I,role:"status",style:{...k,display:"flex",gap:"3cqw",alignItems:"center"},children:[me(ue,{...$}),ve("div",{style:C,children:[me("strong",{style:b("title"),children:u?"Changes saved":"Ready when you are"}),me("span",{style:b("description"),children:"Your project is up to date."})]}),"toast"===e&&me("button",{type:"button","aria-label":"Dismiss preview toast",onClick:()=>p(!u),style:S,children:me(Z,{...$})})]});case"table":return me("div",{...I,style:{...k,padding:0,overflow:"hidden",textAlign:"left"},children:ve("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,font:"inherit",color:"inherit"},children:[me("thead",{style:b("header"),children:me("tr",{children:["Project","Status"].map(e=>me("th",{style:{padding:"2cqw",...b("head")},children:e},e))})}),me("tbody",{children:["Personal","Team"].map(e=>ve("tr",{style:b("row"),children:[me("td",{style:{padding:"2cqw",...b("cell")},children:e}),me("td",{style:{padding:"2cqw",...b("cell")},children:"Active"})]},e))})]})});case"breadcrumb":return ve("nav",{...I,"aria-label":"Preview breadcrumb",style:{...x,display:"flex",gap:"2cqw",alignItems:"center"},children:[R("Home",()=>s(0),b("link")),me(le,{...$}),me("span",{"aria-current":"page",style:b("page"),children:l?"Settings":"Projects"})]});case"pagination":return me("nav",{...I,"aria-label":"Preview pagination",style:{...x,display:"flex",gap:"2cqw"},children:[0,1,2].map(e=>me("button",{type:"button","aria-current":l===e?"page":void 0,onClick:()=>s(e),style:{...S,...b("item",l===e?"active":void 0)},children:e+1},e))});case"calendar":return ve("div",{...I,style:{...k,padding:"2cqw",fontSize:"3.5cqw"},children:[me("div",{style:{textAlign:"center",...b("caption")},children:"September 2026"}),ve("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.5cqw"},children:[["M","T","W","T","F","S","S"].map((e,t)=>me("span",{style:{textAlign:"center",...b("head")},children:e},t)),me("span",{"aria-hidden":"true"}),Array.from({length:30},(e,t)=>me("button",{type:"button","aria-label":`September ${t+1}`,"aria-pressed":l===t,onClick:()=>s(t),style:{...S,border:0,padding:0,...b("day",l===t?"selected":void 0)},children:t+1},t))]})]});case"form":return ve("form",{...I,onSubmit:e=>{e.preventDefault(),c(!0)},style:{...k,...C},children:[me("label",{htmlFor:o,style:b("label"),children:"Project name"}),me("input",{id:o,required:!0,placeholder:"A fresh start",style:{...S,...b("input")}}),me("button",{type:"submit",style:{...S,...b("button")},children:"Create project"}),d&&me("span",{role:"status",children:"Project created (preview)"})]});case"otp":return me("div",{...I,style:{...x,display:"flex",gap:"1cqw"},children:[0,1,2,3].map(e=>me("input",{"aria-label":`Preview digit ${e+1}`,inputMode:"numeric",maxLength:1,pattern:"[0-9]",style:{...S,width:"8cqw",padding:"2cqw 0",textAlign:"center",...b("slot")}},e))});case"scroll":return me("div",{...I,tabIndex:0,"aria-label":"Preview scroll area",style:{...k,maxHeight:"35cqw",overflow:"auto",overscrollBehavior:"contain"},children:Array.from({length:12},(e,t)=>ve("div",{style:{padding:"2cqw",...b("item")},children:["Project ",t+1]},t))});case"chart":return ve("figure",{...I,"aria-label":"Preview project activity chart",style:{...k,margin:0},children:[me("figcaption",{style:b("title"),children:"Activity"}),me("div",{style:{display:"flex",alignItems:"end",gap:"3cqw",height:"25cqw"},children:[35,60,45,85,70].map((e,t)=>me("div",{title:`${e} projects`,style:{flex:1,height:`${e}%`,...b("bar")}},t))})]});default:return null}}var zt=e=>e&&"object"==typeof e&&!Array.isArray(e)?e:{};function Pt(e,t,r){return!!r&&!!It(e)&&!!Object.keys(zt(zt(zt(t).$value).default)).length}function Dt(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)||Dt(a,[...t,n],r);return r}function jt({bridgeUrl:e,id:t,collection:r,section:n,theme:a,onPreview:i,onReconnect:o,cache:l,query:s=""}){let d=c[a],[u,h]=F(),[g,f]=F(""),[m,v]=F(!1),[y,b]=F(!1),[w,x]=F(null),k=W(null),S=`${e??""}/cloud-taste/definition?id=${encodeURIComponent(t)}&collection=${encodeURIComponent(r)}`;async function C(e,t,r=!1){if(!u||y)return;let n=k.current;if(n&&!n.signal.aborted){b(!0),f("");try{let a=await p(S,{signal:n.signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,value:t,reset:r,sourceHash:u.hash,expectedRevision:u.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(S,o),h(o);let s=Qe(o.preview);s&&i(s)}catch(e){l?.invalidate(S),n.signal.aborted||f(e.message)}finally{n.signal.aborted||b(!1)}}}H(()=>{let e=new AbortController;return k.current=e,h(void 0),f(""),v(!1),x(null),(l?l.read(S):p(S,{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||(f(n.message),v(n.reconnect)))}let r=await t.json();if(!r.sections||!Array.isArray(r.overrides))throw new Error("Invalid taste definition");if(!e.signal.aborted){h(r);let e=Qe(r.preview);e&&i(e)}}).catch(t=>{e.signal.aborted||f(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()},[S,i,l]);let $="tokens"===n||"principles"===n?"principles":"visual-directions"===n?"assets":"copy-guidance"===n?"content":n,R=s.trim().toLocaleLowerCase(),E=e=>!R||String(e).toLocaleLowerCase().includes(R),T=Object.entries(zt(u?.sections[$])),I="principles"===$,N=new Map(T.map(([e,t])=>[e,I?$t(e,t,zt(u?.sections.principles)):7]));if(I&&T.sort(([e],[t])=>N.get(e)-N.get(t)||function(e,t){let r=St(e),n=St(t);if(!r||r!==n)return wt(e,t);let a=Ct(e,r),i=Ct(t,n);return null!==a&&null!==i?a-i||wt(e,t):null!==a?-1:null!==i?1:wt(e,t)}(e,t)),"components"===$){let e=(e,t)=>Pt(e,t,Qe(u?.componentPreviews?.[e]));T.sort(([t,r],[n,a])=>Number(e(n,a))-Number(e(t,r))||t.localeCompare(n,void 0,{sensitivity:"base",numeric:!0}))}let A=T.filter(([e,t])=>E(e)||E(JSON.stringify(t))),L=u?.versions?.filter(e=>E(`${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?me("div",{"data-taste-versions":!0,children:g?ve("div",{role:"alert",children:[g,m&&me("div",{style:{marginTop:8},children:me("button",{type:"button",onClick:o,children:"Reconnect"})})]}):u?"public"===r?me("div",{children:"Public version history is not available yet."}):u.versions?ve("dl",{style:{margin:0},children:[L?.map(e=>ve("div",{style:{display:"flex",justifyContent:"space-between",gap:16,padding:"8px 4px"},children:[me("dt",{children:e.version}),me("dd",{style:{margin:0,color:d.secondary},children:e.saved_at?me("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)),!u.versions.length&&me("div",{children:"No version history recorded."}),!!u.versions.length&&!L?.length&&me("div",{role:"status",children:"No matching versions."})]}):me("div",{role:"status",children:"Version history is currently unavailable."}):me("div",{role:"status",children:"Loading versions…"})}):ve("div",{"data-taste-drilldown":!0,style:{display:"flex",flexDirection:"column",gap:0,fontVariantNumeric:"tabular-nums"},children:[me("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 `}),!u&&!g&&me("div",{role:"status",children:"Loading definitions…"}),g&&ve("div",{role:"alert",style:{color:d.secondary},children:[g,!u&&m&&me("button",{type:"button",onClick:o,style:{display:"block",marginTop:8},children:"Reconnect"})]}),!!u?.conflicts.length&&me("div",{role:"status",children:"Some source values changed remotely. Conflicting overrides are not applied; reset or edit them to resolve."}),u&&!A.length&&me("div",{role:"status",children:R&&T.length?"No matching definitions.":"No definitions in this section."}),A.map(([e,t],r)=>{let a=Dt(t,[$,e]).filter(t=>E(e)||E(t.path.join(" "))||E(JSON.stringify(t.value))),i="components"===$;return I&&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)||wt(e.join("."),t.join("."))}(e.path,t.path)),ve("div",{"data-taste-group-path":JSON.stringify([$,e]),style:{display:"flex",flexDirection:"column",gap:i?8:0,marginBottom:i?8:0},children:[I&&(0===r||N.get(A[r-1][0])!==N.get(e))&&me("h2",{"data-taste-token-section":!0,style:{font:"inherit",fontWeight:500,color:d.primary,margin:0===r?"0 4px 8px":"16px 4px 8px"},children:yt[N.get(e)]}),i&&me(Mt,{name:e,definition:t,taste:Qe(u?.preview),tokens:zt(u?.sections.principles),recipe:Qe(u?.componentPreviews?.[e])}),i&&ve("button",{type:"button","data-taste-component-header":!0,disabled:!a.length,onClick:()=>x(w===e?null:e),"aria-expanded":a.length?w===e||!!R: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:[me("span",{children:e}),!!a.length&&me(le,{size:14,style:{boxSizing:"content-box",padding:"2px 4px",borderRadius:8,transform:w===e||R?"rotate(90deg)":void 0,transition:"transform 120ms"}})]}),(!i||w===e||!!R)&&vt(a,"copy-guidance"===n,"visual-directions"===n,i,I).map((e,t,r)=>ve("div",{"data-taste-state-group":i?"":void 0,"data-taste-token-group":I&&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&&me("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&&ve("h3",{"data-taste-token-parent":I?"":void 0,style:{position:"relative",margin:I?0:i?"2px 4px 0":"12px 4px 0",font:"inherit",fontWeight:I?"inherit":500,fontSize:I?12:void 0,color:I?d.secondary:d.primary,display:I?"flex":void 0,alignItems:I?"center":void 0,padding:I?"4px 4px":void 0,...I?gt:{}},children:[i&&me("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,I&&me("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=u.overrides.some(e=>JSON.stringify(e.path)===n),o=me(Ot,{path:t.path,label:t.label,value:t.value,disabled:y,overridden:a,colors:d,componentValue:i,colorTokens:"principles"===$||"components"===$?zt(u?.sections.principles):void 0,onSave:e=>{C(t.path,e)},onReset:()=>{C(t.path,t.value,!0)}},n);return I&&e.heading?ve("div",{"data-taste-token-child":!0,style:{position:"relative",paddingLeft:12},children:[me(ft,{last:r===e.rows.length-1,color:`color-mix(in srgb, ${d.secondary} 40%, ${d.surface})`}),o]},n):o})]},t)),!i&&!a.length&&ve("div",{style:{color:d.secondary,padding:"0 4px",overflowWrap:"anywhere"},children:[e,": ",JSON.stringify(t)]})]},e)})]})}function Mt({name:t,definition:r,recipe:n,tokens:a,taste:i}){let o=It(t),l=/button/i.test(t)?"button":/input|text.?field|textarea/i.test(t)?"input":"card",s=tt(n?.states?.[l],!0,320);if(!n||!o||!Pt(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,...Me(i?.detail?.body,320),...At(zt(zt(r).$value).default,a),...s.style};return me(e,{children:me("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:me(Lt,{kind:o,style:d,handlers:s.handlers,definition:r,tokens:a,accent:n.accent,taste:i})})})}function Ot({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]=F(u),g=W(null),f=W(!1),m=s&&"string"==typeof r?y(p,s):void 0;return H(()=>h(u),[u]),ve("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:[me("label",{style:{flex:1,minWidth:0,overflowWrap:"anywhere",fontSize:12},children:t}),"boolean"==typeof r?me("input",{ref:g,"aria-label":t,type:"checkbox",checked:r,disabled:n,onChange:e=>o(e.target.checked)}):ve("span",{"data-taste-value-field":!0,style:{position:"relative",display:"inline-grid",maxWidth:"52%",marginRight:m?0:-8,minWidth:0},children:[me("span",{"aria-hidden":"true",style:{visibility:"hidden",whiteSpace:"pre",overflow:"hidden",font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14,padding:"2px 8px"},children:p||" "}),me("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&&me("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:me("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:m}})}),a&&me("button",{type:"button",disabled:n,onClick:l,"aria-label":`Reset ${t}`,style:{border:0,background:"transparent",color:i.secondary,padding:0},children:me(de,{size:12})})]})}var Wt=["display","paddingTop","paddingRight","paddingBottom","paddingLeft","rowGap","columnGap","borderTopLeftRadius","fontFamily","fontSize","lineHeight","fontWeight","letterSpacing","color","backgroundColor","borderTopColor","borderTopWidth","boxShadow"];var Ft=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:px|rem|em|vw|vh|vmin|vmax|ch)?$/i;function Bt(e,t){let r,n=k(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)?N(u,t):null;if("inset"===u.toLowerCase()){if(s)return null;s=!0}else if("color"===h?.kind||!c&&y(u,{})){if(r)return null;r=p}else{if("layout"!==h?.kind&&(c||!Ft.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 qt(e,t){let r=D(e,t);if(null===r)return null;let n=Bt(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=L(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"}`:m(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 Ht(e,t,r,n,a){let i=Bt(e,r);if(void 0!==a){let n=i?.dimensions[a];return n&&"layout"===t.kind?void 0!==n.referenceIndex?I(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 I(e,t,r,n)}function Ut(e,t){try{if(Object.entries(t.root.styles).some(([t,r])=>null===Ae(e,r,t)))return!1;for(let t of["basis","padding","gap","body-family","body-size","body-height","body-weight"]){let r=f(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&&Ae(e,n,r);if(!a||("color"===r||"backgroundColor"===r)&&!y(a,{}))return!1}return!0}catch{return!1}}function Vt(e,t,r=0){try{return f(e,t,r)}catch{return null}}function Kt(e,t){let r=c[t],n=t=>Vt(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&&v(n.value,e.constraints);return a&&y(a,{})?a:r},l=n("primary"),s="color"===l?.kind?m(l):r.primary,d=e=>{let t=n(e);return"font"===t?.kind?t.value:"system-ui, sans-serif"},u=(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:u("body-weight",400)},heading:{fontFamily:d("heading-family"),fontSize:i("heading-size",24),lineHeight:i("heading-height",26),fontWeight:u("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 Yt({recipe:e,styles:t}){let r=W(null),n=W(null),[a,i]=F({scale:.5,width:640,height:320});return q(()=>{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]),me("div",{ref:r,className:"tc-preview-demo",style:{backgroundColor:t.page?.backgroundColor??e.background},inert:!0,children:me("div",{style:{position:"absolute",left:"50%",top:"50%",width:a.width*a.scale,height:a.height*a.scale,transform:"translate(-50%, -50%)"},children:me("div",{ref:n,"data-taste-preview-canvas":!0,style:{width:640,transform:`scale(${a.scale})`,transformOrigin:"top left"},children:me(rt,{recipe:e,usageStyles:t})})})})}function Jt({draft:e,dimensionId:t,theme:r,preferPageComponent:n=!1,waitForPageFoundations:a=!1}){let i=V(()=>Kt(e,r),[e,r]),o=V(()=>w(e),[e]),l=e.fragments?.find(t=>t.id===e.featuredComponentId),s=e.constraints.find(e=>e.id===t),d=s&&Vt(e.constraints,s.id),c=s&&d&&"font"!==d.kind?[-2,-1,0,1,2].map(t=>({step:t,value:Vt(e.constraints,s.id,t)})):[],u=Math.max(1,...c.map(({value:e})=>"layout"===e?.kind?e.value:0)),p=e.constraints.filter(t=>Vt(e.constraints,t.id)).length,h="increment"===s?.scaleMode,g=s?.name.endsWith("size"),f=s?.name.endsWith("height"),v="radii"===s?.id,y=s?`${s.name} preview`:"Taste demonstration preview";return ve("div",{className:"tc-dimension-preview","data-taste-constraint-preview":!0,"data-preview-dimension":s?.id,role:"group","aria-label":y,children:[me("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?ve("div",{className:"tc-preview-family",style:{fontFamily:d.value},children:[me("div",{style:{fontSize:32,lineHeight:1.4,color:"var(--tc-primary)"},children:"Aa Bb Cc"}),me("div",{style:{fontSize:13,lineHeight:1.5},children:"The quick brown fox jumps."}),me("div",{className:"tc-preview-step-label",title:d.value,style:{marginTop:8,fontSize:10},children:d.value})]}):me("div",{className:"tc-preview-steps","aria-label":`${s.name} steps`,children:c.map(({step:e,value:t})=>{let r=t&&m(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=v?{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)"}),ve("div",{className:"tc-preview-step","data-base":0===e,"aria-label":`Step ${e}: ${r??"unresolved"}`,title:r??void 0,children:[me("span",{children:e>0?`+${e}`:0===e?"Base":e}),me("span",{className:"tc-preview-sample","aria-hidden":"true",children:me("span",{style:a,children:h||g?"Aa":f?"Ab\nAb":""})}),me("span",{className:"tc-preview-step-label",children:n??"—"})]},e)})}):me("div",{className:"tc-preview-empty",children:s.value||s.parentId?"This dimension does not resolve yet.":"Waiting for this dimension…"}):!l||a&&!Ut(e,l)?p&&!n?me(Yt,{recipe:i,styles:o}):me("div",{className:"tc-preview-empty",children:me("span",{className:"tc-proposal-status","data-state":"in-progress",children:"tracing stylenet"})}):me(at,{fragment:l,draft:e,height:176})]})}var _t=new Map;function Xt(e,a){if(!e||typeof CanvasRenderingContext2D>"u")return;let i=`${a}|${e}`;if(_t.has(i))return _t.get(i);let o=t();if(!o)return;let l=function(e,t){if(!(r(e,t)>=1.6))return n(t)<.179?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.18)"}(o(e,"#d5d5d5"),o(a,"#fff"));return _t.size>=256&&_t.clear(),_t.set(i,l),l}function Gt(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 Zt=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z]+|%)?$/i;function Qt({value:e,spec:t,preview:r,commit:n,cancel:a}){let i=W(null),o=W(0),l=W(!1),s=W(!1),[d,c]=F(null);H(()=>()=>i.current?.(),[]);let u=t?(e.trim()||(void 0===t.defaultValue?"":String(t.defaultValue))).match(Zt):null,p=!!u&&Number.isFinite(Number(u[1]))||!!t?.compound&&Gt(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 Gt(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(Zt):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=Gt(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,P=()=>{x()&&y.exitPointerLock()},D=()=>{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),P(),c(null),i.current=null},j=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),j(e.shiftKey))},O=e=>{e.preventDefault(),e.stopImmediatePropagation(),D(),s.current=$,$?n(L):(v.focus(),v instanceof b.HTMLInputElement&&v.select())},W=()=>{D(),a()},F=e=>{"Shift"!==e.key?"keydown"===e.type&&"Escape"===e.key&&(e.preventDefault(),e.stopImmediatePropagation(),W()):$&&j("keydown"===e.type)},B=()=>{R?P():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=D,(()=>{if(!v.requestPointerLock)return;let e=()=>{y.removeEventListener("pointerlockchange",t),y.removeEventListener("pointerlockerror",e),R&&m===o.current&&P()},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&&be(me("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:me(ce,{size:18})}),d.doc.body)}}var er=O(()=>!1);function tr(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 rr({label:e,onCommit:t,onSelectionStart:r,children:n,...a}){let i=W(null),o=W(null),[l,s]=F(null),[d,c]=F(""),[u,p]=F(""),h=W(!1);q(()=>{!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 me(er.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?tr(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:me("div",{...a,ref:i,children:l?ve("span",{className:"tc-field tc-fit",style:{flex:"1 1 auto",minWidth:0},children:[me("span",{className:"tc-measure","aria-hidden":"true",children:d||"​"}),me("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=tr(l.ranges,a,"ArrowLeft"===e.key);e.preventDefault(),t.setSelectionRange(Math.min(n,i),Math.max(n,i),i<n?"backward":"forward")}}}),u&&me("span",{role:"alert",className:"tc-field-error",children:u})]}):n})})}function nr(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 ar=({parent:e,child:t})=>JSON.stringify([e,t]),ir=128;function or(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 lr({pane:e,edges:t,visible:r,revision:n,suspended:a,color:i}){let[o,l]=F(new Map),s=new Set(r.map(ar)),d=JSON.stringify(t),c=JSON.stringify(r),u=W(null),p=W(r);return p.current=r,H(()=>{let t=e.current;if(!t)return;let r,n=JSON.parse(d),a=n.length>ir,i=new Set,o=!1,s=()=>{if(o)return;let e=or(t),r=p.current.length<=ir?new Set(p.current.map(ar)):new Set,s=a?n.filter(e=>i.has(e.child)||r.has(ar(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(ar(t),nr(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,ir).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]),q(()=>{!a&&p.current.length<=ir&&p.current.some(e=>!o.has(ar(e)))&&u.current?.()},[c,a,o]),me("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 ve("g",{"data-taste-cached-connection":e,"data-taste-connection":o?"":void 0,style:{visibility:o?"visible":"hidden"},children:[me("path",{d:n,fill:"none",stroke:i,strokeWidth:1}),me("circle",{cx:t.x,cy:t.y,r:3,fill:i}),me("circle",{cx:r.x,cy:r.y,r:3,fill:i})]},e)})})}function sr({value:e,label:t,className:r,onEdit:n,onCommit:a,onPreview:i}){let o=Qt({value:e,spec:{step:1,compound:!0},preview:i,commit:e=>{a(e),i(null)},cancel:()=>i(null)});return ve(ye,{children:[me("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 dr({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=X(er),[m,v]=F(null),[y,b]=F(""),w=W(!1),x=Y(),k=m??t,[S,C]=F(!1),[$,R]=F(!0),[E,T]=F(!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=W(null),[L,z]=F(0);q(()=>{z(A.current?.getBoundingClientRect().width??0)},[N]);let P=e=>{try{r(e.trim()),c?.(null),v(null),b("")}catch(e){b(e instanceof Error?e.message:"Check this value")}},D=Qt({value:k,spec:s,preview:e=>{v(e),b(""),c?.(e)},commit:P,cancel:()=>{v(null),b(""),c?.(null),a?.()}}),j="number"==typeof l?l:2,M=3-j,O=l?k.match(/^(-?)(\d*)(\.?)(\d*)$/):null,B=O?`${O[3]?"":"."}${"0".repeat(Math.max(0,j-O[4].length))}`:"",H=O?"0".repeat(Math.max(0,M-O[2].length)):"",U=W(null),[V,K]=F(0);return q(()=>{let e=U.current;if(!e)return;let t=()=>K(e.getBoundingClientRect().width);if(t(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[B]),ve("span",{className:`tc-field${o?" tc-fit":""}${l?" tc-decimal":""}`,children:[o&&me("span",{className:"tc-measure","aria-hidden":"true",children:l?`${"0".repeat(Math.max(4,t.length,O?`${O[1]}${H}${O[2]}${O[3]}${O[4]}${B}`.length:k.length)-j-1)}.${"0".repeat(j)}`:k+N||g.placeholder||"​"}),N&&ve("span",{className:"tc-source-completion","aria-hidden":"true",children:[me("span",{style:{visibility:"hidden"},children:k}),me("span",{ref:A,children:N})]}),l&&O&&ve("span",{className:"tc-decimal-display","aria-hidden":"true",children:[O[1],me("span",{className:"tc-digit-placeholder",children:H}),O[2],O[3],O[4],me("span",{ref:U,className:"tc-digit-placeholder",children:B})]}),me("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":D.enabled||void 0,onPointerDown:D.start,onContextMenu:d||u?e=>{e.preventDefault(),e.stopPropagation(),u?u():P("")}:void 0,placeholder:l?`${"0".repeat(M)}.${"0".repeat(j)}`:g.placeholder,inputMode:l?"decimal":void 0,style:l&&O?{color:"transparent",caretColor:"var(--tc-primary)",paddingRight:6+V}: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,${j}})?$`).test(e.target.value)||(v(e.target.value),b(""))},onBlur:e=>{if(C(!1),!D.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?.());P(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?.())}}),D.cursor,y&&me("span",{id:x,role:"alert",className:"tc-field-error",children:y})]})}function cr({color:e,background:t}){let r=Xt(e,t);return me("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:me("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:e}})})}function ur({value:e,constraints:t,name:r,background:n}){let a=qt(e,t),i=L(t,e),o=/\bcalc\(/i.test(e)?v(e,t):null,l="layout"===i?.kind?`${Math.round(i.value)}${i.unit}`:i?m(i):o??void 0,s=z(e,t);return a||i||o||s.length?ve("span",{className:"tc-token-preview","data-token-preview":!0,"aria-label":`${r} resolves to ${a??l??s.join(", ")}`,children:[me("span",{className:"tc-separator","aria-hidden":"true",children:me(fe,{size:12})}),a?me("span",{className:"tc-resolved-value",children:me("span",{className:"tc-shadow-preview","data-shadow-value":a,"aria-hidden":"true",children:me("span",{style:{boxShadow:a}})})}):s.length?s.map((e,t)=>me("span",{className:"tc-resolved-value",children:me(cr,{color:e,background:n})},`${t}:${e}`)):me("span",{className:"tc-resolved-value",children:l})]}):null}function pr({row:e,constraints:t,background:r}){if("color"===e.kind){let n;try{n=m(f(t,e.id))}catch{}return n?me("span",{className:"tc-resolved-value",children:me(cr,{color:n,background:r})}):null}return null}var hr=e=>e.dataset.connectionId??e.dataset.constraintId??`token:${e.dataset.tokenId}`,gr=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 fr({drag:e,pane:t,color:r}){let[n,a]=F(null);if(q(()=>{let r=t.current;if(!r)return;let n=()=>{let t=or(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?nr(n,i):nr(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 ve("svg",{"data-taste-connection":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[me("path",{d:l,fill:"none",stroke:r,strokeWidth:1}),me("circle",{cx:i.x,cy:i.y,r:3,fill:r}),me("circle",{cx:o.x,cy:o.y,r:3,fill:r})]})}function mr({draft:e,onChange:t,history:r,theme:n,onBack:a,style:i,proposalState:o,preferPageComponent:d,proposalRecovery:p,fragments:h,detail:g,onSave:f,saving:v,saveNotice:y,saveAction:b}){let w=x(e),I="running"===o,z=c[n],P=W(null),D=W(null);!function(e,t,r){let n=W(!1),a=W(0),i=W(t);q(()=>{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]),q(()=>{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])}(D,o,e);let j=W({past:[],future:[]}),M=r??j,O=e=>{I||JSON.stringify(e)!==JSON.stringify(w)&&(M.current.past=[...M.current.past.slice(-99),w],M.current.future=[],t(e))},B=W(null),[U,K]=F(null),[_,X]=F(null),[G,ee]=F(null),[te,re]=F(null),[ne,ae]=F(null),[le,se]=F(null),[de,ue]=F(null),pe=w.constraints.flatMap(e=>e.parentId?[{parent:e.parentId,child:e.id}]:[]);for(let e of w.tokens)k(e.value,w.constraints).forEach((t,r)=>{let n=t&&w.constraints.find(e=>e.name.toLowerCase()===t.name.toLowerCase());n&&pe.push({parent:n.id,child:S(e.value)?`token:${e.id}`:`token:${e.id}:ref:${r}`})});let he=pe.filter(({parent:e,child:t})=>"source"===G?.port?e===G.id:t===G?.id||gr(t).row===G?.id).map(({parent:e,child:t})=>({id:e,target:t,port:"source",active:!0,validTarget:!0,x:0,y:0,toX:0,toY:0})),ge=new Set("source"===G?.port?he.map(({target:e})=>gr(e).row):[]),fe=U?[U]:_?[_]:he,be=W(!1),[we,xe]=F(""),[ke,Se]=F(null),[Ce,$e]=F(null),Re=ke?w.constraints.map(e=>e.id===ke.id?{...e,...ke.patch}:e):w.constraints,Ee=V(()=>({...w,constraints:Re,tokens:Ce?w.tokens.map(e=>e.id===Ce.id?{...e,value:Ce.value}:e):w.tokens}),[w,Re,Ce]),[Te,Ie]=F(null);H(()=>{let e=P.current?.ownerDocument;if(!e)return;let r=e=>{let r=e.key.toLowerCase();if(!e.metaKey&&!e.ctrlKey||e.altKey||"z"!==r&&"y"!==r)return;let n=e.composedPath()[0],a=n instanceof Node&&P.current?.contains(n);if(s(e)&&(!a||n instanceof Element&&n.hasAttribute("data-taste-field-dirty"))||(e.preventDefault(),e.stopImmediatePropagation(),ke||Ce||B.current))return;let i="y"===r||e.shiftKey,o=(i?M.current.future:M.current.past).pop();o&&((i?M.current.past:M.current.future).push(w),X(null),xe(""),t(o))};return e.addEventListener("keydown",r,!0),()=>e.removeEventListener("keydown",r,!0)},[w,M,t,ke,Ce]),H(()=>{if(!Te)return;let e=setTimeout(()=>Ie(null),220);return()=>clearTimeout(e)},[Te]);let Ne=Y(),Ae=W(0),Le=(e,t)=>{X(null),O({...w,constraints:w.constraints.map(r=>r.id===e?{...r,...t}:r)}),xe("")},ze=(e,t)=>O({...w,tokens:w.tokens.map(r=>r.id===e?{...r,value:t}:r)}),Pe=(e,t)=>{if(e.startsWith("token:")){let r=w.constraints.find(e=>e.id===t),n=gr(e),a=w.tokens.find(e=>`token:${e.id}`===n.row);return r&&a&&null!==Ht(a.value,r,w.constraints,n.index,n.dimensionIndex)?null:"Choose a compatible, unambiguous value"}return C(w.constraints,e,t)},De=(e,t,r=!1)=>{let n=Pe(e,t);if(n)throw Error(n);if(e.startsWith("token:")){let r=gr(e),n=w.tokens.find(e=>`token:${e.id}`===r.row),a=w.constraints.find(e=>e.id===t);return void ze(n.id,Ht(n.value,a,w.constraints,r.index,r.dimensionIndex))}Le(e,{parentId:t,...r?{derivative:$(w.constraints,e,t)}:{}})},je=(e,t)=>{let r=P.current,n=r.getBoundingClientRect();return{x:(e-n.left)/(n.width/r.offsetWidth||1),y:(t-n.top)/(n.height/r.offsetHeight||1)}},Me=(e,t,r)=>{if(0!==e.button)return;Ie(null),ee(null),X(null),be.current=!1;let n=je(e.clientX,e.clientY);B.current={id:t,port:r,...n,toX:n.x,toY:n.y,active:!1,target:null,validTarget:!1},e.currentTarget.setPointerCapture(e.pointerId)},Oe=e=>{if(!e||!Number.isFinite(Number(e)))throw Error("Enter a finite number");return Number(e)};return ve("div",{ref:P,role:"region","aria-label":g?`${g.name} uses`:"New taste","data-taste-editor":!0,"data-popmelt-font":"sans","data-popmelt-theme":n,onMouseOver:g?e=>{let t=e.target.closest("[data-token-id], [data-constraint-id]"),r=t?.getAttribute("data-token-id"),n=t?.getAttribute("data-constraint-id");g.onHover?.(r?{kind:"token",id:r}:n?{kind:"dimension",id:n}:null)}:void 0,onMouseLeave:g?()=>g.onHover?.(null):void 0,onPointerMove:e=>{let t=B.current;if(!t&&!_)return;let r=P.current.getRootNode().elementFromPoint(e.clientX,e.clientY);if(!t){let e=P.current.contains(r)?r?.closest(".tc-row"):null;return void(e&&hr(e)!==gr(_.target??"").row&&X(null))}let n=je(e.clientX,e.clientY),a=t.active||Math.hypot(n.x-t.x,n.y-t.y)>5,i=P.current.contains(r)?r?.closest("[data-connection-id], [data-constraint-id], [data-token-id]"):null,o=i?hr(i):null,l=t.landing;if(l&&t.validTarget&&P.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&&!Pe("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})}}B.current={...t,active:a,toX:n.x,toY:n.y,target:o,validTarget:s,landing:l},a&&(be.current=!0,K(B.current))},onPointerUp:()=>{let e=B.current;if(B.current=null,K(null),e?.active&&e.target)try{De("source"===e.port?e.target:e.id,"source"===e.port?e.id:e.target,!0),X({...e})}catch{xe(""),Ie("source"===e.port?e.id:e.target)}},onPointerCancel:()=>{B.current=null,K(null)},onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),B.current||_?(B.current=null,K(null),X(null)):a())},style:{...i,width:"min(360px, 100%)",marginInline:"auto",boxSizing:"border-box",position:"relative",display:"flex",flexDirection:"column",maxHeight:i?.maxHeight??"calc(100dvh - 80px)",border:`1px solid ${z.border}`,borderRadius:20,background:z.surface,color:z.secondary,fontFamily:u,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden","--tc-primary":z.primary,"--tc-muted":z.muted,"--tc-control":z.control,"--tc-secondary":z.secondary,"--tc-border":z.border,"--tc-surface":z.surface},children:[me("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"===n?"#302024":"#f9e9ec"}; color: ${"dark"===n?"#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 [data-taste-editor] .tc-proposal-status[data-state=in-progress] {\n color: var(--tc-primary);\n background: linear-gradient(100deg, var(--tc-muted) 35%, var(--tc-primary) 50%, var(--tc-muted) 65%);\n background-size: 250% 100%;\n background-clip: text;\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n animation: tc-proposal-sweep 2.4s linear infinite;\n }\n @keyframes tc-proposal-sweep {\n 0% { background-position: 100% 0; }\n 80%, 100% { background-position: 0% 0; }\n }\n @media (prefers-reduced-motion: reduce) {\n [data-taste-editor] .tc-proposal-status[data-state=in-progress] {\n animation: none;\n background: none;\n -webkit-text-fill-color: currentColor;\n }\n }\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 { ${l} }\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: ${z.actionSurface}; color: ${z.actionForeground}; font-weight: 500; }\n [data-taste-editor] .tc-save:hover { background: ${z.actionHover}; color: ${z.actionForeground}; }\n `}),ve("div",{ref:D,className:"tc-scroll",style:{overflowAnchor:"none"},tabIndex:I?0:void 0,children:[ve("header",{children:[me("button",{"aria-label":g?"Back to taste":"Back to taste collection",onClick:a,children:me(Q,{size:16})}),me(ie,{size:14}),g?me("span",{className:"tc-title",children:g.name}):me(dr,{label:"Taste name",readOnly:I,compact:!0,value:w.name,placeholder:"Name this taste",className:"tc-title",onCommit:e=>O({...w,name:e})})]}),g?g.preview(Ee):me(Jt,{draft:Ee,preferPageComponent:d,waitForPageFoundations:I&&d,dimensionId:te??ne,theme:n}),g&&me("h3",{children:"Uses"}),["layout","typography","color"].map(e=>{let t="color"===e?"color":"layout",r=t=>(!g||g.constraintIds.includes(t.id))&&(t.group??("text"===t.id?"typography":t.kind))===e;return g&&!w.constraints.some(r)?null:ve("section",{"aria-label":"typography"===e?"Typography constraints":"layout"===t?"Layout constraints":"Color constraints",children:[me("h3",{children:"typography"===e?"Typography":"layout"===t?"Layout":"Color"}),me("datalist",{id:`${Ne}-${e}`,children:w.constraints.filter(e=>e.kind===t).map(e=>me("option",{value:e.name},e.id))}),w.constraints.filter(r).map((e,t,r)=>{let n=e.kind,a=w.constraints.filter(t=>!C(w.constraints,e.id,t.id)).map(e=>e.name),i=w.constraints.find(t=>t.id===e.parentId),l=!!e.parentId,s=fe.some(t=>!!t.active&&("source"===t.port&&t.id===e.id||"target"===t.port&&t.validTarget&&t.target===e.id)),d=fe.some(t=>!!t.active&&("target"===t.port&&t.id===e.id||"source"===t.port&&t.validTarget&&t.target===e.id)),c=U?.active&&U.validTarget?"source"===U.port&&U.target===e.id?U.id:"target"===U.port&&U.id===e.id?U.target:null:null,u=w.constraints.find(e=>e.id===c)?.name,p=!(!U?.active||"source"!==U.port||l||d||C(w.constraints,e.id,U.id)),h=c?$(w.constraints,e.id,c):e.derivative,g=l||d||!!e.value,f=me(pr,{row:e,background:z.surface,constraints:c?Re.map(t=>t.id===e.id?{...t,parentId:c,derivative:h}:t):Re}),m=t=>{if(!t)return X(null),void(e.parentId?O({...w,constraints:T(w.constraints,e.id)}):Le(e.id,{value:""}));let r=w.constraints.find(e=>e.name.toLowerCase()===t.replace(/^@/,"").toLowerCase());if(!r)throw Error("Choose an existing constraint");De(e.id,r.id)};return ve(J,{children:[e.typographyRole&&r[t-1]?.typographyRole!==e.typographyRole&&me("h4",{className:"tc-type-role","data-typography-role":e.typographyRole,style:gt,children:"body"===e.typographyRole?"Body":"Heading"}),ve("div",{"data-typography-role":e.typographyRole,className:"tc-row","data-constraint-id":e.id,onPointerEnter:()=>re(e.id),onPointerLeave:()=>re(null),onFocusCapture:()=>ae(e.id),onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||ae(null)},"data-proposal-status":o?e.value||e.parentId?"done":"pending":void 0,children:[e.typographyRole&&me(ft,{left:-8,color:`color-mix(in srgb, ${z.secondary} 40%, ${z.surface})`,last:r[t+1]?.typographyRole!==e.typographyRole}),me("button",{type:"button",disabled:I,className:"tc-name","data-connection-active":s,"data-connection-rejected":Te===e.id,"aria-label":`Drag ${e.name} to connect`,onPointerDown:t=>Me(t,e.id,"source"),onPointerEnter:()=>ee({id:e.id,port:"source"}),onPointerLeave:()=>ee(null),children:me("span",{style:"source"===G?.port&&e.parentId===G.id?{color:"var(--tc-primary)"}:void 0,children:e.typographyRole?e.name.replace(`${e.typographyRole}-`,""):e.name})}),!I&&"error"!==o||e.value||e.parentId?me("div",{inert:I,style:{display:"contents"},children:ve(rr,{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=w.constraints.find(e=>e.name.toLowerCase()===t.toLowerCase());if(!r)throw Error("Choose an existing constraint");let a=C(w.constraints,e.id,r.id);if(a)throw Error(a);if(d.parentId=r.id,d.derivative=void 0===l?e.derivative:Oe(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()&&R(n,o.trim()),d.value=o.trim(),d.parentId=null}if(void 0!==a&&(d.scale=Oe(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");Le(e.id,d)},onPointerEnter:()=>ee({id:e.id,port:"target"}),onPointerLeave:()=>ee(null),children:[l||d?ve("span",{className:"tc-reference","data-connection-active":d,onContextMenu:t=>{e.parentId&&(t.preventDefault(),t.stopPropagation(),m(""))},children:[me("button",{className:"tc-port","aria-label":`Connect ${e.name} to parent`,onPointerDown:t=>Me(t,e.id,"target"),onClick:e=>{be.current||e.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),me(dr,{compact:!0,label:`${e.name} parent reference`,sourceSuggestions:a,bareSource:!0,arrowNavigation:!0,value:u??(l?i?.name??"":""),onCommit:m})]}):ve(ye,{children:[p&&me("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"}),(!p||!!e.value)&&me(dr,{compact:!0,label:`${e.name} base value`,sourceSuggestions:a,arrowNavigation:!0,value:e.value,onScrubPreview:t=>Se(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("@")?m(t):(t&&R(n,t),Le(e.id,{value:t}))}})]}),"font"!==n&&(l||d)&&ve(ye,{children:[me("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" × ",children:me(Z,{size:12})}),me(dr,{compact:!0,label:`${e.name} derivative`,arrowNavigation:!0,onScrubPreview:t=>Se(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?`${h}deg`:h.toFixed(2),onCommit:t=>{let r=Oe("color"===n?t.replace(/deg$/,""):t);if("layout"===n&&r<0)throw Error("Use zero or a positive multiplier");Le(e.id,{derivative:r})}})]}),"font"!==n&&g&&ve(ye,{children:[me("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" ⇆ ",children:me(ce,{size:12})}),me(dr,{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=>Se(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=Oe(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");Le(e.id,{scale:r})}})]}),"color"===n&&f]})}):me("span",{className:"tc-proposal-status",role:"status","data-state":"pending","aria-label":`${e.name}: ${"error"===o?"Not returned":"Pending"}`,children:"error"===o?"Not returned":"Pending"})]},e.id)]},e.id)})]},e)}),ve("section",{"aria-label":"Ad-hoc tokens",inert:I,children:[me("h3",{children:"Tokens"}),w.tokens.filter(e=>!g||g.tokenIds.includes(e.id)).map(e=>{let t=`token:${e.id}`,r=k(e.value,w.constraints),n="source"===U?.port?U.target:U?.id,a=U?.active&&U.validTarget&&n&&gr(n).row===t?"source"===U.port?U.id:U.target:null,i=w.constraints.find(e=>e.id===a),o=i?Ht(e.value,i,w.constraints,gr(n).index,gr(n).dimensionIndex)??e.value:Ce?.id===e.id?Ce.value:e.value,l=k(o,w.constraints),s=!!S(o),d=Bt(o,w.constraints),c=e=>fe.some(t=>t.active&&("target"===t.port?t.id===e:t.validTarget&&t.target===e)),u=U?.active&&"source"===U.port&&"layout"===w.constraints.find(e=>e.id===U.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=U?.active&&"source"===U.port&&!c(t)&&!Pe(t,U.id),h=p?E(o,w.constraints).find(e=>!e.reference):void 0,f=h&&(h.start>0||h.end<o.length)?h:void 0,v=me("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"},"available"),y=(t,n)=>{let a=r[t];return a?e.value.slice(0,a.start)+n+e.value.slice(a.end):n},b=(e,t)=>{let n={...r[e]??l[e],...t};return y(e,`@${n.name}${null===n.step||0===n.step?"":`: ${n.step}`}${void 0===n.opacity?"":` / ${n.opacity}`}`)},x=[],C=(r,n)=>{if(n<=r)return;let a=r,i=[...f?[{...f,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)$(a,r.start),-1===r.index?(x.push(v),a=r.start):(x.push(ve("span",{className:"tc-shadow-dimension","data-connection-id":`${t}:dim:${r.index}`,"data-shadow-dimension":r.dimension,children:[v,me("button",{className:"tc-literal","aria-label":`Edit ${e.name} ${r.dimension}`,onClick:()=>se(e.id),children:o.slice(r.start,r.end)})]},`dimension-${r.index}`)),a=r.end);$(a,n)},$=(t,r)=>{if(r<=t)return;let n=e=>o.slice(0,t)+e+o.slice(r);x.push(me(sr,{className:"tc-literal"+(r===f?.start?" tc-literal-prefix":""),label:`Edit ${e.name} value`,onEdit:()=>se(e.id),value:o.slice(t,r),onPreview:t=>$e(null===t?null:{id:e.id,value:n(t)}),onCommit:t=>ze(e.id,n(t))},`text-${t}`))},R=0;return l.forEach((a,o)=>{C(R,a.start),x.push(((a,o)=>{let l=d?.dimensions.findIndex((e,r)=>e.start===a.start&&c(`${t}:dim:${r}`)),u="color"===i?.kind&&n===t&&E(e.value,w.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=w.constraints.find(e=>e.name.toLowerCase()===a.name.toLowerCase()),g=c(u)||c(t),f=de?.id===e.id&&de.index===o?de:null,v=!!f||null!==a.step&&0!==a.step||Ce?.id===e.id&&null!=r[o]?.step&&0!==r[o]?.step;return ve("span",{className:"tc-reference","data-connection-id":u,"data-connection-active":g,onBlur:e=>{f&&!e.currentTarget.contains(e.relatedTarget)&&ue(null)},onPointerEnter:()=>ee({id:u,port:"target"}),onPointerLeave:()=>ee(null),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),X(null);let n=r[o],a=n&&L(w.constraints,e.value.slice(n.start,n.end));ze(e.id,y(o,n?.math?N(`calc(${e.value.slice(n.start,n.end)})`,w.constraints)?.css??"":a?m(a):""))},children:[me("button",{className:"tc-port","aria-label":`Connect ${p} to constraint`,onPointerDown:e=>Me(e,u,"target"),onClick:e=>{be.current||e.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),me(dr,{compact:!0,label:`${p} reference`,sourceSuggestions:w.constraints.filter(e=>!Pe(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(v||!t.endsWith(":"))return!1;let r=t.slice(0,-1).trim().replace(/^@/,"");return!!S(`@${r}`)&&(ue({id:e.id,index:o,name:r}),!0)},onCommit:t=>{if(!t)return void ze(e.id,y(o,""));let r=S(t.startsWith("@")?t:`@${t}`);if(!r)throw new Error("Use a source name with an optional : step");ze(e.id,b(o,{name:r.name,...t.includes(":")?{step:r.step}:{},...t.includes("/")?{opacity:r.opacity}:{}}))}}),v&&ve(ye,{children:[ve("span",{"aria-hidden":"true",children:[":"," "]}),me(dr,{compact:!0,className:"tc-token-step",label:`${p} step`,arrowNavigation:!0,value:f||null===a.step?"":String(a.step),placeholder:"step",autoFocus:!!f,onCancel:()=>ue(null),scrub:{step:1,defaultValue:0},onScrubPreview:t=>$e(null===t?null:{id:e.id,value:b(o,{...f?{name:f.name}:{},step:Oe(t)})}),onCommit:t=>{ze(e.id,b(o,{...f?{name:f.name}:{},step:t?Oe(t):null})),ue(null)}})]}),("color"===h?.kind||void 0!==a.opacity)&&ve(ye,{children:[ve("span",{className:"tc-opacity-separator","aria-hidden":"true",children:[" ","/"," "]}),me(dr,{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=>$e(null===t?null:{id:e.id,value:b(o,{opacity:t})}),onCommit:t=>{if(t&&null===A(t))throw Error("Use opacity from 0 to 1, or 0% to 100%");ze(e.id,b(o,{opacity:t||void 0}))}})]})]},o)})(a,o)),R=a.end}),C(R,o.length),ve("div",{className:"tc-row","data-token-id":e.id,"data-token-value":o,children:[me(dr,{label:`${e.name} name`,className:ge.has(t)?"tc-derived-name-active":void 0,compact:!0,value:e.name,onDelete:g?void 0:()=>{X(null),O({...w,tokens:w.tokens.filter(t=>t.id!==e.id)})},onCommit:t=>{if(!t)throw Error("Give this token a name");O({...w,tokens:w.tokens.map(r=>r.id===e.id?{...r,name:t}:r)})}}),ve(rr,{className:"tc-value",label:`${e.name} expression`,onSelectionStart:()=>ue(null),onCommit:t=>ze(e.id,t),onPointerEnter:()=>ee({id:t,port:"target"}),onPointerLeave:()=>ee(null),children:[(l.length>0||f||u.length>0)&&le!==e.id?me("span",{className:"tc-compound",onDoubleClick:t=>{t.target.closest("input, .tc-port")||se(e.id)},children:x}):ve("span",{className:c(t)?"tc-reference":"tc-compound","data-connection-active":c(t),children:[p&&!f&&v,me(dr,{compact:!0,label:`${e.name} value`,sourceSuggestions:w.constraints.map(e=>e.name),scrub:{step:1,shiftStep:5,compound:!0},onScrubPreview:t=>$e(null===t?null:{id:e.id,value:t}),clearable:!0,autoFocus:le===e.id,value:o,placeholder:"–",onCommit:t=>{ze(e.id,t),se(null)}})]}),me(ur,{value:o,background:z.surface,constraints:Re,name:e.name})]})]},e.id)}),!g&&ve("button",{className:"tc-add-token","aria-label":"Add token",onClick:()=>O({...w,tokens:[...w.tokens,{id:`${Ne}-${++Ae.current}`,name:`Token ${w.tokens.length+1}`,value:""}]}),children:[me(oe,{size:12}),"Add token"]})]}),h,(y||we)&&me("p",{role:"status",style:{margin:0,padding:10,borderRadius:8,background:z.control,textAlign:"center"},children:y||we})]}),b,p?ve("div",{className:"tc-proposal-recovery",children:[ve("p",{role:"alert",children:[p.message," Values already received are kept above."]}),ve("nav",{"aria-label":"Proposal recovery",children:[me("button",{type:"button",onClick:p.onRetry,children:"Retry"}),me("button",{type:"button",onClick:p.onTemplate,children:"Use template"})]})]}):g?null:me("button",{className:"tc-save",disabled:v,onClick:()=>I?a():f?f(w):xe("Prototype only — your taste has not been saved"),children:I?"Cancel proposal":v?"Saving…":"Save this taste"}),me(lr,{pane:P,edges:pe,visible:he.map(e=>({parent:e.id,child:e.target})),suspended:!!U||!!_,revision:JSON.stringify([w,ke,Ce,le,U?.id,U?.target,U?.validTarget]),color:z.primary}),(U?[U]:_?[_]:[]).filter(e=>e.active).map(e=>me(fr,{drag:e,pane:P,color:z.primary},`${e.id}:${e.target}`))]})}function vr({root:e,session:t,visible:r=!0}){let n=B(t.subscribeLook,t.getLookSnapshot,t.getLookSnapshot),[a,o]=F(null);return q(()=>{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&&M(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||a?.lookId!==n.id||!a.element||n.expiresAt<=Date.now()?null:me(i,{element:a.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 yr(e,t){t=Se(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=m(f(t.constraints,e))}catch{}i.push({id:e,name:r.name,expression:n(e),value:a}),r.parentId&&c(r.parentId)};e&&k(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=Ae(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 br({fragment:e,draft:t,theme:r,onBack:n,onChange:a}){let i=W(null),[o,l]=F(null),s=yr(e,t),d=[...new Set(s.flatMap(e=>[..."dimension"===e.source.kind?[e.source.id]:[],...e.dependencies.map(e=>e.id)]))],u=s.filter(e=>"token"===e.source.kind).map(e=>e.source.id),p=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)),h=[],g=e=>{let t=Object.entries(e.localStyles??{});t.length&&h.push({id:e.id,entries:t}),e.children.forEach(e=>{"string"!=typeof e&&g(e)})};g(e.root),H(()=>{i.current?.querySelector("button")?.focus()},[e.id]);let f=c[r];return me("section",{ref:i,"aria-label":`${e.name} details`,"data-fragment-detail":!0,"data-popmelt-panel":!0,style:{position:"absolute",inset:0,display:"flex"},children:me(mr,{draft:Se(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:u,onHover:l,preview:t=>me("div",{style:{position:"sticky",top:16,zIndex:1,flexShrink:0,borderRadius:8,background:f.control},children:me(at,{fragment:{...e,tokens:[]},draft:t,height:240,highlightedNodes:p})})},fragments:ve(ye,{children:[me("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"}),ve("details",{children:[me("summary",{children:"Affected parts"}),s.map(e=>ve("details",{"data-fragment-use":e.key,children:[ve("summary",{children:[e.name,e.source.step?`: ${e.source.step}`:""," ·"," ",new Set(e.targets.map(e=>e.nodeId)).size," ","parts"]}),e.targets.map(e=>ve("div",{children:[e.label," · ",e.property]},`${e.nodeId}:${e.property}`))]},e.key))]}),h.length>0&&ve("details",{children:[me("summary",{children:"Local structure"}),h.map(e=>ve("section",{children:[me("h3",{children:e.id}),e.entries.map(([e,t])=>ve("div",{className:"tc-row",children:[me("span",{className:"tc-name",children:e}),me("span",{className:"tc-value",children:t})]},e))]},e.id))]})]})})})}function wr(e){let t=W(null),[r,n]=F(null),a=W(null),[i]=F(()=>{let t=g(e.draft);return e.draft||t.create("extract"),t}),o=e.session??i,l=B(o.subscribe,o.getSnapshot,o.getSnapshot),{draft:s,state:d,message:h,runId:f}=l,m=s?.fragments?.find(e=>e.id===r);q(()=>{m||a.current?.isConnected&&(a.current.focus({preventScroll:!0}),a.current=null)},[m]);let v=W(e.onDraft),y=W(null);v.current=e.onDraft,H(()=>{if("running"!==o.getSnapshot().state)return;let t=Symbol();y.current=t;let r,n=e=>o.stream(f,{draft:e}),a=e=>o.stream(f,{state:e}),i=e=>o.stream(f,{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 Wt)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 p(`${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="",h=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),v.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"));)h(u.slice(0,e)),u=u.slice(e+1)}h(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(()=>{y.current===t&&o.stream(f,{state:"error",message:"Extraction stopped. Retry or continue editing the partial draft."})})}},[e.bridgeUrl,f,o]);let w=c[e.theme];return ve("div",{ref:t,style:{...e.style,display:"flex",flexDirection:"column",background:w.surface,color:w.primary,fontFamily:u,borderRadius:20,overflow:"hidden",position:"relative",minHeight:0},children:[me("div",{inert:!!m||e.saving,style:{display:"flex",flex:1,minHeight:0,visibility:m?"hidden":void 0,opacity:m?0:void 0},children:me(mr,{history:o.history,theme:e.theme,draft:s??b(),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"===d?"complete":d,preferPageComponent:"extract"===l.mode,fragments:me(it,{draft:s??b(),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)}},f),proposalRecovery:"error"===d?{message:h,onRetry:()=>{o.create("extract")},onTemplate:e.onTemplate}:void 0,style:{flex:1,minHeight:0,border:0}},f)}),m&&s&&me(br,{fragment:m,draft:s,theme:e.theme,onBack:()=>n(null),onChange:t=>{o.edit(t),e.onDraft(t)}},m.id),me(vr,{root:t,session:o,visible:e.visible})]})}var xr="popmelt:taste-recovery:v1:",kr=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 Sr(e){if(kr(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 Cr(e,t){if(!e||"object"!=typeof e)return;let r=e;return 1===r.version&&r.scope===t&&kr(r.key)&&kr(r.id)&&(e=>Number.isSafeInteger(e)&&Number(e)>=0)(r.revision)&&Number.isFinite(r.updatedAt)&&Ge(r.document)&&(null===r.pending||r.pending&&r.pending.id===r.id&&r.pending.expectedRevision===r.revision&&kr(r.pending.requestId)&&Ge(r.pending.document))?r:void 0}function $r(e,t=localStorage){let r=[];for(let n=0;n<t.length;n++){let a=t.key(n);if(!a?.startsWith(xr))continue;let i=t.getItem(a);if(i&&!(i.length>45e5))try{let t=Cr(JSON.parse(i),e);t&&a===xr+t.key&&r.push(t)}catch{}}return r.sort((e,t)=>t.updatedAt-e.updatedAt)}function Rr(e,t=localStorage){if(!Cr(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(xr+e.key,r)}function Er(e,t=localStorage){if(!kr(e))throw Error("Invalid recovery key");t.removeItem(xr+e)}function Tr({theme:e,records:t,onResume:r}){let n=c[e];return t.length?ve("section",{"aria-label":"Unsaved tastes","data-taste-recovery":!0,style:{display:"flex",flexDirection:"column",gap:8,marginBottom:24,color:n.secondary},children:[me("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 `}),me("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",letterSpacing:"-.12px"},children:"Unsaved"}),me("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 ve("li",{style:{minWidth:0,position:"relative"},children:[me("div",{"aria-hidden":"true",inert:!0,style:{position:"relative",height:104,overflow:"hidden",borderRadius:8,background:n.control},children:a?.draft.featuredComponentId?me(ot,{document:a}):e.preview?me(rt,{recipe:e.preview}):null}),ve("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:[me("span",{"data-recovery-name":!0,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:t}),me("span",{style:{flexShrink:0,color:n.muted},children:e.pending?"Save unconfirmed":"Draft"})]})]},e.key)})})]}):null}function Ir({theme:e,pending:t,disabled:r=!1,onDiscard:n}){let a=c[e];return ve("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"8px 16px",fontSize:12},children:[me("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."}),me("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 Nr=new WeakMap;function Ar(e){let[t,r]=F(!1),[n,a]=F(null),[i,o]=F(!1),[l,s]=F(!1),[d,u]=F(null),[h,g]=F(null),f=W({}),m=c[e.theme],v=W(!1),y=()=>{let t=e.session??f.current,r=e.session?.getSnapshot().runId??"",n=Nr.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},Nr.set(t,n)),n},b=(t,r)=>{t.recoveryScope&&(Rr({version:1,key:t.recoveryKey,scope:t.recoveryScope,updatedAt:Date.now(),id:t.id,revision:t.revision,document:r,pending:t.pending}),e.onRecoveryChange?.())},w=t=>{t.recoveryScope&&(Er(t.recoveryKey),e.onRecoveryChange?.())},x=W(()=>{});x.current=()=>{if(!e.recoveryScope)return;let t,r=e.session?.getSnapshot(),n=r?.draft??e.draft;if(n&&"running"!==r?.state){try{t=Ze(n)}catch{return}try{let r=y();if(r.recoveryScope&&r.recoveryScope!==e.recoveryScope)return;r.recoveryScope=e.recoveryScope,r.pending||e.recovery||!e.saved||Xe(t)!==Xe(e.saved.document)?b(r,t):w(r),g(null)}catch{g("Browser recovery storage is unavailable. Keep this tab open until a remote save is confirmed.")}}},H(()=>(x.current(),e.session?.subscribe(()=>x.current())),[e.session,e.recoveryScope,e.draft]);let k={font:"inherit",color:m.primary,background:m.control,padding:8,border:0,borderRadius:8,cursor:"pointer"};return me(wr,{...e,onSave:t=>{l||(async t=>{if(!v.current&&e.bridgeUrl){v.current=!0,r(!0),a(null);try{let r=Ze(t),n=y(),i=await p(`${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=Sr(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{b(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 p(`${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||!Ge(l.document)||Xe(l.document)!==Xe(t.document))throw Error("Could not confirm the saved Taste. Your draft is kept; retry safely.");if(n.revision=l.revision,n.pending=null,b(n,r),Xe(t.document)===Xe(r))return a("Saved privately to Popmelt. Not applied."),w(n),s(!1),void e.onSaved(l)}}catch(e){a(e instanceof Error?e.message:"Remote save failed. Your draft is kept.")}finally{v.current=!1,r(!1)}}})(t)},saving:t,saveNotice:n??h,saveAction:ve(ye,{children:[e.recovery&&me(Ir,{theme:e.theme,pending:!!y().pending,disabled:t,onDiscard:()=>{if(!v.current)try{w(y()),e.onBack()}catch{a("Could not discard browser recovery. Your draft is kept.")}}}),l?ve("div",{style:{padding:12,color:m.primary},children:[me("p",{children:"Your draft is retained. Review the saved version before choosing what to keep."}),me("button",{style:k,onClick:()=>{(async()=>{try{let t=await p(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"}),r=await t.json(),n=y();if(!t.ok||n.recoveryScope&&Sr(r)!==n.recoveryScope)throw Error("Reconnect the original account to review this Taste.");let a=await p(`${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||!Ge(i.document))throw Error("Could not load the saved version. Your draft is kept.");u(i)}catch(e){a(e instanceof Error?e.message:"Could not review the saved version.")}})()},children:"Review saved version"}),d&&ve(ye,{children:[ve("p",{children:["Saved revision ",d.revision," ·"," ",d.document.draft.name]}),me(Jt,{draft:d.document.draft,theme:e.theme,preferPageComponent:!0}),me("button",{style:k,onClick:()=>{try{let t=y();t.id=d.id,t.revision=d.revision,t.pending=null,e.session?.edit(d.document.draft),w(t),s(!1),u(null),e.onSaved(d)}catch{a("Could not discard the recovery record. Your draft is kept.")}},children:"Discard my edits and load saved version"}),me("button",{style:k,onClick:()=>{(async()=>{try{let t=await p(`${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=y(),n={...r,id:crypto.randomUUID(),revision:0,pending:null},i=e.session?.getSnapshot().draft??e.draft;if(!i)return;b(n,Ze(i)),Object.assign(r,n),s(!1),u(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?me("button",{type:"button",onClick:e.onEnableSaving,style:{font:"inherit",color:m.primary,background:m.control,padding:8,border:0,borderRadius:8,cursor:"pointer"},children:"Enable remote saving"}):void 0]})})}var Lr=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=p(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()}},zr={principles:"tokens",components:"components",assets:"visual-directions",content:"copy-guidance"};var Pr=e=>"string"==typeof e&&e.length>0&&e.length<=200&&!["__proto__","prototype","constructor"].includes(e);var Dr=(e,t)=>`${e}:${t}`;function jr(e){let t=W(e.onDirectionChange);t.current=e.onDirectionChange;let[r,n]=F([]),a=W(null),l=W(null),[s,d]=F(0),[f,m]=F(!1),[v,y]=F(null),[b,w]=F(!1),[x,k]=F(!1),S=B(h.subscribe,h.getSnapshot,h.getSnapshot),C=S.open,[$,R]=F(null),E=W(new Map),{onEditorVisibilityPinChange:T,visible:I}=e;q(()=>(T?.((C||!!$)&&!1!==I),()=>T?.(!1)),[C,$,I,T]);let N=W(null),[A,L]=F(null),[z,P]=F(null),[D,j]=F(),M=()=>{let e=N.current?.offsetHeight;e&&j(e),k(!0)},[O,K]=F(!1),Y=W(null),J=W(null),_=W(!1);H(()=>{x?Y.current?.focus({preventScroll:!0}):_.current&&J.current?.focus({preventScroll:!0}),_.current=x},[x]);let X=()=>{k(!1),se("")},[le,se]=F(""),de=W(void 0);H(()=>()=>clearTimeout(de.current),[]);let[ce,ue]=F(),[pe,he]=F(!1),[ge,fe]=F(null),be=W(void 0),we=t=>{clearTimeout(be.current),fe(!1===e.visible?null:t),be.current=setTimeout(()=>fe(null),200)};H(()=>{!1===e.visible&&(clearTimeout(be.current),fe(null))},[e.visible]),H(()=>()=>clearTimeout(be.current),[]);let xe=W(void 0);H(()=>()=>clearTimeout(xe.current),[]);let[ke,Se]=F(null),Ce=!!ke&&f,[$e,Re]=F(!1),[Ee,Te]=F(null),[Ie,Ne]=F(),Ae=void 0!==Ie?Ie:Ee?.direction,Le=Ae?Dr(Ae.sourceCollection,Ae.sourceModelId):null,[ze,Pe]=F(!1),[De,je]=F(!1),[Me,Oe]=F(!1),We=W(null);H(()=>()=>We.current?.abort(),[]);let[Fe,Be]=F(!1),[qe,He]=F(!0),[Ue,Ve]=F("Loading collection…"),[Ke,Ye]=F(0),[Je,_e]=F(0),[Xe,Ze]=F(),[et,tt]=F([]),rt=U(()=>{try{tt(Xe?$r(Xe):[])}catch{tt([])}},[Xe]);H(()=>{rt();let e=()=>rt();return window.addEventListener("storage",e),window.addEventListener("focus",e),()=>{window.removeEventListener("storage",e),window.removeEventListener("focus",e)}},[rt]),H(()=>{$&&$.record.scope!==Xe&&R(null)},[$,Xe]);let nt=e.bridgeUrl;H(()=>{let e=new AbortController;return Oe(!1),h.setCreationAllowed(!1),nt&&p(`${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),h.setCreationAllowed(n)}).catch(()=>{}),()=>{e.abort(),h.setCreationAllowed(!1)}},[nt,Ke,Je]);let at=async(e,t=!1)=>{let r=ft.current;try{let n=await p(`${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),h.setCreationAllowed(i),!i)return;X(),h.create(e,t)}catch{if(r!==ft.current)return;Oe(!1),h.setCreationAllowed(!1)}},it=W(0),ot=W(!1),lt=W(""),st=W([]),dt=W(void 0),ct=W(void 0),ut=W(!1),gt=W(0),ft=W(0);H(()=>{if(!nt||!1===e.visible)return void L(null);let t=!0,r=!1,n=async()=>{if(!r){r=!0;try{let e=await p(`${nt}/cloud-taste/agent-look`,{cache:"no-store"}),r=await e.json();t&&L(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)&&Pr(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(Pr)&&["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&&L(null)}finally{r=!1}}};n();let a=setInterval(()=>{n()},750);return()=>{t=!1,clearInterval(a)}},[nt,e.visible]);let mt=V(()=>({bridgeUrl:nt,revision:Ke,cache:new Lr}),[nt,Ke]).cache;H(()=>{let t=N.current;if(!t||!A||!1===e.visible)return void P(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&&zr[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,A,{searchOpen:x,showingDetail:Ce,detailEntryId:ke?.id??null,drilldown:v,drilldownVisible:b});P(t=>t===e?t:e)};r();let n=new MutationObserver(r);return n.observe(t,{childList:!0,subtree:!0}),()=>n.disconnect()},[A,ke,v,b,e.visible,x,Ce]),H(()=>()=>mt.clear(),[mt]);let[,vt]=F(0),yt=V(()=>({bridgeUrl:nt,revision:Ke,requests:new Map}),[nt,Ke]).requests;H(()=>()=>{for(let e of yt.values())e.abort.abort();yt.clear()},[yt]);let bt=U(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 p(`${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||!Ge(t.document))throw Error("Invalid saved Taste.");return r.signal.aborted||(i.facts=[],i.fetchedAt=Date.now(),i.preview={...Kt(t.document.draft,"dark"),savedDocument:t,contentRevision:String(t.revision)},vt(e=>e+1)),[]}let t=await p(`${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=Qe(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]=F(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,gt.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 p(`${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 p(`${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 n=await r.json(),a=o(n.authorizationUrl);t.location.replace(a.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.")}H(()=>{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]),H(()=>{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]),H(()=>{let t=()=>{it.current>0&&!ot.current&&!ut.current&&Date.now()-it.current>=3e4&&_e(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]),H(()=>{let e,r=++ft.current,a=gt.current,i=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),Pe(!1),Re(!1),n([]),st.current=[]),async function o(){try{if(!nt)throw Error("Connection unavailable.");let s=await p(`${nt}/cloud-taste/status`,{signal:i.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){Ze(void 0),E.current.clear(),t.current?.(null),mt.clear(),n([]),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(),E.current.clear(),We.current?.abort(),ue(void 0);for(let e of yt.values())e.abort.abort();yt.clear(),st.current=[],n([]),Se(null)}dt.current=d.accountId,ct.current=d.environment,Ze(Sr(d)),d.canInspect||mt.clear();let[c,u,h]=await Promise.all([p(`${nt}/cloud-taste/catalog`,{signal:i.signal,cache:"no-store"}),p(`${nt}/cloud-taste/direction`,{signal:i.signal,cache:"no-store"}),!0===d.canBrowsePrivate?p(`${nt}/cloud-taste/private-catalog`,{signal:i.signal,cache:"no-store"}):null]);if(!c.ok||!u.ok||h&&!h.ok)throw Error("Could not load tastes. Please retry or reconnect in Settings.");let g=await c.json(),f=h?await h.json():{items:[]},m=await u.json();if(r!==ft.current)return;let v=["private","public"].flatMap(e=>("private"===e?f.items:g.items).map(t=>({id:Dr(e,t.id),sourceModelId:t.id,sourceCollection:e,thumbnailUrl:t.thumbnailUrl,preview:Qe(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 v){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=v,n(v),l&&Se(e=>e?v.find(t=>t.id===e.id)??null:null),it.current=Date.now(),a===gt.current&&(Te(m),"string"==typeof d.accountId&&t.current?.({accountId:d.accountId,environment:d.environment,name:m.direction?.name??null,generation:m.generation})),Pe(!0===d.canWrite),je(!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,i.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=c[e.theme],At=!Ce||b,Lt=x&&At,zt=b&&v?"components"===v?ee:"copy-guidance"===v?te:"version"===v?re:"visual-directions"===v?ne:ae:ie;H(()=>{Ce&&l.current?.focus({preventScroll:!0})},[Ce]);let Pt=()=>{if(K(!1),clearTimeout(be.current),fe(null),k(!1),se(""),b)return w(!1),clearTimeout(de.current),void(de.current=setTimeout(()=>y(null),220));m(!1),clearTimeout(xe.current),xe.current=setTimeout(()=>Se(null),220)};H(()=>{if(!1===e.visible||C)return;let t=t=>{if("Tab"===t.key&&K(!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)K(!1),t.preventDefault(),t.stopImmediatePropagation(),t.repeat||M();else if("Escape"===t.key){if(K(!1),t.preventDefault(),t.stopImmediatePropagation(),t.repeat)return;Lt?X():Ce?Pt():e.onClose()}};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)});let Dt=(ce??yt.get(ke?.id??"")?.preview??ke?.preview)?.savedDocument,Mt=t=>{R(null),rt();let r=E.current.get(t.id);r&&(r.saved=t);let a={id:Dr("private",t.id),sourceModelId:t.id,sourceCollection:"private",name:t.document.draft.name,documentRevision:t.revision,preview:{...Kt(t.document.draft,e.theme),savedDocument:t,contentRevision:String(t.revision)}};yt.get(a.id)?.abort.abort(),yt.delete(a.id),n(e=>[...e.filter(e=>e.id!==a.id),a]),Se(a),ue(a.preview),m(!0),h.close(),Ye(e=>e+1)};if($&&$.record.scope===Xe)return me(Ar,{session:$.session,draft:$.record.document.draft,recovery:$.record,recoveryScope:Xe,onRecoveryChange:rt,theme:e.theme,style:e.style,bridgeUrl:nt,visible:e.visible,onDraft:()=>{},onBack:()=>{R(null),rt()},onTemplate:()=>{},onSaved:Mt,onEnableSaving:()=>{St(!0)}},$.record.key);if(!C&&Ce&&Dt){let t=E.current.get(Dt.id);return t||(t={saved:Dt,session:g(Dt.document.draft)},E.current.set(Dt.id,t)),me(Ar,{saved:t.saved,recoveryScope:Xe,onRecoveryChange:rt,session:t.session,draft:t.saved.document.draft,theme:e.theme,style:e.style,bridgeUrl:nt,visible:e.visible,onDraft:()=>{},onBack:Pt,onTemplate:()=>{},onSaved:Mt,onEnableSaving:()=>{St(!0)}},Dt.id)}return C?me(Ar,{visible:e.visible,session:h,recoveryScope:Xe,onRecoveryChange:rt,theme:e.theme,style:e.style,bridgeUrl:e.bridgeUrl,draft:S.draft,onDraft:()=>{},onBack:()=>h.close(),onTemplate:()=>{at("template",!0)},onSaved:Mt,onEnableSaving:()=>{St(!0)}}):ve("div",{"data-popmelt-font":"sans",ref:N,"data-taste-keyboard-focus":O,onPointerDownCapture:()=>K(!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":b?"drilldown":"overview",style:{position:"relative",height:Lt?D:e.style?.height,maxHeight:e.style?.maxHeight,overflow:"hidden",borderRadius:20,background:Nt.surface,fontFamily:u},children:[me("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 `}),ve("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:[ve("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:[me(G,{size:16}),me("input",{ref:Y,"aria-label":Ce?"Search taste definitions":"Search tastes",placeholder:Ce?"Search keys and values…":"Search tastes…",value:le,onChange:e=>se(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&X()},style:{flex:1,minWidth:0,border:0,outline:"none",background:"transparent",color:Nt.primary,font:"inherit",fontSize:12}}),me("button",{type:"button","aria-label":"Close search",onClick:X,style:{border:0,padding:4,background:"transparent",color:Nt.secondary,cursor:"pointer"},children:me(Z,{size:16})})]}),ve("div",{"data-taste-header-default":!0,inert:Lt,"aria-hidden":Lt,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,width:"100%"},children:[ve("button",{ref:l,type:"button","data-taste-nav-title":!0,"aria-label":Ce?b?"Back to taste details":"Back to taste collection":"Back to settings",onClick:Ce?Pt: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:[me(Q,{size:16,style:{width:16,color:Nt.primary}}),me(zt,{"data-taste-nav-icon":!0,style:{width:Ce?14:16,height:Ce?14:16,transform:zt===ie?"scaleY(-1)":void 0,transitionProperty:"color, width, height, opacity"}}),me("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:Ce?ke.name:void 0,children:Ce?v&&b?{version:"Versions",tokens:"Tokens",components:"Components","visual-directions":"Visual directions","copy-guidance":"Copy guidance"}[v]??v:ke.name:"Taste"})]}),ve("div",{style:{position:"relative",height:28,width:Ce?80:Me?135:28,flexShrink:0},children:[!Ce&&Me&&me("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&&me("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:me(oe,{size:16})}),At?me("button",{type:"button","aria-label":Ce?"Search definitions":"Search tastes",ref:J,"data-taste-search-trigger":!0,onClick:()=>{K(!1),M()},style:{position:"absolute",right:0,border:0,padding:6,background:"transparent",color:Nt.muted,transition:"color 160ms ease",cursor:"pointer"},children:me(G,{size:16})}):me(ye,{children:me("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:ve(ye,ke?.id===Le?{children:["Remove",me(Z,{size:12})]}:{children:[me(oe,{size:12}),"Add"]})})})]})]})]}),ke&&(v?["overview","drilldown"]:["overview"]).map(t=>me("div",{"data-taste-layer":t,inert:!Ce||"drilldown"===t!==b,"aria-hidden":!Ce||"drilldown"===t!==b,children:me(ht,{theme:e.theme,style:{...e.style,...s>0?{minHeight:`min(${s}px, ${"number"==typeof e.style?.maxHeight?`${e.style.maxHeight}px`:e.style?.maxHeight??"calc(100dvh - 64px)"})`}:{}},entry:{...ke,preview:ce??yt.get(ke.id)?.preview??ke.preview},facts:Tt??It?.facts,onOpenFact:e=>{K(!1),we("drilldown"),clearTimeout(de.current),k(!1),se(""),y(e),w(!0)},drilldown:"drilldown"===t&&v?me(jt,{cache:mt,bridgeUrl:e.bridgeUrl,id:ke.sourceModelId,collection:ke.sourceCollection,section:v,query:le,theme:e.theme,onPreview:ue,onReconnect:()=>{St()}},`${ke.id}:${v}`):void 0,summaryNotice:Tt?void 0:It?.notice??"Loading details…",active:ke.id===Le,onBack:Pt,onToggle:ze&&Ee&&!Fe?()=>{kt(ke.id===Le?void 0:ke)}:void 0,notice:Ue},ke.id)},t)),me("div",{ref:a,inert:Ce,"aria-hidden":Ce,style:{display:"contents"},children:me(pt,{...e,style:{...e.style,...Lt&&D?{height:"100%"}:{}},publicEntries:Rt("public").filter(e=>Ce||`${e.name} ${e.metadata?.value??""}`.toLowerCase().includes(le.trim().toLowerCase())),privateEntries:Rt("private").filter(e=>Ce||`${e.name} ${e.metadata?.value??""}`.toLowerCase().includes(le.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(K(!1),we("overview"),clearTimeout(xe.current),he(!0),d(a.current?.firstElementChild?.offsetHeight??0),Se(t),y(null),w(!1),k(!1),se(""),ue(void 0),We.current?.abort(),De&&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=Qe((await e.json()).preview);!r.signal.aborted&&t&&ue(t)}).catch(()=>{})}m(!0)},onPrefetchDetails:e=>{bt(e).catch(()=>{})},privateEmptyMessage:$e?"No private results found.":"Reconnect to browse your private tastes.",notice:Ue,headerAction:ve(ye,{children:[me(Tr,{theme:e.theme,records:et.map(t=>({key:t.key,name:t.document.draft.name,pending:!!t.pending,preview:{...Kt(t.document.draft,e.theme),savedDocument:t}})),onResume:e=>{let t=et.find(t=>t.key===e);if(t)try{let e=$r(t.scope).find(e=>e.key===t.key);if(!e)return void rt();let r={...e,key:crypto.randomUUID(),updatedAt:Date.now()};Rr(r),Er(e.key),R({record:r,session:g(r.document.draft)}),rt()}catch{Ve("Could not resume browser recovery. The original record is kept.")}}}),Et?me("button",{type:"button",disabled:Fe,onClick:()=>{St()},style:{border:0,borderRadius:8,padding:"6px 10px",cursor:"pointer",font:"inherit"},children:"Reconnect account"}):null]})})}),me(i,{element:z,label:"AI is looking at this Taste",inverse:!0})]})}export{jr as PopmeltTasteConnectedPane};