"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),d=require("../chunks/switch-fIkmwzUt.js"),A=require("../chunks/index-DRlMUglg.js");require("../chunks/index-BxM99sFL.js");const V=require("../chunks/palette-DUGktM-M.js"),ge=require("../chunks/braces-C3-w6xDL.js"),be=require("../chunks/save-D3YYinDz.js");/**
 * @license lucide-react v0.453.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fe=d.createLucideIcon("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
 * @license lucide-react v0.453.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const me=d.createLucideIcon("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
 * @license lucide-react v0.453.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xe=d.createLucideIcon("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
 * @license lucide-react v0.453.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const he=d.createLucideIcon("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]),W=[{id:"semaphor",name:"Semaphor",description:"Dense neutral system defaults for embedded analytics.",primary:"#18181b",accent:"#f4f4f5",light:{background:"#ffffff",foreground:"#18181b",muted:"#fafafa",mutedForeground:"#71717a",border:"#e4e4e7",primary:"#18181b",primaryForeground:"#ffffff",accent:"#f4f4f5",accentForeground:"#18181b",card:"#ffffff",cardForeground:"#18181b",chartPalette:["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"]},dark:{background:"#09090b",foreground:"#fafafa",muted:"#18181b",mutedForeground:"#a1a1aa",border:"#27272a",primary:"#fafafa",primaryForeground:"#09090b",accent:"#27272a",accentForeground:"#fafafa",card:"#09090b",cardForeground:"#fafafa",chartPalette:["#60a5fa","#34d399","#fbbf24","#f87171","#a78bfa","#22d3ee"]}},{id:"atlas-blue",name:"Atlas Blue",description:"Crisp enterprise blue with restrained neutral surfaces.",primary:"#2563eb",accent:"#dbeafe",light:{background:"#f8fafc",foreground:"#0f172a",muted:"#f1f5f9",mutedForeground:"#64748b",border:"#cbd5e1",primary:"#2563eb",primaryForeground:"#ffffff",accent:"#dbeafe",accentForeground:"#1e3a8a",card:"#ffffff",cardForeground:"#0f172a",chartPalette:["#2563eb","#0f766e","#ca8a04","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#020617",foreground:"#e2e8f0",muted:"#0f172a",mutedForeground:"#94a3b8",border:"#1e293b",primary:"#60a5fa",primaryForeground:"#020617",accent:"#1e3a8a",accentForeground:"#dbeafe",card:"#0f172a",cardForeground:"#e2e8f0",chartPalette:["#60a5fa","#2dd4bf","#facc15","#f87171","#a78bfa","#22d3ee"]}},{id:"field-green",name:"Field Green",description:"Operational green accents with quiet, readable canvases.",primary:"#047857",accent:"#d1fae5",light:{background:"#fbfdfb",foreground:"#10231d",muted:"#f1f5f3",mutedForeground:"#64746d",border:"#d7ded9",primary:"#047857",primaryForeground:"#ffffff",accent:"#d1fae5",accentForeground:"#064e3b",card:"#ffffff",cardForeground:"#10231d",chartPalette:["#047857","#2563eb","#d97706","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#071511",foreground:"#e7f4ef",muted:"#10231d",mutedForeground:"#92aaa1",border:"#244139",primary:"#34d399",primaryForeground:"#071511",accent:"#064e3b",accentForeground:"#d1fae5",card:"#0b1d17",cardForeground:"#e7f4ef",chartPalette:["#34d399","#60a5fa","#fbbf24","#f87171","#a78bfa","#22d3ee"]}}];function O(r){const n=A.resolveAppearance({organizationAppearance:r??void 0});return je(P(n))}function E(r){const n=P({version:A.APPEARANCE_SPEC_VERSION,mode:r.mode,schemes:r.schemes}),t=A.validateAppearanceSpec(n);if(!t.success){const u=t.issues[0];throw new Error(`Invalid Brand Studio appearance at ${u.path}: ${u.message}`)}return t.value}function re(r,n){const t=W.find(i=>i.id===n);if(!t)return r;const u=P(r);return Q(u.schemes.light,t.light),Q(u.schemes.dark,t.dark),u}function Q(r,n){r.tokens.color.background=n.background,r.tokens.color.foreground=n.foreground,r.tokens.color.muted=n.muted,r.tokens.color.mutedForeground=n.mutedForeground,r.tokens.color.border=n.border,r.tokens.color.input=n.border,r.tokens.color.primary=n.primary,r.tokens.color.primaryForeground=n.primaryForeground,r.tokens.color.accent=n.accent,r.tokens.color.accentForeground=n.accentForeground,r.tokens.color.card=n.card,r.tokens.color.cardForeground=n.cardForeground,r.components.dashboard.background=n.background,r.components.dashboard.foreground=n.foreground,r.components.dashboard.borderColor=n.border,r.components.card.background=n.card,r.components.card.foreground=n.cardForeground,r.components.card.borderColor=n.border,r.components.interactive.toolbarBackground=n.background,r.components.interactive.background=n.card,r.components.interactive.foreground=n.foreground,r.components.interactive.borderColor=n.border,r.components.chart.palette=[...n.chartPalette],r.components.chart.background=n.card,r.components.chart.foreground=n.foreground,r.components.chart.gridColor=n.border,r.components.chart.axisColor=n.mutedForeground,r.components.table.container.background=n.card,r.components.table.container.borderColor=n.border,r.components.table.header.background=n.muted,r.components.table.header.foreground=n.mutedForeground,r.components.table.header.dividerColor=n.border,r.components.table.row.dividerColor=n.border,r.components.table.row.zebraBackground=n.muted,r.components.table.pagination.background=n.card,r.components.table.pagination.foreground=n.foreground,r.components.table.pagination.borderColor=n.border,c(r,"aggregateTable"),c(r,"pivotTable")}function c(r,n){r.components[n]=P(r.components.table)}function ee(r,n,t){switch(r.tokens.color[n]=t,n){case"background":r.components.dashboard.background=t,r.components.interactive.toolbarBackground=t;break;case"foreground":r.components.dashboard.foreground=t,r.components.interactive.foreground=t,r.components.pagination.foreground=t,r.components.chart.foreground=t,r.components.table.pagination.foreground=t,r.components.table.subtotal.foreground=t,r.components.table.grandTotal.foreground=t,c(r,"aggregateTable"),c(r,"pivotTable");break;case"card":r.components.card.background=t,r.components.interactive.background=t,r.components.pagination.background=t,r.components.chart.background=t,r.components.table.container.background=t,r.components.table.pagination.background=t,c(r,"aggregateTable"),c(r,"pivotTable");break;case"cardForeground":r.components.card.foreground=t;break;case"muted":r.components.table.header.background=t,r.components.table.row.zebraBackground=t,r.components.table.subtotal.background=t,r.components.table.grandTotal.background=t,c(r,"aggregateTable"),c(r,"pivotTable");break;case"mutedForeground":r.components.table.header.foreground=t,r.components.chart.axisColor=t,c(r,"aggregateTable"),c(r,"pivotTable");break;case"border":r.tokens.color.input=t,r.components.dashboard.borderColor=t,r.components.card.borderColor=t,r.components.interactive.borderColor=t,r.components.pagination.borderColor=t,r.components.chart.gridColor=t,r.components.table.container.borderColor=t,r.components.table.header.dividerColor=t,r.components.table.row.dividerColor=t,r.components.table.grandTotal.borderColor=t,r.components.table.pagination.borderColor=t,c(r,"aggregateTable"),c(r,"pivotTable");break;case"accent":r.components.table.row.hoverBackground=t,r.components.table.row.selectedBackground=t,c(r,"aggregateTable"),c(r,"pivotTable");break}}function U(r,n,t){switch(r.tokens.radius[n]=t,n){case"control":r.components.interactive.borderRadius=t,r.components.pagination.borderRadius=t;break;case"card":r.components.card.borderRadius=t;break;case"table":r.components.table.container.borderRadius=t,c(r,"aggregateTable"),c(r,"pivotTable");break}}function je(r){var n,t;for(const u of["light","dark"]){const i=r.schemes[u],l=i.tokens,s=l.color,y=(n=i.components)==null?void 0:n.aggregateTable,j=(t=i.components)==null?void 0:t.pivotTable,N={fontFamily:"",headingFontFamily:"",monoFontFamily:"",baseFontSize:14,density:"comfortable"};l.typography={...N,...l.typography};const f={control:5,card:5,table:5,badge:999};l.radius={...f,...l.radius};const g={dashboardPadding:16,gridGap:12,cardPadding:16,controlGap:8,tableCellX:12,tableCellY:8};l.spacing={...g,...l.spacing};const w={card:"none",popover:"0 12px 32px rgba(15, 23, 42, 0.14)",focusRing:"0 0 0 2px rgba(37, 99, 235, 0.35)"};l.shadow={...w,...l.shadow};const T={dashboard:{background:s.background,foreground:s.foreground,borderColor:s.border,padding:l.spacing.dashboardPadding},card:{background:s.card,foreground:s.cardForeground,borderColor:s.border,borderRadius:l.radius.card,padding:l.spacing.cardPadding,shadow:l.shadow.card},interactive:{toolbarBackground:s.background,background:s.card,foreground:s.foreground,borderColor:s.border,borderRadius:l.radius.control},chart:{palette:[],background:s.card,foreground:s.foreground,gridColor:s.border,axisColor:s.mutedForeground},table:F(s,l),aggregateTable:F(s,l),pivotTable:F(s,l),pagination:{background:s.card,foreground:s.foreground,borderColor:s.border,borderRadius:l.radius.control}};i.components={...T,...i.components};const J={palette:[],background:s.card,foreground:s.foreground,gridColor:s.border,axisColor:s.mutedForeground};i.components.chart={...J,...i.components.chart},i.components.table={...F(s,l),...i.components.table},i.components.aggregateTable=y?{...F(s,l),...y}:P(i.components.table),i.components.pivotTable=j?{...F(s,l),...j}:P(i.components.table)}return r}function F(r,n){return{density:n.typography.density,container:{background:r.card,borderColor:r.border,borderRadius:n.radius.table,shadow:n.shadow.card},header:{background:r.muted,foreground:r.mutedForeground,dividerColor:r.border,fontWeight:600,uppercase:!0,sticky:!0},row:{height:32,dividerColor:r.border,zebra:!1,zebraBackground:r.muted,hoverBackground:r.accent,selectedBackground:r.accent},cell:{paddingX:n.spacing.tableCellX,paddingY:n.spacing.tableCellY,verticalAlign:"middle",wrap:"nowrap"},subtotal:{background:r.muted,foreground:r.foreground,fontWeight:600},grandTotal:{background:r.muted,foreground:r.foreground,fontWeight:700,borderColor:r.border},pagination:{background:r.card,foreground:r.foreground,borderColor:r.border}}}function P(r){return JSON.parse(JSON.stringify(r))}const ye=[["background","Canvas"],["foreground","Text"],["card","Card"],["cardForeground","Card text"],["primary","Primary"],["primaryForeground","Primary text"],["accent","Accent"],["accentForeground","Accent text"],["muted","Muted"],["mutedForeground","Muted text"],["border","Border"],["positive","Positive"],["negative","Negative"],["warning","Warning"],["info","Info"]],ke=[0,1,2,3,4,5],q=A.APPEARANCE_FONT_PRESETS,ve=["#ffffff","#f8fafc","#f4f4f5","#e4e4e7","#18181b","#09090b","#2563eb","#0f766e","#047857","#d97706","#dc2626","#7c3aed"];function Ce({appearance:r,previewTitle:n,isLoading:t=!1,isSaving:u=!1,error:i=null,className:l,onDraftChange:s,onSave:y,onClearConfig:j,onCancel:N}){const[f,g]=m.useState(null),[w,T]=m.useState("light"),[J,z]=m.useState(!1),[oe,B]=m.useState("idle"),[X,ae]=m.useState(!1),[I,$]=m.useState(""),[D,x]=m.useState(null),Y=m.useRef(null),L=m.useRef(s),R=m.useRef(!1);m.useEffect(()=>{L.current=s},[s]),m.useEffect(()=>{if(r===void 0){R.current=!0,g(null);return}const o=O(r);R.current=!0,g(o),T("light"),x(null)},[r]),m.useEffect(()=>{var o;if(f){if(R.current){R.current=!1;return}try{const a=E(f);(o=L.current)==null||o.call(L,a),x(null)}catch(a){x(a instanceof Error?a.message:"Appearance is invalid")}}},[f]);const p=f==null?void 0:f.schemes[w],_=u||J,ne=m.useMemo(()=>p?Te(p.tokens.radius.control):void 0,[p]),te=o=>{g(a=>{if(!a)return a;const h=Se(a);return o(h),h})},b=o=>{te(a=>{o(a.schemes[w])})},de=async()=>{if(!f||!y)return;let o;try{o=E(f)}catch(a){x(a instanceof Error?a.message:"Appearance is invalid");return}z(!0);try{await y(o)}finally{z(!1)}},se=()=>{const o=O(null);B("idle"),g(o)},ie=async()=>{if(j){z(!0),x(null),B("idle");try{await j(),R.current=!0,g(O(null)),T("light")}catch(o){x(o instanceof Error?o.message:"Unable to clear organization appearance")}finally{z(!1)}}},Z=m.useCallback(()=>f?JSON.stringify(E(f),null,2):"",[f]),ce=o=>{if(ae(o),o)try{$(Z()),x(null)}catch(a){x(a instanceof Error?a.message:"Appearance is invalid")}},le=async()=>{if(f)try{const o=X&&I?I:Z();await navigator.clipboard.writeText(o),x(null),B("copied")}catch(o){x(o instanceof Error?o.message:"Unable to copy brand spec")}},K=o=>{const a=JSON.parse(o),h=O(a),S=E(h);B("idle"),T("light"),g(h),$(JSON.stringify(S,null,2))},ue=()=>{try{K(I)}catch(o){x(o instanceof Error?o.message:"Brand spec must be valid JSON")}},pe=async o=>{var h;const a=(h=o.target.files)==null?void 0:h[0];if(o.target.value="",!!a)try{K(await Fe(a))}catch(S){x(S instanceof Error?S.message:"Uploaded file must be a valid brand spec")}};return e.jsxs("div",{className:d.cn("flex min-h-0 flex-1 flex-col bg-background text-foreground",l),style:ne,children:[e.jsxs("header",{className:"flex h-11 shrink-0 items-start gap-3 border-b border-border/60 px-4 pt-2",children:[e.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-control border border-border/70",children:e.jsx(V.Palette,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-[13px] font-semibold leading-tight",children:"Brand Studio"}),e.jsxs("p",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:["Previewing ",n||"current dashboard"]})]}),e.jsxs(d.Popover,{open:X,onOpenChange:ce,children:[e.jsx(d.PopoverTrigger,{asChild:!0,children:e.jsxs(d.Button,{type:"button",size:"xs",variant:"ghost",disabled:!f,children:[e.jsx(ge.Braces,{className:"h-3.5 w-3.5"}),"Brand Spec"]})}),e.jsxs(d.PopoverContent,{align:"end",sideOffset:6,className:"z-[60] w-[min(520px,calc(100vw-24px))] rounded-control p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium",children:"Brand spec"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Edit, apply, copy, or upload your brand spec."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs(d.Button,{type:"button",size:"xs",variant:"ghost",onClick:le,children:[e.jsx(me,{className:"h-3.5 w-3.5"}),oe==="copied"?"Copied":"Copy"]}),e.jsxs(d.Button,{type:"button",size:"xs",variant:"ghost",onClick:()=>{var o;return(o=Y.current)==null?void 0:o.click()},children:[e.jsx(d.Upload,{className:"h-3.5 w-3.5"}),"Upload"]}),e.jsx(d.Button,{type:"button",size:"xs",onClick:ue,children:"Apply"})]})]}),e.jsx("div",{className:"h-[320px] overflow-hidden rounded-control border border-input",children:e.jsx(d.CodeEditor,{ariaLabel:"Brand spec",value:I,onValueChange:o=>{$(o),B("idle")},language:"json",embedded:!0,hideLineNumbers:!0,dense:!0})})]})]}),e.jsx("input",{ref:Y,"aria-label":"Upload brand spec",type:"file",accept:"application/json,.json",className:"sr-only",onChange:pe}),e.jsxs(d.Button,{type:"button",size:"xs",variant:"ghost",onClick:se,disabled:!f,children:[e.jsx(d.RotateCcw,{className:"h-3.5 w-3.5"}),"Reset"]}),j&&e.jsxs(d.Button,{type:"button",size:"xs",variant:"ghost",onClick:ie,disabled:_,children:[e.jsx(fe,{className:"h-3.5 w-3.5"}),"No config"]}),e.jsxs(d.Button,{type:"button",size:"xs",onClick:de,disabled:!f||_||!!D||!y,children:[_?e.jsx(d.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(be.Save,{className:"h-3.5 w-3.5"}),"Save"]}),N&&e.jsx("button",{type:"button","aria-label":"Close Brand Studio",className:"flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:N,children:e.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-4 py-2",children:[e.jsx("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:D?e.jsxs(e.Fragment,{children:[e.jsx(d.SlidersHorizontal,{className:"h-3.5 w-3.5 text-destructive"}),"Preview keeps the last valid draft"]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Check,{className:"h-3.5 w-3.5 text-emerald-500"}),"Draft is applied to the live dashboard preview"]})}),e.jsx("div",{className:"inline-flex h-7 items-center overflow-hidden rounded-control border border-border/70",children:["light","dark"].map(o=>e.jsx("button",{type:"button",className:d.cn("h-full px-2.5 text-[12px] capitalize transition-colors",w===o?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>T(o),children:o},o))})]}),D&&e.jsx("div",{className:"border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-[12px] text-destructive",children:D}),t?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(d.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):i?e.jsx("div",{className:"p-4 text-[13px] text-muted-foreground",children:i}):f&&p?e.jsxs(d.Tabs,{defaultValue:"style",className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-3",children:e.jsxs(d.TabsList,{variant:"underline",className:"w-full gap-5",children:[e.jsx(d.TabsTrigger,{value:"style",children:"Style"}),e.jsx(d.TabsTrigger,{value:"surfaces",children:"Surfaces"}),e.jsx(d.TabsTrigger,{value:"data",children:"Data"})]})}),e.jsxs(d.ScrollArea,{className:"min-h-0 flex-1",children:[e.jsxs(d.TabsContent,{value:"style",className:"m-0 p-4",children:[e.jsx(v,{icon:V.Palette,title:"Presets",description:"Start from a full light and dark appearance.",children:e.jsx("div",{className:"grid grid-cols-1 gap-2",children:W.map(o=>e.jsxs("button",{type:"button",className:"flex items-center gap-3 rounded-control border border-border/70 px-3 py-2 text-left hover:bg-muted/60",onClick:()=>{const a=re(f,o.id);g(a)},children:[e.jsxs("div",{className:"flex h-7 w-10 overflow-hidden rounded-control border border-border/70",children:[e.jsx("span",{className:"h-full flex-1",style:{backgroundColor:o.primary}}),e.jsx("span",{className:"h-full flex-1",style:{backgroundColor:o.accent}})]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-[13px] font-medium",children:o.name}),e.jsx("span",{className:"block truncate text-[12px] text-muted-foreground",children:o.description})]})]},o.id))})}),e.jsx(v,{icon:V.Palette,title:"Color",description:`Editing the ${w} scheme.`,children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(([o,a])=>e.jsx(k,{label:a,value:p.tokens.color[o],onChange:h=>b(S=>{ee(S,o,h)})},o))})}),e.jsxs(v,{icon:d.Type,title:"Typography",description:"Fonts and density used by dashboard and workflow chrome.",children:[e.jsx(Ne,{value:p.tokens.typography.fontFamily,onChange:o=>b(a=>{a.tokens.typography.fontFamily=o,a.tokens.typography.headingFontFamily=o})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(C,{label:"Base size",value:p.tokens.typography.baseFontSize,min:11,max:18,onChange:o=>b(a=>{a.tokens.typography.baseFontSize=o})}),e.jsx(G,{label:"Density",value:p.tokens.typography.density,options:[["compact","Compact"],["comfortable","Comfortable"],["spacious","Spacious"]],onChange:o=>b(a=>{a.tokens.typography.density=o,a.components.table.density=a.tokens.typography.density,c(a,"aggregateTable"),c(a,"pivotTable")})})]})]})]}),e.jsxs(d.TabsContent,{value:"surfaces",className:"m-0 p-4",children:[e.jsxs(v,{icon:xe,title:"Layout",description:"Canvas, grid, and card rhythm for embedded dashboards.",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(C,{label:"Canvas pad",tooltip:"Outer padding around the dashboard canvas before cards begin.",value:p.tokens.spacing.dashboardPadding,min:0,max:48,onChange:o=>b(a=>{a.tokens.spacing.dashboardPadding=o,a.components.dashboard.padding=o})}),e.jsx(C,{label:"Grid gap",tooltip:"Spacing between dashboard cards in the grid.",value:p.tokens.spacing.gridGap,min:0,max:32,onChange:o=>b(a=>{a.tokens.spacing.gridGap=o})}),e.jsx(C,{label:"Card pad",tooltip:"Inner padding inside card/widget frames around titles, controls, and visual content.",value:p.tokens.spacing.cardPadding,min:0,max:32,onChange:o=>b(a=>{a.tokens.spacing.cardPadding=o,a.components.card.padding=o})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(C,{label:"Control radius",tooltip:"Corner radius for buttons, inputs, selects, checkboxes, segmented controls, and similar interactive controls.",value:p.tokens.radius.control,min:0,max:12,onChange:o=>b(a=>{U(a,"control",o)})}),e.jsx(C,{label:"Card/widget radius",tooltip:"Corner radius for dashboard card frames and widget containers.",value:p.tokens.radius.card,min:0,max:12,onChange:o=>b(a=>{U(a,"card",o)})}),e.jsx(C,{label:"Table radius",tooltip:"Corner radius for table containers, table chrome, and table pagination surfaces.",value:p.tokens.radius.table,min:0,max:12,onChange:o=>b(a=>{U(a,"table",o)})})]})]}),e.jsx(v,{icon:d.SlidersHorizontal,title:"Filters and Controls",description:"Dashboard filter/control toolbar, chip states, menus, and settings panels.",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(k,{label:"Toolbar background",tooltip:"Background color for the dashboard filter/control toolbar strip. This is separate from chip state colors.",value:p.components.interactive.toolbarBackground||p.tokens.color.background,onChange:o=>b(a=>{a.components.interactive.toolbarBackground=o})}),e.jsx(k,{label:"Default state",tooltip:"Unselected filter/control chips plus the base surface for their menus, dialogs, and pagination fallback.",value:p.components.interactive.background||p.tokens.color.card,onChange:o=>b(a=>{a.components.interactive.background=o,a.components.pagination.background=o})}),e.jsx(k,{label:"Border",tooltip:"Border color for filter/control chips, runtime inputs, settings panels, and related popover chrome.",value:p.components.interactive.borderColor||p.tokens.color.border,onChange:o=>b(a=>{a.components.interactive.borderColor=o,a.components.pagination.borderColor=o})}),e.jsx(k,{label:"Selected state",tooltip:"Selected filter/control chips and hover feedback. This keeps a lighter default state and a stronger selected state.",value:p.tokens.color.accent,onChange:o=>b(a=>{ee(a,"accent",o)})})]})})]}),e.jsxs(d.TabsContent,{value:"data",className:"m-0 p-4",children:[e.jsxs(v,{icon:d.ChartColumn,title:"Charts",description:"Palette and semantic chart text/grid colors.",children:[e.jsx("div",{className:"grid grid-cols-3 gap-2",children:ke.map(o=>e.jsx(k,{label:`Series ${o+1}`,value:p.components.chart.palette[o]||"#000000",onChange:a=>b(h=>{h.components.chart.palette[o]=a})},o))}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(k,{label:"Grid",value:p.components.chart.gridColor,onChange:o=>b(a=>{a.components.chart.gridColor=o})}),e.jsx(k,{label:"Axis",value:p.components.chart.axisColor,onChange:o=>b(a=>{a.components.chart.axisColor=o})})]})]}),e.jsxs(v,{icon:d.Table2,title:"Tables",description:"Flat, aggregate, and pivot tables share this V1 table appearance.",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(G,{label:"Density",value:p.components.table.density,options:[["compact","Compact"],["comfortable","Comfortable"],["spacious","Spacious"]],onChange:o=>b(a=>{a.components.table.density=o,c(a,"aggregateTable"),c(a,"pivotTable")})}),e.jsx(G,{label:"Cell wrap",value:p.components.table.cell.wrap,options:[["nowrap","No wrap"],["wrap","Wrap"]],onChange:o=>b(a=>{a.components.table.cell.wrap=o,c(a,"aggregateTable"),c(a,"pivotTable")})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(k,{label:"Header",value:p.components.table.header.background,onChange:o=>b(a=>{a.components.table.header.background=o,c(a,"aggregateTable"),c(a,"pivotTable")})}),e.jsx(k,{label:"Divider",value:p.components.table.row.dividerColor,onChange:o=>b(a=>{a.components.table.row.dividerColor=o,a.components.table.header.dividerColor=o,c(a,"aggregateTable"),c(a,"pivotTable")})})]}),e.jsx(H,{label:"Zebra rows",checked:p.components.table.row.zebra,onCheckedChange:o=>b(a=>{a.components.table.row.zebra=o,c(a,"aggregateTable"),c(a,"pivotTable")})}),e.jsx(H,{label:"Sticky headers",checked:p.components.table.header.sticky,onCheckedChange:o=>b(a=>{a.components.table.header.sticky=o,c(a,"aggregateTable"),c(a,"pivotTable")})}),e.jsx(H,{label:"Uppercase headers",checked:p.components.table.header.uppercase,onCheckedChange:o=>b(a=>{a.components.table.header.uppercase=o,c(a,"aggregateTable"),c(a,"pivotTable")})})]})]})]})]}):null]})}function v({icon:r,title:n,description:t,children:u}){return e.jsxs("section",{className:"mb-6 last:mb-0",children:[e.jsxs("div",{className:"mb-3 flex items-start gap-2",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 items-center justify-center rounded-control border border-border/70",children:e.jsx(r,{className:"h-3 w-3 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-[13px] font-semibold",children:n}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-4 text-muted-foreground",children:t})]})]}),e.jsx("div",{className:"space-y-2",children:u}),e.jsx(d.Separator,{className:"mt-5 bg-border/60"})]})}function Ne({value:r,onChange:n}){var u;const t=(u=q.find(i=>i.value===r))==null?void 0:u.id;return e.jsxs("div",{children:[e.jsx(d.Label,{className:"mb-1 block text-[11px] font-normal text-muted-foreground",children:"Font family"}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_150px] gap-2",children:[e.jsxs(d.Select,{value:t,onValueChange:i=>{const l=q.find(s=>s.id===i);l&&n(l.value)},children:[e.jsx(d.SelectTrigger,{size:"xs","aria-label":"Font family preset",children:e.jsx(d.SelectValue,{placeholder:"Select font"})}),e.jsx(d.SelectContent,{children:q.map(i=>e.jsx(d.SelectItem,{value:i.id,children:i.label},i.id))})]}),e.jsx("div",{className:"flex h-7 items-center rounded-control border border-border/60 bg-muted/30 px-2 text-[12px]",style:{fontFamily:r},children:"Aa 123"})]})]})}function k({label:r,tooltip:n,value:t,onChange:u}){const[i,l]=m.useState(!1),[s,y]=m.useState(t),j=we(t),N=t!==s,f=g=>{l(g),g&&y(t)};return e.jsxs("div",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(d.Label,{className:"text-[11px] font-normal text-muted-foreground",children:r}),n?e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`${r} details`,className:"inline-flex h-3.5 w-3.5 items-center justify-center rounded-control text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",children:e.jsx(d.Info,{className:"h-3 w-3"})})}),e.jsx(d.TooltipContent,{side:"top",className:"max-w-64",children:n})]})}):null]}),e.jsxs("div",{className:"flex h-7 items-center overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(d.Popover,{open:i,onOpenChange:f,children:[e.jsx(d.PopoverTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Open ${r} color picker`,className:"ml-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-control border border-border/70",style:{backgroundColor:t},children:e.jsx("span",{className:"sr-only",children:r})})}),e.jsxs(d.PopoverContent,{align:"start",sideOffset:6,className:"z-[60] w-64 rounded-control p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("label",{className:"relative flex h-16 w-16 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-control border border-border/70",style:{backgroundColor:t},children:[e.jsx("input",{"aria-label":`${r} native color picker`,type:"color",value:j,onChange:g=>u(g.target.value),className:"absolute inset-0 h-full w-full cursor-pointer opacity-0"}),e.jsx("span",{className:"rounded-control bg-black/45 p-1 text-white shadow-sm",children:e.jsx(he,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsx(d.Label,{className:"block text-[11px] font-normal text-muted-foreground",children:"Color value"}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Reset ${r} color to previous value`,disabled:!N,className:"inline-flex h-5 w-5 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-35",onClick:()=>u(s),children:e.jsx(d.RotateCcw,{className:"h-3 w-3"})})}),e.jsx(d.TooltipContent,{side:"top",children:"Reset to previous value"})]})})]}),e.jsx(d.Input,{size:"xs","aria-label":`${r} popover color value`,value:t,onChange:g=>u(g.target.value),className:"font-mono"})]})]}),e.jsx("div",{className:"mt-2 grid grid-cols-6 gap-1",children:ve.map(g=>e.jsx("button",{type:"button","aria-label":`Set ${r} to ${g}`,className:d.cn("h-6 rounded-control border border-border/70 shadow-sm",t.toLowerCase()===g&&"ring-2 ring-ring"),style:{backgroundColor:g},onClick:()=>u(g)},g))})]})]}),e.jsx(d.Input,{size:"xs","aria-label":`${r} color value`,value:t,onChange:g=>u(g.target.value),className:"h-full border-0 px-2 font-mono shadow-none focus-visible:border-0"})]})]})}function we(r){const n=A.parseAppearanceColor(r);return n?`#${M(n.r)}${M(n.g)}${M(n.b)}`:"#000000"}function M(r){return Math.round(r).toString(16).padStart(2,"0")}function C({label:r,tooltip:n,value:t,min:u,max:i,onChange:l}){const s=m.useId();return e.jsxs("div",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(d.Label,{htmlFor:s,className:"text-[11px] font-normal text-muted-foreground",children:r}),n?e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`${r} details`,className:"inline-flex h-3.5 w-3.5 items-center justify-center rounded-control text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",children:e.jsx(d.Info,{className:"h-3 w-3"})})}),e.jsx(d.TooltipContent,{side:"top",className:"max-w-56",children:n})]})}):null]}),e.jsx(d.Input,{id:s,size:"xs",type:"number",min:u,max:i,value:t,onChange:y=>{const j=Number(y.target.value);Number.isNaN(j)||l(j)}})]})}function G({label:r,value:n,options:t,onChange:u}){return e.jsxs("div",{children:[e.jsx(d.Label,{className:"mb-1 block text-[11px] font-normal text-muted-foreground",children:r}),e.jsxs(d.Select,{value:n,onValueChange:u,children:[e.jsx(d.SelectTrigger,{size:"xs",children:e.jsx(d.SelectValue,{})}),e.jsx(d.SelectContent,{children:t.map(([i,l])=>e.jsx(d.SelectItem,{value:i,children:l},i))})]})]})}function H({label:r,checked:n,onCheckedChange:t}){return e.jsxs("div",{className:"flex h-8 items-center justify-between rounded-control border border-border/60 px-2",children:[e.jsx("span",{className:"text-[12px]",children:r}),e.jsx(d.Switch,{size:"xs",checked:n,onCheckedChange:t})]})}function Te(r){const n=`${Number((r/16).toFixed(4))}rem`;return{"--semaphor-radius":n,"--semaphor-control-radius":n}}function Se(r){return JSON.parse(JSON.stringify(r))}function Fe(r){return typeof r.text=="function"?r.text():new Promise((n,t)=>{const u=new FileReader;u.onload=()=>n(String(u.result??"")),u.onerror=()=>t(u.error??new Error("Unable to read file")),u.readAsText(r)})}exports.BRAND_STUDIO_PRESETS=W;exports.BrandStudioEditor=Ce;exports.applyBrandStudioPreset=re;exports.buildAppearanceSpecFromDraft=E;exports.createBrandStudioDraft=O;exports.mirrorTableAppearance=c;
