@smart-tools/t3-code-pixso-mcp-assistant 1.0.1 → 1.0.2

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.
@@ -1,10 +1,7 @@
1
- import{n as e,t}from"../chunk-CbfVNrr-.mjs";import{t as n}from"../constants-C3TxS7N-.mjs";import{C as r,S as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,u as x,y as S}from"../renderPreview-BNqmGtPz.mjs";import{AppWindowIcon as C,ArrowDownIcon as w,ArrowUpIcon as ee,ArrowUpToLineIcon as te,BlocksIcon as ne,ChartColumnIcon as re,CheckIcon as ie,ChevronDownIcon as T,ChevronLeftIcon as ae,ChevronRightIcon as E,ComponentIcon as oe,CopyIcon as se,CornerLeftUpIcon as ce,CrosshairIcon as le,EllipsisVerticalIcon as ue,ExternalLinkIcon as D,EyeIcon as de,FlaskConicalIcon as fe,FolderIcon as pe,FolderInputIcon as me,FolderPlusIcon as he,GripVerticalIcon as ge,ImageOffIcon as _e,ImagesIcon as ve,InboxIcon as ye,ListTreeIcon as be,LoaderIcon as xe,MessageSquareCodeIcon as Se,MousePointerClickIcon as Ce,PaletteIcon as we,PenToolIcon as Te,PencilIcon as Ee,PinIcon as De,PinOffIcon as Oe,PlayIcon as ke,PlusIcon as Ae,RefreshCwIcon as je,ScanIcon as Me,SearchIcon as Ne,SettingsIcon as Pe,Trash2Icon as Fe,TriangleAlertIcon as Ie,UnplugIcon as Le,XIcon as Re}from"lucide-react";import{createContext as ze,useCallback as Be,useContext as Ve,useEffect as O,useLayoutEffect as He,useMemo as k,useRef as Ue,useState as A,useSyncExternalStore as We}from"react";import{create as Ge}from"zustand";import{useCopyToClipboard as Ke}from"@smart-tools/qwen-cli-ui-kit";import{mergeProps as qe}from"@base-ui/react/merge-props";import{useRender as Je}from"@base-ui/react/use-render";import{cva as Ye}from"class-variance-authority";import{Fragment as j,jsx as M,jsxs as N}from"react/jsx-runtime";import{getSharedHighlighter as Xe}from"@pierre/diffs";import{Dialog as P}from"@base-ui/react/dialog";import{Menu as F}from"@base-ui/react/menu";import{DndContext as Ze,DragOverlay as Qe,PointerSensor as $e,closestCenter as et,pointerWithin as tt,rectIntersection as nt,useDraggable as rt,useDroppable as it,useSensor as at,useSensors as ot}from"@dnd-kit/core";import{SortableContext as st,useSortable as ct,verticalListSortingStrategy as lt}from"@dnd-kit/sortable";import{CSS as ut}from"@dnd-kit/utilities";import{ContextMenu as dt}from"@base-ui/react/context-menu";function ft(e){return`pixso:${e}`}function pt(e){return{id:ft(e.key),sectionId:`pixso:${e.cardId}`,sectionTitle:`Pixso · ${e.cardName}`,filePath:`pixso/${e.cardName}`,startIndex:0,endIndex:0,rangeLabel:e.shortLabel,text:e.label,diff:e.payload,fenceLanguage:e.fenceLanguage}}let mt=null;const ht=e=>{mt=e};function I(){if(mt===null)throw Error(`PixsoAssistant: ports are not configured — call configurePixsoAssistantPorts() at the host seam`);return mt}const gt=()=>I().useResolvedTheme(),_t=()=>I().useActiveComposerTarget();function vt(e,t){return e===t?!0:e===null||t===null?!1:typeof e==`string`||typeof t==`string`?e===t:e.environmentId===t.environmentId&&e.threadId===t.threadId}const yt=(e,t)=>n=>n.key===e&&vt(n.attachedTo,t);function bt(e){e.attachedTo!==null&&I().composer.removeReviewComment(e.attachedTo,ft(e.key))}const xt=e=>e instanceof Error?e.message:String(e),L=e=>t=>{I().toastError(e,xt(t))},R=Ge((e,t)=>{let n=0,r=0,i=null,a=e=>e===`running`?1:e===`settled`?2:0,o=()=>{let e=new Map,t=new Map,r=t=>({global:n,key:e.get(t)??0}),i=(t,r)=>r.global===n&&r.key===(e.get(t)??0);return{claim:e=>{let n=t.get(e);if(n!==void 0&&i(e,n))return null;let a=r(e);return t.set(e,a),a},isLive:i,release:(e,n)=>{t.get(e)===n&&t.delete(e)},evict:t=>{for(let n of t)e.set(n,(e.get(n)??0)+1)}}},c=o(),l=o(),u=o(),d=(e,t)=>{let n={},r=new Set,i=new Set;for(let[a,o]of Object.entries(e.details)){if(t.has(a)){o.catalogHash!==null&&i.add(o.catalogHash);continue}n[a]=o,o.catalogHash!==null&&r.add(o.catalogHash)}for(let t of Object.keys(e.catalogs))i.add(t);for(let t of e.catalogErrors)i.add(t);for(let e of r)i.delete(e);let a=Object.fromEntries(Object.entries(e.raws).filter(([e])=>!t.has(e))),o=Object.fromEntries(Object.entries(e.catalogs).filter(([e])=>r.has(e)));return c.evict(t),l.evict(t),u.evict(i),{details:n,raws:a,catalogs:o,detailErrors:new Set([...e.detailErrors].filter(e=>!t.has(e))),rawErrors:new Set([...e.rawErrors].filter(e=>!t.has(e))),catalogErrors:new Set([...e.catalogErrors].filter(e=>!i.has(e)))}},f=(e,t)=>new Set(e).add(t),p=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},m=0,h=0,g=n=>{let i=r,a=t(),o=S({groups:a.groups,groupByCardId:a.groupByCardId,unsortedPinned:a.unsortedPinned,unsortedCollapsed:a.unsortedCollapsed},n),c=new Set(o.removedCardIds);e({groups:o.state.groups,groupByCardId:o.state.groupByCardId,unsortedPinned:o.state.unsortedPinned,unsortedCollapsed:o.state.unsortedCollapsed,...c.size>0?{cards:a.cards.filter(e=>!c.has(e.id)),recents:a.recents.filter(e=>!c.has(e)),...d(a,c)}:{}}),h+=1,h===1&&e({gallerySyncing:!0}),I().client.groupsMutate(n).catch(e=>{i===r&&L(s(`Failed to save the gallery`,`Не удалось сохранить галерею`))(e)}).finally(()=>{i===r&&(--h,h===0&&(e({gallerySyncing:!1}),t().refreshSnapshot()))})};return{view:`tabs`,activeTab:`import`,selectedCardId:null,searchQuery:``,cards:[],groups:[],groupByCardId:{},unsortedPinned:!0,unsortedCollapsed:!1,recents:[],lastCheck:null,lastProbe:null,detailErrors:new Set,lastCheckError:null,lastProbeError:null,lastScanAtIso:null,snapshotPhase:`idle`,snapshotError:null,gallerySyncing:!1,supportsReparse:!1,scanJob:{phase:`idle`},details:{},raws:{},catalogs:{},rawErrors:new Set,catalogErrors:new Set,latestReport:null,connection:`unchecked`,probePhase:`idle`,debugRescanning:!1,reparsing:!1,lastReparse:null,tray:[],composerTarget:null,setComposerTarget:t=>e(e=>vt(e.composerTarget,t)?e:{composerTarget:t}),setTab:t=>e({activeTab:t,view:`tabs`}),openDetail:n=>{e({view:`detail`,selectedCardId:n}),t().loadDetail(n)},openDiagnostics:()=>{e({view:`diagnostics`}),t().loadReport()},backToTabs:()=>e({view:`tabs`}),setSearchQuery:t=>e({searchQuery:t}),resetAuthority:()=>{r+=1,n+=1,m=0,h=0,i=null,e({cards:[],groups:[],groupByCardId:{},unsortedPinned:!0,unsortedCollapsed:!1,recents:[],lastCheck:null,lastProbe:null,lastCheckError:null,lastProbeError:null,lastScanAtIso:null,snapshotPhase:`idle`,snapshotError:null,gallerySyncing:!1,supportsReparse:!1,scanJob:{phase:`idle`},details:{},raws:{},catalogs:{},detailErrors:new Set,rawErrors:new Set,catalogErrors:new Set,latestReport:null,connection:`unchecked`,probePhase:`idle`,debugRescanning:!1,reparsing:!1,lastReparse:null})},refreshSnapshot:()=>{if(t().snapshotPhase===`loading`)return;let n=r,i=m+=1;e({...t().snapshotPhase===`loaded`?{}:{snapshotPhase:`loading`},snapshotError:null}),I().client.snapshot().then(a=>{if(n===r&&i===m){if(h>0){t().snapshotPhase===`loading`&&e({snapshotPhase:`idle`});return}e({cards:a.cards,groups:a.groups,groupByCardId:a.groupByCardId,unsortedPinned:a.unsortedPinned,unsortedCollapsed:a.unsortedCollapsed,recents:a.recents,lastCheck:a.lastCheck,lastProbe:a.lastProbe,lastScanAtIso:a.lastScanAtIso,snapshotPhase:`loaded`,snapshotError:null,supportsReparse:a.supportsReparse===!0})}}).catch(a=>{n===r&&i===m&&(e({snapshotPhase:t().snapshotPhase===`loaded`?`loaded`:`failed`,snapshotError:xt(a)}),L(s(`Failed to load the gallery`,`Не удалось загрузить галерею`))(a))})},applyScanJobState:n=>{let r=`startedAtIso`in n?n.startedAtIso:null,o=a(n.phase);if(i!==null&&r!==null&&(r<i.startedAtIso||r===i.startedAtIso&&o<i.ordinal))return;r!==null&&(i={startedAtIso:r,ordinal:o});let s=t().scanJob;if(e({scanJob:n}),s.phase===`idle`&&t().snapshotPhase!==`loaded`&&t().refreshSnapshot(),n.phase===`running`){e({connection:`checking`});return}if(n.phase===`settled`&&s.phase!==`idle`&&(s.phase!==`settled`||s.settledAtIso!==n.settledAtIso)&&(e({connection:n.outcome===`mcp-down`?`error`:`connected`}),t().refreshSnapshot(),t().loadReport(),n.cardId!==null)){let r=n.cardId,i=t().raws[r]!==void 0;e(e=>d(e,new Set([r])));let{view:a,selectedCardId:o}=t();a===`detail`&&o===r&&(t().loadDetail(r),i&&t().loadRaw(r))}},runImport:()=>{let{scanJob:e}=t();if(e.phase===`running`)return;let n=r;I().client.scanStart().then(e=>{n===r&&t().applyScanJobState(e)}).catch(e=>{n===r&&L(s(`Failed to start the scan`,`Не удалось запустить скан`))(e)})},recheck:()=>{if(t().connection===`checking`)return;let n=r;e({connection:`checking`}),I().client.check().then(t=>{n===r&&e({connection:`connected`,lastCheck:t,lastCheckError:null})}).catch(t=>{n===r&&e({connection:`error`,lastCheckError:xt(t)})})},runProbe:()=>{if(t().probePhase===`running`)return;let n=r;e({probePhase:`running`,connection:`checking`}),I().client.probe().then(t=>{n===r&&e({probePhase:`done`,connection:`connected`,lastProbe:t,lastProbeError:null})}).catch(t=>{n===r&&e({probePhase:`failed`,connection:`error`,lastProbeError:xt(t)})})},debugRescan:()=>{if(t().debugRescanning)return;let n=r;e({debugRescanning:!0}),I().client.rescanDebug().then(t=>{n===r&&e({debugRescanning:!1,latestReport:t,lastScanAtIso:t.atIso})}).catch(t=>{n===r&&(e({debugRescanning:!1}),L(s(`Rescan failed`,`Пересканирование не удалось`))(t))})},loadReport:()=>{let t=r;I().client.reportLatest().then(n=>{t===r&&e({latestReport:n})}).catch(e=>{t===r&&L(s(`Failed to load the report`,`Не удалось загрузить отчёт`))(e)})},runReparse:()=>{if(t().reparsing)return;let i=r;e({reparsing:!0}),I().client.reparse().then(a=>{i===r&&(e({reparsing:!1,lastReparse:a}),n+=1,e({details:{},raws:{},detailErrors:new Set,rawErrors:new Set}),t().refreshSnapshot())}).catch(t=>{i===r&&(e({reparsing:!1}),L(s(`Re-parse failed`,`Перечитать карточки не удалось`))(t))})},loadDetail:n=>{if(t().details[n]!==void 0||t().detailErrors.has(n))return;let i=c.claim(n);if(i===null)return;let a=r;I().client.card(n).then(t=>{a!==r||!c.isLive(n,i)||e(e=>({details:{...e.details,[n]:t},detailErrors:p(e.detailErrors,n)}))}).catch(t=>{a!==r||!c.isLive(n,i)||(e(e=>({detailErrors:f(e.detailErrors,n)})),L(s(`Failed to load the card`,`Не удалось загрузить карточку`))(t))}).finally(()=>c.release(n,i))},retryDetail:n=>{e(e=>({detailErrors:p(e.detailErrors,n)})),t().loadDetail(n)},loadRaw:n=>{if(t().raws[n]!==void 0||t().rawErrors.has(n))return;let i=l.claim(n);if(i===null)return;let a=r;I().client.cardRaw(n).then(({raw:t})=>{a!==r||!l.isLive(n,i)||e(e=>({raws:{...e.raws,[n]:t},rawErrors:p(e.rawErrors,n)}))}).catch(t=>{a!==r||!l.isLive(n,i)||(e(e=>({rawErrors:f(e.rawErrors,n)})),L(s(`Failed to load the DSL`,`Не удалось загрузить DSL`))(t))}).finally(()=>l.release(n,i))},retryRaw:n=>{e(e=>({rawErrors:p(e.rawErrors,n)})),t().loadRaw(n)},loadCatalog:n=>{if(t().catalogs[n]!==void 0||t().catalogErrors.has(n))return;let i=u.claim(n);if(i===null)return;let a=r;I().client.catalog(n).then(t=>{a!==r||!u.isLive(n,i)||e(e=>({catalogs:{...e.catalogs,[n]:t},catalogErrors:p(e.catalogErrors,n)}))}).catch(t=>{a!==r||!u.isLive(n,i)||(e(e=>({catalogErrors:f(e.catalogErrors,n)})),L(s(`Failed to load the catalog`,`Не удалось загрузить каталог`))(t))}).finally(()=>u.release(n,i))},retryCatalog:n=>{e(e=>({catalogErrors:p(e.catalogErrors,n)})),t().loadCatalog(n)},createGroup:e=>{let t=`group-${crypto.randomUUID()}`;return g({op:`create`,groupId:t,name:e}),t},renameGroup:(e,t)=>g({op:`rename`,groupId:e,name:t}),deleteGroup:(e,{deleteCards:t})=>g({op:`delete`,groupId:e,deleteCards:t}),reorderGroups:(e,t)=>g({op:`reorder`,activeId:e,overId:t}),moveGroup:(e,t)=>g({op:`move`,groupId:e,direction:t}),toggleGroupPinned:e=>g({op:`togglePinned`,groupId:e}),toggleGroupCollapsed:e=>g({op:`toggleCollapsed`,groupId:e}),toggleUnsortedPinned:()=>g({op:`toggleUnsortedPinned`}),toggleUnsortedCollapsed:()=>g({op:`toggleUnsortedCollapsed`}),moveCardToGroup:(e,t)=>g({op:`moveCardToGroup`,cardId:e,groupId:t}),removeCard:n=>{let i=r;e(e=>{let{[n]:t,...r}=e.groupByCardId;return{cards:e.cards.filter(e=>e.id!==n),groupByCardId:r,...d(e,new Set([n])),...e.selectedCardId===n?{view:`tabs`,selectedCardId:null}:{},recents:e.recents.filter(e=>e!==n)}}),h+=1,h===1&&e({gallerySyncing:!0}),I().client.removeCard(n).catch(e=>{i===r&&L(s(`Failed to delete the card`,`Не удалось удалить карточку`))(e)}).finally(()=>{i===r&&(--h,h===0&&(e({gallerySyncing:!1}),t().refreshSnapshot()))})},toggleTrayItem:t=>e(e=>{let n=e.composerTarget,r=e.tray.find(yt(t.key,n));return r===void 0?(n!==null&&I().composer.addReviewComment(n,pt(t)),{tray:[...e.tray,{...t,attachedTo:n}]}):(bt(r),{tray:e.tray.filter(e=>e!==r)})}),upsertTrayItem:t=>e(e=>{let n=e.composerTarget,r=e.tray.find(yt(t.key,n));return r===void 0||r.payload===t.payload&&r.label===t.label&&r.shortLabel===t.shortLabel&&r.fenceLanguage===t.fenceLanguage?e:(n!==null&&I().composer.addReviewComment(n,pt(t)),{tray:e.tray.map(e=>e===r?{...t,attachedTo:n}:e)})}),removeTrayItem:t=>e(e=>{let n=e.tray.find(yt(t,e.composerTarget));return n===void 0?e:(bt(n),{tray:e.tray.filter(e=>e!==n)})}),clearTray:()=>e(e=>{let t=e.composerTarget,n=e.tray.filter(e=>vt(e.attachedTo,t));if(n.length===0)return e;for(let e of n)bt(e);return{tray:e.tray.filter(e=>!n.includes(e))}}),pruneDetachedTrayItems:()=>e(e=>{let t=I().composer,n=e.tray.filter(e=>e.attachedTo===null?!0:(t.getReviewCommentIds(e.attachedTo)??[]).includes(ft(e.key)));return n.length===e.tray.length?e:{tray:n}})}}),St=()=>{R.getState().resetAuthority()};function z(e){return R(t=>t.tray.some(yt(e,t.composerTarget)))}function Ct(){let e=R(e=>e.tray),t=R(e=>e.composerTarget);return k(()=>e.filter(e=>vt(e.attachedTo,t)),[e,t])}function wt(){let e=R(e=>e.setComposerTarget),t=_t();return O(()=>{e(t),R.getState().pruneDetachedTrayItems()},[t,e]),O(()=>I().composer.subscribe(()=>{R.getState().pruneDetachedTrayItems()}),[]),null}function Tt(){try{return globalThis.localStorage?.getItem(`pixsoDebug`)===`true`}catch{return!1}}var Et=t({});import*as Dt from"@smart-tools/qwen-cli-ui-kit";e(Et,Dt);var B=t({});import*as Ot from"@smart-tools/qwen-cli-ui-kit";e(B,Ot);var kt=t({});import*as At from"@smart-tools/qwen-cli-ui-kit";e(kt,At);var jt=t({});import*as Mt from"@smart-tools/qwen-cli-ui-kit";e(jt,Mt);var V=t({});import*as Nt from"@smart-tools/qwen-cli-ui-kit";e(V,Nt);const Pt=Ye(`[&_svg]:-mx-0.5 relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-lg border font-medium text-base outline-none transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-9 px-[calc(--spacing(3)-1px)] sm:h-8`,icon:`size-9 sm:size-8`,"icon-lg":`size-10 sm:size-9`,"icon-sm":`size-8 sm:size-7`,"icon-xl":`size-11 sm:size-10 [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,"icon-xs":`size-7 rounded-md before:rounded-[calc(var(--radius-md)-1px)] sm:size-6 not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-4 sm:not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-3.5`,lg:`h-10 px-[calc(--spacing(3.5)-1px)] sm:h-9`,sm:`h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:h-7`,xl:`h-11 px-[calc(--spacing(4)-1px)] text-lg sm:h-10 sm:text-base [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,xs:`h-7 gap-1 rounded-md px-[calc(--spacing(2)-1px)] text-sm before:rounded-[calc(var(--radius-md)-1px)] sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5`},variant:{default:`not-disabled:inset-shadow-[0_1px_--theme(--color-white/16%)] border-primary bg-primary text-primary-foreground shadow-primary/24 shadow-xs [:active,[data-pressed]]:inset-shadow-[0_1px_--theme(--color-black/8%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-primary/90`,destructive:`not-disabled:inset-shadow-[0_1px_--theme(--color-white/16%)] border-destructive bg-destructive text-white shadow-destructive/24 shadow-xs [:active,[data-pressed]]:inset-shadow-[0_1px_--theme(--color-black/8%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-destructive/90`,"destructive-outline":`border-input bg-popover not-dark:bg-clip-padding text-destructive-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:border-destructive/32 [:hover,[data-pressed]]:bg-destructive/4`,ghost:`border-transparent text-foreground data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent [&_svg:not([class*='text-'])]:text-muted-foreground`,link:`border-transparent underline-offset-4 [:hover,[data-pressed]]:underline`,outline:`border-input bg-popover not-dark:bg-clip-padding text-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground`,secondary:`border-transparent bg-secondary text-secondary-foreground [:active,[data-pressed]]:bg-secondary/80 [:hover,[data-pressed]]:bg-secondary/90`}}});function H({className:e,variant:t,size:n,render:r,...i}){let a=r?void 0:`button`;return Je({defaultTagName:`button`,props:qe({className:(0,V.cn)(Pt({className:e,size:n,variant:t})),"data-slot":`button`,type:a},i),render:r})}var U=t({});import*as Ft from"@smart-tools/qwen-cli-ui-kit";e(U,Ft);const It=1e3;function W({value:e,label:t,className:n}){let r=Ue(null),{copyToClipboard:i,isCopied:a}=Ke({timeout:It,onCopy:()=>{r.current&&I().anchoredToast({anchor:r.current,timeoutMs:It,title:s(`Copied!`,`Скопировано!`)})},onError:e=>{r.current&&I().anchoredToast({anchor:r.current,timeoutMs:It,title:s(`Failed to copy`,`Не удалось скопировать`),description:e.message})}});return N(U.Tooltip,{children:[M(U.TooltipTrigger,{render:M(`button`,{ref:r,type:`button`,"aria-label":t,disabled:a,className:(0,V.cn)(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,a&&`text-success hover:text-success`,n),onClick:t=>{t.stopPropagation(),i(e)}}),children:M(a?ie:se,{className:`size-3`})}),M(U.TooltipPopup,{children:t})]})}var Lt=t({});import*as Rt from"@smart-tools/qwen-cli-ui-kit";e(Lt,Rt);function zt(e){let t=new Map((e.componentsUsed??[]).map(e=>[e.key,e])),n=l(e.root),r=new Set,i=(e,t)=>{let n=e.type===`instance`||e.type===`symbol`?t+1:t;n>0&&r.add(e.id);for(let t of e.children??[])i(t,n)};i(e.root,0);let a=n.map(({node:e,depth:n})=>{let r=e.componentRef===void 0?void 0:t.get(e.componentRef);return{id:e.id,depth:n,name:e.name,type:e.type,text:e.text?.trim()||null,componentName:r?.name??null,library:r?.library??null,caption:r?.description??null,width:Math.round(e.width),height:Math.round(e.height),url:e.url??null}}),o=new Map;for(let e of a)o.set(e.type,(o.get(e.type)??0)+1);let s=a.map(e=>e.text).filter(e=>e!==null);return{rows:a,nodesByType:[...o.entries()].map(([e,t])=>({type:e,count:t})).sort((e,t)=>t.count-e.count),depth:v(e.root),copy:s,copyWordCount:s.join(` `).split(/\s+/).filter(Boolean).length,componentCoverage:a.length===0?0:Math.round(r.size/a.length*100),libraries:[...new Set((e.componentsUsed??[]).map(e=>e.library).filter(e=>e!==null))],deprecatedCount:(e.componentsUsed??[]).filter(e=>e.deprecated).length,designerUrls:n.filter(({node:e})=>e.url!==void 0).map(({node:e})=>({node:e.name,url:e.url}))}}function Bt(e){try{return new URL(e).host}catch{return e}}function Vt(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}function Ht(e){switch(e){case`frame`:return s(`Frame`,`Фрейм`);case`group`:return s(`Group`,`Группа`);case`text`:case`paragraph`:case`span`:return s(`Text`,`Текст`);case`rect`:case`ellipse`:case`vector`:case`line`:return s(`Shape`,`Фигура`);case`mask`:return s(`Mask`,`Маска`);case`instance`:return s(`Component`,`Компонент`);case`symbol`:return s(`Master component`,`Эталон компонента`);default:return s(`Layer`,`Слой`)}}function Ut(e){return e.nodeType===`instance`&&e.identity.componentName!==null?{label:e.identity.componentName,library:e.identity.library,deprecated:e.identity.deprecated}:e.nodeType===`symbol`?{label:s(`Master component`,`Эталон компонента`),library:null,deprecated:!1}:{label:Ht(e.nodeType),library:null,deprecated:!1}}function Wt(e){if(e.type===`instance`){let t=e.root.componentRef,n=t===void 0?void 0:(e.componentsUsed??[]).find(e=>e.key===t);return n===void 0?{label:s(`Component`,`Компонент`),library:null,deprecated:!1}:{label:n.name,library:n.library,deprecated:n.deprecated}}return e.type===`symbol`?{label:s(`Master component`,`Эталон компонента`),library:null,deprecated:!1}:{label:Ht(e.type),library:null,deprecated:!1}}const Gt=e=>({typography:s(`Typography`,`Типографика`),layout:s(`Spacing & grid`,`Отступы и сетка`),components:s(`Components`,`Компоненты`),behavior:s(`Behavior`,`Поведение`),violations:s(`Violations`,`Нарушения`)})[e];function Kt(e){let t=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e),n=/^#?([0-9a-f]{6})/i.exec(e);if(t===null&&n===null)return e;let r=n===null?0:parseInt(n[1],16),i=t===null?r>>16&255:Number(t[1]),a=t===null?r>>8&255:Number(t[2]),o=t===null?r&255:Number(t[3]),s=Math.max(i,a,o),c=Math.min(i,a,o),l=(s+c)/2;if((s===c?0:(s-c)/(255-Math.abs(s+c-255)))<.12)return l>235?`белый`:l>190?`светло-серый`:l>110?`серый`:l>45?`тёмно-серый`:`чёрный`;let u=s===i?60*(a-o)/(s-c)+(a<o?360:0):s===a?60*(o-i)/(s-c)+120:60*(i-a)/(s-c)+240,d=u<20||u>=345?`красный`:u<45?`оранжевый`:u<70?`жёлтый`:u<160?`зелёный`:u<200?`бирюзовый`:u<260?`синий`:u<300?`фиолетовый`:`розовый`;return l>190?`светло-${d}`:l<80?`тёмно-${d}`:d}const qt={Light:`тонкий`,Regular:`обычный`,Medium:`средней жирности`,Semibold:`полужирный`,Bold:`жирный`};function Jt(e){let t=String(p(e.font?.style)),n=e.textMeta?.lineHeightPx==null?``:`/${e.textMeta.lineHeightPx}px`;return`${t} ${e.font?.size??`?`}px${n} "${e.font?.family??`?`}"`}function Yt(e,t){return`${e.name} → ${t.name} [${t.id}]`}function Xt(e){let t=[],n=new Map((e.componentsUsed??[]).map(e=>[e.key,e])),r=0,i=(n,i,a,o,s)=>{r+=1,t.push({id:`${e.id}:qa:${r}`,group:n,nodeId:i,manual:a,auto:{target:o,assertions:s}})};for(let{node:t,parent:r}of l(e.root)){if(t.text!==void 0&&t.text.trim()!==``&&t.font!==void 0){let n=t.font.style,r=(n===void 0?void 0:qt[n])??n??`—`,a=t.textColor===void 0?``:`, цвет ${Kt(t.textColor)}`,o=t.textMeta?.upperCase===!0?`, все буквы ЗАГЛАВНЫЕ`:``;i(`typography`,t.id,`Текст «${t.text.trim()}» — ${r}, размер как в макете${a}${o}.`,Yt(e,t),[`font: ${Jt(t)}`,...t.textColor===void 0?[]:[`color: ${t.textColor}`],...t.textMeta?.letterSpacing===void 0?[]:[`letter-spacing: ${t.textMeta.letterSpacing.value}${t.textMeta.letterSpacing.unit}`],...t.textMeta?.upperCase===!0?[`text-transform: uppercase`]:[]])}if(t.layout!==void 0&&(t.children??[]).length>=2){let n=t.layout.mode===`vertical`?`друг под другом`:`в один ряд`,r=t.layout.gap===null?``:`, расстояние между ними одинаковое (${t.layout.gap})`;i(`layout`,t.id,`Блок «${t.name}» — элементы стоят ${n}${r}, ничего не прилипает к краям.`,Yt(e,t),[`display: flex`,`flex-direction: ${t.layout.mode===`vertical`?`column`:`row`}`,...t.layout.gap===null?[]:[`gap: ${t.layout.gap}px`],...t.layout.padding===null?[]:[`padding: ${t.layout.padding.top}px ${t.layout.padding.right}px ${t.layout.padding.bottom}px ${t.layout.padding.left}px`]])}if(t.componentRef!==void 0){let r=n.get(t.componentRef);if(r!==void 0){let n=r.props.map(e=>e.kind===`visible`?`${e.name} — ${e.value===`on`?`показан`:`скрыт`}`:`${e.name}: «${e.value}»`).join(`; `);i(`components`,t.id,`Компонент «${r.name}»${n===``?``:` — ${n}`}.`,Yt(e,t),[`component: ${r.name}${r.variantGroup===null?``:` (${r.variantGroup})`}`,...r.props.map(e=>`prop ${e.name} = ${e.kind===`text`?`"${e.value}"`:e.value}`)])}}if(t.sticky===!0&&i(`behavior`,t.id,`«${t.name}» остаётся на месте при прокрутке страницы.`,Yt(e,t),[`position: fixed`]),t.mask===!0||t.type===`mask`){let n=r?.children?.find(e=>e.id!==t.id);i(`behavior`,t.id,`Содержимое блока «${r?.name??t.name}» обрезано по форме маски${n===void 0?``:` (виден только «${n.name}» внутри неё)`}.`,Yt(e,t),[`overflow: hidden`,...t.radius===void 0?[]:[`border-radius: ${t.radius}px`]])}}for(let t of e.componentsUsed??[])t.deprecated&&i(`violations`,null,`Используется устаревший компонент «${t.name}» — согласовать замену с дизайнером.`,t.name,[`deprecated component: ${t.name}${t.variantGroup===null?``:` (${t.variantGroup})`}`]),t.resolved||i(`violations`,null,`Компонент «${t.name}» из неподключённой библиотеки — каталожных данных нет.`,t.name,[`unresolved library: ${t.libraryFileKey??`?`}`]);for(let{node:t}of l(e.root))t.fill!==void 0&&t.fillToken===void 0&&t.type!==`instance`&&i(`violations`,t.id,`Цвет заливки «${t.name}» (${Kt(t.fill)}) не привязан к стилю библиотеки.`,Yt(e,t),[`background: ${t.fill} /* без токена */`]);return t}function Zt(e){let t=zt(e),n=Xt(e),r=_(e.root),i=b(e.root),o=e.componentsUsed??[],s=new Set;for(let{node:t}of l(e.root))t.fill!==void 0&&t.fillToken!==void 0&&s.add(a(t.fill)),t.textColor!==void 0&&t.textToken!==void 0&&s.add(a(t.textColor));let c=[],u=(e,t)=>{let n=e.layout!==void 0&&e.layout.mode!==`unknown`?` — ${e.layout.mode===`vertical`?`колонка`:`ряд`}${e.layout.gap===null?``:`, интервал ${e.layout.gap}`}`:``,r=e.text!==void 0&&e.text.trim()!==``?` — «${e.text.trim()}»`:``;c.push(`${` `.repeat(t)}- ${e.name} (${Ht(e.type)}, ${Math.round(e.width)}×${Math.round(e.height)})${n}${r}`);for(let n of e.children??[])u(n,t+1)};return u(e.root,0),[`# ${e.name} — UI-спецификация`,``,`> Источник: Pixso, узел \`${e.id}\`, DSL ${e.dslVersion}. Сгенерировано автоматически из данных скана.`,``,`## 1. Обзор`,``,`- Размер: **${Math.round(e.root.width)}×${Math.round(e.root.height)} px**, слоёв: ${t.rows.length}, глубина: ${t.depth}`,`- Компоненты дизайн-системы: ${o.reduce((e,t)=>e+t.count,0)} экземпляров из ${t.libraries.length} библиотек (покрытие ${t.componentCoverage}%)`,...t.deprecatedCount>0?[`- ⚠ **Использовано устаревших компонентов: ${t.deprecatedCount}** — требуется решение до реализации`]:[],``,`## 2. Структура`,``,...c,``,`## 3. Компоненты`,``,`| Компонент | Набор вариантов | Библиотека | Кол-во | Свойства | Статус |`,`|---|---|---|---|---|---|`,...o.map(e=>{let t=e.props.map(e=>`${e.name}${e.kind===`text`?` = «${e.value}»`:` = ${e.value===`on`?`вкл`:`выкл`}`}`).join(`; `),n=e.deprecated?`⚠ устарел`:e.resolved?`ок`:`библиотека не подключена`;return`| ${e.name} | ${e.variantGroup??`—`} | ${e.library??`—`} | ${e.count} | ${t||`—`} | ${n} |`}),``,`## 4. Типографика`,``,`| Шрифт | Начертание | Размер | Использований |`,`|---|---|---|---|`,...i.map(e=>`| ${e.font.family??`—`} | ${e.font.style??`—`} | ${e.font.size===void 0?`—`:`${String(e.font.size)} px`} | ${e.count} |`),``,`## 5. Цвета`,``,`| HEX | Токен | Где используется |`,`|---|---|---|`,...r.map(e=>`| \`${e.color}\` | ${s.has(e.color)?`✓`:`⚠ без токена`} | ${e.usedBy.join(`, `)} |`),``,`## 6. Поведение`,``,...(()=>{let t=l(e.root),n=[];for(let{node:e}of t)e.sticky===!0&&n.push(`- «${e.name}» закреплён при прокрутке (position: fixed)`),(e.mask===!0||e.type===`mask`)&&n.push(`- Маска в «${e.name}» — содержимое обрезается по её форме`),e.hidden===!0&&n.push(`- «${e.name}» скрыт в макете (visible: false)`);return n.length>0?n:[`- Особого поведения не обнаружено.`]})(),``,`## 7. Контент (дословно)`,``,...t.copy.map(e=>`- ${e}`),``,`## 8. Критерии приёмки`,``,...n.map(e=>`- [ ] ${e.manual}`),``,`## 9. Реализация`,``,`- Точная вёрстка: используйте вложение «Спека UI» (HTML-скелет + полный CSS каждого элемента) — прикрепляется из вкладки «Промпт».`,`- Единицы: размеры в px; letter-spacing в % от кегля (переводить в em).`,...t.designerUrls.length>0?[`- Ссылки дизайнера:`,...t.designerUrls.map(e=>` - ${e.node}: ${e.url}`)]:[]].join(`
2
- `)}const G={name:`font-medium text-foreground`,type:`font-mono text-info`,geometry:`font-mono text-muted-foreground`,value:`font-mono text-primary`,string:`font-mono text-success`,id:`font-mono text-muted-foreground`};function Qt({attached:e,onToggle:t,label:n,className:r}){return M(`button`,{type:`button`,"aria-label":n,"aria-pressed":e,title:n,className:(0,V.cn)(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-md border transition-colors`,e?`border-primary/60 bg-primary/12 text-primary`:`border-border bg-background text-muted-foreground/70 hover:border-primary/40 hover:bg-primary/8 hover:text-primary`,r),onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},children:M(e?ie:Ae,{className:`size-3`})})}const $t={light:`pierre-light`,dark:`pierre-dark`};function en({code:e,language:t,theme:n,className:r}){let[i,a]=A(null);return O(()=>{let r=!1,i=n===`dark`?$t.dark:$t.light;return Xe({themes:[$t.dark,$t.light],langs:[t],preferredHighlighter:`shiki-js`}).then(n=>{if(!r)try{a(n.codeToHtml(e,{lang:t,theme:i}))}catch{a(null)}}).catch(()=>{r||a(null)}),()=>{r=!0}},[e,t,n]),i===null?M(`pre`,{className:(0,V.cn)(`whitespace-pre-wrap break-words px-2.5 py-2 font-mono text-[13px] leading-snug text-muted-foreground`,r),children:e}):M(`div`,{className:(0,V.cn)(`px-2.5 py-2 text-[13px] leading-snug [&_pre]:!m-0 [&_pre]:!bg-transparent [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:font-mono`,r),dangerouslySetInnerHTML:{__html:i}})}var K=t({});import*as tn from"@smart-tools/qwen-cli-ui-kit";e(K,tn);var q=t({});import*as nn from"@smart-tools/qwen-cli-ui-kit";e(q,nn);function rn({children:e,tone:t=`default`,className:n}){return M(`span`,{className:(0,V.cn)(`inline-flex shrink-0 items-center rounded-full border border-border bg-background px-2 py-px font-mono text-xs tabular-nums leading-4`,t===`default`&&`text-muted-foreground`,t===`zero`&&`text-muted-foreground/60`,t===`na`&&`border-warning/40 text-warning`,n),children:e})}function J({title:e,sublabel:t,count:n,countTone:r=`default`,attachItem:i,headerActions:a,flush:o=!1,defaultOpen:s=!1,onOpenChange:c,children:l,className:u}){let d=R(e=>e.toggleTrayItem),f=z(i?.key??``);return N(q.Collapsible,{defaultOpen:s,onOpenChange:c,className:(0,V.cn)(`overflow-hidden rounded-lg border border-border bg-card`,u),children:[N(q.CollapsibleTrigger,{className:`group flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-accent/40`,children:[M(E,{className:`size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-data-panel-open:rotate-90`}),M(`span`,{className:`text-xs font-semibold`,children:e}),t!==void 0&&M(`span`,{className:`truncate text-xs text-muted-foreground/60`,children:t}),N(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[a,i!==void 0&&M(Qt,{attached:f,label:i.label,onToggle:()=>d(i)}),M(rn,{tone:r,children:n})]})]}),M(q.CollapsiblePanel,{children:M(`div`,{className:(0,V.cn)(`border-t border-border/60`,!o&&`px-3 pb-3 pt-2`),children:l})})]})}function an({card:e,text:t,index:n}){let r=R(e=>e.toggleTrayItem),i={key:`${e.id}:copy:${n}`,label:`${s(`Text`,`Текст`)} «${t.length>40?`${t.slice(0,40)}…`:t}»`,shortLabel:s(`text`,`текст`),cardId:e.id,cardName:e.name,payload:t,fenceLanguage:`text`},a=z(i.key);return N(`div`,{className:`flex min-w-0 items-center gap-1.5 rounded-md border border-border/60 bg-background px-2 py-1`,children:[M(`span`,{className:(0,V.cn)(`min-w-0 flex-1 truncate text-[13px]`,G.string),children:t}),M(W,{value:t,label:s(`Copy text`,`Скопировать текст`)}),M(Qt,{attached:a,label:i.label,onToggle:()=>r(i)})]})}function on({usage:e,item:t}){let n=R(e=>e.toggleTrayItem),r=z(t.key);return N(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[13px]`,children:[M(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),e.deprecated&&M(`span`,{className:`shrink-0 text-warning`,children:`⚠`}),N(`span`,{className:`shrink-0 tabular-nums text-muted-foreground/70`,children:[`×`,e.count]}),e.library!==null&&M(`span`,{className:`shrink-0 truncate text-xs text-muted-foreground/60`,children:e.library}),M(`span`,{className:`ml-auto`}),M(W,{value:e.name,label:s(`Copy name`,`Скопировать название`)}),M(Qt,{attached:r,label:t.label,onToggle:()=>n(t)})]})}function sn({label:e,value:t}){return N(`div`,{className:`rounded-md border border-border/60 bg-background px-2 py-1.5`,children:[M(`div`,{className:`text-sm font-semibold tabular-nums`,children:t}),M(`div`,{className:`text-xs text-muted-foreground/70`,children:e})]})}function cn({card:e}){let t=k(()=>zt(e),[e]),n=k(()=>Zt(e),[e]),r=k(()=>{let e=new Map;for(let n of t.nodesByType){let t=Ht(n.type);e.set(t,(e.get(t)??0)+n.count)}return[...e.entries()].map(([e,t])=>({kind:e,count:t})).toSorted((e,t)=>t.count-e.count)},[t.nodesByType]),i=e.componentsUsed??[],a=R(e=>e.toggleTrayItem),o=gt(),c={key:`${e.id}:pdlc`,label:`${s(`PDLC spec`,`PDLC-спека`)} «${e.name}»`,shortLabel:s(`PDLC spec`,`PDLC-спека`),cardId:e.id,cardName:e.name,payload:n,fenceLanguage:`markdown`},l={key:`${e.id}:analytics`,label:`${s(`Analytics inventory`,`Аналитика`)} ${e.id} (${t.rows.length} ${s(`rows`,`строк`)})`,shortLabel:s(`analytics`,`аналитика`),cardId:e.id,cardName:e.name,payload:JSON.stringify({itemId:e.id,name:e.name,aggregates:{nodesByType:t.nodesByType,depth:t.depth,copyWordCount:t.copyWordCount,componentCoverage:t.componentCoverage,libraries:t.libraries,deprecatedCount:t.deprecatedCount},inventory:t.rows,copy:t.copy},null,2),fenceLanguage:`json`},u=z(l.key);return N(`div`,{className:`flex flex-col gap-2 pt-2`,children:[N(`div`,{className:`flex items-center gap-1.5`,children:[M(`span`,{className:`text-xs text-muted-foreground/70`,children:s(`Everything below derives from the scan data`,`Всё ниже выведено из данных скана`)}),M(`span`,{className:`ml-auto`}),M(Qt,{attached:u,label:l.label,onToggle:()=>a(l)})]}),N(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[M(sn,{label:s(`layers`,`слоёв`),value:String(t.rows.length)}),M(sn,{label:s(`depth`,`глубина`),value:String(t.depth)}),M(sn,{label:s(`DS coverage`,`покрытие ДС`),value:`${t.componentCoverage}%`}),M(sn,{label:s(`words of copy`,`слов текста`),value:String(t.copyWordCount)}),M(sn,{label:s(`libraries`,`библиотек`),value:String(t.libraries.length)}),M(sn,{label:s(`deprecated`,`устаревших`),value:String(t.deprecatedCount)})]}),N(J,{title:s(`PDLC spec`,`PDLC-спека`),sublabel:s(`markdown for a Jira task`,`markdown для задачи в Jira`),count:`md`,attachItem:c,children:[N(`div`,{className:`flex items-center gap-1.5 pb-1.5 pt-1`,children:[M(`p`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground/70`,children:s(`A complete screen specification — paste into the task; the implementing agent pairs it with the UI spec from the Prompt tab.`,`Полная спецификация экрана — вставьте в задачу; агент-исполнитель работает по ней вместе со спекой UI из вкладки «Промпт».`)}),M(W,{value:n,label:s(`Copy markdown`,`Скопировать markdown`)})]}),M(`div`,{className:`overflow-hidden rounded-md border border-border/60 bg-background`,children:M(K.ScrollArea,{className:`max-h-80`,children:M(en,{code:n,language:`markdown`,theme:o})})})]}),M(J,{title:s(`Nodes by kind`,`Слои по видам`),count:r.length,children:M(`div`,{className:`flex flex-col gap-1 pt-1`,children:r.map(e=>N(`div`,{"data-testid":`pixso-analytics-kind`,className:`flex items-center gap-2 text-[13px]`,children:[M(`span`,{className:G.type,children:e.kind}),N(`span`,{className:`tabular-nums text-muted-foreground/70`,children:[`×`,e.count]}),M(`span`,{className:`ml-auto`}),M(W,{value:e.kind,label:s(`Copy kind`,`Скопировать вид`)})]},e.kind))})}),i.length>0&&M(J,{title:s(`Components`,`Компоненты`),sublabel:s(`unique in this selection`,`уникальные в выборке`),count:i.length,children:M(`div`,{className:`flex flex-col gap-1 pt-1`,children:i.map(t=>M(on,{usage:t,item:{key:`${e.id}:component:${t.key}`,label:`${s(`Component`,`Компонент`)} «${t.name}»`,shortLabel:t.name,cardId:e.id,cardName:e.name,payload:JSON.stringify(t,null,2),fenceLanguage:`json`}},t.key))})}),M(`div`,{className:`px-0.5 pt-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:s(`Inventory`,`Инвентарь`)}),M(`div`,{className:`overflow-hidden rounded-md border border-border/60 bg-background`,children:M(K.ScrollArea,{className:`max-h-72`,children:N(`table`,{className:`w-full min-w-max text-left text-xs`,children:[M(`thead`,{className:`sticky top-0 bg-muted/80 text-muted-foreground backdrop-blur-sm`,children:N(`tr`,{children:[M(`th`,{className:`px-2 py-1 font-medium`,children:s(`layer`,`слой`)}),M(`th`,{className:`px-2 py-1 font-medium`,children:s(`type`,`тип`)}),M(`th`,{className:`px-2 py-1 font-medium`,children:s(`text`,`текст`)}),M(`th`,{className:`px-2 py-1 font-medium`,children:s(`component`,`компонент`)}),M(`th`,{className:`px-2 py-1 font-medium`,children:s(`size`,`размер`)})]})}),M(`tbody`,{children:t.rows.map(e=>N(`tr`,{className:`border-t border-border/40`,children:[M(`td`,{className:`max-w-40 truncate px-2 py-1`,style:{paddingLeft:`${8+e.depth*8}px`},children:e.name}),M(`td`,{className:(0,V.cn)(`px-2 py-1`,G.type),children:Ht(e.type)}),M(`td`,{className:(0,V.cn)(`max-w-44 truncate px-2 py-1`,G.string),children:e.text??``}),M(`td`,{className:`max-w-36 truncate px-2 py-1`,children:e.componentName!==null&&N(`span`,{title:e.caption??void 0,children:[e.componentName,e.library!==null&&N(`span`,{className:`text-muted-foreground/60`,children:[` · `,e.library]})]})}),N(`td`,{className:(0,V.cn)(`px-2 py-1 tabular-nums`,G.geometry),children:[e.width,`×`,e.height]})]},e.id))})]})})}),M(J,{title:s(`Texts`,`Тексты`),count:t.copy.length,children:M(`div`,{className:`flex flex-col gap-1 pt-1`,children:t.copy.map((t,n)=>M(an,{card:e,text:t,index:n},`${n}-${t.slice(0,12)}`))})}),t.designerUrls.length>0&&N(j,{children:[M(`div`,{className:`px-0.5 pt-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:s(`Designer links on layers`,`Ссылки дизайнера на слоях`)}),t.designerUrls.map((e,t)=>{let n=Vt(e.url);return n===null?N(`span`,{title:e.url,className:`flex items-center gap-1.5 truncate px-0.5 text-[13px] text-muted-foreground/70`,children:[M(D,{className:`size-3 shrink-0`}),M(`span`,{className:`truncate`,children:e.url})]},`${t}-${e.url}`):N(`a`,{href:n,target:`_blank`,rel:`noreferrer`,title:e.url,className:`flex items-center gap-1.5 truncate px-0.5 text-[13px] text-primary hover:underline`,children:[M(D,{className:`size-3 shrink-0`}),M(`span`,{className:`truncate`,children:Bt(e.url)})]},`${t}-${e.url}`)})]})]})}const ln=1e5;function Y(e,t=!1){if(!Number.isFinite(e))return`0px`;let n=Math.min(ln,Math.max(t?-ln:0,e));return`${String(Number(n.toFixed(2)))}px`}const X=e=>Y(e,!0),un=e=>e.replaceAll(/["\\;\r\n]/g,``),dn=new Set([`underline`,`line-through`,`overline`]);function fn(e,t){return pn(Z(e),mn(e,t))}function pn(e,t){return`.${e} {\n${t.map(e=>` ${e}`).join(`
3
- `)}\n}`}function mn(e,t){let n=[],r=(e,t)=>n.push(`${e}: ${t};`),i=t!==null&&(t.text!==void 0||t.type===`paragraph`||t.type===`text`||t.type===`span`);if(e.sticky===!0)r(`position`,`fixed`);else if(t!==null&&t.layout===void 0&&!i){let n=f(e,t);r(`position`,`absolute`),r(`left`,X(Math.round(n.x))),r(`top`,X(Math.round(n.y)))}let a=e.text!==void 0||e.type===`text`||e.type===`paragraph`||e.type===`span`,o=e.layout?.sizing;if(a){let t=e.textMeta?.lineHeightPx??null;(e.textMeta?.autoResize===`height`||(e.text?.includes(`
4
- `)??!1)||t!==null&&e.height>t*1.5)&&(r(`width`,Y(Math.round(e.width))),r(`min-height`,Y(Math.round(e.height))))}else r(`width`,o?.w===`hug`?`fit-content`:o?.w===`fill`?`100%`:Y(Math.round(e.width))),r(`height`,o?.h===`hug`?`fit-content`:o?.h===`fill`?`100%`:Y(Math.round(e.height)));if(e.layout!==void 0&&e.layout.mode!==`unknown`){r(`display`,`flex`);let t=e.layout.mode!==`vertical`;if(r(`flex-direction`,t?`row`:`column`),e.layout.gap!==null){let n=Y(e.layout.gap),i=e.layout.counterGap;r(`gap`,i===void 0?n:t?`${Y(i)} ${n}`:`${n} ${Y(i)}`)}if(e.layout.padding!==null){let{top:t,right:n,bottom:i,left:a}=e.layout.padding;r(`padding`,`${Y(t)} ${Y(n)} ${Y(i)} ${Y(a)}`)}e.layout.primaryAlign!==void 0&&r(`justify-content`,e.layout.primaryAlign),e.layout.counterAlign!==void 0&&r(`align-items`,e.layout.counterAlign)}if(e.layout?.minWidth!==void 0&&r(`min-width`,Y(e.layout.minWidth)),e.layout?.maxWidth!==void 0&&r(`max-width`,Y(e.layout.maxWidth)),e.layout?.minHeight!==void 0&&r(`min-height`,Y(e.layout.minHeight)),e.layout?.maxHeight!==void 0&&r(`max-height`,Y(e.layout.maxHeight)),e.opacity!==void 0&&e.opacity<1&&r(`opacity`,String(e.opacity)),e.radii!==void 0){let{topLeft:t,topRight:n,bottomRight:i,bottomLeft:a}=e.radii;r(`border-radius`,`${Y(t)} ${Y(n)} ${Y(i)} ${Y(a)}`)}else e.radius!==void 0&&e.radius>0&&r(`border-radius`,Y(e.radius));if(e.rotation!==void 0&&e.rotation!==0&&r(`transform`,`rotate(${e.rotation}deg)`),e.gradient!==void 0){let t=e.gradient.stops.map(e=>`${d(e.color,e.alpha)} ${String(Math.round(e.position*1e3)/10)}%`).join(`, `);r(`background`,`linear-gradient(${e.gradient.angle}deg, ${t})`)}else e.fill!==void 0&&r(`background`,e.fill);if(e.borders!==void 0){let t=e.borders.color??e.stroke?.color??`currentColor`,n=e.stroke?.dashed===!0?`dashed`:`solid`,i=i=>{let a=e.borders?.[i];a!==void 0&&r(`border-${i}`,`${Y(a)} ${n} ${t}`)};i(`top`),i(`right`),i(`bottom`),i(`left`),r(`box-sizing`,`border-box`)}else e.stroke!==void 0&&(r(`border`,`${Y(e.stroke.weight)} ${e.stroke.dashed===!0?`dashed`:`solid`} ${e.stroke.color}`),e.stroke.align===`inside`&&r(`box-sizing`,`border-box`));if((e.mask===!0||e.type===`mask`)&&r(`overflow`,`hidden`),e.blendMode!==void 0&&r(`mix-blend-mode`,e.blendMode),e.font?.family!==void 0&&r(`font-family`,`"${un(e.font.family)}", system-ui, sans-serif`),e.font?.size!==void 0&&r(`font-size`,Y(e.font.size)),e.font?.style!==void 0){let t=y[e.font.style];t!==void 0&&e.font.style!==`Regular`&&r(`font-weight`,String(t))}e.textMeta?.lineHeightPx!=null&&r(`line-height`,Y(e.textMeta.lineHeightPx));let s=e.textMeta?.letterSpacing;if(s===void 0?e.textMeta?.letterSpacingPx!=null&&r(`letter-spacing`,X(e.textMeta.letterSpacingPx)):r(`letter-spacing`,s.unit===`%`?`${String(Number((s.value/100).toFixed(4)))}em`:X(s.value)),e.textMeta?.upperCase===!0&&r(`text-transform`,`uppercase`),e.textMeta?.decoration!==void 0){let t=e.textMeta.decoration.toLowerCase();dn.has(t)&&r(`text-decoration`,t)}if(e.textMeta?.textAlign!==void 0&&r(`text-align`,e.textMeta.textAlign),e.textColor!==void 0&&r(`color`,e.textColor),e.margin!==void 0)for(let[t,n]of Object.entries(e.margin))typeof n==`number`&&r(`margin-${t}`,X(n));let c=[],l=[],u=[];for(let t of e.effects??[])t.kind===`background-blur`?u.push(`blur(${Y(t.radius??0)})`):t.kind===`foreground-blur`?l.push(`blur(${Y(t.radius??0)})`):c.push(`${X(t.offsetX??0)} ${X(t.offsetY??0)} ${Y(t.radius??0)} ${X(t.spread??0)} ${t.color??`rgba(0, 0, 0, 0.25)`}`);return c.length>0&&r(`box-shadow`,c.join(`, `)),l.length>0&&r(`filter`,l.join(` `)),u.length>0&&r(`backdrop-filter`,u.join(` `)),n}const hn=new WeakMap;function gn(e,t,n){let r=hn.get(e);if(r!==void 0)return t?r.row:r.column;let i=t=>{let r=[],i=0;for(let a of e)r.push(i),i+=(t?a.width:a.height)+n;return r},a={row:i(!0),column:i(!1)};return hn.set(e,a),t?a.row:a.column}function _n(e,t,n,r){let i=e.layout;if(i===void 0||i.mode===`unknown`)return[];let a=i.mode===`horizontal`,o=i.padding??{top:0,right:0,bottom:0,left:0},s=i.gap??0,c=[];if((i.primaryAlign??`flex-start`)===`flex-start`){let i=(a?e.x+o.left:e.y+o.top)+gn(r,a,s)[n];(a?t.x:t.y)-i>2&&c.push(`margin-${a?`left`:`top`}: auto;`)}let l=a?e.y+o.top:e.x+o.left,u=a?e.height-o.top-o.bottom:e.width-o.left-o.right,d=a?t.y:t.x,f=a?t.height:t.width,p=i.counterAlign??`flex-start`,m=null;return f>=u-1?c:(Math.abs(d+f/2-(l+u/2))<=1&&f<u-1?m=`center`:Math.abs(d+f-(l+u))<=1&&Math.abs(d-l)>1?m=`flex-end`:Math.abs(d-l)<=1&&(m=`flex-start`),m!==null&&m!==p&&c.push(`align-self: ${m};`),c)}function Z(e){let t=e.name.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,24);return`${e.type}${t===``?``:`-${t}`}-${g(e.id)}`}const vn=/placeholder|hint|clear|подсказк/i,yn=/input|select|search|textarea|field|поле/i,bn=/button|btn|кнопк/i,xn=/^[\d\s.,%+/-]+$/,Sn=/^[A-Za-z]+$/;function Cn(e){let t=(e.children??[]).filter(e=>e.text!==void 0);if(t.length<1||t.length>3)return!1;let n=t.some(e=>e.font?.size!==void 0&&e.font.size<=12),r=t.some(e=>e.font?.size!==void 0&&e.font.size>=13);return n&&(r||t.length===1)}function wn(e){let t=new Map;if(e===void 0)return t;for(let n of e.entries){let e=n.containing_frame.containingStateGroup?.name;if(e===void 0)continue;let r=n.name.split(`/`).at(-1)?.trim();if(r===void 0||r===``||!Sn.test(r))continue;let i=t.get(e);i===void 0?t.set(e,[r]):!i.includes(r)&&i.length<8&&i.push(r)}return t}const Tn=(e,t)=>e?.variantGroup==null?[]:t.get(e.variantGroup)??[];function En(e,t,n){let r=[],i=0,a=0,o=t?.variantGroup??t?.name??e.name;yn.test(o)&&(i+=2,r.push(`имя компонента/набора «${o}»`)),bn.test(o)&&(a+=2,r.push(`имя компонента/набора «${o}»`)),t!==void 0&&t.props.some(e=>vn.test(e.name))&&(i+=2,r.push(`props ${t.props.filter(e=>vn.test(e.name)).map(e=>`«${e.name}»`).join(`, `)}`));let s=e.stroke!==void 0||e.fill!==void 0;e.stroke!==void 0&&(e.radius??0)>0&&e.height>=28&&e.height<=56&&Cn(e)&&(i+=2,r.push(`рамка ${e.stroke.weight}px r${e.radius}, высота ${Math.round(e.height)}, мелкий приглушённый + основной текст внутри`));let c=(e.children??[]).filter(e=>e.text!==void 0);if(s&&(e.radius??0)>0&&c.length===1&&e.layout?.primaryAlign===`center`&&e.height>=24&&e.height<=56&&(a+=2,r.push(`скруглённый ${e.fill===void 0?`обведённый`:`залитый`} контейнер с одним центрированным текстом`)),(e.type===`instance`||e.type===`vector`)&&(e.children??[]).length===0&&e.width<=32&&e.height<=32)return{role:`icon-button`,confidence:t===void 0?`low`:`medium`,evidence:[`иконка ${Math.round(e.width)}×${Math.round(e.height)} без содержимого${t===void 0?``:`, компонент «${t.name}»`}`],hint:`вероятно, иконка-кнопка: <button aria-label=…> с svg-иконкой; если не интерактивна — просто svg`,states:Tn(t,n)};if(i>0){let e=c.find(e=>(e.font?.size??0)>=13)?.text??``;xn.test(e)&&e.trim()!==``&&(i+=1,r.push(`значение похоже на вводимое («${e.trim()}»)`))}if(i===0&&a===0)return null;let l=i>=a?`input`:`button`,u=Math.max(i,a);return{role:l,confidence:u>=4?`high`:u>=2?`medium`:`low`,evidence:r,hint:l===`input`?`реализовать как <label> (мелкий текст) + <input> (значение) внутри рамки; фокус — по состояниям ДС`:`реализовать как <button>; текст — содержимое кнопки`,states:Tn(t,n)}}const Dn=/title|label|заголов/i;function On(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function kn(e){return e.text!==void 0||e.type===`text`||e.type===`paragraph`?`p`:e.type===`span`?`span`:`div`}function An(e){let t=[],n=e=>{e.text!==void 0&&e.text.trim()!==``&&t.push(e.text.trim());for(let t of e.children??[])n(t)};for(let t of e.children??[])n(t);return t}const jn=new Set([`nodeText`,`fillPaints`,`inheritFillStyleID`,`inheritTextStyleID`,`cornerRadius`,`width`,`height`,`fontSize`,`fontFamily`,`fontStyle`]);function Mn(e){let t=[];for(let n of e.overrides??[]){let e=n.changed.filter(e=>jn.has(e));if(e.length===0)continue;let r=n.name??n.targetId,i=n.text!==void 0&&n.text.trim()!==``?` «${n.text.trim()}»`:``;t.push(`${r}: ${e.join(`+`)}${i}`)}if(t.length===0)return``;let n=t.slice(0,8),r=t.length-n.length;return` overrides={${n.join(`; `)}${r>0?`; …ещё ${String(r)}`:``}}`}function Nn(e,t,n,r,i=0){if(t.hidden===!0)return;let a=` `.repeat(r),o=Z(t),s=t.componentRef===void 0?void 0:e.usagesByRef.get(t.componentRef);if(s!==void 0&&e.collapseInstances){let r=An(t),c=r.length>0?` content={${r.map(e=>`«${e}»`).join(`, `)}}`:``;e.skeleton.push(`${a}<Component name="${s.name}" class="${o}"${c}${Mn(t)}/>`);let l=[...mn(t,n),...n===null?[]:_n(n,t,i,n.children??[])];e.css.push(pn(o,l));return}let c=kn(t),l=t.text!==void 0&&t.text.trim()!==``?On(t.text.trim()):null,u=t.children??[];u.length===0?e.skeleton.push(l===null?`${a}<${c} class="${o}"></${c}>`:`${a}<${c} class="${o}">${l}</${c}>`):(e.skeleton.push(`${a}<${c} class="${o}">${l===null?``:l}`),u.forEach((n,i)=>Nn(e,n,t,r+1,i)),e.skeleton.push(`${a}</${c}>`));let d=[...mn(t,n),...n===null?[]:_n(n,t,i,n.children??[])];e.css.push(pn(o,d))}function Pn(e,t,n){let r=[],i=[t.variantGroup===null?null:`variant-set ${t.variantGroup}`,t.library??t.libraryFileKey,t.resolved?null:`библиотека не подключена`,t.description!==null&&t.description!==``?`«${t.description}»`:null,t.deprecated?`⚠ DEPRECATED — не использовать в новом коде`:null].filter(Boolean).join(` · `);if(r.push(`### «${t.name}» ×${t.count} — ${i}`),t.props.length>0){let e=t.count>1?`props (первого экземпляра из ${String(t.count)})`:`props`;r.push(`${e}: ${t.props.map(e=>`${e.name}(${e.kind}${e.overridden?``:`, по умолчанию ${e.defaultValue}`})`).join(`, `)}`)}if(n!==null&&(n.children??[]).length>0){r.push(`Внутреннее устройство (эталонный экземпляр — остальные отличаются только текстами/props):`);let t={...e,skeleton:[],css:[],collapseInstances:!1};Nn(t,n,null,0),r.push("```html",...t.skeleton,"```","```css",...t.css,"```")}else r.push(`Внутреннее устройство недоступно в этом скане — рендерить как контейнер ${Math.round(n?.width??0)}×${Math.round(n?.height??0)} с плейсхолдером.`);return r}function Fn(e,t){let n=e.componentsUsed??[],r=new Map(n.map(e=>[e.key,e])),i=new Map,a=e=>{e.componentRef!==void 0&&!i.has(e.componentRef)&&i.set(e.componentRef,e);for(let t of e.children??[])a(t)};a(e.root);let o=[`# UI SPEC — «${e.name}» (${Math.round(e.root.width)}×${Math.round(e.root.height)} px · Pixso DSL ${e.dslVersion})`,``,`Задача: сверстать экран ПИКСЕЛЬ-В-ПИКСЕЛЬ по спецификации ниже.`,`Формат: HTML-скелет задаёт вложенность и дословные тексты; каждый класс имеет`,`ПОЛНОЕ CSS-правило — ничего не нужно домысливать. <Component name=…/> — экземпляр`,`из раздела COMPONENTS (его внутренняя вёрстка приведена там один раз); content={…} —`,`тексты этого конкретного экземпляра в визуальном порядке.`,``,`## RULES (обязательно)`,`1. НИЧЕГО не добавлять сверх спеки: ни теней, ни курсоров, ни анимаций, ни своих`,` отступов — только правила ниже + семантика из SEMANTICS.`,"2. Начать с этого reset: `* { margin: 0; padding: 0; box-sizing: border-box; }`.",`3. Классы использовать РОВНО как в спеке (они валидны и уникальны).`,`4. Тени: добавлять только там, где в CSS есть комментарий о тени, подобрав blur визуально.`,`5. Интерактивные состояния реализовать по разделам SEMANTICS/CONTROLS (hover/focus/`,` disabled), визуально не отклоняясь от базового состояния спеки.`,`6. Экземпляр компонента — ТОЧНАЯ копия разметки из его раздела COMPONENTS (те же`,` классы); по content={…} меняются только тексты. overrides={…} перечисляет поля,`,` которые ЭТОТ экземпляр переопределил относительно мастера: значения уже учтены в`,` CSS, поэтому ничего не пересчитывать — это пометка «здесь отличие намеренное, не`,` выносить в общий стиль компонента».`,`7. Превращая текстовый узел в контрол (см. CONTROLS), повесь класс ЭТОГО узла на`,` контрол (например <input class="…-value">) — собственный CSS для контролов не писать.`,`8. Шрифты из FONTS могут отсутствовать в системе — метрики fallback шире; высоты`,` текстов в спеке намеренно не зафиксированы, перенос должен ДВИГАТЬ соседей, а не`,` перекрывать их.`],s=b(e.root);s.length>0&&o.push(``,`## FONTS (использованы в макете)`,...s.map(e=>`- ${[e.font.family,e.font.style,e.font.size===void 0?null:`${String(e.font.size)}px`].filter(e=>e!=null).join(` `)} (×${e.count}) — fallback: system-ui, sans-serif`));let c={card:e,usagesByRef:r,skeleton:[],css:[],collapseInstances:!0};if(Nn(c,e.root,null,0),t.includeComponentDefs&&n.length>0){o.push(``,`## COMPONENTS`);for(let e of n)o.push(``,...Pn(c,e,i.get(e.key)??null))}let l=wn(e.catalog),u=new Map,d=e=>{let t=e.componentRef===void 0?void 0:r.get(e.componentRef);u.set(e.id,En(e,t,l));for(let t of e.children??[])d(t)};d(e.root);{let t=[],n=new Set,i=e=>{let a=e.componentRef===void 0?void 0:r.get(e.componentRef),o=u.get(e.id)??null;if(o!==null&&o.role!==`static`){let r=`${a?.name??e.name}:${o.role}`;n.has(r)||(n.add(r),t.push(`- «${a?.name??e.name}» → ${o.role} (уверенность: ${o.confidence===`high`?`высокая`:o.confidence===`medium`?`средняя`:`низкая`}; признаки: ${o.evidence.join(`; `)}). ${o.hint}.${o.states.length>0?` Состояния в ДС: ${o.states.join(`, `)} — реализовать.`:``}`))}for(let t of e.children??[])i(t)};i(e.root),t.length>0&&o.push(``,`## SEMANTICS (дедукция по данным — при несоответствии верстать статически)`,...t)}{let t=[],n=e=>{let i=e.componentRef===void 0?void 0:r.get(e.componentRef),a=u.get(e.id)??null;if(a!==null&&a.role!==`static`){let n=[],r=e=>{e.text!==void 0&&e.text.trim()!==``&&n.push(e);for(let t of e.children??[])r(t)};for(let t of e.children??[])r(t);let o=a.confidence===`high`?`высокая`:a.confidence===`medium`?`средняя`:`низкая`,s=a.states.length>0?` Состояния ДС: ${a.states.join(`, `)} — реализовать.`:``;if(a.role===`input`){let r=[...n].sort((e,t)=>(e.font?.size??0)-(t.font?.size??0)),a=r.length>1?r[0]:void 0,c=r.at(-1),l=(i?.props??[]).find(e=>e.kind===`text`&&!Dn.test(e.name));t.push(`- .${Z(e)}${i===void 0?``:` («${i.name}»)`}: ПОЛЕ ВВОДА (дедукция, уверенность ${o} — в DSL признака редактируемости НЕТ).`+(a===void 0?``:` Label: «${a.text.trim()}».`)+(c===void 0?` Текста значения нет — пустой <input>.`:` Контрол: <input class="${Z(c)}"> (класс value-узла — унаследовать его CSS); value="${c.text.trim()}"; редактируемое (НЕ readonly).`)+(l===void 0?` placeholder: данных нет — оставить пустым.`:` placeholder="${l.defaultValue}" (default пропа «${l.name}» [данные]) — виден при очистке.`)+s)}else if(a.role===`button`){let r=n[0];t.push(`- .${Z(e)}${i===void 0?``:` («${i.name}»)`}: КНОПКА (дедукция, уверенность ${o}). <button class="${Z(e)}">${r===void 0?``:` Текст: <span class="${Z(r)}">«${r.text.trim()}»</span>.`}${s}`)}else t.push(`- .${Z(e)}${i===void 0?``:` («${i.name}»)`}: ИКОНКА-КНОПКА (дедукция, уверенность ${o}) — <button aria-label> с svg; если не интерактивна, просто svg.${s}`)}for(let t of e.children??[])n(t)};n(e.root),t.length>0&&o.push(``,`## CONTROLS (поведение; роль — дедукция из данных, редактируемость в DSL отсутствует)`,...t)}if(o.push(``,`## SCREEN — HTML`,"```html",...c.skeleton,"```"),o.push(``,`## SCREEN — CSS (полный, для каждого элемента)`,"```css",...c.css,"```"),t.includeCopy){let t=[],n=e=>{e.text!==void 0&&e.text.trim()!==``&&t.push(e.text.trim());for(let t of e.children??[])n(t)};n(e.root),t.length>0&&o.push(``,`## COPY (дословно, для сверки)`,...t.map(e=>`- ${e}`))}return o.join(`
5
- `)}function In(e){return Math.ceil(e.length/4)}function Ln({checked:e,onChange:t,label:n}){return N(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-[13px] text-muted-foreground hover:text-foreground`,children:[M(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`size-3 accent-[var(--primary)]`}),n]})}function Rn({title:e,count:t,actions:n,defaultOpen:r,children:i}){return N(q.Collapsible,{defaultOpen:r,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[N(`div`,{className:`flex w-full items-center gap-2 pr-2`,children:[N(q.CollapsibleTrigger,{className:`group flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-accent/40`,children:[M(E,{className:`size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-data-panel-open:rotate-90`}),M(`span`,{className:`text-xs font-semibold`,children:e}),M(rn,{children:t})]}),n!==void 0&&M(`span`,{className:`flex shrink-0 items-center gap-1`,children:n})]}),M(q.CollapsiblePanel,{children:M(`div`,{className:`border-t border-border/60 px-3 pb-3 pt-2`,children:i})})]})}function zn({card:e}){let t=Ct(),n=R(e=>e.removeTrayItem),r=R(e=>e.composerTarget),i=gt(),a=t.reduce((e,t)=>e+In(t.payload),0);return N(Rn,{title:s(`In the composed request`,`В составе запроса`),count:t.length===0?0:`${t.length} · ~${a} ${s(`tok`,`ток`)}`,defaultOpen:t.length>0,children:[r===null&&M(`p`,{className:`mt-1 text-xs text-warning`,children:s(`No open chat — open a thread so attachments land in the composer.`,`Нет открытого чата — откройте тред, чтобы вложения попали в поле ввода.`)}),t.length===0?M(`p`,{className:`py-1 text-[13px] text-muted-foreground/70`,children:s(`Nothing attached yet — press + next to any data block, component, QA case or the spec below.`,`Пока ничего не прикреплено — нажмите + рядом с любым блоком данных, компонентом, QA-кейсом или спекой ниже.`)}):M(`div`,{className:`flex flex-col gap-1`,children:t.map(t=>N(q.Collapsible,{className:`rounded-md border border-border/60 bg-background`,children:[N(`div`,{className:`flex items-center gap-1`,children:[N(q.CollapsibleTrigger,{className:`group flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1.5 text-left transition-colors hover:bg-accent/40`,children:[M(E,{className:`size-3 shrink-0 text-muted-foreground/50 transition-transform duration-150 group-data-panel-open:rotate-90`}),M(`span`,{className:`min-w-0 truncate text-[13px]`,children:t.label}),t.cardId!==e.id&&M(`span`,{className:`shrink-0 truncate text-xs text-muted-foreground/50`,children:t.cardName}),N(`span`,{className:`ml-auto shrink-0 pl-1.5 text-xs tabular-nums text-muted-foreground/50`,children:[`~`,In(t.payload)]})]}),M(`span`,{className:`shrink-0 pr-1.5`,children:M(H,{size:`icon-xs`,variant:`ghost`,"aria-label":`${s(`Remove from the request`,`Убрать из запроса`)}: ${t.label}`,onClick:()=>n(t.key),className:`text-muted-foreground/60 hover:text-destructive`,children:M(Re,{className:`size-3`})})})]}),M(q.CollapsiblePanel,{children:M(`div`,{className:`max-h-48 overflow-hidden border-t border-border/50`,children:M(K.ScrollArea,{className:`max-h-48`,children:M(en,{code:t.payload.length>6e3?`${t.payload.slice(0,6e3)}\n…`:t.payload,language:t.fenceLanguage,theme:i})})})})]},t.key))})]})}function Bn({card:e}){let t=gt(),n=R(e=>e.toggleTrayItem),i=R(e=>e.upsertTrayItem),[a,o]=A({includeComponentDefs:!0,includeCopy:!0}),c=k(()=>Fn(e,a),[e,a]),l=In(c),u=k(()=>({key:`${e.id}:prompt`,label:`${s(`UI spec (pixel-perfect)`,`Спека UI (pixel-perfect)`)} «${e.name}» · ~${l} ${s(`tokens`,`токенов`)}`,shortLabel:s(`UI spec`,`спека UI`),cardId:e.id,cardName:e.name,payload:c,fenceLanguage:`markdown`}),[e.id,e.name,c,l]),d=z(u.key);return O(()=>{d&&i(u)},[d,u,i]),N(Rn,{title:s(`UI spec (pixel-perfect)`,`Спека UI (pixel-perfect)`),count:`~${l} ${s(`tok`,`ток`)}`,defaultOpen:!0,actions:N(j,{children:[M(W,{value:c,label:s(`Copy the spec`,`Скопировать спеку`)}),M(Qt,{attached:d,label:u.label,onToggle:()=>n(u)})]}),children:[M(`p`,{className:`pb-1.5 text-[13px] leading-snug text-muted-foreground/80`,children:s(`Byte-for-byte what the model receives: an HTML skeleton plus a COMPLETE CSS rule for every element — nothing left to interpretation.`,`Ровно то, что получит модель: HTML-скелет плюс ПОЛНОЕ CSS-правило для каждого элемента — ничего не остаётся на догадки.`)}),N(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pb-2`,children:[M(Ln,{checked:a.includeComponentDefs,onChange:e=>o(t=>({...t,includeComponentDefs:e})),label:s(`components internals`,`внутренности компонентов`)}),M(Ln,{checked:a.includeCopy,onChange:e=>o(t=>({...t,includeCopy:e})),label:s(`verbatim copy`,`тексты дословно`)}),N(`span`,{className:(0,V.cn)(`ml-auto text-xs tabular-nums text-muted-foreground/60`),children:[c.length.toLocaleString(r()),` `,s(`chars`,`символов`)]})]}),M(`div`,{className:`max-h-96 overflow-hidden rounded-md border border-border/60 bg-background`,children:M(K.ScrollArea,{className:`max-h-96`,children:M(en,{code:c,language:`markdown`,theme:t})})})]})}function Vn({card:e}){return N(`div`,{className:`flex flex-col gap-2 pt-2`,children:[M(zn,{card:e}),M(Bn,{card:e})]})}const Hn=[`violations`,`components`,`typography`,`layout`,`behavior`];function Un({flavor:e,onChange:t}){let n=(n,r)=>M(`button`,{type:`button`,onClick:()=>t(n),className:(0,V.cn)(`cursor-pointer rounded-md px-2 py-1 text-[13px] transition-colors`,e===n?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),children:r});return N(`div`,{className:`flex w-fit shrink-0 items-center gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5`,children:[n(`manual`,s(`Manual testing`,`Ручная приёмка`)),n(`auto`,s(`Autotests`,`Автотесты`))]})}function Wn(e,t){return t===`manual`?`- [ ] ${e.manual}`:JSON.stringify({target:e.auto.target,assertions:e.auto.assertions},null,2)}const Gn=e=>e===`manual`?`markdown`:`json`;function Kn({card:e,qaCase:t,flavor:n,onShowNode:r}){let i=R(e=>e.toggleTrayItem),a={key:`${t.id}:${n}`,label:`${s(`QA case`,`QA-кейс`)}: ${t.manual.slice(0,60)}`,shortLabel:`QA: ${t.manual.slice(0,28)}…`,cardId:e.id,cardName:e.name,payload:Wn(t,n),fenceLanguage:Gn(n)},o=z(a.key);return N(q.Collapsible,{"data-testid":`pixso-qa-case`,className:`rounded-md border border-border/60 bg-background`,children:[N(`div`,{className:`flex items-center gap-1`,children:[N(q.CollapsibleTrigger,{className:`group flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1.5 text-left transition-colors hover:bg-accent/40`,children:[M(E,{className:`size-3 shrink-0 text-muted-foreground/50 transition-transform duration-150 group-data-panel-open:rotate-90`}),n===`manual`?M(`span`,{className:`min-w-0 truncate text-[13px] leading-snug`,children:t.manual}):M(`span`,{className:(0,V.cn)(`min-w-0 truncate text-[13px]`,G.name),children:t.auto.target})]}),N(`span`,{className:`flex shrink-0 items-center gap-0.5 pr-1.5`,children:[t.nodeId!==null&&M(`button`,{type:`button`,title:s(`Show the layer in Structure`,`Показать слой в «Структуре»`),onClick:()=>r(t.nodeId),className:`flex size-5 cursor-pointer items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,children:M(le,{className:`size-3`})}),M(Qt,{attached:o,label:a.label,onToggle:()=>i(a)})]})]}),M(q.CollapsiblePanel,{children:N(`div`,{className:`flex flex-col gap-1.5 border-t border-border/50 px-2 py-1.5`,children:[M(`div`,{className:`text-[13px] leading-snug`,children:t.manual}),M(`div`,{className:(0,V.cn)(`text-xs`,G.name),children:t.auto.target}),M(`div`,{className:`flex flex-col gap-px`,children:t.auto.assertions.map(e=>M(`code`,{className:(0,V.cn)(`text-xs leading-4`,G.value),children:e},e))})]})})]})}function qn({card:e,onShowNode:t}){let[n,r]=A(`manual`),i=k(()=>Xt(e),[e]),a=n===`manual`?i.map(e=>`- [ ] ${e.manual}`).join(`
6
- `):JSON.stringify(i.map(e=>({target:e.auto.target,assertions:e.auto.assertions})),null,2);return N(`div`,{className:`flex flex-col gap-2 pt-2`,children:[N(`div`,{className:`flex items-center gap-2`,children:[M(Un,{flavor:n,onChange:r}),N(`span`,{"data-testid":`pixso-qa-case-count`,className:`ml-auto text-xs tabular-nums text-muted-foreground/60`,children:[i.length,` `,s(`cases`,`кейсов`)]}),M(W,{value:a,label:s(`Copy all cases`,`Скопировать все кейсы`)})]}),Hn.map(r=>{let a=i.filter(e=>e.group===r);if(a.length===0)return null;let o={key:`${e.id}:qa-group:${r}:${n}`,label:`${s(`QA`,`QA`)} · ${Gt(r)} (${a.length})`,shortLabel:`QA ${Gt(r).toLowerCase()}`,cardId:e.id,cardName:e.name,payload:a.map(e=>Wn(e,n)).join(`
7
- `),fenceLanguage:Gn(n)};return M(J,{title:Gt(r),count:a.length,countTone:`default`,sublabel:r===`violations`?s(`needs a decision`,`требуют решения`):void 0,attachItem:o,defaultOpen:r===`violations`,children:M(`div`,{className:`flex flex-col gap-1 pt-1`,children:a.map(r=>M(Kn,{card:e,qaCase:r,flavor:n,onShowNode:t},r.id))})},`${r}-${n}`)})]})}function Jn(e){return new Date(e).toLocaleTimeString(r(),{hour:`2-digit`,minute:`2-digit`})}function Yn(e){let t=new Date(e),n=new Date,i=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),a=Jn(e);return i?a:`${t.toLocaleDateString(r(),{day:`2-digit`,month:`2-digit`})} ${a}`}var Q=t({});import*as Xn from"@smart-tools/qwen-cli-ui-kit";e(Q,Xn);const Zn=e=>e.trim()===``?{kind:`error`}:{kind:`loaded`,svg:e};function Qn(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}function $n({state:e,alt:t,className:n,natural:r=!1,fit:i=`contain`,focus:a=`center`}){let o=i===`cover`?(0,V.cn)(`size-full object-cover`,a===`top`&&`object-top`):`max-h-full max-w-full object-contain`;return N(`div`,{className:(0,V.cn)(`relative flex items-center justify-center overflow-hidden bg-muted/40`,n),children:[e.kind===`loading`&&M(Q.Skeleton,{className:`absolute inset-0 rounded-none`}),e.kind===`error`&&N(`div`,{className:`flex flex-col items-center gap-1 text-muted-foreground/60`,children:[M(_e,{className:`size-4`}),M(`span`,{className:`text-xs`,children:s(`image unavailable`,`изображение недоступно`)})]}),e.kind===`loaded`&&M(`img`,{src:Qn(e.svg),alt:t,className:r?`max-h-[calc(100vh-120px)] max-w-[calc(100vw-80px)]`:o,draggable:!1})]})}function er(){let e=R(e=>e.selectedCardId),t=R(e=>e.selectedCardId===null?null:e.cards.find(t=>t.id===e.selectedCardId)??null),n=R(e=>e.selectedCardId===null?null:e.details[e.selectedCardId]??null),r=R(e=>e.selectedCardId===null?!1:e.detailErrors.has(e.selectedCardId)),i=R(e=>e.selectedCardId===null?void 0:e.raws[e.selectedCardId]),a=n?.catalogHash??null,o=R(e=>a===null?void 0:e.catalogs[a]);return{card:k(()=>t===null||n===null?null:{id:t.id,nodeId:t.nodeId,name:n.name,type:n.nodeType,dslVersion:n.dslVersion??``,...n.versionUnverified===!0?{versionUnverified:!0}:{},importedAt:Yn(n.importedAtIso),pagePath:n.pagePath,root:n.root,preview:Zn(t.previewSvg),...i===void 0?{}:{rawDsl:i},...n.catalogHash===null?{}:{catalogHash:n.catalogHash},...n.component===null?{}:{component:n.component},componentsUsed:n.componentsUsed,...o===void 0?{}:{catalog:o}},[t,n,i,o]),loading:e!==null&&t!==null&&n===null&&!r,failed:e!==null&&t!==null&&n===null&&r}}const tr=[{value:`overview`,icon:de,label:()=>s(`Overview`,`Обзор`)},{value:`structure`,icon:be,label:()=>s(`Structure`,`Структура`)},{value:`styles`,icon:we,label:()=>s(`Styles`,`Стили`)},{value:`components`,icon:ne,label:()=>s(`Components`,`Компоненты`)},{value:`qa`,icon:fe,label:()=>`QA`},{value:`analytics`,icon:re,label:()=>s(`Analytics`,`Аналитика`)},{value:`prompt`,icon:Se,label:()=>s(`Prompt`,`Промпт`)}];P.createHandle;const nr=P.Root,rr=P.Portal;function ir(e){return M(P.Trigger,{"data-slot":`dialog-trigger`,...e})}function ar({className:e,...t}){return M(P.Backdrop,{forceRender:!0,className:(0,V.cn)(`fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`dialog-backdrop`,...t})}function or({className:e,...t}){return M(P.Viewport,{className:(0,V.cn)(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,e),"data-slot":`dialog-viewport`,...t})}function sr({className:e,children:t,showCloseButton:n=!0,bottomStickOnMobile:r=!0,...i}){return N(rr,{children:[M(ar,{}),M(or,{className:(0,V.cn)(r&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`),children:N(P.Popup,{className:(0,V.cn)(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover not-dark:bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg/5 transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,r&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none`,e),"data-slot":`dialog-popup`,...i,children:[t,n&&M(P.Close,{"aria-label":s(`Close`,`Закрыть`),className:`absolute end-2 top-2`,render:M(H,{size:`icon`,variant:`ghost`}),children:M(Re,{})})]})})]})}function cr({className:e,...t}){return M(`div`,{className:(0,V.cn)(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`dialog-header`,...t})}function lr({className:e,variant:t=`default`,...n}){return M(`div`,{className:(0,V.cn)(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t===`default`&&`border-t bg-muted/72 py-4`,t===`bare`&&`in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6`,e),"data-slot":`dialog-footer`,...n})}function ur({className:e,...t}){return M(P.Title,{className:(0,V.cn)(`font-heading font-semibold text-xl leading-none`,e),"data-slot":`dialog-title`,...t})}function dr({className:e,...t}){return M(P.Description,{className:(0,V.cn)(`text-muted-foreground text-sm`,e),"data-slot":`dialog-description`,...t})}F.createHandle;const fr=F.Root;F.Portal;function pr({className:e,children:t,...n}){return M(F.Trigger,{className:e,"data-slot":`menu-trigger`,...n,children:t})}function mr({children:e,className:t,sideOffset:n=4,align:r=`center`,alignOffset:i,side:a=`bottom`,anchor:o,...s}){return M(F.Portal,{children:M(F.Positioner,{align:r,alignOffset:i,anchor:o,className:`z-50`,"data-slot":`menu-positioner`,side:a,sideOffset:n,children:M(F.Popup,{className:(0,V.cn)(`relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] focus:outline-none dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,t),"data-slot":`menu-popup`,...s,children:M(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1`,children:e})})})})}function $({className:e,inset:t,variant:n=`default`,...r}){return M(F.Item,{className:(0,V.cn)(`[&>svg]:-mx-0.5 flex min-h-8 cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-inset:ps-8 data-[variant=destructive]:text-destructive-foreground data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&>svg:not([class*='opacity-'])]:opacity-80 [&>svg:not([class*='size-'])]:size-4.5 sm:[&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:[&>svg:not([class*='text-'])]:text-current [&>svg]:pointer-events-none [&>svg]:shrink-0`,e),"data-inset":t,"data-slot":`menu-item`,"data-variant":n,...r})}function hr({className:e,...t}){return M(F.Separator,{className:(0,V.cn)(`mx-2 my-1 h-px bg-border`,e),"data-slot":`menu-separator`,...t})}function gr(e){return M(F.SubmenuRoot,{"data-slot":`menu-sub`,...e})}function _r({className:e,inset:t,children:n,...r}){return N(F.SubmenuTrigger,{className:(0,V.cn)(`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-popup-open:bg-accent data-inset:ps-8 data-highlighted:text-accent-foreground data-popup-open:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none`,e),"data-inset":t,"data-slot":`menu-sub-trigger`,...r,children:[n,M(E,{className:`-me-0.5 ms-auto opacity-80`})]})}function vr({className:e,sideOffset:t=0,alignOffset:n,align:r=`start`,...i}){return M(mr,{align:r,alignOffset:n??(r===`center`?void 0:-5),className:e,"data-slot":`menu-sub-content`,side:`inline-end`,sideOffset:t,...i})}var yr=t({});import*as br from"@smart-tools/qwen-cli-ui-kit";e(yr,br);function xr({open:e,onOpenChange:t,assignCardId:n}){let r=R(e=>e.createGroup),i=R(e=>e.moveCardToGroup),[a,o]=A(``),c=()=>{let e=a.trim();if(e===``)return;let s=r(e);n!==void 0&&i(n,s),o(``),t(!1)};return M(nr,{open:e,onOpenChange:t,children:N(sr,{className:`max-w-sm`,showCloseButton:!1,children:[N(cr,{children:[M(ur,{children:s(`New group`,`Новая группа`)}),M(dr,{children:s(`Groups keep the gallery tidy — drag cards in or assign them from a card's detail view.`,`Группы наводят порядок в галерее — перетаскивайте карточки или назначайте их из детального вида.`)})]}),M(`div`,{className:`px-6 pb-2`,children:M(yr.Input,{autoFocus:!0,value:a,onValueChange:o,placeholder:s(`Group name`,`Название группы`),onKeyDown:e=>{e.key===`Enter`&&c()},"aria-label":s(`Group name`,`Название группы`),"data-testid":`pixso-new-group-name`})}),N(lr,{children:[M(H,{variant:`ghost`,onClick:()=>t(!1),children:s(`Cancel`,`Отмена`)}),M(H,{onClick:c,disabled:a.trim()===``,"data-testid":`pixso-new-group-create`,children:s(`Create`,`Создать`)})]})]})})}function Sr({group:e,cardCount:t,open:n,onOpenChange:r}){let i=R(e=>e.deleteGroup),a=t=>{i(e.id,{deleteCards:t}),r(!1)};return M(nr,{open:n,onOpenChange:r,children:N(sr,{className:`max-w-md`,showCloseButton:!1,children:[N(cr,{children:[N(ur,{children:[s(`Delete group`,`Удалить группу`),` «`,e.name,`»?`]}),M(dr,{children:t===0?s(`The group is empty.`,`Группа пуста.`):`${s(`It holds`,`В ней`)} ${t} ${s(`cards. What should happen to them?`,`карточек. Что с ними сделать?`)}`})]}),N(lr,{className:`flex-wrap`,children:[M(H,{variant:`ghost`,onClick:()=>r(!1),children:s(`Cancel`,`Отмена`)}),t>0?N(j,{children:[M(H,{variant:`outline`,onClick:()=>a(!1),children:s(`Move to Unsorted`,`Переместить в «Неразобранное»`)}),M(H,{variant:`destructive`,onClick:()=>a(!0),children:s(`Delete with cards`,`Удалить вместе с карточками`)})]}):M(H,{variant:`destructive`,onClick:()=>a(!1),children:s(`Delete`,`Удалить`)})]})]})})}function Cr({card:e}){let t=R(e=>e.groups),n=R(e=>e.groupByCardId),r=R(e=>e.moveCardToGroup),[i,a]=A(!1),o=n[e.id]??null,c=t.find(e=>e.id===o)??null;return N(`div`,{className:`flex items-center gap-2 px-0.5 pt-2`,children:[M(pe,{className:`size-3.5 shrink-0 text-muted-foreground/70`}),N(`span`,{className:`text-xs text-muted-foreground/60`,children:[s(`Group`,`Группа`),`:`]}),N(fr,{children:[N(pr,{render:M(H,{variant:`outline`,size:`xs`}),children:[c?.name??s(`Unsorted`,`Неразобранное`),M(T,{})]}),N(mr,{align:`start`,children:[t.map(t=>N($,{onClick:()=>r(e.id,t.id),children:[t.id===o?M(ie,{}):M(pe,{}),t.name]},t.id)),t.length>0&&N($,{onClick:()=>r(e.id,null),children:[M(o===null?ie:ye,{}),s(`Unsorted`,`Неразобранное`)]}),t.length>0&&M(hr,{}),N($,{onClick:()=>a(!0),children:[M(he,{}),s(`New group…`,`Новая группа…`)]})]})]}),M(xr,{open:i,onOpenChange:a,assignCardId:e.id})]})}function wr({card:e,onOpenPrompt:t}){let n=R(e=>e.toggleTrayItem),r=k(()=>Fn(e,{includeComponentDefs:!0,includeCopy:!0}),[e]),i={key:`${e.id}:node`,label:`${s(`UI spec`,`Спека UI`)} «${e.name}»`,shortLabel:s(`UI spec`,`спека UI`),cardId:e.id,cardName:e.name,payload:r,fenceLanguage:`markdown`};return N(`div`,{className:`flex items-center gap-2 px-0.5 pt-2`,children:[M(Qt,{attached:z(i.key),label:i.label,onToggle:()=>n(i)}),N(`span`,{className:`text-[13px] text-muted-foreground/60`,children:[s(`attach the converted spec to your prompt`,`прикрепить конвертированную спеку к запросу`),` · `,M(`button`,{type:`button`,onClick:t,className:`cursor-pointer text-primary hover:underline`,children:s(`preview the spec`,`посмотреть спеку`)})]})]})}function Tr({card:e,stickyCount:t,maskCount:n,hiddenCount:r,deprecatedUsed:i,componentsUsed:a,designerLinks:o,onOpenPrompt:c}){return N(j,{children:[N(`div`,{className:`pt-2.5`,children:[N(nr,{children:[M(ir,{render:M(`button`,{type:`button`,title:s(`Open full size`,`Открыть в полном размере`),className:`block w-full cursor-zoom-in`}),children:M($n,{state:e.preview,alt:e.name,className:`h-64 w-full rounded-lg border border-border transition-colors hover:border-primary/40`})}),M(sr,{className:`w-fit max-w-none`,children:N(`div`,{className:`flex flex-col gap-2 p-4`,children:[N(`div`,{className:`flex items-baseline gap-2 pr-8`,children:[M(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),N(`span`,{className:(0,V.cn)(`shrink-0 tabular-nums text-[13px]`,G.geometry),children:[Math.round(e.root.width),` × `,Math.round(e.root.height)]})]}),M($n,{state:e.preview,alt:e.name,natural:!0,className:`w-fit rounded-lg border border-border bg-transparent`})]})})]}),M(`p`,{className:`px-0.5 pt-1 text-xs text-muted-foreground/50`,children:s(`Preview is computed from the DSL (algorithmic render, not a screenshot) — click to enlarge.`,`Превью построено из DSL (алгоритмический рендер, не скриншот) — клик открывает в полном размере.`)})]}),M(Cr,{card:e}),M(wr,{card:e,onOpenPrompt:c}),(t>0||n>0||r>0||i>0)&&N(`div`,{className:`flex flex-wrap items-center gap-1.5 px-0.5 pt-2.5`,children:[t>0&&N(`span`,{className:`rounded-md border border-info/40 bg-info/10 px-1.5 py-px text-xs text-info`,children:[s(`fixed on scroll`,`закреплены при скролле`),` ×`,t]}),n>0&&N(`span`,{className:`rounded-md border border-border bg-muted px-1.5 py-px text-xs text-muted-foreground`,children:[s(`masks`,`маски`),` ×`,n]}),r>0&&N(`span`,{className:`rounded-md border border-border bg-muted px-1.5 py-px text-xs text-muted-foreground`,children:[s(`hidden layers`,`скрытые слои`),` ×`,r]}),i>0&&N(`span`,{className:`rounded-md border border-warning/40 bg-warning/10 px-1.5 py-px text-xs text-warning`,children:[s(`deprecated components`,`устаревшие компоненты`),` ×`,i]})]}),a.length>0&&N(`p`,{className:`px-0.5 pt-2 text-[13px] text-muted-foreground/70`,children:[s(`Built from`,`Собран из`),` `,a.reduce((e,t)=>e+t.count,0),` `,s(`component instances`,`экземпляров компонентов`),` ·`,` `,new Set(a.map(e=>e.library).filter(Boolean)).size,` `,s(`libraries`,`библиотек`)]}),o.length>0&&M(`div`,{className:`pt-2.5`,children:M(J,{title:s(`Designer links`,`Ссылки дизайнера`),sublabel:s(`from the layers' url field`,`из поля url на слоях`),count:o.length,defaultOpen:!0,children:M(`div`,{className:`flex flex-col gap-1 pt-1`,children:o.map((e,t)=>{let n=Vt(e.url);return n===null?N(`span`,{title:e.url,className:`flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5 text-[13px] text-muted-foreground/70`,children:[M(D,{className:`size-3.5 shrink-0`}),M(`span`,{className:`min-w-0 truncate`,children:e.url})]},`${t}-${e.url}`):N(`a`,{href:n,target:`_blank`,rel:`noreferrer`,title:e.url,className:`flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5 text-[13px] text-primary transition-colors hover:bg-accent/40 hover:underline`,children:[M(D,{className:`size-3.5 shrink-0`}),M(`span`,{className:`min-w-0 truncate`,children:Bt(e.url)})]},`${t}-${e.url}`)})})})})]})}const Er={frame:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},group:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},instance:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},symbol:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},rect:{fill:`fill-muted-foreground/10`,stroke:`stroke-muted-foreground/70`},ellipse:{fill:`fill-success/10`,stroke:`stroke-success/70`},text:{fill:`fill-info/12`,stroke:`stroke-info/70`},vector:{fill:`fill-warning/12`,stroke:`stroke-warning/70`},paragraph:{fill:`fill-info/12`,stroke:`stroke-info/70`},span:{fill:`fill-info/8`,stroke:`stroke-info/50`},line:{fill:`fill-warning/12`,stroke:`stroke-warning/70`},mask:{fill:`fill-muted-foreground/8`,stroke:`stroke-muted-foreground/50`}};function Dr({node:e,className:t,interactive:n,onClick:r}){let i={className:(0,V.cn)(t,n&&`cursor-pointer`),vectorEffect:`non-scaling-stroke`,...n?{onClick:e=>{e.stopPropagation(),r?.()}}:{pointerEvents:`none`}};return e.type===`ellipse`?M(`ellipse`,{cx:e.x+e.width/2,cy:e.y+e.height/2,rx:e.width/2,ry:e.height/2,...i,children:M(`title`,{children:e.name})}):M(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:e.radius??0,...i,children:M(`title`,{children:e.name})})}function Or({root:e,focusId:t,onFocusChange:n,selectedId:r,onSelect:i}){let[a,o]=A(null),l=c(e,t)??e,d=x(e,l.id),p=d.length>=2?d[d.length-2]??null:null,g=l.children??[],_=Math.max(4,Math.max(l.width,l.height)*.04),v=`${l.x-_} ${l.y-_} ${l.width+_*2} ${l.height+_*2}`,y=(a===null?null:c(l,a))??(r===null?null:c(e,r)),b=y===null?null:m(e,y.id),S=y===null?null:f(y,b),C=y===null?null:h(y),w=y===null?null:u(y),ee=e=>{let t=(e.children??[]).length>0;if(r===e.id&&t){n(e.id);return}i(e.id)};return N(`div`,{children:[N(`div`,{className:`flex flex-wrap items-center gap-1 pb-1.5 text-xs`,children:[p!==null&&M(`button`,{type:`button`,title:s(`Up one level`,`На уровень вверх`),onClick:()=>n(p.id),className:`flex size-4 cursor-pointer items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,children:M(ce,{className:`size-3`})}),d.map((e,t)=>N(`span`,{className:`flex items-center gap-1`,children:[t>0&&M(`span`,{className:`text-muted-foreground/40`,children:`▸`}),t===d.length-1?M(`span`,{className:`font-medium text-foreground`,children:e.name}):M(`button`,{type:`button`,onClick:()=>n(e.id),className:`cursor-pointer text-muted-foreground/70 transition-colors hover:text-foreground`,children:e.name})]},e.id))]}),N(`svg`,{viewBox:v,className:`max-h-64 w-full rounded-md border border-border/60 bg-background`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":l.name,onMouseLeave:()=>o(null),children:[M(Dr,{node:l,interactive:!1,className:`fill-transparent stroke-foreground/25 [stroke-dasharray:4_3]`}),g.flatMap(e=>(e.children??[]).map(e=>M(Dr,{node:e,interactive:!1,className:`fill-transparent stroke-border [stroke-dasharray:2_2]`},e.id))),g.map(e=>{let t=Er[e.type],n=r===e.id,i=a===e.id;return M(`g`,{onMouseEnter:()=>o(e.id),onMouseLeave:()=>o(t=>t===e.id?null:t),children:M(Dr,{node:e,interactive:!0,onClick:()=>ee(e),className:(0,V.cn)(t.fill,n?`stroke-primary [stroke-width:2]`:t.stroke,i&&!n&&`[stroke-width:1.75]`)})},e.id)}),g.length===0&&M(`text`,{x:l.x+l.width/2,y:l.y+l.height/2,textAnchor:`middle`,className:`fill-muted-foreground/50`,style:{fontSize:Math.max(l.width,l.height)*.06},children:s(`leaf node — no children`,`конечный слой — без вложенности`)})]}),M(`div`,{className:`h-11 overflow-hidden pt-1.5 text-[13px] leading-[1.4]`,children:y===null||S===null?M(`span`,{className:`text-muted-foreground/60`,children:s(`Click a layer to measure it; click a selected container again to enter it.`,`Кликните слой — размеры и отступы; повторный клик по выбранному контейнеру — вход внутрь.`)}):N(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:[M(`span`,{className:G.name,children:y.name}),M(`span`,{className:(0,V.cn)(`text-xs`,G.type),children:Ht(y.type)}),N(`span`,{className:(0,V.cn)(`tabular-nums`,G.value),children:[Math.round(y.width),`×`,Math.round(y.height)]}),N(`span`,{className:(0,V.cn)(`tabular-nums`,G.geometry),children:[`@`,Math.round(S.x),`,`,Math.round(S.y),` `,s(`from parent`,`от родителя`)]}),C!==null&&N(`span`,{className:(0,V.cn)(`tabular-nums`,G.geometry),children:[s(`padding`,`отступы`),`: `,C.top,` `,C.right,` `,C.bottom,` `,C.left]}),w!==null&&w.gaps.length>0&&N(`span`,{className:(0,V.cn)(`tabular-nums`,G.geometry),children:[s(`gaps`,`интервалы`),` (`,w.axis,`): `,w.gaps.join(` `)]}),y.layout!==void 0&&N(`span`,{className:(0,V.cn)(`text-xs`,G.type),children:[s(`declared auto-layout`,`автолейаут`),`: `,y.layout.summary]})]})})]})}function kr({color:e,size:t=`md`,className:n}){return M(`span`,{className:(0,V.cn)(`inline-block shrink-0 rounded-[4px] ring-1 ring-inset ring-foreground/15`,t===`sm`?`size-2.5`:`size-4`,n),style:{backgroundColor:e},"aria-hidden":!0})}function Ar({colors:e,className:t}){return M(`div`,{className:(0,V.cn)(`flex items-center gap-1`,t),children:e.map(e=>M(kr,{color:e,size:`sm`,className:`rounded-[3px]`},e))})}function jr({root:e,selectedId:t,onSelect:n,revealTick:r=0}){let i=l(e),o=Ue(null);return O(()=>{r===0||t===null||o.current?.querySelector(`[data-node-id="${CSS.escape(t)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[r,t]),M(`div`,{ref:o,className:`flex w-max min-w-full flex-col py-0.5`,children:i.map(({node:e,parent:r,depth:i,isLast:o})=>{let c=f(e,r),l=e.type===`text`||e.type===`paragraph`||e.type===`span`;return N(`button`,{"data-node-id":e.id,type:`button`,onClick:()=>n(e.id),className:(0,V.cn)(`flex min-w-max items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left text-[13px] leading-5 transition-colors`,t===e.id?`bg-accent`:`hover:bg-accent/50`,e.hidden===!0&&`opacity-50`),children:[i>0&&M(`span`,{className:`shrink-0 whitespace-pre font-mono text-muted-foreground/40`,"aria-hidden":!0,children:` `.repeat(i-1)+(o?`└`:`├`)}),M(`span`,{className:(0,V.cn)(`truncate`,l?G.string:G.name),children:l?`"${e.name}"`:e.name}),M(`span`,{className:(0,V.cn)(`shrink-0 text-xs`,G.type),children:Ht(e.type)}),N(`span`,{className:(0,V.cn)(`shrink-0 text-xs tabular-nums`,G.geometry),children:[Math.round(e.width),`×`,Math.round(e.height),r!==null&&` @${Math.round(c.x)},${Math.round(c.y)}`,e.radius!==void 0&&` · r${e.radius}`]}),e.layout!==void 0&&N(`span`,{className:(0,V.cn)(`shrink-0 text-xs`,G.type),title:e.layout.summary,children:[e.layout.mode===`horizontal`?`⇆`:e.layout.mode===`vertical`?`⇅`:`▦`,e.layout.gap!==null&&` gap ${e.layout.gap}`,e.layout.padding!==null&&` pad ${e.layout.padding.top}/${e.layout.padding.right}/${e.layout.padding.bottom}/${e.layout.padding.left}`]}),e.fill!==void 0&&N(`span`,{className:(0,V.cn)(`flex shrink-0 items-center gap-1 text-xs`,G.value),children:[M(kr,{color:e.fill,size:`sm`}),a(e.fill)]}),e.stroke!==void 0&&N(`span`,{className:(0,V.cn)(`flex shrink-0 items-center gap-1 text-xs`,G.value),title:`stroke ${e.stroke.weight}px${e.stroke.align===void 0?``:` ${e.stroke.align}`}${e.stroke.dashed===!0?` dashed`:``}`,children:[M(`span`,{className:(0,V.cn)(`inline-block size-2.5 shrink-0 rounded-[3px] border-2 bg-transparent`,e.stroke.dashed===!0&&`border-dashed`),style:{borderColor:e.stroke.color},"aria-hidden":!0}),a(e.stroke.color),`·`,e.stroke.weight,e.stroke.dashed===!0&&`┅`]}),e.font!==void 0&&N(`span`,{className:(0,V.cn)(`shrink-0 text-xs`,G.value),children:[e.font.family,` `,e.font.style,` `,e.font.size,e.textMeta?.lineHeightPx!=null&&`/${e.textMeta.lineHeightPx}`,e.textMeta?.letterSpacing===void 0?e.textMeta?.letterSpacingPx!=null&&` ls ${e.textMeta.letterSpacingPx}`:` ls ${e.textMeta.letterSpacing.value}${e.textMeta.letterSpacing.unit}`,e.textMeta?.upperCase===!0&&` AA`]}),e.sticky===!0&&M(`span`,{className:`shrink-0 rounded border border-info/40 bg-info/10 px-1 text-xs leading-4 text-info`,children:s(`fixed`,`закреплён`)}),e.mask===!0&&M(`span`,{className:`shrink-0 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:s(`mask`,`маска`)}),e.hidden===!0&&M(`span`,{className:`shrink-0 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:s(`hidden`,`скрыт`)}),e.textColor!==void 0&&N(`span`,{className:(0,V.cn)(`flex shrink-0 items-center gap-1 text-xs`,G.value),children:[M(kr,{color:e.textColor,size:`sm`}),a(e.textColor)]})]},e.id)})})}function Mr({card:e,flatCount:t,selectedNodeId:n,onTreeSelect:r,revealTick:i,effectiveFocusId:a,onFocusChange:o,onRevealSelect:c,cssNode:l,cssText:u,cssItem:d,rawDslText:f,onLoadRaw:p,resolvedTheme:m}){let h=R(t=>t.rawErrors.has(e.id)),g=R(e=>e.retryRaw);return N(`div`,{className:`flex flex-col gap-2 pt-2`,children:[M(J,{title:s(`Layers`,`Слои`),count:t,defaultOpen:!0,children:M(`div`,{className:`mt-1 overflow-hidden rounded-md border border-border/60 bg-background`,children:M(K.ScrollArea,{className:`max-h-72`,children:M(jr,{root:e.root,selectedId:n,onSelect:r,revealTick:i})})})}),M(J,{title:s(`Geometry`,`Геометрия`),sublabel:s(`click to measure`,`клик для измерения`),count:`${Math.round(e.root.width)}×${Math.round(e.root.height)}`,defaultOpen:!0,children:M(Or,{root:e.root,focusId:a,onFocusChange:o,selectedId:n,onSelect:c})}),M(J,{title:`CSS`,sublabel:l?.name??``,count:u===``?0:u.split(`
8
- `).length,attachItem:d,headerActions:M(W,{value:u,label:s(`Copy CSS`,`Скопировать CSS`)}),flush:!0,defaultOpen:!0,children:M(K.ScrollArea,{className:`max-h-72`,children:M(en,{code:u,language:`css`,theme:m})})}),M(J,{title:s(`Raw DSL`,`Сырой DSL`),sublabel:`JSON`,count:f===null?`—`:`${Math.max(1,Math.round(f.length/1024))} KB`,headerActions:f===null?void 0:M(W,{value:f,label:s(`Copy JSON`,`Скопировать JSON`)}),onOpenChange:e=>{e&&p()},flush:!0,children:f===null?h?N(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[M(`p`,{className:`text-[13px] text-muted-foreground/70`,"data-testid":`pixso-raw-error`,children:s(`Failed to load the raw DSL.`,`Не удалось загрузить сырой DSL.`)}),M(H,{variant:`outline`,size:`sm`,onClick:()=>g(e.id),children:s(`Retry`,`Повторить`)})]}):M(`p`,{className:`px-3 py-2 text-[13px] text-muted-foreground/70`,children:s(`Loading the raw dump…`,`Загружаем сырой дамп…`)}):M(K.ScrollArea,{className:`max-h-72`,children:M(en,{code:f,language:`json`,theme:m})})})]})}function Nr({card:e}){let t=_(e.root),n=b(e.root),r=l(e.root),i=new Set;for(let{node:e}of r)e.fill!==void 0&&e.fillToken!==void 0&&i.add(a(e.fill)),e.textColor!==void 0&&e.textToken!==void 0&&i.add(a(e.textColor));let o=r.filter(({node:e})=>(e.effects??[]).length>0),c={key:`${e.id}:colors`,label:`${s(`Palette`,`Палитра`)} (${t.length}) ${e.id}`,shortLabel:s(`palette`,`палитра`),cardId:e.id,cardName:e.name,payload:JSON.stringify(t.map(e=>({...e,token:i.has(e.color)})),null,2),fenceLanguage:`json`},u={key:`${e.id}:fonts`,label:`${s(`Fonts`,`Шрифты`)} (${n.length}) ${e.id}`,shortLabel:s(`fonts`,`шрифты`),cardId:e.id,cardName:e.name,payload:JSON.stringify(n,null,2),fenceLanguage:`json`};return N(`div`,{className:`flex flex-col gap-2 pt-2`,children:[M(J,{title:s(`Colors`,`Цвета`),sublabel:s(`token binding from the DSL`,`привязка к токенам из DSL`),count:t.length,attachItem:c,defaultOpen:!0,children:M(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:t.map(e=>{let t=i.has(e.color);return N(`div`,{"data-testid":`pixso-style-color`,className:`flex items-center gap-2 text-[13px]`,children:[M(kr,{color:e.color}),M(`span`,{className:G.value,children:e.color}),t?N(`span`,{className:`rounded border border-success/40 bg-success/10 px-1 text-xs leading-4 text-success`,children:[s(`token`,`токен`),` ✓`]}):N(`span`,{className:`rounded border border-warning/40 bg-warning/10 px-1 text-xs leading-4 text-warning`,title:s(`Raw color — not bound to a library style`,`Сырой цвет — не привязан к стилю библиотеки`),children:[s(`no token`,`без токена`),` ⚠`]}),M(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground/60`,children:e.usedBy.join(`, `)}),M(W,{value:e.color,label:s(`Copy hex`,`Скопировать hex`)})]},e.color)})})}),M(J,{title:s(`Fonts`,`Шрифты`),count:n.length,attachItem:u,defaultOpen:!0,children:M(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:n.map(e=>N(`div`,{"data-testid":`pixso-style-font`,className:`flex items-center gap-2 text-[13px]`,children:[M(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-md border border-border bg-muted font-mono text-xs text-muted-foreground`,children:`Aa`}),N(`span`,{className:G.name,children:[e.font.family,` `,e.font.style]}),M(`span`,{className:(0,V.cn)(`ml-auto tabular-nums`,G.value),children:e.font.size}),N(`span`,{className:(0,V.cn)(`text-xs tabular-nums`,G.geometry),children:[`×`,e.count]})]},`${e.font.family}-${e.font.style}-${e.font.size}`))})}),o.length>0&&M(J,{title:s(`Effects`,`Эффекты`),count:o.length,children:M(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:o.map(({node:e})=>(e.effects??[]).map((t,n)=>N(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[M(`span`,{className:G.name,children:e.name}),M(`span`,{className:G.type,children:t.kind===`drop-shadow`?s(`shadow`,`тень`):t.kind===`foreground-blur`?s(`layer blur`,`блюр слоя`):s(`background blur`,`блюр фона`)}),t.color!==void 0&&M(kr,{color:t.color,size:`sm`}),N(`span`,{className:(0,V.cn)(`text-xs tabular-nums`,G.geometry),children:[t.offsetX!==void 0&&`→${t.offsetX},${t.offsetY??0}`,t.spread!==void 0&&` spread ${t.spread}`]})]},`${e.id}-${n}`)))})})]})}var Pr=class{listeners=new Set;container=null;scrollTop=0;viewportHeight=0;rowHeight=0;epoch=0;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));emit(){for(let e of this.listeners)e()}get containerEl(){return this.container}setContainer(e){this.container=e,e!==null&&(this.scrollTop=e.scrollTop)}handleScroll(){let e=this.container?.scrollTop??0;e!==this.scrollTop&&(this.scrollTop=e,this.emit())}setViewportHeight(e){e!==this.viewportHeight&&(this.viewportHeight=e,this.emit())}setRowHeight(e){e<=0||e===this.rowHeight||(this.rowHeight=e,this.emit())}bumpEpoch(){this.epoch+=1,this.emit()}};const Fr=ze(null);function Ir(){let e=Ve(Fr);if(e===null)throw Error(`useScrollViewportStore must be used inside <ScrollViewport>`);return e}function Lr({layoutKey:e,className:t,children:n}){let[r]=A(()=>new Pr),i=Be(e=>r.setContainer(e),[r]);return He(()=>{let e=r.containerEl;if(e===null)return;let t=new ResizeObserver(()=>r.setViewportHeight(e.clientHeight));return t.observe(e),r.setViewportHeight(e.clientHeight),()=>t.disconnect()},[r]),He(()=>{r.bumpEpoch()},[r,e,We(r.subscribe,()=>r.rowHeight,()=>r.rowHeight)]),M(Fr.Provider,{value:r,children:M(`div`,{ref:i,onScroll:()=>r.handleScroll(),className:t,children:n})})}function Rr(e){return e.rowHeight+e.rowGap}function zr(e,t){return e===0?0:Math.ceil(e/t)}function Br(e,t){return e===0?0:e*t.rowHeight+(e-1)*t.rowGap}function Vr(e,t){return e*Rr(t)}function Hr(e){let t=Rr(e.metrics),n=e.scrollTop-e.gridTop,r=Math.floor(n/t)-e.overscan,i=Math.ceil((n+e.viewportHeight)/t)+e.overscan,a=Math.min(Math.max(r,0),e.rowCount);return{start:a,end:Math.min(Math.max(i,a),e.rowCount)}}function Ur(e,t,n,r){let i=Ir(),[a,o]=A(0);He(()=>{let t=i.containerEl,n=e.current;if(t===null||n===null)return;let r=n.getBoundingClientRect(),a=t.getBoundingClientRect(),s=r.top-a.top+t.scrollTop;o(e=>e===s?e:s)},[i,i.epoch,e]);let s=()=>{let e=i.rowHeight>0?{...n,rowHeight:i.rowHeight}:n,{start:o,end:s}=Hr({gridTop:a,scrollTop:i.scrollTop,viewportHeight:i.viewportHeight,rowCount:t,metrics:e,overscan:r});return`${o}:${s}:${e.rowHeight}`},[c=`0`,l=`0`,u=`0`]=We(i.subscribe,s,s).split(`:`),d=Number(u),f=k(()=>d>0?{...n,rowHeight:d}:n,[n,d]);return{start:Number(c),end:Number(l),metrics:f}}function Wr(e,t,n,r){let i=new URLSearchParams;n!==void 0&&i.set(`item-id`,n),r!==void 0&&i.set(`page-id`,r);let a=i.toString();return`${e.replace(/\/$/,``)}/app/design/${t}${a===``?``:`?${a}`}`}function Gr(e){return e.containing_frame.containingStateGroup?.name.includes(`❌Deprecated`)===!0||e.name.includes(`❌Deprecated`)}function Kr({entry:e,libraryName:t,host:n,scanUsage:r}){let i=Gr(e);return N(`div`,{"data-testid":`pixso-catalog-row`,className:(0,V.cn)(`flex flex-col gap-0.5 overflow-hidden rounded-md border bg-background px-2 py-1`,i?`border-warning/40`:`border-border/60`),style:{height:48},children:[N(`span`,{className:`flex w-full min-w-0 items-center gap-1.5`,children:[M(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,children:e.name}),i&&M(Ie,{className:`size-3 shrink-0 text-warning`}),e.containing_frame.containingStateGroup!==void 0&&M(`span`,{className:`shrink-0 truncate rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:e.containing_frame.containingStateGroup.name}),r!==void 0&&M(`span`,{className:`shrink-0 rounded border border-primary/30 bg-primary/8 px-1 text-xs leading-4 text-primary`,children:s(`in scan`,`в скане`)}),n!==null&&M(`a`,{href:Wr(n,e.file_key,e.node_id,e.containing_frame.pageId),target:`_blank`,rel:`noreferrer`,title:s(`Open on the Pixso host`,`Открыть на хосте Pixso`),className:`ml-auto shrink-0 text-muted-foreground/60 transition-colors hover:text-primary`,children:M(D,{className:`size-3.5`})})]}),N(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 text-xs text-muted-foreground/70`,children:[M(`span`,{className:`shrink-0`,children:t}),N(`span`,{className:`shrink-0`,children:[`· `,e.containing_frame.pageName]}),N(`span`,{className:`shrink-0 tabular-nums`,children:[`· min `,e.min_node_width,`×`,e.min_node_height]}),e.updated_at!==null&&N(`span`,{className:`shrink-0 tabular-nums`,children:[`· `,e.updated_at.slice(0,10)]}),e.description!==``&&N(`span`,{className:(0,V.cn)(`min-w-0 truncate`,G.string),children:[`· «`,e.description,`»`]})]})]})}const qr={columns:1,rowHeight:52,rowGap:0};function Jr({entries:e,libraryNames:t,host:n,usagesByKey:r}){let i=Ue(null),a=zr(e.length,qr.columns),{start:o,end:s,metrics:c}=Ur(i,a,qr,8),l=k(()=>{let i=[];for(let a=o;a<s;a+=1){let o=e[a];o!==void 0&&i.push(M(`div`,{className:`absolute inset-x-0 px-3 py-0.5`,style:{top:Vr(a,c),height:c.rowHeight},children:M(Kr,{entry:o,libraryName:t[o.file_key]??o.file_key,host:n,scanUsage:r.get(o.component_key)})},o.component_key))}return i},[e,o,s,c,t,n,r]);return M(`div`,{ref:i,"data-testid":`pixso-catalog-grid`,className:`relative`,style:{height:Br(a,c)},children:l})}function Yr({snapshot:e,usages:t,host:n,capturedAtLabel:r}){let[i,a]=A(``),[o,c]=A(null),[l,u]=A(!1),d=k(()=>new Map(t.map(e=>[e.key,e])),[t]),f=k(()=>{let t=new Map;for(let n of e.entries)t.set(n.file_key,(t.get(n.file_key)??0)+1);return[...t.entries()].map(([t,n])=>({key:t,count:n,name:e.libraryNames[t]??t}))},[e]),p=k(()=>{let t=i.trim().toLowerCase();return e.entries.filter(e=>o!==null&&e.file_key!==o||l&&!Gr(e)?!1:t===``?!0:e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.containing_frame.pageName.toLowerCase().includes(t))},[e,i,o,l]),m=`${p.length}:${o??``}:${l?1:0}:${i}`,h=f.find(e=>e.key===o)??null;return N(`div`,{className:`-mx-3 flex min-h-0 flex-1 flex-col gap-1.5 pt-2`,children:[N(`div`,{className:`shrink-0 px-3 text-xs text-muted-foreground/70`,children:[s(`catalog at scan time`,`каталог на момент скана`),` (`,r,`) ·`,` `,f.length,` `,s(`libraries`,`библиотек`),` · `,e.entries.length,` `,s(`components`,`компонентов`)]}),N(`div`,{className:`flex shrink-0 items-center gap-1.5 px-3`,children:[N(`div`,{className:`relative min-w-0 flex-1`,children:[M(Ne,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/60`}),M(yr.Input,{size:`sm`,value:i,onValueChange:a,placeholder:s(`Search components…`,`Поиск по компонентам…`),className:`pl-7`})]}),N(fr,{children:[N(pr,{render:M(H,{variant:`outline`,size:`sm`,className:`shrink-0`}),children:[h?.name??s(`All libraries`,`Все библиотеки`),M(T,{})]}),N(mr,{align:`end`,children:[M($,{onClick:()=>c(null),children:s(`All libraries`,`Все библиотеки`)}),f.map(e=>N($,{onClick:()=>c(e.key),children:[e.name,M(`span`,{className:`ml-auto pl-3 text-xs tabular-nums text-muted-foreground/60`,children:e.count})]},e.key))]})]}),M(kt.Toggle,{size:`sm`,pressed:l,onPressedChange:e=>u(e),"aria-label":s(`Deprecated only`,`Только устаревшие`),title:s(`Deprecated only`,`Только устаревшие`),children:M(Ie,{className:`size-3.5`})})]}),M(Lr,{layoutKey:m,className:`min-h-0 flex-1 overflow-y-auto border-t border-border/50`,children:M(Jr,{entries:p,libraryNames:e.libraryNames,host:n,usagesByKey:d})},i),M(`div`,{className:`shrink-0 px-3 pb-1 text-xs tabular-nums text-muted-foreground/60`,"data-testid":`pixso-catalog-count`,children:p.length===e.entries.length?`${p.length} ${s(`components`,`компонентов`)}`:`${s(`found`,`найдено`)} ${p.length} ${s(`of`,`из`)} ${e.entries.length}`})]})}function Xr({value:e,kind:t}){if(t===`visible`){let t=e===`on`;return M(`span`,{className:(0,V.cn)(`rounded border px-1 text-xs leading-4`,t?`border-success/40 bg-success/10 text-success`:`border-border bg-muted text-muted-foreground`),children:t?s(`on`,`вкл`):s(`off`,`выкл`)})}return N(`span`,{className:(0,V.cn)(`truncate`,G.string),children:[`«`,e,`»`]})}function Zr({usage:e,host:t,catalog:n}){let r=e.props.filter(e=>e.overridden).length,i=n?.entries.find(t=>t.component_key===e.key),a=t===null?null:i===void 0?e.libraryFileKey===null?null:Wr(t,e.libraryFileKey):Wr(t,i.file_key,i.node_id,i.containing_frame.pageId);return N(`div`,{"data-testid":`pixso-component-usage`,className:(0,V.cn)(`rounded-md border border-border/60 bg-background px-2 py-1.5`,e.deprecated&&`border-warning/50`),children:[N(`div`,{className:`flex items-center gap-1.5`,children:[M(oe,{className:`size-3.5 shrink-0 text-primary/70`}),M(`span`,{className:`truncate text-[13px] font-medium`,children:e.name}),e.count>1&&N(`span`,{className:(0,V.cn)(`shrink-0 text-xs tabular-nums`,G.geometry),children:[`×`,e.count]}),e.variantGroup!==null&&!e.deprecated&&M(`span`,{className:`shrink-0 truncate rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:e.variantGroup}),e.deprecated&&N(`span`,{className:`flex shrink-0 items-center gap-0.5 rounded border border-warning/40 bg-warning/10 px-1 text-xs leading-4 text-warning`,children:[M(Ie,{className:`size-2.5`}),s(`deprecated`,`устарел`)]}),!e.resolved&&N(`span`,{"data-testid":`pixso-component-unresolved`,className:`flex shrink-0 items-center gap-0.5 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,title:s(`The component's library is not connected — no catalog data.`,`Библиотека компонента не подключена — данных каталога нет.`),children:[M(Le,{className:`size-2.5`}),s(`library not connected`,`библиотека не подключена`)]}),N(`span`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[a!==null&&M(`a`,{href:a,target:`_blank`,rel:`noreferrer`,title:s(`Open on the Pixso host (URL format pending one live check)`,`Открыть на хосте Pixso (формат ссылки будет сверен на живом хосте)`),className:`text-muted-foreground/50 hover:text-primary`,children:M(D,{className:`size-3`})}),M(W,{value:e.key,label:s(`Copy component key`,`Скопировать ключ компонента`)})]})]}),(e.library!==null||e.pageName!==null||e.description!==null)&&N(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 pl-5 text-xs text-muted-foreground/70`,children:[e.library!==null&&M(`span`,{className:`truncate`,children:e.library}),e.pageName!==null&&N(`span`,{className:`truncate`,children:[s(`page`,`стр.`),` «`,e.pageName,`»`]}),e.description!==null&&e.description!==``&&M(`span`,{className:(0,V.cn)(`truncate`,G.string),children:e.description}),e.updatedAt!==null&&M(`span`,{className:`shrink-0 tabular-nums`,children:e.updatedAt})]}),e.props.length>0&&N(q.Collapsible,{className:`mt-1 pl-5`,children:[N(q.CollapsibleTrigger,{className:`group flex items-center gap-1 text-xs text-muted-foreground/70 transition-colors hover:text-foreground`,children:[M(E,{className:`size-2.5 transition-transform duration-150 group-data-panel-open:rotate-90`}),e.props.length,` `,s(`props`,`свойств`),e.count>1&&M(`span`,{"data-testid":`pixso-props-first-instance`,className:`truncate text-muted-foreground/50`,title:s(`Values of the first instance — other instances may differ.`,`Значения первого экземпляра — у остальных они могут отличаться.`),children:s(`(first instance)`,`(первого экземпляра)`)}),r>0&&N(`span`,{className:`rounded border border-primary/30 bg-primary/8 px-1 text-xs leading-4 text-primary`,children:[r,` `,s(`overridden`,`переопределено`)]})]}),M(q.CollapsiblePanel,{children:M(`div`,{className:`mt-1 flex flex-col gap-0.5`,children:e.props.map(e=>N(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[M(`span`,{className:(0,V.cn)(`shrink-0`,G.name),children:e.name}),M(Xr,{value:e.value,kind:e.kind}),e.overridden&&N(`span`,{className:`truncate text-muted-foreground/50`,title:s(`Default value`,`Значение по умолчанию`),children:[`(`,s(`default`,`по умолч.`),` `,e.kind===`visible`?e.defaultValue===`on`?s(`on`,`вкл`):s(`off`,`выкл`):`«${e.defaultValue}»`,`)`]})]},e.name))})})]})]})}function Qr({usages:e,host:t,catalog:n}){let r=new Set(e.filter(e=>e.libraryFileKey!==null).map(e=>e.libraryFileKey)),i=e.filter(e=>e.deprecated).length,a=e.filter(e=>!e.resolved).length;return N(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:[N(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 px-0.5 text-xs text-muted-foreground/70`,children:[N(`span`,{children:[e.reduce((e,t)=>e+t.count,0),` `,s(`instances`,`экземпляров`),` ·`,` `,e.length,` `,s(`components`,`компонентов`),` · `,r.size,` `,s(`libraries`,`библиотек`)]}),i>0&&N(`span`,{className:`flex items-center gap-0.5 text-warning`,children:[M(Ie,{className:`size-2.5`}),i,` `,s(`deprecated`,`устаревших`)]}),a>0&&N(`span`,{className:`text-muted-foreground/60`,children:[a,` `,s(`outside connected libraries`,`вне подключённых библиотек`)]})]}),e.map(e=>M(Zr,{usage:e,host:t,catalog:n},e.key))]})}function $r({card:e}){let[t,n]=A(`used`),r=R(e=>e.loadCatalog),i=R(e=>e.retryCatalog),a=R(t=>e.catalogHash===void 0?!1:t.catalogErrors.has(e.catalogHash)),o=e.componentsUsed??[],c=e.catalogHash;O(()=>{t===`catalog`&&c!==void 0&&r(c)},[t,c,r]);let l=(e,r)=>M(`button`,{type:`button`,"data-testid":`pixso-components-view-${e}`,onClick:()=>n(e),className:(0,V.cn)(`cursor-pointer rounded-md px-2 py-1 text-[13px] transition-colors`,t===e?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),children:r});return N(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-2`,children:[N(`div`,{className:`flex w-fit shrink-0 items-center gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5`,children:[l(`used`,`${s(`In this selection`,`В выборке`)} · ${o.length}`),c!==void 0&&l(`catalog`,e.catalog===void 0?s(`Catalog`,`Каталог`):`${s(`Catalog`,`Каталог`)} · ${e.catalog.entries.length}`)]}),t===`used`?M(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-3`,children:o.length>0?M(Qr,{usages:o,host:null,catalog:e.catalog}):M(`p`,{className:`px-0.5 pt-2 text-xs text-muted-foreground/70`,children:s(`No component instances in this selection.`,`В выборке нет экземпляров компонентов.`)})}):e.catalog===void 0?a?N(`div`,{className:`flex items-center gap-2 pt-2`,children:[M(`p`,{className:`px-0.5 text-xs text-muted-foreground/70`,"data-testid":`pixso-catalog-error`,children:s(`Failed to load the catalog.`,`Не удалось загрузить каталог.`)}),c!==void 0&&M(H,{variant:`outline`,size:`sm`,onClick:()=>i(c),children:s(`Retry`,`Повторить`)})]}):M(`p`,{className:`px-0.5 pt-2 text-xs text-muted-foreground/70`,children:s(`Loading the catalog…`,`Загружаем каталог…`)}):M(Yr,{snapshot:e.catalog,usages:o,host:null,capturedAtLabel:e.importedAt})]})}function ei(){let e=R(e=>e.backToTabs),t=R(e=>e.loadRaw),n=gt(),{card:r,loading:i,failed:a}=er(),u=R(e=>e.retryDetail),d=R(e=>e.selectedCardId),[f,p]=A(null),[h,g]=A(null),[_,v]=A(0),[y,b]=A(`overview`);O(()=>{r===null&&!i&&!a&&e()},[r,i,a,e]);let x=r===null?null:f===null?r.root:c(r.root,f)??r.root,S=r===null||x===null?``:fn(x,m(r.root,x.id)),C={key:`${r?.id??`-`}:css:${x?.id??`-`}`,label:`CSS «${x?.name??``}»`,shortLabel:`css ${x?.name??``}`,cardId:r?.id??``,cardName:r?.name??``,payload:S,fenceLanguage:`css`};if(r===null)return a?N(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[M(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:N(H,{variant:`ghost`,size:`sm`,onClick:e,children:[M(ae,{className:`size-4`}),s(`Back`,`Назад`)]})}),N(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-4 text-center`,children:[M(`p`,{className:`text-[13px] text-muted-foreground`,children:s(`Could not load the card.`,`Не удалось загрузить карточку.`)}),M(H,{variant:`outline`,size:`sm`,onClick:()=>{d!==null&&u(d)},children:s(`Retry`,`Повторить`)})]})]}):i?N(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[M(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:N(H,{variant:`ghost`,size:`sm`,onClick:e,children:[M(ae,{className:`size-4`}),s(`Back`,`Назад`)]})}),M(`div`,{className:`flex flex-1 items-center justify-center`,children:M(Lt.Spinner,{className:`size-4 text-muted-foreground/60`})})]}):null;let w=o(r.root),ee=Wt(r),te=l(r.root),ne=te.filter(e=>e.node.sticky===!0).length,re=te.filter(e=>e.node.mask===!0).length,ie=te.filter(e=>e.node.hidden===!0).length,T=r.componentsUsed??[],E=T.filter(e=>e.deprecated).length,oe=h??r.root.id,se=e=>{p(e);let t=m(r.root,e);g(t===null?r.root.id:t.id)},ce=e=>{p(e),v(e=>e+1)},le=r.rawDsl??null,ue=te.filter(({node:e})=>e.url!==void 0).map(({node:e})=>({name:e.name,url:e.url})),D=`block min-h-0 flex-1 overflow-y-auto px-3 pb-3`;return N(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[M(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:N(H,{variant:`ghost`,size:`sm`,onClick:e,children:[M(ae,{className:`size-4`}),s(`Back`,`Назад`)]})}),M(`div`,{className:`shrink-0 px-3 pt-2.5`,children:N(`div`,{className:`min-w-0`,children:[N(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[M(`h3`,{className:`truncate text-sm font-semibold`,children:r.name}),M(jt.Badge,{variant:`outline`,size:`sm`,className:`shrink-0 text-xs`,children:ee.label}),ee.library!==null&&M(`span`,{className:`shrink-0 truncate text-xs text-muted-foreground/60`,children:ee.library})]}),N(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-[13px]`,children:[N(`span`,{className:(0,V.cn)(`flex items-center gap-1`,G.id),children:[r.id,M(W,{value:r.id,label:s(`Copy id`,`Скопировать id`)})]}),N(`span`,{className:(0,V.cn)(`tabular-nums`,G.geometry),children:[Math.round(r.root.width),` × `,Math.round(r.root.height)]}),N(`span`,{className:G.geometry,children:[w.layers,` `,s(`layers`,`слоёв`)]}),N(`span`,{className:G.geometry,children:[`DSL `,r.dslVersion,r.versionUnverified===!0&&` · ${s(`unverified`,`не подтверждена`)}`]})]})]})}),N(B.Tabs,{value:y,onValueChange:e=>b(e),className:`mt-2 flex min-h-0 flex-1 flex-col`,children:[N(B.TabsList,{className:`shrink-0 gap-0.5 overflow-x-auto border-b border-border/60 px-3 py-1 [scrollbar-width:none]`,children:[tr.map(e=>{let t=y===e.value;return N(U.Tooltip,{children:[M(U.TooltipTrigger,{render:N(B.TabsTab,{value:e.value,className:(0,V.cn)(`z-10 h-7 shrink-0 gap-0 px-2 text-[13px] transition-colors`,!t&&`hover:bg-muted/60`),children:[N(`span`,{className:`relative shrink-0`,children:[M(e.icon,{className:(0,V.cn)(`size-3.5 transition-[color,transform] duration-300`,t&&`scale-110 text-primary`)}),e.value===`components`&&E>0&&M(`span`,{className:`absolute -right-1 -top-1 size-1.5 rounded-full bg-warning`,"aria-label":s(`uses deprecated components`,`есть устаревшие компоненты`)})]}),M(`span`,{className:(0,V.cn)(`grid transition-[grid-template-columns] duration-300 ease-[cubic-bezier(0.3,1.4,0.5,1)]`,t?`grid-cols-[1fr]`:`grid-cols-[0fr]`),children:M(`span`,{className:`min-w-0 overflow-hidden`,children:M(`span`,{className:(0,V.cn)(`block whitespace-nowrap pl-1.5 font-medium transition-opacity duration-200`,t?`opacity-100 delay-100`:`opacity-0`),children:e.label()})})})]})}),M(U.TooltipPopup,{side:`bottom`,children:e.label()})]},e.value)}),M(B.TabsIndicator,{className:`inset-y-1 h-auto rounded-md bg-accent shadow-sm ring-1 ring-border/60 duration-300 ease-[cubic-bezier(0.3,1.4,0.5,1)]`})]}),M(B.TabsPanel,{value:`overview`,className:D,"data-testid":`pixso-tab-overview`,children:M(Tr,{card:r,stickyCount:ne,maskCount:re,hiddenCount:ie,deprecatedUsed:E,componentsUsed:T,designerLinks:ue,onOpenPrompt:()=>b(`prompt`)})}),M(B.TabsPanel,{value:`structure`,className:D,"data-testid":`pixso-tab-structure`,children:M(Mr,{card:r,flatCount:te.length,selectedNodeId:f,onTreeSelect:se,revealTick:_,effectiveFocusId:oe,onFocusChange:g,onRevealSelect:ce,cssNode:x,cssText:S,cssItem:C,rawDslText:le,onLoadRaw:()=>t(r.id),resolvedTheme:n})}),M(B.TabsPanel,{value:`styles`,className:D,"data-testid":`pixso-tab-styles`,children:M(Nr,{card:r})}),M(B.TabsPanel,{value:`components`,className:`min-h-0 flex-1 overflow-hidden`,"data-testid":`pixso-tab-components`,children:M($r,{card:r})}),M(B.TabsPanel,{value:`qa`,className:D,"data-testid":`pixso-tab-qa`,children:M(qn,{card:r,onShowNode:e=>{se(e),v(e=>e+1),b(`structure`)}})}),M(B.TabsPanel,{value:`analytics`,className:D,"data-testid":`pixso-tab-analytics`,children:M(cn,{card:r})}),M(B.TabsPanel,{value:`prompt`,className:D,"data-testid":`pixso-tab-prompt`,children:M(Vn,{card:r})})]})]})}const ti={ok:{en:`OK`,ru:`OK`,className:`bg-success/10 text-success`},dead:{en:`DEAD`,ru:`DEAD`,className:`bg-destructive/10 text-destructive`},empty:{en:`empty`,ru:`пусто`,className:`bg-muted text-muted-foreground/70`},"needs-args":{en:`contract`,ru:`контракт`,className:`bg-warning/10 text-warning`},skip:{en:`skip`,ru:`skip`,className:`bg-muted text-muted-foreground/70`}};function ni(){let e=R(e=>e.probePhase),t=R(e=>e.runProbe),n=R(e=>e.lastProbe),r=R(e=>e.lastProbeError),[i,a]=A(!0),o=n===null?[]:n.rows.filter(e=>e.status!==`skip`);return N(J,{title:s(`Diagnostics probe`,`Диагностическая проба`),sublabel:s(`over the current selection`,`по текущему выделению`),count:n===null?`—`:Jn(n.atIso),countTone:n===null?`na`:`default`,defaultOpen:!0,children:[N(`div`,{className:`flex items-center gap-2 pt-1`,children:[N(H,{variant:`outline`,size:`sm`,onClick:t,disabled:e===`running`,className:`shrink-0`,children:[e===`running`?M(Lt.Spinner,{className:`size-3.5`}):M(ke,{}),s(`Run diagnostics`,`Запустить диагностику`)]}),M(`span`,{className:`text-xs text-muted-foreground/60`,children:s(`read tools only; results are saved`,`только read-инструменты; результаты сохраняются`)})]}),e===`running`&&M(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:Array.from({length:4},(e,t)=>M(Q.Skeleton,{className:`h-6 w-full rounded-md`},t))}),e===`failed`&&M(`p`,{className:`mt-2 rounded-md border border-destructive/30 bg-destructive/6 px-2.5 py-1.5 text-[13px] text-destructive`,children:r??s(`Probe failed.`,`Проба не удалась.`)}),e===`done`&&n!==null&&N(`div`,{className:`mt-2 flex flex-col`,children:[o.map(e=>N(`div`,{className:`flex items-center gap-2 border-b border-border/50 py-1.5 text-[13px] last:border-0`,children:[M(`code`,{className:`font-mono text-foreground`,children:e.tool}),M(`span`,{className:(0,V.cn)(`ml-auto shrink-0 rounded-full px-2 py-px font-mono text-xs leading-4`,ti[e.status].className),children:s(ti[e.status].en,ti[e.status].ru)}),M(`span`,{className:`w-32 shrink-0 truncate text-right font-mono text-xs tabular-nums text-muted-foreground/60`,children:e.detail})]},e.tool)),n.deviations.length>0?N(`div`,{className:`mt-2 rounded-md border border-warning/30 bg-warning/8 px-2.5 py-1.5`,children:[N(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-1 text-left text-[13px] font-medium text-warning`,children:[M(i?T:E,{className:`size-3.5 shrink-0`}),s(`Contract deviations`,`Отклонения от контракта`),` ·`,` `,n.deviations.length]}),i&&M(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4 text-xs text-foreground/80`,children:n.deviations.map(e=>M(`li`,{children:e},e))})]}):M(`p`,{className:`mt-2 rounded-md border border-success/25 bg-success/6 px-2.5 py-1.5 text-[13px] text-success`,children:s(`No contract deviations detected.`,`Отклонений от контракта не обнаружено.`)}),N(`p`,{className:`mt-2 text-xs text-muted-foreground/60`,children:[s(`Report saved to: `,`Отчёт сохранён: `),n.savedTo]})]})]})}var ri=t({});import*as ii from"@smart-tools/qwen-cli-ui-kit";e(ri,ii);const ai={danger:{box:`border-destructive/30 bg-destructive/6`,title:`text-destructive`,message:`text-destructive/75`,marker:`marker:text-destructive/40`},warning:{box:`border-warning/40 bg-warning/8`,title:`text-warning`,message:`text-warning/80`,marker:`marker:text-warning/50`},info:{box:`border-info/40 bg-info/8`,title:`text-info`,message:`text-info/80`,marker:`marker:text-info/50`}},oi={danger:`danger`,warning:`warning`,info:`info`};function si({title:e,message:t,recommendations:n,actions:r,tone:i=`danger`,className:a}){let o=ai[i];return N(`div`,{className:(0,V.cn)(`rounded-lg border px-3 py-2.5`,o.box,a),role:`alert`,children:[N(`div`,{className:(0,V.cn)(`flex items-center gap-2 text-xs font-medium`,o.title),children:[M(ri.StatusDot,{tone:oi[i],size:`sm`}),e]}),t!==``&&M(`p`,{className:(0,V.cn)(`mt-1.5 break-words font-mono text-[13px] leading-relaxed`,o.message),"data-testid":`pixso-outcome-message`,children:t}),M(`ul`,{className:(0,V.cn)(`mt-2 list-disc space-y-1 pl-4 text-xs text-foreground/75`,o.marker),children:n.map((e,t)=>M(`li`,{children:e},t))}),r!==void 0&&M(`div`,{className:`mt-2.5 flex items-center gap-2`,children:r})]})}function ci({tools:e}){return M(`div`,{className:`flex flex-col gap-1.5`,children:e.map(e=>N(q.Collapsible,{className:`overflow-hidden rounded-lg border border-border bg-card`,children:[N(q.CollapsibleTrigger,{className:`group flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-accent/40`,children:[M(`code`,{className:`truncate font-mono text-[13px] text-foreground`,children:e.name}),e.write&&M(`span`,{className:`shrink-0 rounded-md border border-warning/40 bg-warning/8 px-1 font-mono text-xs leading-4 text-warning`,children:s(`write`,`запись`)}),N(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[e.params.length>0&&M(rn,{children:e.params.length}),M(T,{className:`size-3 text-muted-foreground/60 transition-transform duration-150 group-data-panel-open:rotate-180`})]})]}),M(q.CollapsiblePanel,{children:N(`div`,{className:`border-t border-border/60 px-2.5 pb-2 pt-1.5`,children:[M(`p`,{className:`text-[13px] text-muted-foreground`,children:e.description}),e.params.length===0?M(`p`,{className:`pt-1 text-xs text-muted-foreground/60`,children:s(`No parameters.`,`Без параметров.`)}):M(`div`,{className:`flex flex-col pt-1`,children:e.params.map(e=>N(`div`,{className:`flex items-baseline gap-2 py-0.5 text-[13px]`,children:[M(`code`,{className:`font-mono text-foreground`,children:e.name}),M(`span`,{className:(0,V.cn)(`text-xs`,G.type),children:e.type}),e.required?M(`span`,{className:`rounded-md border border-warning/40 px-1 font-mono text-xs leading-4 text-warning`,children:s(`required`,`обязательный`)}):M(`span`,{className:`font-mono text-xs text-muted-foreground/50`,children:s(`optional`,`необязательный`)}),e.description!==void 0&&M(`span`,{className:`ml-auto max-w-40 text-right text-xs text-muted-foreground/60`,children:e.description})]},e.name))})]})})]},e.name))})}const li=[{label:()=>s(`Connect to MCP`,`Подключение к MCP`),detail:`http://127.0.0.1:3667/mcp`},{label:()=>s(`Read the selection`,`Чтение выделения`),detail:`get_node_dsl`},{label:()=>s(`Components catalog`,`Каталог компонентов`),detail:`get_all_components`},{label:()=>s(`Parse & assemble the card`,`Разбор и сборка карточки`),detail:`parser`}];function ui(e){switch(e){case`success`:return`success`;case`success-warnings`:return`warning`;case`reimport`:return`duplicate`;case`components-error`:case`mcp-down`:case`tool-timeout`:case`dsl-error`:case`empty-selection`:case`multi-selection`:case`parse-error`:case`internal-error`:return`error`}}function di(e,t,n){return[`# Pixso scan report — ${e.cardName??`—`} · ${t}`,`DSL ${e.dslVersion??`—`} · converter ${e.converterVersion??`—`} · envelope: MCP content[0].text`,n,``]}function fi(e,t){return t.length===0?[]:[`## ${e}`,...t,``]}function pi(e){let t=e.data,n=Jn(e.atIso);if(t.nodesParsed===0&&t.diagnostics.length===0&&t.rootGuids.length===0){let e=t.failedStep===null?null:li[t.failedStep];return[...di(t,n,`разбор не выполнялся`),`## Скан прервался до разбора`,`- шаг: ${e==null?`—`:e.label()}`,...t.toolTimings.filter(e=>!e.ok).map(e=>`- ${e.tool}: ${e.detail??`ошибка`}`),`- данных для отчёта парсера нет`,...t.byteDiff===null?[]:[``,`Пересканирование: ${t.byteDiff.note}`]].join(`
9
- `)}let r=[...di(t,n,[`nodes: ${t.nodesParsed} parsed / ${t.nodesWithIssues} with issues`,`unknown keys: ${t.unknownKeys.length}`,`unknown enums: ${t.unknownEnums.length}`,...t.catalogStatus===`failed`?[`catalog: НЕДОСТУПЕН`]:[],...t.catalogStatus===`skipped`?[`catalog: не запрашивался`]:[]].join(` · `))];return t.rootGuids.length>1&&r.push(`## Несколько корней в pixDslNodes`,`- guids: ${t.rootGuids.join(`, `)}`,`- импорт отклонён по правилу «один фрейм за скан»`,``),r.push(...fi(`Unknown enum values`,t.unknownEnums.map(e=>`- ${e.field}: ${e.value} · ${e.count} узлов${e.exampleGuid===null?``:` · e.g. ${e.exampleGuid}`}`)),...fi(`Unknown keys (sanitized sample)`,t.unknownKeys.map(e=>`- node.${e.key} = ${e.sample} · ${e.count} узлов${e.exampleGuid===null?``:` · e.g. ${e.exampleGuid}`}`)),...fi(`Unresolved component libraries`,t.unresolvedLibraries.map(e=>`- library \`${e.fileKey}\` отсутствует в get_all_components · ${e.count} экземпляров${e.exampleGuid===null?``:` · e.g. ${e.exampleGuid}`}`)),...fi(`Diagnostics`,t.diagnostics.map(e=>`- ${e.severity} ${e.code}${e.path===void 0?``:` @${e.path}`} — ${e.message}`))),t.excerpts.length>0&&r.push(`## Node excerpts (sanitized)`,"```json",...t.excerpts,"```",``),t.unknownEnums.length===0&&t.unknownKeys.length===0&&t.unresolvedLibraries.length===0&&t.diagnostics.length===0&&r.push(`## Аномалий не обнаружено`,`Все узлы разобраны по подтверждённому контракту; неизвестных полей и значений нет.`,``),t.duplicate&&r.push(`Примечание: узел уже был импортирован — дубликат не создавался.`,``),t.byteDiff!==null&&r.push(`Пересканирование: ${t.byteDiff.note}`,``),r.join(`
10
- `).replace(/\n+$/,``)}const mi={unchecked:{tone:`neutral`,pulse:!1},checking:{tone:`info`,pulse:!0},connected:{tone:`success`,pulse:!1},error:{tone:`danger`,pulse:!1}};function hi(){let e=R(e=>e.connection),t=R(e=>e.lastCheck),r=R(e=>e.lastCheckError),i=R(e=>e.recheck),a=R(e=>e.backToTabs),o=R(e=>e.latestReport),c=R(e=>e.debugRescanning),l=R(e=>e.debugRescan),u=R(e=>e.reparsing),d=R(e=>e.lastReparse),f=R(e=>e.runReparse),p=R(e=>e.supportsReparse),m=gt(),h=t!==null,g=t?.tools.length??0,_=k(()=>o===null?null:pi(o),[o]),v=mi[e]??mi.unchecked,y=e===`unchecked`?s(`Not checked`,`Не проверено`):e===`checking`?s(`Checking…`,`Проверка…`):e===`connected`?s(`Connected`,`Подключено`):s(`Connection error`,`Ошибка подключения`),b=e===`connected`?`${g} ${s(`tools discovered`,`инструментов обнаружено`)}`:e===`checking`?`…`:s(`press «Check»`,`нажмите «Проверить»`);return N(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[M(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:N(H,{variant:`ghost`,size:`sm`,onClick:a,children:[M(ae,{className:`size-4`}),s(`Back`,`Назад`)]})}),N(`div`,{className:`block min-h-0 flex-1 overflow-y-auto p-3`,"data-testid":`pixso-diagnostics-view`,children:[M(`h3`,{className:`text-sm font-semibold`,children:s(`Diagnostics & settings`,`Диагностика и настройки`)}),N(`div`,{className:`mt-3 flex flex-col gap-2`,children:[N(`div`,{className:`rounded-lg border border-border bg-card px-3 py-2.5`,children:[N(`div`,{className:`flex items-center gap-2`,children:[M(ri.StatusDot,{tone:v.tone,pulse:v.pulse,size:`sm`,label:y}),M(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground/60`,children:b})]}),N(`div`,{className:`mt-2 flex items-center gap-2`,children:[M(yr.Input,{value:n,readOnly:!0,spellCheck:!1,className:`flex-1 font-mono text-[13px] text-muted-foreground`,"aria-label":s(`MCP endpoint (read-only)`,`Адрес MCP (только чтение)`)}),N(H,{variant:`outline`,size:`sm`,onClick:i,disabled:e===`checking`,className:`shrink-0`,children:[M(je,{className:(0,V.cn)(e===`checking`&&`animate-spin`)}),s(`Check`,`Проверить`)]})]})]}),e===`error`&&M(si,{title:s(`Connection error`,`Ошибка подключения`),message:r??s(`Connection failed.`,`Не удалось подключиться.`),recommendations:[s(`Start Pixso and enable MCP in the file menu`,`Запустите Pixso и включите MCP в меню файла`),s(`Make sure port 3667 is free`,`Убедитесь, что порт 3667 свободен`)],actions:M(H,{variant:`outline`,size:`xs`,onClick:i,children:s(`Retry`,`Повторить`)})}),M(J,{title:s(`Tools`,`Инструменты`),sublabel:`tools/list`,count:h?g:`—`,countTone:h?`default`:`na`,children:t===null?M(`p`,{className:`py-1 text-[13px] text-muted-foreground/70`,children:s(`Tools are unknown until the first check — press «Check» above.`,`Инструменты неизвестны до первой проверки — нажмите «Проверить» выше.`)}):M(`div`,{className:`pt-1`,children:M(ci,{tools:t.tools})})}),M(J,{title:s(`Latest scan report`,`Отчёт последнего скана`),sublabel:s(`for improving the parser`,`для доработки парсера`),count:o===null?`—`:Jn(o.atIso),countTone:o===null?`na`:`default`,headerActions:_===null?void 0:M(W,{value:_,label:s(`Copy the report`,`Скопировать отчёт`)}),flush:!0,defaultOpen:!0,children:_===null?M(`p`,{className:`px-3 py-2 text-[13px] text-muted-foreground/70`,children:s(`No scans yet — run one from the Import tab; only anomalies land here (unknown fields, enum values, parser diagnostics).`,`Сканов ещё не было — запустите на вкладке «Импорт»; сюда попадают только аномалии (неизвестные поля, значения enum, диагностика парсера).`)}):M(K.ScrollArea,{className:`max-h-80`,children:M(en,{code:_,language:`markdown`,theme:m})})}),N(`div`,{className:`flex items-center gap-2`,children:[N(H,{variant:`outline`,size:`sm`,onClick:l,disabled:c,className:`shrink-0`,"data-testid":`pixso-debug-rescan`,children:[c&&M(Lt.Spinner,{className:`size-3.5`}),s(`Rescan the selection`,`Пересканировать выделение`)]}),M(`span`,{className:`text-xs text-muted-foreground/60`,children:s(`no card is saved — report only`,`карточка не сохраняется — только отчёт`)})]}),p&&N(`div`,{className:`flex items-center gap-2`,children:[N(H,{variant:`outline`,size:`sm`,onClick:f,disabled:u,className:`shrink-0`,children:[u&&M(Lt.Spinner,{className:`size-3.5`}),s(`Re-parse stored cards`,`Перечитать карточки из raw`)]}),M(`span`,{className:`text-xs text-muted-foreground/60`,children:d===null?s(`re-decodes cards that still have raw DSL`,`перечитывает карточки, у которых сохранён сырой DSL`):`${d.reparsed}/${d.total} · ${s(`no raw`,`без raw`)}: ${d.skippedNoRaw}${d.skippedNoCatalog!==void 0&&d.skippedNoCatalog>0?` · ${s(`no catalog`,`без каталога`)}: ${d.skippedNoCatalog}`:``} · ${s(`failed`,`с ошибкой`)}: ${d.failed}`})]}),M(ni,{})]})]})]})}function gi(e,t,n,r,i){let a=r.trim().toLowerCase(),o=a===``?t:t.filter(e=>e.name.toLowerCase().includes(a)||e.id.includes(a)),s=new Set(e.map(e=>e.id)),c=new Map;for(let e of o){let t=n[e.id],r=t!==void 0&&s.has(t)?t:null,i=c.get(r)??[];i.push(e),c.set(r,i)}let l=a!==``,u=e.map(e=>({group:e,cards:c.get(e.id)??[]})).filter(e=>!l||e.cards.length>0),d=c.get(null)??[];if(!(d.length>0||i.includeEmptyUnsorted&&!l))return u;let f={group:null,cards:d};return i.unsortedPinned?[f,...u]:[...u,f]}const _i=dt.Root;function vi(e){return M(dt.Trigger,{"data-slot":`context-menu-trigger`,...e})}function yi({children:e,className:t,...n}){return M(dt.Portal,{children:M(dt.Positioner,{className:`z-50`,"data-slot":`context-menu-positioner`,children:M(dt.Popup,{className:(0,V.cn)(`relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] focus:outline-none dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,t),"data-slot":`context-menu-popup`,...n,children:M(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1`,children:e})})})})}const bi={simple:`bg-success`,medium:`bg-warning`,complex:`bg-destructive`};function xi({band:e,filled:t,className:n}){return M(`div`,{className:(0,V.cn)(`flex gap-[3px]`,n),role:`img`,"aria-label":e,children:Array.from({length:5},(n,r)=>M(`span`,{className:(0,V.cn)(`h-1 flex-1 rounded-full`,r<t?bi[e]:`bg-border`)},r))})}function Si({card:e,onDelete:t}){let n=R(e=>e.groups),r=R(e=>e.groupByCardId),i=R(e=>e.moveCardToGroup),a=r[e.id]??null;return N(j,{children:[n.length>0&&N(gr,{children:[N(_r,{children:[M(me,{}),s(`Move to group`,`В группу`)]}),M(vr,{children:n.map(t=>N($,{onClick:()=>i(e.id,t.id),children:[t.id===a?M(ie,{}):M(pe,{}),t.name]},t.id))})]}),a!==null&&N($,{onClick:()=>i(e.id,null),children:[M(ye,{}),s(`Move to Unsorted`,`В «Неразобранное»`)]}),(n.length>0||a!==null)&&M(hr,{}),N($,{variant:`destructive`,"data-testid":`pixso-card-delete`,onClick:t,children:[M(Fe,{}),s(`Delete card`,`Удалить карточку`)]})]})}function Ci({card:e,open:t,onOpenChange:n}){let r=R(e=>e.removeCard);return M(nr,{open:t,onOpenChange:n,children:N(sr,{className:`max-w-sm`,showCloseButton:!1,children:[N(cr,{children:[N(ur,{children:[s(`Delete card`,`Удалить карточку`),` «`,e.name,`»?`]}),M(dr,{children:s(`The decoded card and its stored DSL are removed for good — there is no undo. Re-scanning the node in Pixso imports it again.`,`Разобранная карточка и её сохранённый DSL удаляются безвозвратно — отменить нельзя. Повторный скан узла в Pixso импортирует её заново.`)})]}),N(lr,{children:[M(H,{variant:`ghost`,onClick:()=>n(!1),children:s(`Cancel`,`Отмена`)}),M(H,{variant:`destructive`,"data-testid":`pixso-card-delete-confirm`,onClick:()=>{r(e.id),n(!1)},children:s(`Delete`,`Удалить`)})]})]})})}const wi=e=>({simple:s(`Simple`,`Простой`),medium:s(`Medium`,`Средний`),complex:s(`Complex`,`Сложный`)})[e]??e;function Ti({card:e,onOpen:t,className:n}){let r={band:e.complexityBand,filled:e.complexityFilled},i=e.instanceTotal,a=e.deprecatedUsed,[o,c]=A(!1);return N(_i,{children:[N(vi,{render:M(`div`,{role:`button`,tabIndex:0,"data-testid":`pixso-card`,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:(0,V.cn)(`group cursor-pointer overflow-hidden rounded-lg border border-border bg-card text-left transition-colors hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,n)}),children:[N(`div`,{className:`relative`,children:[M($n,{state:Zn(e.previewSvg),alt:e.name,fit:`cover`,focus:e.height>e.width*1.2?`top`:`center`,className:`h-24 w-full border-b border-border/60`}),M(`span`,{onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:N(fr,{children:[M(pr,{render:M(H,{size:`icon-xs`,variant:`ghost`,"aria-label":`${s(`Card actions`,`Действия карточки`)} ${e.name}`,className:`absolute right-1 top-1 bg-card/80 opacity-0 backdrop-blur-sm transition-opacity focus-visible:opacity-100 group-hover:opacity-100 data-popup-open:opacity-100`}),children:M(ue,{className:`size-3.5`})}),M(mr,{align:`end`,children:M(Si,{card:e,onDelete:()=>c(!0)})})]})})]}),N(`div`,{className:`px-2.5 pb-2.5 pt-2`,children:[N(`div`,{className:`flex items-center gap-1.5`,children:[M(`span`,{className:`truncate text-xs font-semibold`,children:e.name}),M(jt.Badge,{variant:`outline`,size:`sm`,className:`shrink-0 text-xs`,children:Ut(e).label}),a>0&&M(`span`,{title:`${s(`Uses deprecated components`,`Использует устаревшие компоненты`)}: ${a}`,className:`flex shrink-0 items-center text-warning`,children:M(Ie,{className:`size-3`})})]}),N(`div`,{className:`mt-0.5 truncate font-mono text-xs tabular-nums text-muted-foreground/70`,children:[Math.round(e.width),`×`,Math.round(e.height),` · `,e.layerCount,` `,s(`layers`,`слоёв`),i>0&&` · ${i} ${s(`comp.`,`комп.`)}`,` ·`,` `,Yn(e.importedAtIso)]}),N(`div`,{className:`mt-2 flex items-center gap-2`,children:[M(xi,{band:r.band,filled:r.filled,className:`flex-1`}),M(`span`,{className:`shrink-0 text-xs text-muted-foreground/70`,children:wi(r.band)})]}),M(Ar,{colors:[...e.colors],className:`mt-2`})]})]}),M(yi,{children:M(Si,{card:e,onDelete:()=>c(!0)})}),M(Ci,{card:e,open:o,onOpenChange:c})]})}function Ei({card:e,className:t}){let n=R(e=>e.openDetail),{attributes:r,listeners:i,setNodeRef:a,isDragging:o}=rt({id:`card:${e.id}`,data:{type:`card`,cardId:e.id}});return M(`div`,{ref:a,...r,...i,className:(0,V.cn)(`touch-none transition-opacity`,o&&`opacity-30 grayscale-[30%]`,t),children:M(Ti,{card:e,onOpen:()=>n(e.id),className:`h-full`})})}function Di(e){let t=`calc(50% - 4px)`,n=`<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><rect y="0" height="${e.rowHeight}" rx="8" ry="8" style="width:${t}"/><rect y="0" height="${e.rowHeight}" rx="8" ry="8" style="width:${t};x:calc(50% + 4px)"/></svg>`,r=`url("data:image/svg+xml;utf8,${encodeURIComponent(n)}")`,i=`100% ${Rr(e)}px`;return{maskImage:r,maskSize:i,maskRepeat:`repeat-y`,WebkitMaskImage:r,WebkitMaskSize:i,WebkitMaskRepeat:`repeat-y`}}const Oi={columns:2,rowHeight:182,rowGap:8};function ki({cards:e}){let t=Ue(null),n=zr(e.length,Oi.columns),{start:r,end:i,metrics:a}=Ur(t,n,Oi,6),o=k(()=>{let t=[];for(let n=r;n<i;n+=1){let r=n*a.columns;t.push(M(`div`,{className:`absolute inset-x-0 grid grid-cols-2 grid-rows-1 gap-2`,style:{top:Vr(n,a),height:a.rowHeight},children:e.slice(r,r+a.columns).map(e=>M(Ei,{card:e,className:`h-full`},e.id))},n))}return t},[e,r,i,a]),s=Math.floor(e.length/a.columns),c=e.length%a.columns!==0;return N(`div`,{ref:t,className:`relative`,style:{height:Br(n,a)},children:[s>0&&M(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 bg-muted`,style:{height:Br(s,a),...Di(a)}}),c&&M(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 rounded-lg bg-muted`,style:{top:Vr(s,a),height:a.rowHeight,width:`calc(50% - 4px)`}}),o]})}function Ai({group:e,onRename:t,onDelete:n}){let r=R(e=>e.toggleGroupPinned),i=R(e=>e.groups),a=R(e=>e.moveGroup),o=i.findIndex(t=>t.id===e.id),c=o<=0,l=o===i.length-1;return N(j,{children:[N($,{onClick:t,children:[M(Ee,{}),s(`Rename`,`Переименовать`)]}),N($,{onClick:()=>r(e.id),children:[e.pinned?M(Oe,{}):M(De,{}),e.pinned?s(`Unpin`,`Открепить`):s(`Pin`,`Закрепить`)]}),M(hr,{}),N($,{disabled:c,onClick:()=>a(e.id,`top`),children:[M(te,{}),s(`Move to top`,`В начало`)]}),N($,{disabled:c,onClick:()=>a(e.id,`up`),children:[M(ee,{}),s(`Move up`,`Выше`)]}),N($,{disabled:l,onClick:()=>a(e.id,`down`),children:[M(w,{}),s(`Move down`,`Ниже`)]}),M(hr,{}),N($,{variant:`destructive`,onClick:n,children:[M(Fe,{}),s(`Delete group…`,`Удалить группу…`)]})]})}function ji(){let e=R(e=>e.unsortedPinned);return N($,{onClick:R(e=>e.toggleUnsortedPinned),children:[M(e?Oe:De,{}),e?s(`Unpin (move below groups)`,`Открепить (вниз, под группы)`):s(`Pin to top`,`Закрепить сверху`)]})}function Mi({group:e,cards:t,cardDragActive:n}){let r=R(e=>e.renameGroup),i=R(e=>e.toggleGroupCollapsed),a=R(e=>e.unsortedPinned),o=R(e=>e.unsortedCollapsed),c=R(e=>e.toggleUnsortedCollapsed),[l,u]=A(!1),[d,f]=A(``),[p,m]=A(!1),h=ct({id:e?.id??`unsorted-sortable-placeholder`,data:{type:`group`},disabled:e===null}),g=it({id:`drop:${e?.id??`unsorted`}`,data:{type:`card-drop`,groupId:e?.id??null}}),_=e?.collapsed??o,v=e?.pinned??a,y=g.isOver&&n,b=()=>{e!==null&&(f(e.name),u(!0))},x=()=>{if(e===null)return;let t=d.trim();t!==``&&t!==e.name&&r(e.id,t),u(!1)},S=()=>{e===null?c():i(e.id)};return N(`section`,{ref:h.setNodeRef,"data-testid":`pixso-group-section`,style:{transform:ut.Transform.toString(h.transform),transition:h.transition},className:(0,V.cn)(`group/section`,h.isDragging&&`z-10 opacity-60`),children:[N(`div`,{ref:g.setNodeRef,className:(0,V.cn)(`rounded-xl border border-transparent transition-all duration-150`,n&&`border-border/60 bg-muted/20`,y&&`border-primary/50 bg-primary/6 ring-2 ring-primary/30`),children:[N(_i,{children:[N(vi,{render:M(`div`,{className:`flex h-8 select-none items-center gap-1 px-1`}),children:[e===null?M(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground/50`,children:M(ye,{className:`size-3.5`})}):M(`button`,{type:`button`,"aria-label":s(`Reorder group`,`Изменить порядок группы`),...h.attributes,...h.listeners,className:`flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/40 opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover/section:opacity-100 active:cursor-grabbing`,children:M(ge,{className:`size-3.5`})}),l&&e!==null?N(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 px-1 py-0.5`,children:[M(T,{className:(0,V.cn)(`size-3.5 shrink-0 text-muted-foreground/60 transition-transform duration-150`,_&&`-rotate-90`)}),M(yr.Input,{autoFocus:!0,size:`sm`,value:d,onValueChange:f,onKeyDown:e=>{e.key===`Enter`&&x(),e.key===`Escape`&&u(!1)},onBlur:x,className:`h-6 max-w-48`,"aria-label":s(`Group name`,`Название группы`)}),v&&M(De,{className:`size-3 shrink-0 fill-primary/20 text-primary`}),M(rn,{tone:t.length===0?`zero`:`default`,children:t.length})]}):N(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent/40`,onClick:S,"aria-expanded":!_,children:[M(T,{className:(0,V.cn)(`size-3.5 shrink-0 text-muted-foreground/60 transition-transform duration-150`,_&&`-rotate-90`)}),M(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e?.name??s(`Unsorted`,`Неразобранное`)}),v&&M(De,{className:`size-3 shrink-0 fill-primary/20 text-primary`}),M(rn,{tone:t.length===0?`zero`:`default`,children:t.length})]}),N(fr,{children:[M(pr,{render:M(H,{size:`icon-xs`,variant:`ghost`,"aria-label":`${s(`Group actions`,`Действия группы`)} ${e?.name??s(`Unsorted`,`Неразобранное`)}`,className:`opacity-0 focus-visible:opacity-100 group-hover/section:opacity-100 data-popup-open:opacity-100`}),children:M(ue,{className:`size-3.5`})}),M(mr,{align:`end`,children:e===null?M(ji,{}):M(Ai,{group:e,onRename:b,onDelete:()=>m(!0)})})]})]}),M(yi,{children:e===null?M(ji,{}):M(Ai,{group:e,onRename:b,onDelete:()=>m(!0)})})]}),!_&&M(`div`,{className:`px-1 pb-1.5`,children:t.length===0?M(`div`,{"data-testid":`pixso-group-dropzone`,className:(0,V.cn)(`flex h-16 items-center justify-center rounded-lg border border-dashed border-border/70 text-[13px] text-muted-foreground/50 transition-colors`,y&&`border-primary/60 text-primary`),children:y?s(`Drop here`,`Отпустите здесь`):e===null?s(`No unsorted cards`,`Неразобранных карточек нет`):s(`Empty group — drag cards here`,`Пустая группа — перетащите карточки сюда`)}):M(ki,{cards:t})}),_&&y&&M(`div`,{className:`px-2 pb-1.5 text-[13px] text-primary`,children:s(`Drop to add to the collapsed group`,`Отпустите — карточка попадёт в свёрнутую группу`)})]}),e!==null&&M(Sr,{group:e,cardCount:t.length,open:p,onOpenChange:m})]})}function Ni({card:e}){let t=Ir(),n=Ue(null);return He(()=>{let e=n.current;if(e===null)return;let r=()=>t.setRowHeight(Math.round(e.getBoundingClientRect().height)),i=new ResizeObserver(r);return i.observe(e),r(),()=>i.disconnect()},[t]),M(`div`,{"aria-hidden":!0,className:`pointer-events-none relative h-0 overflow-hidden`,children:M(`div`,{ref:n,className:`absolute w-48`,children:M(Ti,{card:e,onOpen:()=>{}})})})}var Pi=t({});import*as Fi from"@smart-tools/qwen-cli-ui-kit";e(Pi,Fi);const Ii=e=>{if(e.active.data.current?.type===`card`){let t=e.droppableContainers.filter(e=>e.data.current?.type===`card-drop`),n=tt({...e,droppableContainers:t});return n.length>0?n:nt({...e,droppableContainers:t})}return et({...e,droppableContainers:e.droppableContainers.filter(e=>e.data.current?.type===`group`)})};function Li(){let e=R(e=>e.cards),t=R(e=>e.snapshotPhase),n=R(e=>e.snapshotError),r=R(e=>e.refreshSnapshot),i=R(e=>e.groups),a=R(e=>e.groupByCardId),o=R(e=>e.searchQuery),c=R(e=>e.setSearchQuery),l=R(e=>e.setTab),u=R(e=>e.moveCardToGroup),d=R(e=>e.reorderGroups),[f,p]=A(null),[m,h]=A(!1),g=ot(at($e,{activationConstraint:{distance:4}})),_=R(e=>e.unsortedPinned),v=R(e=>e.unsortedCollapsed),y=f?.type===`card`,b=k(()=>gi(i,e,a,o,{unsortedPinned:_,includeEmptyUnsorted:y}),[i,e,a,o,_,y]),x=k(()=>i.map(e=>e.id),[i]),S=k(()=>b.map(e=>e.group===null?`unsorted:${v?1:0}:${e.cards.length}`:`${e.group.id}:${e.group.collapsed?1:0}:${e.cards.length}`).join(`|`),[b,v]);if(t!==`loaded`)return n===null?M(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:Array.from({length:4},(e,t)=>M(Q.Skeleton,{className:`h-36 w-full rounded-lg`},t))}):M(`div`,{className:`p-3`,"data-testid":`pixso-gallery-error`,children:M(si,{title:s(`Failed to load the gallery`,`Не удалось загрузить галерею`),message:n,recommendations:[s(`The imported cards are on disk — only this load failed`,`Импортированные карточки на диске — не удалась только загрузка`),s(`If the app is still starting up, the panel refreshes itself`,`Если приложение ещё запускается, панель обновится сама`)],actions:M(H,{variant:`outline`,size:`xs`,onClick:r,children:s(`Retry`,`Повторить`)})})});if(e.length===0&&i.length===0)return N(Pi.Empty,{className:`py-10`,children:[N(Pi.EmptyHeader,{children:[M(Pi.EmptyMedia,{variant:`icon`,children:M(ve,{})}),M(Pi.EmptyTitle,{className:`text-base`,children:s(`Gallery is empty`,`Галерея пуста`)}),M(Pi.EmptyDescription,{className:`text-xs`,children:s(`Imported nodes appear here as cards with structure, colors and fonts.`,`Импортированные узлы появятся здесь карточками со структурой, цветами и шрифтами.`)})]}),M(H,{variant:`outline`,size:`sm`,onClick:()=>l(`import`),children:s(`Import a node`,`Импортировать узел`)})]});let C=t=>{let n=t.active.data.current;if(n?.type===`card`){let t=e.find(e=>e.id===n.cardId)??null;t!==null&&p({type:`card`,card:t});return}let r=i.find(e=>e.id===t.active.id)??null;r!==null&&p({type:`group`,group:r})},w=e=>{let{active:t,over:n}=e;if(p(null),n===null)return;let r=t.data.current;if(r?.type===`card`){let e=n.data.current;if(e?.type!==`card-drop`)return;let t=String(r.cardId),i=e.groupId??null;i!==(a[t]??null)&&u(t,i);return}r?.type===`group`&&n.id!==t.id&&d(String(t.id),String(n.id))};return N(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[N(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2.5`,children:[M(yr.Input,{type:`search`,value:o,onValueChange:e=>c(e),placeholder:s(`Search imported nodes…`,`Поиск по импортированным узлам…`),size:`sm`,className:`flex-1 text-xs`,"aria-label":s(`Search the gallery`,`Поиск по галерее`)}),N(H,{variant:`outline`,size:`sm`,className:`shrink-0`,"data-testid":`pixso-new-group-button`,onClick:()=>h(!0),children:[M(he,{}),s(`Group`,`Группа`)]})]}),N(Lr,{layoutKey:S,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[e.length>0&&M(Ni,{card:e[0]}),N(Ze,{sensors:g,collisionDetection:Ii,onDragStart:C,onDragEnd:w,onDragCancel:()=>p(null),children:[M(`div`,{className:`flex flex-col gap-1.5`,children:M(st,{items:x,strategy:lt,children:b.map(e=>M(Mi,{group:e.group,cards:e.cards,cardDragActive:y},e.group?.id??`unsorted`))})}),b.length===0&&M(`p`,{className:`py-6 text-center text-xs text-muted-foreground/60`,children:s(`Nothing matches the search.`,`По запросу ничего не найдено.`)}),N(Qe,{dropAnimation:{duration:180,easing:`ease-out`},children:[f?.type===`card`&&M(`div`,{className:`w-48 rotate-2 cursor-grabbing shadow-2xl shadow-black/25`,children:M(Ti,{card:f.card,onOpen:()=>{}})}),f?.type===`group`&&N(`div`,{className:(0,V.cn)(`flex h-8 w-64 cursor-grabbing items-center gap-1.5 rounded-lg border border-primary/40 bg-card px-2 shadow-xl shadow-black/20`),children:[M(ge,{className:`size-3.5 text-muted-foreground/60`}),M(`span`,{className:`truncate text-xs font-semibold`,children:f.group.name})]})]})]})]}),M(xr,{open:m,onOpenChange:h})]})}function Ri(e,t,n,r){return r===null?t?e<n?`done`:e===n?`active`:`pending`:`done`:e<r?`done`:e===r?`failed`:`pending`}function zi({state:e}){return e===`done`?M(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-success/10 text-success-foreground`,children:M(ie,{className:`size-3`})}):e===`active`?M(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary`,children:M(xe,{className:`size-3 animate-spin`})}):e===`failed`?M(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-destructive/10 text-destructive`,children:M(Re,{className:`size-3`})}):M(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted/30`,children:M(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/30`})})}function Bi({running:e,currentStep:t,failedStep:n}){return N(`div`,{className:`relative rounded-xl border border-border/70 bg-background p-3`,"data-testid":`pixso-import-stepper`,children:[M(`span`,{"aria-hidden":!0,className:`absolute bottom-6 left-[21.5px] top-6 w-px bg-border/70`}),M(`div`,{className:`relative flex flex-col gap-3`,children:li.map((r,i)=>{let a=Ri(i,e,t,n);return N(`div`,{className:`flex items-center gap-2.5`,children:[M(`span`,{className:`relative z-10 shrink-0 bg-background py-0.5`,children:M(zi,{state:a})}),M(`span`,{className:(0,V.cn)(`min-w-0 text-[13px] transition-colors`,a===`pending`&&`text-muted-foreground/60`,a===`active`&&`font-medium text-foreground`,a===`done`&&`text-foreground/80`,a===`failed`&&`font-medium text-destructive`),children:r.label()})]},r.detail)})})]})}function Vi({index:e,icon:t,title:n,detail:r}){return N(`div`,{className:`flex items-start gap-2.5`,children:[M(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-primary/10 text-xs font-semibold text-primary`,children:e}),N(`div`,{className:`min-w-0`,children:[N(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[M(t,{className:`size-3.5 shrink-0 text-muted-foreground`}),n]}),M(`p`,{className:`mt-0.5 text-[13px] leading-snug text-muted-foreground/70`,children:r})]})]})}function Hi(){return N(`div`,{className:`rounded-xl border border-border/70 bg-muted/20 p-3`,children:[N(`div`,{className:`flex flex-col gap-3`,children:[M(Vi,{index:1,icon:C,title:s(`Open Pixso`,`Откройте Pixso`),detail:s(`Launch the desktop app and enable Pixso MCP in the file menu.`,`Запустите десктоп-приложение и включите Pixso MCP в меню файла.`)}),M(Vi,{index:2,icon:Ce,title:s(`Select ONE frame`,`Выделите ОДИН фрейм`),detail:s(`Click the frame you need on the canvas — everything inside it is scanned automatically.`,`Кликните нужный фрейм на холсте — всё, что внутри него, попадёт в скан автоматически.`)}),M(Vi,{index:3,icon:Me,title:s(`Press “Scan”`,`Нажмите «Сканировать»`),detail:s(`The panel connects for the duration of the scan, reads the selection and builds the card.`,`Панель подключится на время скана, прочитает выделение и соберёт карточку.`)})]}),N(`div`,{className:`mt-3 flex items-start gap-1.5 rounded-md border border-warning/30 bg-warning/8 px-2 py-1.5 text-[13px] leading-snug text-foreground/80`,children:[M(Ie,{className:`mt-px size-3.5 shrink-0 text-warning`}),s(`Select exactly one frame. If several frames are selected, the scan is rejected and asks you to pick one.`,`Выделяйте ровно один фрейм: при нескольких выделенных скан будет отклонён с просьбой выбрать один.`)]})]})}function Ui(e,t,n){switch(e){case`success`:return null;case`mcp-down`:return{tone:`danger`,title:s(`Could not connect to Pixso MCP`,`Не удалось подключиться к Pixso MCP`),message:t??``,recommendations:[s(`Start the Pixso app on this machine`,`Запустите приложение Pixso на этой машине`),s(`Enable Pixso MCP in the file menu`,`Включите Pixso MCP в меню файла`),s(`Make sure port 3667 is not taken by another process`,`Убедитесь, что порт 3667 не занят другим процессом`)]};case`tool-timeout`:return{tone:`danger`,title:s(`The selection read timed out`,`Чтение выделения не уложилось в таймаут`),message:t??``,recommendations:[s(`The selection is probably too large — select a smaller frame or a single block`,`Скорее всего, выделение слишком большое — выделите фрейм поменьше или отдельный блок`),s(`Retry — every scan opens a fresh connection`,`Повторите скан — каждая попытка открывает новое соединение`),s(`If it keeps happening, restart Pixso`,`Если повторяется — перезапустите Pixso`)]};case`dsl-error`:return{tone:`danger`,title:s(`Pixso returned an error for the selection`,`Pixso вернул ошибку на чтение выделения`),message:t??``,recommendations:[s(`Re-select the frame and retry`,`Выделите фрейм заново и повторите скан`),s(`Re-open the file in Pixso if it repeats`,`Если повторяется — переоткройте файл в Pixso`)]};case`empty-selection`:return{tone:`danger`,title:s(`Nothing is selected in Pixso`,`В Pixso ничего не выделено`),message:t??``,recommendations:[s(`Click a frame on the canvas — its border should highlight`,`Кликните фрейм на холсте — его рамка должна подсветиться`),s(`Then press “Scan” again`,`Затем нажмите «Сканировать» ещё раз`)]};case`multi-selection`:return{tone:`danger`,title:s(`Several frames are selected`,`Выделено несколько фреймов`),message:t??``,recommendations:[s(`Select exactly ONE frame and rescan`,`Выделите ровно ОДИН фрейм и повторите скан`),s(`Icons and small elements inside the frame need no separate selection — they are scanned automatically`,`Иконки и мелкие элементы внутри фрейма выделять не нужно — они попадут в скан автоматически`)]};case`parse-error`:return{tone:`danger`,title:s(`Could not parse the DSL`,`Не удалось разобрать ответ Pixso`),message:t??``,recommendations:[s(`Retry the scan`,`Повторите скан`),s(`If it repeats, contact the developers for diagnostics`,`Если повторяется — свяжитесь с разработчиками для диагностики`)]};case`components-error`:return{tone:`danger`,title:s(`Could not fetch the components catalog`,`Не удалось получить каталог компонентов`),message:t??``,recommendations:[s(`Retry — the card is not created without the components catalog`,`Повторите скан — карточка не создаётся без каталога компонентов`),s(`Every scan opens a fresh connection`,`Каждая попытка открывает новое соединение`)]};case`internal-error`:return{tone:`danger`,title:s(`Internal scan error`,`Внутренняя ошибка скана`),message:t??``,recommendations:[s(`Select a simpler frame and retry`,`Выделите более простой фрейм и повторите скан`),s(`If it repeats, contact the developers for diagnostics`,`Если повторяется — свяжитесь с разработчиками для диагностики`)]};case`success-warnings`:return{tone:`warning`,title:s(`Imported with a warning`,`Импортировано с предупреждением`),message:t??``,recommendations:[s(`Some component instances have no library links on the card`,`У части экземпляров компонентов на карточке нет ссылок на библиотеку`),s(`Connect the library in Pixso and rescan to resolve them`,`Подключите библиотеку в Pixso и повторите скан, чтобы они разрешились`)]};case`reimport`:return{tone:`info`,title:s(`This node is already imported`,`Этот узел уже импортирован`),message:n===null?s(`The card is already in the gallery`,`Карточка уже есть в галерее`):`${n} ${s(`is already in the gallery`,`уже есть в галерее`)}`,recommendations:[s(`Open the existing card — nothing was duplicated`,`Откройте существующую карточку — дубликат не создавался`),s(`A changed node (even by one bit) becomes a NEW card on scan`,`Изменённый узел (даже на один бит) при скане станет НОВОЙ карточкой`)]}}}function Wi({children:e}){return M(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:e})}function Gi(){return N(`div`,{className:`overflow-hidden rounded-lg border border-border bg-card`,children:[M(Q.Skeleton,{className:`h-24 w-full rounded-none`}),N(`div`,{className:`flex flex-col gap-2 px-2.5 pb-2.5 pt-2`,children:[M(Q.Skeleton,{className:`h-3.5 w-2/5 rounded-full`}),M(Q.Skeleton,{className:`h-2.5 w-3/5 rounded-full`}),M(Q.Skeleton,{className:`h-1.5 w-full rounded-full`})]})]})}function Ki(){let e=R(e=>e.scanJob),t=R(e=>e.runImport),n=R(e=>e.openDetail),r=R(e=>e.openDiagnostics),i=R(e=>e.recents),a=R(e=>e.cards),o=e.phase===`running`,c=e.phase===`settled`?e:null,l=i.map(e=>a.find(t=>t.id===e)).filter(e=>e!==void 0),u=l[0]??null,d=c?.cardId==null?null:a.find(e=>e.id===c.cardId)??null,f=c===null?null:Ui(c.outcome,c.detail,d?.name??u?.name??null),p=c===null?null:ui(c.outcome),m=c!==null&&(p===`success`||p===`warning`),h=o?e.step:c?.failedStep??li.length-1;return N(`div`,{className:`flex min-h-full flex-col`,children:[M(Hi,{}),N(`div`,{className:`mt-5 flex flex-col items-center gap-1.5`,children:[N(H,{size:`lg`,onClick:t,disabled:o,className:`px-7 shadow-lg shadow-primary/20`,"data-testid":`pixso-scan-button`,children:[o?M(Lt.Spinner,{className:`size-4`}):M(Me,{}),o?s(`Scanning…`,`Сканируем…`):s(`Scan the selection`,`Сканировать выделенное`)]}),M(`span`,{className:`text-xs text-muted-foreground/60`,children:s(`Connects only for the duration of the scan`,`Соединение открывается только на время скана`)})]}),(o||c!==null)&&M(`div`,{className:`mt-4`,children:M(Bi,{running:o,currentStep:h,failedStep:c?.failedStep??null})}),f!==null&&M(si,{className:`mt-3`,tone:f.tone,title:f.title,message:f.message,recommendations:f.recommendations,actions:p===`duplicate`?d!==null&&M(H,{variant:`outline`,size:`xs`,onClick:()=>n(d.id),children:s(`Open the card`,`Открыть карточку`)}):N(j,{children:[M(H,{variant:`outline`,size:`xs`,onClick:t,children:s(`Retry`,`Повторить`)}),Tt()&&M(H,{variant:`outline`,size:`xs`,onClick:r,children:s(`Open diagnostics`,`Открыть диагностику`)})]})}),N(`div`,{className:`mt-5`,children:[M(Wi,{children:o?s(`Importing…`,`Импортируем…`):m?s(`Imported — the assembled card`,`Импортировано — собранная карточка`):s(`Recent scans`,`Недавние сканы`)}),o?N(`div`,{className:`grid grid-cols-2 gap-2`,children:[M(Gi,{}),u!==null&&M(Ti,{card:u,onOpen:()=>n(u.id)})]}):l.length>0?M(`div`,{className:`grid grid-cols-2 gap-2`,children:l.map(e=>M(Ti,{card:e,onOpen:()=>n(e.id)},e.id))}):M(`p`,{className:`text-[13px] text-muted-foreground/60`,children:s(`Nothing imported yet — select a frame in Pixso and scan.`,`Пока ничего не импортировано — выделите фрейм в Pixso и сканируйте.`)})]})]})}function qi({children:e}){return M(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:e})}function Ji({onClose:e,mode:t=`sidebar`}){let n=R(e=>e.view),r=R(e=>e.activeTab),i=R(e=>e.setTab),a=R(e=>e.openDiagnostics),o=R(e=>e.backToTabs),c=R(e=>e.refreshSnapshot),l=R(e=>e.applyScanJobState),u=R(e=>e.gallerySyncing);return O(()=>(c(),I().client.subscribeScan(l)),[c,l]),M(Et.DiffPanelShell,{mode:t,header:N(j,{children:[N(`div`,{className:`flex min-w-0 items-center gap-2`,children:[M(Te,{className:`size-4 text-muted-foreground`}),M(`h2`,{className:`truncate text-sm font-semibold`,children:`Pixso`})]}),N(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[Tt()&&M(kt.Toggle,{variant:`outline`,size:`xs`,pressed:n===`diagnostics`,onPressedChange:()=>n===`diagnostics`?o():a(),"aria-label":s(`Diagnostics & settings`,`Диагностика и настройки`),"data-testid":`pixso-diagnostics-toggle`,children:M(Pe,{className:`size-3`})}),M(kt.Toggle,{variant:`outline`,size:`xs`,pressed:!1,onPressedChange:e,"aria-label":s(`Close the Pixso panel`,`Закрыть панель Pixso`),children:M(Re,{className:`size-3`})})]})]}),className:`bg-card`,children:N(`div`,{style:{display:`contents`},"data-testid":`pixso-panel-root`,"data-pixso-syncing":u?`true`:`false`,children:[M(wt,{}),n===`diagnostics`?M(hi,{}):N(B.Tabs,{value:r,onValueChange:e=>i(e),className:`min-h-0 flex-1`,children:[N(B.TabsList,{className:`shrink-0 border-b border-border px-2`,children:[M(B.TabsTab,{value:`import`,onClick:()=>i(`import`),children:s(`Import`,`Импорт`)}),M(B.TabsTab,{value:`gallery`,onClick:()=>i(`gallery`),children:s(`Gallery`,`Галерея`)}),M(B.TabsIndicator,{})]}),n===`detail`?M(ei,{}):N(j,{children:[M(B.TabsPanel,{value:`import`,children:M(qi,{children:M(Ki,{})})}),M(B.TabsPanel,{value:`gallery`,children:M(Li,{})})]})]})]})})}export{Ji as PixsoAssistantPanel,i as configurePixsoAssistantLocale,ht as configurePixsoAssistantPorts,St as resetPixsoAuthority};
1
+ import{n as e,t}from"../chunk-CbfVNrr-.mjs";import{t as n}from"../galleryState-DvtxfQ-P.mjs";import{L as r,LT as i,PIXSO_MCP_ENDPOINT as a,PIXSO_REMOTE_MCP_ENDPOINT as o,buildPromptPayload as s,buildRowOffsets as c,catalogComponentCount as l,catalogItemKey as u,catalogRowKey as d,collectColors as f,collectFonts as p,collectTokenedColors as m,complexityOf as h,configurePixsoAssistantLocale as g,countCatalogComponents as _,cssForNode as v,currentLocaleTag as y,displayColor as b,estimateTokens as x,findNode as S,findParent as C,findPath as w,flattenTree as T,formatEntryTitle as ee,gapsOf as te,isDeprecatedEntry as ne,isTokenBacked as re,matchesCatalogQuery as ie,maxDepth as ae,paddingOf as oe,parseDesignUrl as se,planCatalogList as ce,pxLineHeight as le,relativeOffset as ue,resolveCatalogIdentities as de,resolveLibraryLabels as fe,setLatestUpdatedAt as pe,setSizeRangeLabel as me,shapeOf as he,singletonBody as ge,sizeLabel as _e,totalRowsHeight as ve,visibleRowRange as ye}from"@smart-tools/pixso-core";import{AppWindowIcon as be,ArrowDownIcon as xe,ArrowUpIcon as Se,ArrowUpToLineIcon as Ce,BlocksIcon as we,ChartColumnIcon as Te,CheckIcon as E,ChevronDownIcon as Ee,ChevronLeftIcon as De,ChevronRightIcon as Oe,ComponentIcon as ke,CopyIcon as Ae,CornerLeftUpIcon as je,CrosshairIcon as Me,EllipsisVerticalIcon as Ne,ExternalLinkIcon as D,EyeIcon as Pe,FlaskConicalIcon as Fe,FolderIcon as Ie,FolderInputIcon as Le,FolderPlusIcon as Re,GlobeIcon as ze,GripVerticalIcon as Be,ImageOffIcon as Ve,ImagesIcon as He,InboxIcon as Ue,KeyRoundIcon as We,LinkIcon as Ge,ListTreeIcon as Ke,LoaderIcon as qe,MessageSquareCodeIcon as Je,MonitorIcon as Ye,MousePointerClickIcon as Xe,PaletteIcon as Ze,PenToolIcon as Qe,PencilIcon as $e,PinIcon as et,PinOffIcon as tt,PlayIcon as nt,PlusIcon as rt,RefreshCwIcon as it,ScanIcon as at,SearchIcon as ot,SettingsIcon as st,ShieldCheckIcon as ct,SquareAsteriskIcon as lt,Trash2Icon as ut,TriangleAlertIcon as O,UnplugIcon as dt,UserRoundIcon as ft,WrenchIcon as pt,XIcon as mt}from"lucide-react";import{createContext as ht,useCallback as gt,useContext as _t,useEffect as k,useLayoutEffect as vt,useMemo as A,useRef as yt,useState as j,useSyncExternalStore as bt}from"react";import{create as xt}from"zustand";import{mergeProps as St}from"@base-ui/react/merge-props";import{useRender as Ct}from"@base-ui/react/use-render";import{cva as wt}from"class-variance-authority";import{useCopyToClipboard as Tt}from"@smart-tools/qwen-cli-ui-kit";import{Dialog as M}from"@base-ui/react/dialog";import{Fragment as N,jsx as P,jsxs as F}from"react/jsx-runtime";import{getSharedHighlighter as Et}from"@pierre/diffs";import{Menu as I}from"@base-ui/react/menu";import{DndContext as Dt,DragOverlay as Ot,PointerSensor as kt,closestCenter as At,pointerWithin as jt,rectIntersection as Mt,useDraggable as Nt,useDroppable as Pt,useSensor as Ft,useSensors as It}from"@dnd-kit/core";import{SortableContext as Lt,useSortable as Rt,verticalListSortingStrategy as zt}from"@dnd-kit/sortable";import{CSS as Bt}from"@dnd-kit/utilities";import{ContextMenu as Vt}from"@base-ui/react/context-menu";function Ht(e){return`pixso:${e}`}function Ut(e){return{id:Ht(e.key),sectionId:`pixso:${e.cardId}`,sectionTitle:`Pixso · ${e.cardName}`,filePath:`pixso/${e.cardName}`,startIndex:0,endIndex:0,rangeLabel:e.shortLabel,text:e.label,diff:e.payload,fenceLanguage:e.fenceLanguage}}let Wt=null;const Gt=e=>{Wt=e};function L(){if(Wt===null)throw Error(`PixsoAssistant: ports are not configured — call configurePixsoAssistantPorts() at the host seam`);return Wt}const Kt=()=>L().useResolvedTheme(),qt=()=>L().useActiveComposerTarget(),Jt=[{label:()=>r(`Connect to MCP`,`Подключение к MCP`),detail:a},{label:()=>r(`Read the selection`,`Чтение выделения`),detail:`get_node_dsl`},{label:()=>r(`Components catalog`,`Каталог компонентов`),detail:`get_all_components`},{label:()=>r(`Parse & assemble the card`,`Разбор и сборка карточки`),detail:`parser`}];function Yt(e){let t=Math.min(e.done+1,Math.max(e.total,1));return`${r(`Fetching additional node`,`Запрос дополнительной ноды`)} ${String(t)}/${String(e.total)}`}function Xt(e,t){return t===null?e:[...e.slice(0,2),{label:()=>Yt(t),detail:`get_node_dsl (nodes)`},...e.slice(2)]}function Zt(e,t){return t&&e===1?2:e>=2?e+1:e}function Qt(e){let t=e.fetched.length+e.failed.length;return{done:t,total:t}}function $t(e){switch(e){case`success`:return`success`;case`success-warnings`:return`warning`;case`reimport`:return`duplicate`;case`components-error`:case`mcp-down`:case`tool-timeout`:case`dsl-error`:case`empty-selection`:case`multi-selection`:case`parse-error`:case`internal-error`:case`access-denied`:case`cancelled`:return`error`}}function en(e,t){return e===t?!0:e===null||t===null?!1:typeof e==`string`||typeof t==`string`?e===t:e.environmentId===t.environmentId&&e.threadId===t.threadId}const tn=(e,t)=>n=>n.key===e&&en(n.attachedTo,t);function nn(e){e.attachedTo!==null&&L().composer.removeReviewComment(e.attachedTo,Ht(e.key))}const rn=e=>e instanceof Error?e.message:String(e),R=e=>t=>{L().toastError(e,rn(t))},an={phase:`idle`,raw:null,failKind:null,toolCount:null,latencyMs:null},on=/(?<![\w-])401(?![\w.])|unauthoriz/i,sn=e=>e.httpStatus===401||e.httpStatus===403?!0:e.detail!==null&&on.test(e.detail),cn=e=>{let t=typeof e==`object`&&e&&`httpStatus`in e&&typeof e.httpStatus==`number`?e.httpStatus:null;return sn({detail:e instanceof Error?e.message:String(e),httpStatus:t})?`auth`:`network`},z=xt((e,t)=>{let n=0,i=null;return{source:`remote`,setSource:t=>e({source:t,sourceHydratedOnce:!0}),sourceHydratedOnce:!1,settingsOpen:!1,openSettings:()=>e({settingsOpen:!0}),closeSettings:()=>e({settingsOpen:!1}),tokenStatus:`none`,tokenTail:null,tokenSavedAgo:null,tokenWasReset:!1,authRaw:null,hydrateFromSnapshot:n=>{let r=t().tokenStatus,i=t().sourceHydratedOnce?{}:{source:n.remoteByDefault??!0?`remote`:`local`,sourceHydratedOnce:!0};if(r===`verifying`||r===`dead`){e({remoteByDefault:n.remoteByDefault??!0,...i});return}e({tokenStatus:n.remoteTokenSet===!0?`verified`:`none`,remoteByDefault:n.remoteByDefault??!0,...i})},wizardOpen:!1,openWizard:()=>e({wizardOpen:!0,verify:an}),closeWizard:()=>e({wizardOpen:!1,verify:an}),verify:an,verifyToken:r=>{if(t().verify.phase===`checking`)return;let i=n;e({verify:{phase:`checking`,raw:null,failKind:null,toolCount:null,latencyMs:null}}),L().client.remoteTokenCheck(r).then(r=>{i!==n||t().verify.phase!==`checking`||e({verify:{phase:`ok`,raw:null,failKind:null,toolCount:r.toolCount,latencyMs:r.latencyMs}})}).catch(r=>{i!==n||t().verify.phase!==`checking`||e({verify:{phase:`fail`,raw:r instanceof Error?r.message:String(r),failKind:cn(r),toolCount:null,latencyMs:null}})})},resetVerify:()=>e({verify:an}),saveToken:t=>{let i=t.trim();n+=1;let a=n;L().client.remoteTokenSave(i).then(()=>{a===n&&e({tokenStatus:`verified`,tokenTail:i.slice(-4),tokenSavedAgo:`только что`,tokenWasReset:!1,authRaw:null})}).catch(e=>{a===n&&R(r(`Failed to save the token`,`Не удалось сохранить токен`))(e)})},deleteToken:()=>{n+=1;let t=n;L().client.remoteTokenDelete().then(()=>{t===n&&(i!==null&&(i(),i=null),e({tokenStatus:`none`,tokenTail:null,tokenSavedAgo:null,tokenWasReset:!0,authRaw:null,designUrl:``,scan:{phase:`idle`},verify:an}))}).catch(e=>{t===n&&R(r(`Failed to delete the token`,`Не удалось удалить токен`))(e)})},recheckToken:()=>{if(t().tokenStatus===`verifying`)return;let r=n;e({tokenStatus:`verifying`}),L().client.remoteTokenCheck().then(()=>{r!==n||t().tokenStatus!==`verifying`||e({tokenStatus:`verified`,authRaw:null})}).catch(i=>{r!==n||t().tokenStatus!==`verifying`||e({tokenStatus:`dead`,authRaw:i instanceof Error?i.message:String(i)})})},remoteByDefault:!0,setRemoteByDefault:n=>{let i=t().remoteByDefault;e({remoteByDefault:n}),L().client.remoteModeSet(n).catch(t=>{e({remoteByDefault:i}),R(r(`Failed to save the setting`,`Не удалось сохранить настройку`))(t)})},probeUrl:``,setProbeUrl:t=>e({probeUrl:t}),designUrl:``,setDesignUrl:t=>e({designUrl:t}),scan:{phase:`idle`},runRemoteScan:()=>{if(t().scan.phase===`running`)return;let a=se(t().designUrl);if(a.kind!==`ok`)return;let o=n;i!==null&&(i(),i=null),e({scan:{phase:`running`,step:0}});let{client:s}=L(),c=null,l=t=>{if(o!==n||t.phase===`idle`||c===null||t.startedAtIso!==c)return;if(t.phase===`running`){e({scan:{phase:`running`,step:t.step,...t.nodes===void 0?{}:{nodes:t.nodes}}});return}let r=$t(t.outcome)!==`error`;if(B.getState().refreshSnapshot(),!r&&sn(t)){e({scan:{phase:`settled`,ok:!1,failedStep:t.failedStep,outcome:t.outcome,detail:t.detail,cardId:t.cardId},tokenStatus:`dead`,authRaw:t.detail});return}e({scan:{phase:`settled`,ok:r,failedStep:t.failedStep,outcome:t.outcome,detail:t.detail,cardId:t.cardId,...t.resolvedNodes===void 0?{}:{resolvedNodes:t.resolvedNodes}}})};i=s.subscribeScan(l),s.scanStart({fileKey:a.fileKey,itemId:a.itemId}).then(e=>{o===n&&(c=e.phase===`idle`?null:e.startedAtIso,l(e))},t=>{i!==null&&(i(),i=null),o===n&&(e({scan:{phase:`settled`,ok:!1,failedStep:0,outcome:`empty-selection`,detail:t instanceof Error?t.message:String(t),cardId:null}}),R(r(`Could not start the scan`,`Не удалось запустить скан`))(t))})},cancelRemoteScan:()=>{let t=n;L().client.scanCancel(`remote`).then(r=>{t===n&&r.phase===`idle`&&(i!==null&&(i(),i=null),e({scan:{phase:`idle`}}))}).catch(e=>{t===n&&R(r(`Failed to cancel the scan`,`Не удалось отменить скан`))(e)})},resetScan:()=>{i!==null&&(i(),i=null),e({scan:{phase:`idle`},designUrl:``})},applyRemoteBootReplay:t=>{if(t.phase!==`idle`){if(t.phase===`running`){e({scan:{phase:`running`,step:t.step,...t.nodes===void 0?{}:{nodes:t.nodes}}});return}e({scan:{phase:`settled`,ok:$t(t.outcome)!==`error`,failedStep:t.failedStep,outcome:t.outcome,detail:t.detail,cardId:t.cardId,...t.resolvedNodes===void 0?{}:{resolvedNodes:t.resolvedNodes}}})}}}}),B=xt((e,t)=>{let i=0,a=0,o=null,s=e=>e===`running`?1:e===`settled`?2:0,c=()=>{let e=new Map,t=new Map,n=t=>({global:i,key:e.get(t)??0}),r=(t,n)=>n.global===i&&n.key===(e.get(t)??0);return{claim:e=>{let i=t.get(e);if(i!==void 0&&r(e,i))return null;let a=n(e);return t.set(e,a),a},isLive:r,release:(e,n)=>{t.get(e)===n&&t.delete(e)},evict:t=>{for(let n of t)e.set(n,(e.get(n)??0)+1)}}},l=c(),u=c(),d=c(),f=c(),p=(e,t)=>{let n={},r=new Set,i=new Set;for(let[a,o]of Object.entries(e.details)){if(t.has(a)){o.catalogHash!==null&&i.add(o.catalogHash);continue}n[a]=o,o.catalogHash!==null&&r.add(o.catalogHash)}for(let t of Object.keys(e.catalogs))i.add(t);for(let t of e.catalogErrors)i.add(t);for(let e of r)i.delete(e);let a=Object.fromEntries(Object.entries(e.raws).filter(([e])=>!t.has(e))),o=Object.fromEntries(Object.entries(e.images).filter(([e])=>!t.has(e))),s=Object.fromEntries(Object.entries(e.catalogs).filter(([e])=>r.has(e)));return l.evict(t),u.evict(t),d.evict(t),f.evict(i),{details:n,raws:a,images:o,catalogs:s,detailErrors:new Set([...e.detailErrors].filter(e=>!t.has(e))),rawErrors:new Set([...e.rawErrors].filter(e=>!t.has(e))),imageErrors:new Set([...e.imageErrors].filter(e=>!t.has(e))),catalogErrors:new Set([...e.catalogErrors].filter(e=>!i.has(e)))}},m=(e,t)=>new Set(e).add(t),h=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},g=0,_=0,v=i=>{let o=a,s=t(),c=n({groups:s.groups,groupByCardId:s.groupByCardId,unsortedPinned:s.unsortedPinned,unsortedCollapsed:s.unsortedCollapsed},i),l=new Set(c.removedCardIds);e({groups:c.state.groups,groupByCardId:c.state.groupByCardId,unsortedPinned:c.state.unsortedPinned,unsortedCollapsed:c.state.unsortedCollapsed,...l.size>0?{cards:s.cards.filter(e=>!l.has(e.id)),recents:s.recents.filter(e=>!l.has(e)),...p(s,l)}:{}}),_+=1,_===1&&e({gallerySyncing:!0}),L().client.groupsMutate(i).catch(e=>{o===a&&R(r(`Failed to save the gallery`,`Не удалось сохранить галерею`))(e)}).finally(()=>{o===a&&(--_,_===0&&(e({gallerySyncing:!1}),t().refreshSnapshot()))})};return{view:`tabs`,activeTab:`import`,selectedCardId:null,searchQuery:``,cards:[],groups:[],groupByCardId:{},unsortedPinned:!0,unsortedCollapsed:!1,recents:[],lastCheck:null,lastProbe:null,detailErrors:new Set,lastCheckError:null,lastProbeError:null,lastScanAtIso:null,snapshotPhase:`idle`,snapshotError:null,gallerySyncing:!1,supportsReparse:!1,scanJob:{phase:`idle`},dismissedSettledAtIso:null,dismissLocalOutcome:()=>{let{scanJob:n}=t();n.phase===`settled`&&e({dismissedSettledAtIso:n.settledAtIso})},details:{},raws:{},images:{},catalogs:{},rawErrors:new Set,imageErrors:new Set,catalogErrors:new Set,latestReport:null,connection:`unchecked`,probePhase:`idle`,debugRescanning:!1,debugRescanResult:null,reparsing:!1,lastReparse:null,tray:[],composerTarget:null,setComposerTarget:t=>e(e=>en(e.composerTarget,t)?e:{composerTarget:t}),setTab:t=>e({activeTab:t,view:`tabs`}),openDetail:n=>{e({view:`detail`,selectedCardId:n}),t().loadDetail(n)},openDiagnostics:()=>{e({view:`diagnostics`}),t().loadReport()},backToTabs:()=>e({view:`tabs`}),setSearchQuery:t=>e({searchQuery:t}),resetAuthority:()=>{a+=1,i+=1,g=0,_=0,o=null,e({cards:[],groups:[],groupByCardId:{},unsortedPinned:!0,unsortedCollapsed:!1,recents:[],lastCheck:null,lastProbe:null,lastCheckError:null,lastProbeError:null,lastScanAtIso:null,snapshotPhase:`idle`,snapshotError:null,gallerySyncing:!1,supportsReparse:!1,scanJob:{phase:`idle`},dismissedSettledAtIso:null,details:{},raws:{},images:{},catalogs:{},detailErrors:new Set,rawErrors:new Set,imageErrors:new Set,catalogErrors:new Set,latestReport:null,connection:`unchecked`,probePhase:`idle`,debugRescanning:!1,debugRescanResult:null,reparsing:!1,lastReparse:null})},refreshSnapshot:()=>{if(t().snapshotPhase===`loading`)return;let n=a,i=g+=1;e({...t().snapshotPhase===`loaded`?{}:{snapshotPhase:`loading`},snapshotError:null}),L().client.snapshot().then(r=>{if(n===a&&i===g){if(_>0){t().snapshotPhase===`loading`&&e({snapshotPhase:`idle`});return}e({cards:r.cards,groups:r.groups,groupByCardId:r.groupByCardId,unsortedPinned:r.unsortedPinned,unsortedCollapsed:r.unsortedCollapsed,recents:r.recents,lastCheck:r.lastCheck,lastProbe:r.lastProbe,lastScanAtIso:r.lastScanAtIso,snapshotPhase:`loaded`,snapshotError:null,supportsReparse:r.supportsReparse===!0}),z.getState().hydrateFromSnapshot(r)}}).catch(o=>{n===a&&i===g&&(e({snapshotPhase:t().snapshotPhase===`loaded`?`loaded`:`failed`,snapshotError:rn(o)}),R(r(`Failed to load the gallery`,`Не удалось загрузить галерею`))(o))})},applyScanJobState:n=>{if(`origin`in n&&n.origin===`remote`){z.getState().applyRemoteBootReplay(n);return}let r=`startedAtIso`in n?n.startedAtIso:null,i=s(n.phase);if(o!==null&&r!==null&&(r<o.startedAtIso||r===o.startedAtIso&&i<o.ordinal))return;r!==null&&(o={startedAtIso:r,ordinal:i});let a=t().scanJob;if(e({scanJob:n}),a.phase===`idle`&&t().snapshotPhase!==`loaded`&&t().refreshSnapshot(),n.phase===`running`){e({connection:`checking`});return}if(n.phase===`settled`&&a.phase!==`idle`&&(a.phase!==`settled`||a.settledAtIso!==n.settledAtIso)&&(e({connection:n.outcome===`mcp-down`?`error`:`connected`}),t().refreshSnapshot(),t().loadReport(),n.cardId!==null)){let r=n.cardId,i=t().raws[r]!==void 0;e(e=>p(e,new Set([r])));let{view:a,selectedCardId:o}=t();a===`detail`&&o===r&&(t().loadDetail(r),i&&t().loadRaw(r))}},runImport:()=>{let{scanJob:e}=t();if(e.phase===`running`)return;let n=a;L().client.scanStart().then(e=>{n===a&&t().applyScanJobState(e)}).catch(e=>{n===a&&R(r(`Failed to start the scan`,`Не удалось запустить скан`))(e)})},cancelImport:()=>{let e=a;L().client.scanCancel(`local`).then(n=>{e===a&&t().applyScanJobState(n)}).catch(t=>{e===a&&R(r(`Failed to cancel the scan`,`Не удалось отменить скан`))(t)})},recheck:()=>{if(t().connection===`checking`)return;let n=a;e({connection:`checking`}),L().client.check().then(t=>{n===a&&e({connection:`connected`,lastCheck:t,lastCheckError:null})}).catch(t=>{n===a&&e({connection:`error`,lastCheckError:rn(t)})})},runProbe:()=>{if(t().probePhase===`running`)return;let n=a;e({probePhase:`running`,connection:`checking`}),L().client.probe().then(t=>{n===a&&e({probePhase:`done`,connection:`connected`,lastProbe:t,lastProbeError:null})}).catch(t=>{n===a&&e({probePhase:`failed`,connection:`error`,lastProbeError:rn(t)})})},debugRescan:()=>{if(t().debugRescanning)return;let n=a;e({debugRescanning:!0}),L().client.rescanDebug().then(t=>{if(n!==a)return;let i=t.data.outcome===`success`||t.data.outcome===`success-warnings`,o=t.data.toolTimings.reduce((e,t)=>e+t.ms,0);e({debugRescanning:!1,debugRescanResult:{ok:i,detail:i?`${t.data.cardName??t.data.nodeId??`?`} · ${String(o)} ms`:t.data.toolTimings.find(e=>!e.ok)?.detail??r(`rescan failed`,`пересканирование не удалось`)},latestReport:t,lastScanAtIso:t.atIso})}).catch(t=>{n===a&&(e({debugRescanning:!1,debugRescanResult:{ok:!1,detail:t instanceof Error?t.message:String(t)}}),R(r(`Rescan failed`,`Пересканирование не удалось`))(t))})},loadReport:()=>{let t=a;L().client.reportLatest().then(n=>{t===a&&e({latestReport:n})}).catch(e=>{t===a&&R(r(`Failed to load the report`,`Не удалось загрузить отчёт`))(e)})},runReparse:()=>{if(t().reparsing)return;let n=a;e({reparsing:!0}),L().client.reparse().then(r=>{n===a&&(e({reparsing:!1,lastReparse:r}),i+=1,e({details:{},raws:{},detailErrors:new Set,rawErrors:new Set}),t().refreshSnapshot())}).catch(t=>{n===a&&(e({reparsing:!1}),R(r(`Re-parse failed`,`Перечитать карточки не удалось`))(t))})},loadDetail:n=>{if(t().details[n]!==void 0||t().detailErrors.has(n))return;let i=l.claim(n);if(i===null)return;let o=a;L().client.card(n).then(t=>{o!==a||!l.isLive(n,i)||e(e=>({details:{...e.details,[n]:t},detailErrors:h(e.detailErrors,n)}))}).catch(t=>{o!==a||!l.isLive(n,i)||(e(e=>({detailErrors:m(e.detailErrors,n)})),R(r(`Failed to load the card`,`Не удалось загрузить карточку`))(t))}).finally(()=>l.release(n,i))},retryDetail:n=>{e(e=>({detailErrors:h(e.detailErrors,n)})),t().loadDetail(n)},loadRaw:n=>{if(t().raws[n]!==void 0||t().rawErrors.has(n))return;let i=u.claim(n);if(i===null)return;let o=a;L().client.cardRaw(n).then(({raw:t})=>{o!==a||!u.isLive(n,i)||e(e=>({raws:{...e.raws,[n]:t},rawErrors:h(e.rawErrors,n)}))}).catch(t=>{o!==a||!u.isLive(n,i)||(e(e=>({rawErrors:m(e.rawErrors,n)})),R(r(`Failed to load the DSL`,`Не удалось загрузить DSL`))(t))}).finally(()=>u.release(n,i))},retryRaw:n=>{e(e=>({rawErrors:h(e.rawErrors,n)})),t().loadRaw(n)},loadImage:n=>{if(t().images[n]!==void 0||t().imageErrors.has(n))return;let r=d.claim(n);if(r===null)return;let i=a;L().client.cardImage(n).then(({pngBase64:t})=>{i!==a||!d.isLive(n,r)||e(e=>({images:{...e.images,[n]:t},imageErrors:h(e.imageErrors,n)}))}).catch(()=>{i!==a||!d.isLive(n,r)||e(e=>({imageErrors:m(e.imageErrors,n)}))}).finally(()=>d.release(n,r))},loadCatalog:n=>{if(t().catalogs[n]!==void 0||t().catalogErrors.has(n))return;let i=f.claim(n);if(i===null)return;let o=a;L().client.catalog(n).then(t=>{o!==a||!f.isLive(n,i)||e(e=>({catalogs:{...e.catalogs,[n]:t},catalogErrors:h(e.catalogErrors,n)}))}).catch(t=>{o!==a||!f.isLive(n,i)||(e(e=>({catalogErrors:m(e.catalogErrors,n)})),R(r(`Failed to load the catalog`,`Не удалось загрузить каталог`))(t))}).finally(()=>f.release(n,i))},retryCatalog:n=>{e(e=>({catalogErrors:h(e.catalogErrors,n)})),t().loadCatalog(n)},createGroup:e=>{let t=`group-${crypto.randomUUID()}`;return v({op:`create`,groupId:t,name:e}),t},renameGroup:(e,t)=>v({op:`rename`,groupId:e,name:t}),deleteGroup:(e,{deleteCards:t})=>v({op:`delete`,groupId:e,deleteCards:t}),reorderGroups:(e,t)=>v({op:`reorder`,activeId:e,overId:t}),moveGroup:(e,t)=>v({op:`move`,groupId:e,direction:t}),toggleGroupPinned:e=>v({op:`togglePinned`,groupId:e}),toggleGroupCollapsed:e=>v({op:`toggleCollapsed`,groupId:e}),toggleUnsortedPinned:()=>v({op:`toggleUnsortedPinned`}),toggleUnsortedCollapsed:()=>v({op:`toggleUnsortedCollapsed`}),moveCardToGroup:(e,t)=>v({op:`moveCardToGroup`,cardId:e,groupId:t}),removeCard:n=>{let i=a;e(e=>{let{[n]:t,...r}=e.groupByCardId;return{cards:e.cards.filter(e=>e.id!==n),groupByCardId:r,...p(e,new Set([n])),...e.selectedCardId===n?{view:`tabs`,selectedCardId:null}:{},recents:e.recents.filter(e=>e!==n)}}),_+=1,_===1&&e({gallerySyncing:!0}),L().client.removeCard(n).catch(e=>{i===a&&R(r(`Failed to delete the card`,`Не удалось удалить карточку`))(e)}).finally(()=>{i===a&&(--_,_===0&&(e({gallerySyncing:!1}),t().refreshSnapshot()))})},toggleTrayItem:t=>e(e=>{let n=e.composerTarget,r=e.tray.find(tn(t.key,n));return r===void 0?(n!==null&&L().composer.addReviewComment(n,Ut(t)),{tray:[...e.tray,{...t,attachedTo:n}]}):(nn(r),{tray:e.tray.filter(e=>e!==r)})}),upsertTrayItem:t=>e(e=>{let n=e.composerTarget,r=e.tray.find(tn(t.key,n));return r===void 0||r.payload===t.payload&&r.label===t.label&&r.shortLabel===t.shortLabel&&r.fenceLanguage===t.fenceLanguage?e:(n!==null&&L().composer.addReviewComment(n,Ut(t)),{tray:e.tray.map(e=>e===r?{...t,attachedTo:n}:e)})}),removeTrayItem:t=>e(e=>{let n=e.tray.find(tn(t,e.composerTarget));return n===void 0?e:(nn(n),{tray:e.tray.filter(e=>e!==n)})}),clearTray:()=>e(e=>{let t=e.composerTarget,n=e.tray.filter(e=>en(e.attachedTo,t));if(n.length===0)return e;for(let e of n)nn(e);return{tray:e.tray.filter(e=>!n.includes(e))}}),pruneDetachedTrayItems:()=>e(e=>{let t=L().composer,n=e.tray.filter(e=>e.attachedTo===null?!0:(t.getReviewCommentIds(e.attachedTo)??[]).includes(Ht(e.key)));return n.length===e.tray.length?e:{tray:n}})}}),ln=()=>{B.getState().resetAuthority()};function un(e){return B(t=>t.tray.some(tn(e,t.composerTarget)))}function dn(){let e=B(e=>e.tray),t=B(e=>e.composerTarget);return A(()=>e.filter(e=>en(e.attachedTo,t)),[e,t])}function fn(){let e=B(e=>e.setComposerTarget),t=qt();return k(()=>{e(t),B.getState().pruneDetachedTrayItems()},[t,e]),k(()=>L().composer.subscribe(()=>{B.getState().pruneDetachedTrayItems()}),[]),null}const pn=()=>{try{return globalThis.localStorage.getItem(`debugPixso`)===`true`}catch{return!1}},mn=`pixsoDebugMode`,hn=()=>{try{return globalThis.localStorage.getItem(mn)===`remote`?`remote`:`local`}catch{return`local`}},gn=e=>{try{globalThis.localStorage.setItem(mn,e)}catch{}},_n={phase:`idle`,toolCount:null,latencyMs:null,raw:null},V=xt((e,t)=>{let n=0;return{mode:hn(),setMode:r=>{t().mode!==r&&(n+=1,gn(r),e({mode:r,remoteCheck:_n,remoteTools:null,scanProbe:{phase:`idle`},fullProbe:{phase:`idle`}}))},remoteCheck:_n,runRemoteCheck:()=>{if(t().remoteCheck.phase===`checking`)return;let i=n;e({remoteCheck:{phase:`checking`,toolCount:null,latencyMs:null,raw:null}}),L().client.remoteTokenCheck().then(a=>{i!==n||t().remoteCheck.phase!==`checking`||(e({remoteCheck:{phase:`ok`,toolCount:a.toolCount,latencyMs:a.latencyMs,raw:null}}),L().client.remoteToolsList().then(t=>{i===n&&e({remoteTools:t.tools})}).catch(e=>{i===n&&R(r(`Failed to list remote tools`,`Не удалось получить список инструментов`))(e)}))}).catch(r=>{i!==n||t().remoteCheck.phase!==`checking`||e({remoteCheck:{phase:`fail`,toolCount:null,latencyMs:null,raw:r instanceof Error?r.message:String(r)}})})},remoteTools:null,scanProbe:{phase:`idle`},runRemoteScanProbe:()=>{if(t().scanProbe.phase===`running`)return;let i=se(z.getState().probeUrl);if(i.kind!==`ok`)return;let a=n;e({scanProbe:{phase:`running`}}),L().client.remoteScanProbe({fileKey:i.fileKey,itemId:i.itemId}).then(i=>{if(a!==n||t().scanProbe.phase!==`running`)return;let o=i.data.outcome===`success`||i.data.outcome===`success-warnings`,s=i.data.toolTimings.reduce((e,t)=>e+t.ms,0);e({scanProbe:{phase:`settled`,ok:o,detail:o?`${i.data.cardName??i.data.nodeId??`?`} · ${String(s)} ms`:i.data.toolTimings.find(e=>!e.ok)?.detail??r(`scan failed`,`скан не удался`)}}),B.getState().loadReport()}).catch(r=>{a!==n||t().scanProbe.phase!==`running`||e({scanProbe:{phase:`settled`,ok:!1,detail:r instanceof Error?r.message:String(r)}})})},fullProbe:{phase:`idle`},runRemoteFullProbe:()=>{if(t().fullProbe.phase===`running`)return;let r=se(z.getState().probeUrl);if(r.kind!==`ok`)return;let i=n;e({fullProbe:{phase:`running`}}),L().client.remoteFullProbe({fileKey:r.fileKey,itemId:r.itemId}).then(r=>{i!==n||t().fullProbe.phase!==`running`||e({fullProbe:{phase:`done`,rows:r.rows.map(e=>({tool:e.tool,status:e.status===`ok`||e.status===`empty`?`ok`:`dead`,detail:e.detail})),savedTo:r.savedTo,deviations:r.deviations}})}).catch(r=>{i!==n||t().fullProbe.phase!==`running`||e({fullProbe:{phase:`failed`,raw:r instanceof Error?r.message:String(r)}})})}}});var H=t({});import*as vn from"@smart-tools/qwen-cli-ui-kit";e(H,vn);const yn=wt(`[&_svg]:-mx-0.5 relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-lg border font-medium text-base outline-none transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-9 px-[calc(--spacing(3)-1px)] sm:h-8`,icon:`size-9 sm:size-8`,"icon-lg":`size-10 sm:size-9`,"icon-sm":`size-8 sm:size-7`,"icon-xl":`size-11 sm:size-10 [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,"icon-xs":`size-7 rounded-md before:rounded-[calc(var(--radius-md)-1px)] sm:size-6 not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-4 sm:not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-3.5`,lg:`h-10 px-[calc(--spacing(3.5)-1px)] sm:h-9`,sm:`h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:h-7`,xl:`h-11 px-[calc(--spacing(4)-1px)] text-lg sm:h-10 sm:text-base [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,xs:`h-7 gap-1 rounded-md px-[calc(--spacing(2)-1px)] text-sm before:rounded-[calc(var(--radius-md)-1px)] sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5`},variant:{default:`not-disabled:inset-shadow-[0_1px_--theme(--color-white/16%)] border-primary bg-primary text-primary-foreground shadow-primary/24 shadow-xs [:active,[data-pressed]]:inset-shadow-[0_1px_--theme(--color-black/8%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-primary/90`,destructive:`not-disabled:inset-shadow-[0_1px_--theme(--color-white/16%)] border-destructive bg-destructive text-white shadow-destructive/24 shadow-xs [:active,[data-pressed]]:inset-shadow-[0_1px_--theme(--color-black/8%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-destructive/90`,"destructive-outline":`border-input bg-popover not-dark:bg-clip-padding text-destructive-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:border-destructive/32 [:hover,[data-pressed]]:bg-destructive/4`,ghost:`border-transparent text-foreground data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent [&_svg:not([class*='text-'])]:text-muted-foreground`,link:`border-transparent underline-offset-4 [:hover,[data-pressed]]:underline`,outline:`border-input bg-popover not-dark:bg-clip-padding text-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground`,secondary:`border-transparent bg-secondary text-secondary-foreground [:active,[data-pressed]]:bg-secondary/80 [:hover,[data-pressed]]:bg-secondary/90`}}});function U({className:e,variant:t,size:n,render:r,...i}){let a=r?void 0:`button`;return Ct({defaultTagName:`button`,props:St({className:(0,H.cn)(yn({className:e,size:n,variant:t})),"data-slot":`button`,type:a},i),render:r})}var W=t({});import*as bn from"@smart-tools/qwen-cli-ui-kit";e(W,bn),M.createHandle;const xn=M.Root,Sn=M.Portal;function Cn(e){return P(M.Trigger,{"data-slot":`dialog-trigger`,...e})}function wn({className:e,...t}){return P(M.Backdrop,{forceRender:!0,className:(0,H.cn)(`fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`dialog-backdrop`,...t})}function Tn({className:e,...t}){return P(M.Viewport,{className:(0,H.cn)(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,e),"data-slot":`dialog-viewport`,...t})}function En({className:e,children:t,showCloseButton:n=!0,bottomStickOnMobile:i=!0,...a}){return F(Sn,{children:[P(wn,{}),P(Tn,{className:(0,H.cn)(i&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`),children:F(M.Popup,{className:(0,H.cn)(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover not-dark:bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg/5 transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,i&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none`,e),"data-slot":`dialog-popup`,...a,children:[t,n&&P(M.Close,{"aria-label":r(`Close`,`Закрыть`),className:`absolute end-2 top-2`,render:P(U,{size:`icon`,variant:`ghost`}),children:P(mt,{})})]})})]})}function Dn({className:e,...t}){return P(`div`,{className:(0,H.cn)(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`dialog-header`,...t})}function On({className:e,variant:t=`default`,...n}){return P(`div`,{className:(0,H.cn)(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t===`default`&&`border-t bg-muted/72 py-4`,t===`bare`&&`in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6`,e),"data-slot":`dialog-footer`,...n})}function kn({className:e,...t}){return P(M.Title,{className:(0,H.cn)(`font-heading font-semibold text-xl leading-none`,e),"data-slot":`dialog-title`,...t})}function An({className:e,...t}){return P(M.Description,{className:(0,H.cn)(`text-muted-foreground text-sm`,e),"data-slot":`dialog-description`,...t})}function jn({className:e,scrollFade:t=!0,...n}){return P(W.ScrollArea,{scrollFade:t,children:P(`div`,{className:(0,H.cn)(`p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:has([data-slot=dialog-footer]:not(.border-t))]:pb-1`,e),"data-slot":`dialog-panel`,...n})})}var Mn=t({});import*as Nn from"@smart-tools/qwen-cli-ui-kit";e(Mn,Nn);var G=t({});import*as Pn from"@smart-tools/qwen-cli-ui-kit";e(G,Pn);var Fn=t({});import*as In from"@smart-tools/qwen-cli-ui-kit";e(Fn,In);var Ln=t({});import*as Rn from"@smart-tools/qwen-cli-ui-kit";e(Ln,Rn);const zn={none:`neutral`,verifying:`info`,verified:`success`,dead:`danger`};function Bn(e){switch(e){case`none`:return r(`not set`,`не задан`);case`verifying`:return r(`checking…`,`проверяем…`);case`verified`:return r(`active`,`активен`);case`dead`:return r(`rejected`,`отклонён`)}}function Vn(){let e=z(e=>e.tokenStatus),t=z(e=>e.tokenTail),n=z(e=>e.tokenSavedAgo),i=z(e=>e.authRaw),a=z(e=>e.openWizard),o=z(e=>e.recheckToken),s=z(e=>e.deleteToken),[c,l]=j(!1),u=e===`verified`||e===`dead`;return F(`div`,{className:(0,H.cn)(`rounded-xl border px-3.5 py-3 transition-colors`,e===`verified`&&`border-success/24 bg-success/4`,e===`dead`&&`border-destructive/30 bg-destructive/4`,(e===`none`||e===`verifying`)&&`border-border/70 bg-background`),"data-testid":`pixso-token-card`,"data-token-status":e,children:[F(`div`,{className:`flex items-center gap-3`,children:[P(`span`,{className:`grid w-4 shrink-0 place-items-center`,children:e===`verifying`?P(G.Spinner,{className:`size-3 text-info`}):P(Fn.StatusDot,{tone:zn[e],size:`sm`})}),P(`span`,{className:(0,H.cn)(`grid size-8 shrink-0 place-items-center rounded-lg border border-border/70 bg-muted/60 text-muted-foreground`,e===`verified`&&`border-success/24 bg-success/8 text-success-foreground`,e===`dead`&&`border-destructive/30 bg-destructive/8 text-destructive`),children:P(We,{className:`size-4`})}),F(`div`,{className:`min-w-0 flex-1`,children:[F(`div`,{className:`flex items-center gap-2`,children:[P(`span`,{className:`text-[13px] font-semibold text-foreground`,children:`Access token`}),P(`span`,{className:(0,H.cn)(`font-mono text-[10px] font-semibold uppercase tracking-[0.06em]`,e===`verified`&&`text-success-foreground`,e===`dead`&&`text-destructive`,e===`verifying`&&`text-info`,e===`none`&&`text-muted-foreground/60`),children:Bn(e)})]}),F(`div`,{className:`mt-0.5 break-words text-xs text-muted-foreground`,children:[u?P(`span`,{className:`font-mono`,children:`pix_••••${t??``}`}):e===`verifying`?r(`asking the server (tools/list)…`,`запрашиваем сервер (tools/list)…`):r(`Needed for remote access to pixso.`,`Нужен для удалённого доступа к pixso.`),u&&n!==null?F(`span`,{children:[` · `,r(`saved`,`сохранён`),` `,n]}):null]})]}),e===`none`?F(U,{size:`sm`,onClick:a,"data-testid":`pixso-settings-create-token`,children:[P(We,{}),r(`Create a token`,`Создать токен`)]}):null,u?F(N,{children:[P(U,{variant:`outline`,size:`xs`,onClick:a,"data-testid":`pixso-settings-new-token`,children:r(`Create new`,`Создать новый`)}),P(U,{variant:`ghost`,size:`icon-xs`,"aria-label":r(`Delete the token`,`Удалить токен`),onClick:()=>l(!0),"data-testid":`pixso-token-delete`,children:P(ut,{})})]}):null]}),e===`dead`?F(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-2 border-t border-destructive/20 pt-2.5`,children:[P(`p`,{className:`min-w-0 flex-1 font-mono text-xs leading-relaxed text-destructive/80`,children:i??`401 Unauthorized`}),F(U,{variant:`outline`,size:`xs`,onClick:o,"data-testid":`pixso-settings-recheck`,children:[P(it,{}),r(`Check`,`Проверить`)]})]}):null,P(xn,{open:c,onOpenChange:l,children:F(En,{className:`max-w-sm`,showCloseButton:!1,children:[F(Dn,{children:[P(kn,{children:r(`Delete the token?`,`Удалить токен?`)}),P(An,{children:r(`The remote setup on the Import tab will be reset. Local scans keep working as before.`,`Настройка удалённого доступа на вкладке «Импорт» будет сброшена. Локальные сканы продолжат работать как раньше.`)})]}),F(On,{children:[P(U,{variant:`ghost`,onClick:()=>l(!1),children:r(`Cancel`,`Отмена`)}),P(U,{variant:`destructive`,"data-testid":`pixso-token-delete-confirm`,onClick:()=>{s(),l(!1)},children:r(`Delete`,`Удалить`)})]})]})})]})}function Hn(){let e=z(e=>e.remoteByDefault),t=z(e=>e.setRemoteByDefault);return F(`div`,{className:`flex items-start justify-between gap-3 rounded-xl border border-border/70 bg-background px-3.5 py-3`,"data-testid":`pixso-remote-default-card`,children:[F(`div`,{className:`min-w-0`,children:[P(Mn.Label,{htmlFor:`pixso-remote-default`,className:`text-[13px]`,children:r(`Remote mode by default`,`Удалённый режим по умолчанию`)}),P(`p`,{className:`mt-0.5 text-xs leading-snug text-muted-foreground/70`,children:r(`The Import tab opens in “Remote” — the switch on the tab still works either way.`,`Вкладка «Импорт» открывается в режиме «Удалённо» — переключатель на вкладке работает в любом случае.`)})]}),P(Ln.Switch,{id:`pixso-remote-default`,checked:e,onCheckedChange:t,"aria-label":r(`Remote mode by default`,`Удалённый режим по умолчанию`),"data-testid":`pixso-remote-default-switch`})]})}function Un(){let e=z(e=>e.closeSettings);return F(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`pixso-settings-view`,children:[P(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:F(U,{variant:`ghost`,size:`sm`,onClick:e,children:[P(De,{className:`size-4`}),r(`Back`,`Назад`)]})}),F(`div`,{className:`block min-h-0 flex-1 overflow-y-auto p-3`,children:[P(`h3`,{className:`text-sm font-semibold`,children:r(`Pixso settings`,`Настройки Pixso`)}),P(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:r(`Remote access to pixso. The token is stored encrypted.`,`Удалённый доступ к pixso. Токен хранится в зашифрованном виде.`)}),F(`div`,{className:`mt-3 flex flex-col gap-3`,children:[P(Vn,{}),P(Hn,{})]})]})]})}const Wn={danger:{box:`border-destructive/30 bg-destructive/6`,title:`text-destructive`,message:`text-destructive/75`,marker:`marker:text-destructive/40`},warning:{box:`border-warning/40 bg-warning/8`,title:`text-warning`,message:`text-warning/80`,marker:`marker:text-warning/50`},info:{box:`border-info/40 bg-info/8`,title:`text-info`,message:`text-info/80`,marker:`marker:text-info/50`}},Gn={danger:`danger`,warning:`warning`,info:`info`};function K({title:e,message:t,recommendations:n,actions:r,tone:i=`danger`,className:a}){let o=Wn[i];return F(`div`,{className:(0,H.cn)(`rounded-lg border px-3 py-2.5`,o.box,a),role:`alert`,children:[F(`div`,{className:(0,H.cn)(`flex items-center gap-2 text-xs font-medium`,o.title),children:[P(Fn.StatusDot,{tone:Gn[i],size:`sm`}),e]}),t!==``&&P(`p`,{className:(0,H.cn)(`mt-1.5 break-words font-mono text-[13px] leading-relaxed`,o.message),"data-testid":`pixso-outcome-message`,children:t}),P(`ul`,{className:(0,H.cn)(`mt-2 list-disc space-y-1 pl-4 text-xs text-foreground/75`,o.marker),children:n.map((e,t)=>P(`li`,{children:e},t))}),r!==void 0&&P(`div`,{className:`mt-2.5 flex items-center gap-2`,children:r})]})}var q=t({});import*as Kn from"@smart-tools/qwen-cli-ui-kit";e(q,Kn);function qn({total:e,current:t,className:n}){return F(`div`,{className:(0,H.cn)(`flex items-center gap-1.5`,n),"data-slot":`wizard-steps`,children:[P(`span`,{className:`sr-only`,children:r(`Step ${String(t+1)} of ${String(e)}`,`Шаг ${String(t+1)} из ${String(e)}`)}),Array.from({length:e},(e,n)=>P(`span`,{"aria-hidden":!0,className:(0,H.cn)(`h-1 flex-1 rounded-full transition-colors duration-300`,n<t?`bg-success`:n===t?`bg-primary`:`bg-border`)},n))]})}const Jn=`https://company-pixso.com`;function Yn({index:e,icon:t,title:n,detail:r}){return F(`div`,{className:`flex items-start gap-2.5`,children:[P(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-primary/10 text-xs font-semibold text-primary`,children:e}),F(`div`,{className:`min-w-0`,children:[F(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[P(t,{className:`size-3.5 shrink-0 text-muted-foreground`}),n]}),P(`p`,{className:`mt-0.5 text-[13px] leading-snug text-muted-foreground/70`,children:r})]})]})}function Xn(){return F(`a`,{href:Jn,target:`_blank`,rel:`noreferrer`,"data-testid":`pixso-token-page-link`,className:`inline-flex items-center gap-1 font-medium text-primary underline-offset-2 hover:underline`,children:[Jn.replace(/^https?:\/\//,``),P(D,{className:`size-3`})]})}function Zn({title:e,description:t}){return F(`div`,{className:`flex flex-col items-center gap-3 py-4 text-center`,children:[P(`span`,{className:`grid size-14 place-items-center rounded-full bg-success/10 text-success-foreground`,children:P(E,{className:`size-7`})}),P(`div`,{className:`text-[15px] font-semibold text-foreground`,children:e}),P(`p`,{className:`max-w-sm text-[13px] leading-relaxed text-muted-foreground`,children:t})]})}function Qn({onClose:e}){let t=z(e=>e.verify),n=z(e=>e.verifyToken),i=z(e=>e.resetVerify),a=z(e=>e.saveToken),[o,s]=j(0),[c,l]=j(``);return F(N,{children:[F(Dn,{children:[F(`div`,{className:`flex items-start gap-3`,children:[P(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-primary/8 text-primary`,children:P(We,{className:`size-4.5`})}),F(`div`,{className:`min-w-0`,children:[P(kn,{className:`text-lg`,children:r(`Create an access token`,`Создайте access token`)}),P(An,{className:`mt-1`,children:r(`The panel will connect to pixso on your behalf — one token, created once.`,`Панель будет подключаться к pixso от вашего имени — токен создаётся один раз.`)})]})]}),P(qn,{className:`mt-3`,current:o,total:3})]}),F(jn,{className:`space-y-4`,children:[o===0?F(N,{children:[P(`div`,{className:`rounded-xl border border-border/70 bg-muted/20 p-3`,children:F(`div`,{className:`flex flex-col gap-3`,children:[P(Yn,{index:1,icon:D,title:r(`Open the pixso link`,`Перейдите по ссылке pixso`),detail:P(Xn,{})}),P(Yn,{index:2,icon:ft,title:r(`Click your avatar`,`Нажмите на аватар пользователя`),detail:r(`In the top-right corner — the profile menu opens.`,`В правом верхнем углу — откроется меню профиля.`)}),P(Yn,{index:3,icon:Xe,title:r(`Access token → Generate token`,`Access token → Generate token`),detail:r(`Choose “Access token”, then press “Generate token”.`,`Выберите пункт «Access token» и нажмите «Generate token».`)}),P(Yn,{index:4,icon:lt,title:r(`Copy the value`,`Сохраните значение`),detail:r(`Copy the generated value into the field below.`,`Скопируйте сгенерированное значение в поле ниже.`)})]})}),F(`div`,{className:`space-y-1.5`,children:[P(Mn.Label,{htmlFor:`pixso-token-input`,children:`Access token`}),P(q.Input,{id:`pixso-token-input`,"data-testid":`pixso-token-input`,type:`password`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-[13px]`,placeholder:`pix_…`,value:c,onChange:e=>{l(e.target.value),i()}}),P(`p`,{className:`text-xs text-muted-foreground/80`,children:r(`The token is stored encrypted.`,`Токен хранится в зашифрованном виде.`)})]})]}):null,o===1?F(N,{children:[P(`p`,{className:`text-[13px] leading-relaxed text-muted-foreground`,children:r(`The panel will connect to the Pixso server.`,`Панель подключится к серверу Pixso.`)}),F(`div`,{className:`flex items-start gap-2 rounded-lg border border-info/40 bg-info/8 px-3 py-2.5 text-[13px] leading-snug text-foreground/80`,children:[P(ct,{className:`mt-px size-3.5 shrink-0 text-info`}),r(`Nothing is saved until the check passes.`,`Токен не сохраняется, пока проверка не пройдёт.`)]}),t.phase===`checking`?F(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-muted/30 px-3 py-2.5 text-[13px] text-muted-foreground`,"data-testid":`pixso-token-verify-loading`,children:[P(G.Spinner,{className:`size-4`}),r(`Checking the token…`,`Проверяем токен…`)]}):null,t.phase===`ok`?P(`div`,{className:`rounded-lg border border-success/30 bg-success/8 px-3 py-2.5`,"data-testid":`pixso-token-verify-ok`,children:F(`div`,{className:`flex items-center gap-2 text-xs font-medium text-success-foreground`,children:[P(E,{className:`size-3.5`}),r(`The server is reachable`,`Сервер доступен`)]})}):null,t.phase===`fail`&&t.failKind===`auth`?P(`div`,{"data-testid":`pixso-token-verify-fail-auth`,children:P(K,{title:r(`The server rejected the token`,`Сервер отклонил токен`),message:t.raw??``,recommendations:[r(`Generate a new token in pixso — this one expired or was revoked`,`Сгенерируйте новый токен в pixso — этот истёк или был отозван`),r(`Check that you copied the whole value`,`Проверьте, что скопировали значение целиком`)]})}):null,t.phase===`fail`&&t.failKind!==`auth`?P(`div`,{"data-testid":`pixso-token-verify-fail-network`,children:P(K,{title:r(`Could not reach the server`,`Сервер недоступен — проверить токен не удалось`),message:t.raw??``,recommendations:[r(`Check the network and that the pixso server is reachable (VPN, proxy)`,`Проверьте сеть и доступность сервера pixso (VPN, прокси)`),r(`The token was not judged — retry once the connection is back`,`Токен ни при чём — сервер не ответил; повторите, когда связь появится`)]})}):null]}):null,o===2?P(Zn,{title:r(`Token saved`,`Токен сохранён`),description:r(`It is stored encrypted on this computer. You can delete or replace it any time in the Pixso settings.`,`Хранится в зашифрованном виде на этом компьютере. Удалить или заменить его можно в любой момент в настройках Pixso.`)}):null]}),F(On,{children:[o===1?P(U,{className:`me-auto`,variant:`ghost`,onClick:()=>s(0),children:r(`Back`,`Назад`)}):null,o===0?P(U,{"data-testid":`pixso-token-check`,disabled:c.trim().length===0,onClick:()=>{s(1),n(c)},children:r(`Check the token`,`Проверить токен`)}):null,o===1?t.phase===`fail`?P(U,{variant:`outline`,onClick:()=>n(c),children:r(`Retry`,`Повторить`)}):F(U,{"data-testid":`pixso-token-save`,disabled:t.phase!==`ok`,onClick:()=>{a(c),s(2)},children:[t.phase===`checking`?P(G.Spinner,{}):null,r(`Save the token`,`Сохранить токен`)]}):null,o===2?P(U,{onClick:e,children:r(`Done`,`Готово`)}):null]})]})}function $n(){let e=z(e=>e.wizardOpen),t=z(e=>e.closeWizard);return P(xn,{open:e,onOpenChange:e=>e?void 0:t(),children:P(En,{"data-testid":`pixso-token-wizard`,children:e?P(Qn,{onClose:t}):null})})}var er=t({});import*as tr from"@smart-tools/qwen-cli-ui-kit";e(er,tr);var J=t({});import*as nr from"@smart-tools/qwen-cli-ui-kit";e(J,nr);var rr=t({});import*as ir from"@smart-tools/qwen-cli-ui-kit";e(rr,ir);var ar=t({});import*as or from"@smart-tools/qwen-cli-ui-kit";e(ar,or);var sr=t({});import*as cr from"@smart-tools/qwen-cli-ui-kit";e(sr,cr);function lr(e){let t=new Set,n=(e,r)=>{let i=e.type===`instance`||e.type===`symbol`?r+1:r;i>0&&t.add(e.id);for(let t of e.children??[])n(t,i)};return n(e,0),t}function ur(e){let t=new Map((e.componentsUsed??[]).map(e=>[e.key,e])),n=T(e.root),r=lr(e.root),i=n.map(({node:e,depth:n})=>{let r=e.component?.key===void 0?void 0:t.get(e.component.key);return{id:e.id,depth:n,name:e.name,type:e.type,text:e.text?.trim()||null,componentName:r?.name??null,library:r?.library??null,caption:r?.description??null,width:Math.round(e.width),height:Math.round(e.height),url:e.links?.[0]?.url??null}}),a=new Map;for(let e of i)a.set(e.type,(a.get(e.type)??0)+1);let o=i.map(e=>e.text).filter(e=>e!==null);return{rows:i,nodesByType:[...a.entries()].map(([e,t])=>({type:e,count:t})).sort((e,t)=>t.count-e.count),depth:ae(e.root),copy:o,copyWordCount:o.join(` `).split(/\s+/).filter(Boolean).length,componentCoverage:i.length===0?0:Math.round(r.size/i.length*100),libraries:[...new Set((e.componentsUsed??[]).map(e=>e.library).filter(e=>e!==null))],deprecatedCount:(e.componentsUsed??[]).filter(e=>e.deprecated).length,designerUrls:n.flatMap(({node:e})=>(e.links??[]).map(t=>({node:e.name,url:t.url})))}}function dr(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].map(([e,t])=>({url:e,count:t}))}function fr(e,t){if(e.length<=t)return e;if(t<=1)return`…`;let n=t-1,r=Math.ceil(n/2),i=n-r;return`${e.slice(0,r)}…${i===0?``:e.slice(e.length-i)}`}function pr(e){try{let t=new URL(e);return t.host===``?null:`${t.protocol}//${t.host}`}catch{return null}}function mr(e,t=72){if(e.length<=t)return e;let n=pr(e);return n===null||n.length+2>t?fr(e,t):`${n}…${e.slice(e.length-(t-n.length-1))}`}function hr(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}function gr(e){switch(e){case`frame`:return r(`Frame`,`Фрейм`);case`group`:return r(`Group`,`Группа`);case`text`:case`paragraph`:case`span`:return r(`Text`,`Текст`);case`rect`:case`ellipse`:case`vector`:case`line`:return r(`Shape`,`Фигура`);case`mask`:return r(`Mask`,`Маска`);case`instance`:return r(`Component`,`Компонент`);case`symbol`:return r(`Master component`,`Эталон компонента`);default:return r(`Layer`,`Слой`)}}function _r(e){return e.nodeType===`instance`&&e.identity.componentName!==null?{label:e.identity.componentName,library:e.identity.library,deprecated:e.identity.deprecated}:e.nodeType===`symbol`?{label:r(`Master component`,`Эталон компонента`),library:null,deprecated:!1}:{label:gr(e.nodeType),library:null,deprecated:!1}}function vr(e){if(e.type===`instance`){let t=e.root.component?.key,n=t===void 0?void 0:(e.componentsUsed??[]).find(e=>e.key===t);return n===void 0?{label:r(`Component`,`Компонент`),library:null,deprecated:!1}:{label:n.name,library:n.library,deprecated:n.deprecated}}return e.type===`symbol`?{label:r(`Master component`,`Эталон компонента`),library:null,deprecated:!1}:{label:gr(e.type),library:null,deprecated:!1}}const yr=e=>({typography:r(`Typography`,`Типографика`),layout:r(`Spacing & grid`,`Отступы и сетка`),components:r(`Components`,`Компоненты`),behavior:r(`Behavior`,`Поведение`),violations:r(`Violations`,`Нарушения`)})[e];function br(e){let t=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e),n=/^#?([0-9a-f]{6})/i.exec(e);if(t===null&&n===null)return e;let r=n===null?0:parseInt(n[1],16),i=t===null?r>>16&255:Number(t[1]),a=t===null?r>>8&255:Number(t[2]),o=t===null?r&255:Number(t[3]),s=Math.max(i,a,o),c=Math.min(i,a,o),l=(s+c)/2;if((s===c?0:(s-c)/(255-Math.abs(s+c-255)))<.12)return l>235?`белый`:l>190?`светло-серый`:l>110?`серый`:l>45?`тёмно-серый`:`чёрный`;let u=s===i?60*(a-o)/(s-c)+(a<o?360:0):s===a?60*(o-i)/(s-c)+120:60*(i-a)/(s-c)+240,d=u<20||u>=345?`красный`:u<45?`оранжевый`:u<70?`жёлтый`:u<160?`зелёный`:u<200?`бирюзовый`:u<260?`синий`:u<300?`фиолетовый`:`розовый`;return l>190?`светло-${d}`:l<80?`тёмно-${d}`:d}const xr={Light:`тонкий`,Regular:`обычный`,Medium:`средней жирности`,Semibold:`полужирный`,Bold:`жирный`};function Sr(e){let t=String(e.font?.weight??400),n=le(e.textMeta),r=n===null?``:`/${n}px`;return`${t} ${e.font?.size??`?`}px${r} "${e.font?.family??`?`}"`}function Cr(e,t){return`${e.name} → ${t.name} [${t.id}]`}function wr(e){let t=[],n=new Map((e.componentsUsed??[]).map(e=>[e.key,e])),r=0,i=(n,i,a,o,s)=>{r+=1,t.push({id:`${e.id}:qa:${r}`,group:n,nodeId:i,manual:a,auto:{target:o,assertions:s}})};for(let{node:t,parent:r}of T(e.root)){if(t.text!==void 0&&t.text.trim()!==``&&t.font!==void 0){let n=t.font.style,r=(n===void 0?void 0:xr[n])??n??`—`,a=t.textColor===void 0?``:`, цвет ${br(t.textColor)}`,o=t.textMeta?.upperCase===!0?`, все буквы ЗАГЛАВНЫЕ`:``;i(`typography`,t.id,`Текст «${t.text.trim()}» — ${r}, размер как в макете${a}${o}.`,Cr(e,t),[`font: ${Sr(t)}`,...t.textColor===void 0?[]:[`color: ${t.textColor}`],...t.textMeta?.letterSpacing===void 0?[]:[`letter-spacing: ${t.textMeta.letterSpacing.value}${t.textMeta.letterSpacing.unit}`],...t.textMeta?.upperCase===!0?[`text-transform: uppercase`]:[]])}if(t.layout!==void 0&&(t.children??[]).length>=2){let n=t.layout.mode===`vertical`?`друг под другом`:`в один ряд`,r=t.layout.gap===null?``:`, расстояние между ними одинаковое (${t.layout.gap})`;i(`layout`,t.id,`Блок «${t.name}» — элементы стоят ${n}${r}, ничего не прилипает к краям.`,Cr(e,t),[`display: flex`,`flex-direction: ${t.layout.mode===`vertical`?`column`:`row`}`,...t.layout.gap===null?[]:[`gap: ${t.layout.gap}px`],...t.layout.padding===null?[]:[`padding: ${t.layout.padding.top}px ${t.layout.padding.right}px ${t.layout.padding.bottom}px ${t.layout.padding.left}px`]])}if(t.component?.key!==void 0){let r=n.get(t.component.key);if(r!==void 0){let n=r.props.map(e=>e.kind===`visible`?`${e.name} — ${e.value===`on`?`показан`:`скрыт`}`:`${e.name}: «${e.value}»`).join(`; `);i(`components`,t.id,`Компонент «${r.name}»${n===``?``:` — ${n}`}.`,Cr(e,t),[`component: ${r.name}${r.variantGroup===null?``:` (${r.variantGroup})`}`,...r.props.map(e=>`prop ${e.name} = ${e.kind===`text`?`"${e.value}"`:e.value}`)])}}if(t.sticky===!0&&i(`behavior`,t.id,`«${t.name}» остаётся на месте при прокрутке страницы.`,Cr(e,t),[`position: fixed`]),t.mask===!0||t.type===`mask`){let n=r?.children?.find(e=>e.id!==t.id);i(`behavior`,t.id,`Содержимое блока «${r?.name??t.name}» обрезано по форме маски${n===void 0?``:` (виден только «${n.name}» внутри неё)`}.`,Cr(e,t),[`overflow: hidden`,...t.radius===void 0?[]:[`border-radius: ${t.radius}px`]])}}for(let t of e.componentsUsed??[])t.deprecated&&i(`violations`,null,`Используется устаревший компонент «${t.name}» — согласовать замену с дизайнером.`,t.name,[`deprecated component: ${t.name}${t.variantGroup===null?``:` (${t.variantGroup})`}`]),!t.resolved&&e.source!==`remote`&&i(`violations`,null,`Компонент «${t.name}» из неподключённой библиотеки — каталожных данных нет.`,t.name,[`unresolved library: ${t.libraryFileKey??`?`}`]);for(let{node:t}of T(e.root))t.fill!==void 0&&!re(t,`fill`)&&t.type!==`instance`&&i(`violations`,t.id,`Цвет заливки «${t.name}» (${br(t.fill)}) не привязан к стилю библиотеки.`,Cr(e,t),[`background: ${t.fill} /* без токена */`]);return t}function Tr(e){let t=ur(e),n=wr(e),r=f(e.root),i=p(e.root),a=e.componentsUsed??[],o=m(e.root),s=[],c=(e,t)=>{let n=e.layout!==void 0&&e.layout.mode!==`unknown`?` — ${e.layout.mode===`vertical`?`колонка`:`ряд`}${e.layout.gap===null?``:`, интервал ${e.layout.gap}`}`:``,r=e.text!==void 0&&e.text.trim()!==``?` — «${e.text.trim()}»`:``;s.push(`${` `.repeat(t)}- ${e.name} (${gr(e.type)}, ${Math.round(e.width)}×${Math.round(e.height)})${n}${r}`);for(let n of e.children??[])c(n,t+1)};return c(e.root,0),[`# ${e.name} — UI-спецификация`,``,`> Источник: Pixso, узел \`${e.id}\`, DSL ${e.dslVersion}. Сгенерировано автоматически из данных скана.`,``,`## 1. Обзор`,``,`- Размер: **${Math.round(e.root.width)}×${Math.round(e.root.height)} px**, слоёв: ${t.rows.length}, глубина: ${t.depth}`,`- Компоненты дизайн-системы: ${a.reduce((e,t)=>e+t.count,0)} экземпляров из ${t.libraries.length} библиотек (покрытие ${t.componentCoverage}%)`,...t.deprecatedCount>0?[`- ⚠ **Использовано устаревших компонентов: ${t.deprecatedCount}** — требуется решение до реализации`]:[],``,`## 2. Структура`,``,...s,``,`## 3. Компоненты`,``,`| Компонент | Набор вариантов | Библиотека | Кол-во | Свойства | Статус |`,`|---|---|---|---|---|---|`,...a.map(t=>{let n=t.props.map(e=>`${e.name}${e.kind===`text`?` = «${e.value}»`:` = ${e.value===`on`?`вкл`:`выкл`}`}`).join(`; `),r=t.deprecated?`⚠ устарел`:t.resolved||e.source===`remote`?`ок`:`библиотека не подключена`;return`| ${t.name} | ${t.variantGroup??`—`} | ${t.library??`—`} | ${t.count} | ${n||`—`} | ${r} |`}),``,`## 4. Типографика`,``,`| Шрифт | Начертание | Размер | Использований |`,`|---|---|---|---|`,...i.map(e=>`| ${e.font.family??`—`} | ${e.font.style??`—`} | ${e.font.size===void 0?`—`:`${String(e.font.size)} px`} | ${e.count} |`),``,`## 5. Цвета`,``,`| HEX | Токен | Где используется |`,`|---|---|---|`,...r.map(e=>`| \`${e.color}\` | ${o.has(e.color)?`✓`:`⚠ без токена`} | ${e.usedBy.join(`, `)} |`),``,`## 6. Поведение`,``,...(()=>{let t=T(e.root),n=[];for(let{node:e}of t)e.sticky===!0&&n.push(`- «${e.name}» закреплён при прокрутке (position: fixed)`),(e.mask===!0||e.type===`mask`)&&n.push(`- Маска в «${e.name}» — содержимое обрезается по её форме`),e.visible===!1&&n.push(`- «${e.name}» скрыт в макете (visible: false)`);return n.length>0?n:[`- Особого поведения не обнаружено.`]})(),``,`## 7. Контент (дословно)`,``,...t.copy.map(e=>`- ${e}`),``,`## 8. Критерии приёмки`,``,...n.map(e=>`- [ ] ${e.manual}`),``,`## 9. Реализация`,``,`- Точная вёрстка: используйте вложение «Спека UI» (HTML-скелет + полный CSS каждого элемента) — прикрепляется из вкладки «Промпт».`,`- Единицы: размеры в px; letter-spacing в % от кегля (переводить в em).`,...t.designerUrls.length>0?[`- Ссылки дизайнера:`,...t.designerUrls.map(e=>` - ${e.node}: ${e.url}`)]:[]].join(`
2
+ `)}const Y={name:`font-medium text-foreground`,type:`font-mono text-info`,geometry:`font-mono text-muted-foreground`,value:`font-mono text-primary`,string:`font-mono text-success`,id:`font-mono text-muted-foreground`};function Er({attached:e,onToggle:t,label:n,className:r}){return P(`button`,{type:`button`,"aria-label":n,"aria-pressed":e,title:n,className:(0,H.cn)(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-md border transition-colors`,e?`border-primary/60 bg-primary/12 text-primary`:`border-border bg-background text-muted-foreground/70 hover:border-primary/40 hover:bg-primary/8 hover:text-primary`,r),onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},children:P(e?E:rt,{className:`size-3`})})}const Dr=1e3;function X({value:e,label:t,className:n}){let i=yt(null),{copyToClipboard:a,isCopied:o}=Tt({timeout:Dr,onCopy:()=>{i.current&&L().anchoredToast({anchor:i.current,timeoutMs:Dr,title:r(`Copied!`,`Скопировано!`)})},onError:e=>{i.current&&L().anchoredToast({anchor:i.current,timeoutMs:Dr,title:r(`Failed to copy`,`Не удалось скопировать`),description:e.message})}});return F(sr.Tooltip,{children:[P(sr.TooltipTrigger,{render:P(`button`,{ref:i,type:`button`,"aria-label":t,disabled:o,className:(0,H.cn)(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,o&&`text-success hover:text-success`,n),onClick:t=>{t.stopPropagation(),a(e)}}),children:P(o?E:Ae,{className:`size-3`})}),P(sr.TooltipPopup,{children:t})]})}const Or={light:`pierre-light`,dark:`pierre-dark`};function kr({code:e,language:t,theme:n,className:r}){let[i,a]=j(null);return k(()=>{let r=!1,i=n===`dark`?Or.dark:Or.light;return Et({themes:[Or.dark,Or.light],langs:[t],preferredHighlighter:`shiki-js`}).then(n=>{if(!r)try{a(n.codeToHtml(e,{lang:t,theme:i}))}catch{a(null)}}).catch(()=>{r||a(null)}),()=>{r=!0}},[e,t,n]),i===null?P(`pre`,{className:(0,H.cn)(`whitespace-pre-wrap break-words px-2.5 py-2 font-mono text-[13px] leading-snug text-muted-foreground`,r),children:e}):P(`div`,{className:(0,H.cn)(`px-2.5 py-2 text-[13px] leading-snug [&_pre]:!m-0 [&_pre]:!bg-transparent [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:font-mono`,r),dangerouslySetInnerHTML:{__html:i}})}var Z=t({});import*as Ar from"@smart-tools/qwen-cli-ui-kit";e(Z,Ar);function jr({children:e,tone:t=`default`,className:n}){return P(`span`,{className:(0,H.cn)(`inline-flex shrink-0 items-center rounded-full border border-border bg-background px-2 py-px font-mono text-xs tabular-nums leading-4`,t===`default`&&`text-muted-foreground`,t===`zero`&&`text-muted-foreground/60`,t===`na`&&`border-warning/40 text-warning`,n),children:e})}function Q({title:e,sublabel:t,count:n,countTone:r=`default`,attachItem:i,headerActions:a,flush:o=!1,defaultOpen:s=!1,onOpenChange:c,children:l,className:u}){let d=B(e=>e.toggleTrayItem),f=un(i?.key??``);return F(Z.Collapsible,{defaultOpen:s,onOpenChange:c,className:(0,H.cn)(`overflow-hidden rounded-lg border border-border bg-card`,u),children:[F(Z.CollapsibleTrigger,{className:`group flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-accent/40`,children:[P(Oe,{className:`size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-data-panel-open:rotate-90`}),P(`span`,{className:`text-xs font-semibold`,children:e}),t!==void 0&&P(`span`,{className:`truncate text-xs text-muted-foreground/60`,children:t}),F(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[a,i!==void 0&&P(Er,{attached:f,label:i.label,onToggle:()=>d(i)}),P(jr,{tone:r,children:n})]})]}),P(Z.CollapsiblePanel,{children:P(`div`,{className:(0,H.cn)(`border-t border-border/60`,!o&&`px-3 pb-3 pt-2`),children:l})})]})}function Mr({card:e,text:t,index:n}){let i=B(e=>e.toggleTrayItem),a={key:`${e.id}:copy:${n}`,label:`${r(`Text`,`Текст`)} «${t.length>40?`${t.slice(0,40)}…`:t}»`,shortLabel:r(`text`,`текст`),cardId:e.id,cardName:e.name,payload:t,fenceLanguage:`text`},o=un(a.key);return F(`div`,{className:`flex min-w-0 items-center gap-1.5 rounded-md border border-border/60 bg-background px-2 py-1`,children:[P(`span`,{className:(0,H.cn)(`min-w-0 flex-1 truncate text-[13px]`,Y.string),children:t}),P(X,{value:t,label:r(`Copy text`,`Скопировать текст`)}),P(Er,{attached:o,label:a.label,onToggle:()=>i(a)})]})}function Nr({usage:e,item:t}){let n=B(e=>e.toggleTrayItem),i=un(t.key);return F(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[13px]`,children:[P(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),e.deprecated&&P(`span`,{className:`shrink-0 text-warning`,children:`⚠`}),F(`span`,{className:`shrink-0 tabular-nums text-muted-foreground/70`,children:[`×`,e.count]}),e.library!==null&&P(`span`,{className:`shrink-0 truncate text-xs text-muted-foreground/60`,children:e.library}),P(`span`,{className:`ml-auto`}),P(X,{value:e.name,label:r(`Copy name`,`Скопировать название`)}),P(Er,{attached:i,label:t.label,onToggle:()=>n(t)})]})}function Pr({label:e,value:t}){return F(`div`,{className:`rounded-md border border-border/60 bg-background px-2 py-1.5`,children:[P(`div`,{className:`text-sm font-semibold tabular-nums`,children:t}),P(`div`,{className:`text-xs text-muted-foreground/70`,children:e})]})}function Fr({card:e}){let t=A(()=>ur(e),[e]),n=A(()=>Tr(e),[e]),i=A(()=>{let e=new Map;for(let n of t.nodesByType){let t=gr(n.type);e.set(t,(e.get(t)??0)+n.count)}return[...e.entries()].map(([e,t])=>({kind:e,count:t})).toSorted((e,t)=>t.count-e.count)},[t.nodesByType]),a=e.componentsUsed??[],o=B(e=>e.toggleTrayItem),s=Kt(),c={key:`${e.id}:pdlc`,label:`${r(`PDLC spec`,`PDLC-спека`)} «${e.name}»`,shortLabel:r(`PDLC spec`,`PDLC-спека`),cardId:e.id,cardName:e.name,payload:n,fenceLanguage:`markdown`},l={key:`${e.id}:analytics`,label:`${r(`Analytics inventory`,`Аналитика`)} ${e.id} (${t.rows.length} ${r(`rows`,`строк`)})`,shortLabel:r(`analytics`,`аналитика`),cardId:e.id,cardName:e.name,payload:JSON.stringify({itemId:e.id,name:e.name,aggregates:{nodesByType:t.nodesByType,depth:t.depth,copyWordCount:t.copyWordCount,componentCoverage:t.componentCoverage,libraries:t.libraries,deprecatedCount:t.deprecatedCount},inventory:t.rows,copy:t.copy},null,2),fenceLanguage:`json`},u=un(l.key);return F(`div`,{className:`flex flex-col gap-2 pt-2`,children:[F(`div`,{className:`flex items-center gap-1.5`,children:[P(`span`,{className:`text-xs text-muted-foreground/70`,children:r(`Everything below derives from the scan data`,`Всё ниже выведено из данных скана`)}),P(`span`,{className:`ml-auto`}),P(Er,{attached:u,label:l.label,onToggle:()=>o(l)})]}),F(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[P(Pr,{label:r(`layers`,`слоёв`),value:String(t.rows.length)}),P(Pr,{label:r(`depth`,`глубина`),value:String(t.depth)}),P(Pr,{label:r(`DS coverage`,`покрытие ДС`),value:`${t.componentCoverage}%`}),P(Pr,{label:r(`words of copy`,`слов текста`),value:String(t.copyWordCount)}),P(Pr,{label:r(`libraries`,`библиотек`),value:String(t.libraries.length)}),P(Pr,{label:r(`deprecated`,`устаревших`),value:String(t.deprecatedCount)})]}),F(Q,{title:r(`PDLC spec`,`PDLC-спека`),sublabel:r(`markdown for a Jira task`,`markdown для задачи в Jira`),count:`md`,attachItem:c,children:[F(`div`,{className:`flex items-center gap-1.5 pb-1.5 pt-1`,children:[P(`p`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground/70`,children:r(`A complete screen specification — paste into the task; the implementing agent pairs it with the UI spec from the Prompt tab.`,`Полная спецификация экрана — вставьте в задачу; агент-исполнитель работает по ней вместе со спекой UI из вкладки «Промпт».`)}),P(X,{value:n,label:r(`Copy markdown`,`Скопировать markdown`)})]}),P(`div`,{className:`overflow-hidden rounded-md border border-border/60 bg-background`,children:P(W.ScrollArea,{className:`max-h-80`,children:P(kr,{code:n,language:`markdown`,theme:s})})})]}),P(Q,{title:r(`Nodes by kind`,`Слои по видам`),count:i.length,children:P(`div`,{className:`flex flex-col gap-1 pt-1`,children:i.map(e=>F(`div`,{"data-testid":`pixso-analytics-kind`,className:`flex items-center gap-2 text-[13px]`,children:[P(`span`,{className:Y.type,children:e.kind}),F(`span`,{className:`tabular-nums text-muted-foreground/70`,children:[`×`,e.count]}),P(`span`,{className:`ml-auto`}),P(X,{value:e.kind,label:r(`Copy kind`,`Скопировать вид`)})]},e.kind))})}),a.length>0&&P(Q,{title:r(`Components`,`Компоненты`),sublabel:r(`unique in this selection`,`уникальные в выборке`),count:a.length,children:P(`div`,{className:`flex flex-col gap-1 pt-1`,children:a.map(t=>P(Nr,{usage:t,item:{key:`${e.id}:component:${t.key}`,label:`${r(`Component`,`Компонент`)} «${t.name}»`,shortLabel:t.name,cardId:e.id,cardName:e.name,payload:JSON.stringify(t,null,2),fenceLanguage:`json`}},t.key))})}),P(`div`,{className:`px-0.5 pt-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:r(`Inventory`,`Инвентарь`)}),P(`div`,{className:`overflow-hidden rounded-md border border-border/60 bg-background`,children:P(W.ScrollArea,{className:`max-h-72`,children:F(`table`,{className:`w-full min-w-max text-left text-xs`,children:[P(`thead`,{className:`sticky top-0 bg-muted/80 text-muted-foreground backdrop-blur-sm`,children:F(`tr`,{children:[P(`th`,{className:`px-2 py-1 font-medium`,children:r(`layer`,`слой`)}),P(`th`,{className:`px-2 py-1 font-medium`,children:r(`type`,`тип`)}),P(`th`,{className:`px-2 py-1 font-medium`,children:r(`text`,`текст`)}),P(`th`,{className:`px-2 py-1 font-medium`,children:r(`component`,`компонент`)}),P(`th`,{className:`px-2 py-1 font-medium`,children:r(`size`,`размер`)})]})}),P(`tbody`,{children:t.rows.map(e=>F(`tr`,{className:`border-t border-border/40`,children:[P(`td`,{className:`max-w-40 truncate px-2 py-1`,style:{paddingLeft:`${8+e.depth*8}px`},children:e.name}),P(`td`,{className:(0,H.cn)(`px-2 py-1`,Y.type),children:gr(e.type)}),P(`td`,{className:(0,H.cn)(`max-w-44 truncate px-2 py-1`,Y.string),children:e.text??``}),P(`td`,{className:`max-w-36 truncate px-2 py-1`,children:e.componentName!==null&&F(`span`,{title:e.caption??void 0,children:[e.componentName,e.library!==null&&F(`span`,{className:`text-muted-foreground/60`,children:[` · `,e.library]})]})}),F(`td`,{className:(0,H.cn)(`px-2 py-1 tabular-nums`,Y.geometry),children:[e.width,`×`,e.height]})]},e.id))})]})})}),P(Q,{title:r(`Texts`,`Тексты`),count:t.copy.length,children:P(`div`,{className:`flex flex-col gap-1 pt-1`,children:t.copy.map((t,n)=>P(Mr,{card:e,text:t,index:n},`${n}-${t.slice(0,12)}`))})}),t.designerUrls.length>0&&F(N,{children:[P(`div`,{className:`px-0.5 pt-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:r(`Designer links on layers`,`Ссылки дизайнера на слоях`)}),dr(t.designerUrls.map(e=>e.url)).map(e=>{let t=hr(e.url);return t===null?F(`span`,{title:e.url,className:`flex items-center gap-1.5 truncate px-0.5 text-[13px] text-muted-foreground/70`,children:[P(D,{className:`size-3 shrink-0`}),P(`span`,{className:`truncate`,children:mr(e.url)}),e.count>1&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs tabular-nums`,Y.geometry),children:[`×`,e.count]})]},e.url):F(`a`,{href:t,target:`_blank`,rel:`noreferrer`,title:e.url,className:`flex items-center gap-1.5 truncate px-0.5 text-[13px] text-primary hover:underline`,children:[P(D,{className:`size-3 shrink-0`}),P(`span`,{className:`truncate`,children:mr(e.url)}),e.count>1&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs tabular-nums`,Y.geometry),children:[`×`,e.count]})]},e.url)})]})]})}function Ir({checked:e,onChange:t,label:n}){return F(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-[13px] text-muted-foreground hover:text-foreground`,children:[P(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`size-3 accent-[var(--primary)]`}),n]})}function Lr({title:e,count:t,actions:n,defaultOpen:r,children:i}){return F(Z.Collapsible,{defaultOpen:r,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[F(`div`,{className:`flex w-full items-center gap-2 pr-2`,children:[F(Z.CollapsibleTrigger,{className:`group flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-accent/40`,children:[P(Oe,{className:`size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-data-panel-open:rotate-90`}),P(`span`,{className:`text-xs font-semibold`,children:e}),P(jr,{children:t})]}),n!==void 0&&P(`span`,{className:`flex shrink-0 items-center gap-1`,children:n})]}),P(Z.CollapsiblePanel,{children:P(`div`,{className:`border-t border-border/60 px-3 pb-3 pt-2`,children:i})})]})}function Rr({card:e}){let t=dn(),n=B(e=>e.removeTrayItem),i=B(e=>e.composerTarget),a=Kt(),o=t.reduce((e,t)=>e+x(t.payload),0);return F(Lr,{title:r(`In the composed request`,`В составе запроса`),count:t.length===0?0:`${t.length} · ~${o} ${r(`tok`,`ток`)}`,defaultOpen:t.length>0,children:[i===null&&P(`p`,{className:`mt-1 text-xs text-warning`,children:r(`No open chat — open a thread so attachments land in the composer.`,`Нет открытого чата — откройте тред, чтобы вложения попали в поле ввода.`)}),t.length===0?P(`p`,{className:`py-1 text-[13px] text-muted-foreground/70`,children:r(`Nothing attached yet — press + next to any data block, component, QA case or the spec below.`,`Пока ничего не прикреплено — нажмите + рядом с любым блоком данных, компонентом, QA-кейсом или спекой ниже.`)}):P(`div`,{className:`flex flex-col gap-1`,children:t.map(t=>F(Z.Collapsible,{className:`rounded-md border border-border/60 bg-background`,children:[F(`div`,{className:`flex items-center gap-1`,children:[F(Z.CollapsibleTrigger,{className:`group flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1.5 text-left transition-colors hover:bg-accent/40`,children:[P(Oe,{className:`size-3 shrink-0 text-muted-foreground/50 transition-transform duration-150 group-data-panel-open:rotate-90`}),P(`span`,{className:`min-w-0 truncate text-[13px]`,children:t.label}),t.cardId!==e.id&&P(`span`,{className:`shrink-0 truncate text-xs text-muted-foreground/50`,children:t.cardName}),F(`span`,{className:`ml-auto shrink-0 pl-1.5 text-xs tabular-nums text-muted-foreground/50`,children:[`~`,x(t.payload)]})]}),P(`span`,{className:`shrink-0 pr-1.5`,children:P(U,{size:`icon-xs`,variant:`ghost`,"aria-label":`${r(`Remove from the request`,`Убрать из запроса`)}: ${t.label}`,onClick:()=>n(t.key),className:`text-muted-foreground/60 hover:text-destructive`,children:P(mt,{className:`size-3`})})})]}),P(Z.CollapsiblePanel,{children:P(`div`,{className:`max-h-48 overflow-hidden border-t border-border/50`,children:P(W.ScrollArea,{className:`max-h-48`,children:P(kr,{code:t.payload.length>6e3?`${t.payload.slice(0,6e3)}\n…`:t.payload,language:t.fenceLanguage,theme:a})})})})]},t.key))})]})}function zr({card:e}){let t=Kt(),n=B(e=>e.toggleTrayItem),i=B(e=>e.upsertTrayItem),[a,o]=j({includeComponentDefs:!0,includeCopy:!0}),c=A(()=>s(e,a),[e,a]),l=x(c),u=A(()=>({key:`${e.id}:prompt`,label:`${r(`UI spec (pixel-perfect)`,`Спека UI (pixel-perfect)`)} «${e.name}» · ~${l} ${r(`tokens`,`токенов`)}`,shortLabel:r(`UI spec`,`спека UI`),cardId:e.id,cardName:e.name,payload:c,fenceLanguage:`markdown`}),[e.id,e.name,c,l]),d=un(u.key);return k(()=>{d&&i(u)},[d,u,i]),F(Lr,{title:r(`UI spec (pixel-perfect)`,`Спека UI (pixel-perfect)`),count:`~${l} ${r(`tok`,`ток`)}`,defaultOpen:!0,actions:F(N,{children:[P(X,{value:c,label:r(`Copy the spec`,`Скопировать спеку`)}),P(Er,{attached:d,label:u.label,onToggle:()=>n(u)})]}),children:[P(`p`,{className:`pb-1.5 text-[13px] leading-snug text-muted-foreground/80`,children:r(`Byte-for-byte what the model receives: an HTML skeleton plus a COMPLETE CSS rule for every element — nothing left to interpretation.`,`Ровно то, что получит модель: HTML-скелет плюс ПОЛНОЕ CSS-правило для каждого элемента — ничего не остаётся на догадки.`)}),F(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pb-2`,children:[P(Ir,{checked:a.includeComponentDefs,onChange:e=>o(t=>({...t,includeComponentDefs:e})),label:r(`components internals`,`внутренности компонентов`)}),P(Ir,{checked:a.includeCopy,onChange:e=>o(t=>({...t,includeCopy:e})),label:r(`verbatim copy`,`тексты дословно`)}),F(`span`,{className:(0,H.cn)(`ml-auto text-xs tabular-nums text-muted-foreground/60`),children:[c.length.toLocaleString(y()),` `,r(`chars`,`символов`)]})]}),P(`div`,{className:`max-h-96 overflow-hidden rounded-md border border-border/60 bg-background`,children:P(W.ScrollArea,{className:`max-h-96`,children:P(kr,{code:c,language:`markdown`,theme:t})})})]})}function Br({card:e}){return F(`div`,{className:`flex flex-col gap-2 pt-2`,children:[P(Rr,{card:e}),P(zr,{card:e})]})}const Vr=[`violations`,`components`,`typography`,`layout`,`behavior`];function Hr({flavor:e,onChange:t}){let n=(n,r)=>P(`button`,{type:`button`,onClick:()=>t(n),className:(0,H.cn)(`cursor-pointer rounded-md px-2 py-1 text-[13px] transition-colors`,e===n?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),children:r});return F(`div`,{className:`flex w-fit shrink-0 items-center gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5`,children:[n(`manual`,r(`Manual testing`,`Ручная приёмка`)),n(`auto`,r(`Autotests`,`Автотесты`))]})}function Ur(e,t){return t===`manual`?`- [ ] ${e.manual}`:JSON.stringify({target:e.auto.target,assertions:e.auto.assertions},null,2)}const Wr=e=>e===`manual`?`markdown`:`json`;function Gr({card:e,qaCase:t,flavor:n,onShowNode:i}){let a=B(e=>e.toggleTrayItem),o={key:`${t.id}:${n}`,label:`${r(`QA case`,`QA-кейс`)}: ${t.manual.slice(0,60)}`,shortLabel:`QA: ${t.manual.slice(0,28)}…`,cardId:e.id,cardName:e.name,payload:Ur(t,n),fenceLanguage:Wr(n)},s=un(o.key);return F(Z.Collapsible,{"data-testid":`pixso-qa-case`,className:`rounded-md border border-border/60 bg-background`,children:[F(`div`,{className:`flex items-center gap-1`,children:[F(Z.CollapsibleTrigger,{className:`group flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1.5 text-left transition-colors hover:bg-accent/40`,children:[P(Oe,{className:`size-3 shrink-0 text-muted-foreground/50 transition-transform duration-150 group-data-panel-open:rotate-90`}),n===`manual`?P(`span`,{className:`min-w-0 truncate text-[13px] leading-snug`,children:t.manual}):P(`span`,{className:(0,H.cn)(`min-w-0 truncate text-[13px]`,Y.name),children:t.auto.target})]}),F(`span`,{className:`flex shrink-0 items-center gap-0.5 pr-1.5`,children:[t.nodeId!==null&&P(`button`,{type:`button`,title:r(`Show the layer in Structure`,`Показать слой в «Структуре»`),onClick:()=>i(t.nodeId),className:`flex size-5 cursor-pointer items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,children:P(Me,{className:`size-3`})}),P(Er,{attached:s,label:o.label,onToggle:()=>a(o)})]})]}),P(Z.CollapsiblePanel,{children:F(`div`,{className:`flex flex-col gap-1.5 border-t border-border/50 px-2 py-1.5`,children:[P(`div`,{className:`text-[13px] leading-snug`,children:t.manual}),P(`div`,{className:(0,H.cn)(`text-xs`,Y.name),children:t.auto.target}),P(`div`,{className:`flex flex-col gap-px`,children:t.auto.assertions.map(e=>P(`code`,{className:(0,H.cn)(`text-xs leading-4`,Y.value),children:e},e))})]})})]})}function Kr({card:e,onShowNode:t}){let[n,i]=j(`manual`),a=A(()=>wr(e),[e]),o=n===`manual`?a.map(e=>`- [ ] ${e.manual}`).join(`
3
+ `):JSON.stringify(a.map(e=>({target:e.auto.target,assertions:e.auto.assertions})),null,2);return F(`div`,{className:`flex flex-col gap-2 pt-2`,children:[F(`div`,{className:`flex items-center gap-2`,children:[P(Hr,{flavor:n,onChange:i}),F(`span`,{"data-testid":`pixso-qa-case-count`,className:`ml-auto text-xs tabular-nums text-muted-foreground/60`,children:[a.length,` `,r(`cases`,`кейсов`)]}),P(X,{value:o,label:r(`Copy all cases`,`Скопировать все кейсы`)})]}),Vr.map(i=>{let o=a.filter(e=>e.group===i);if(o.length===0)return null;let s={key:`${e.id}:qa-group:${i}:${n}`,label:`${r(`QA`,`QA`)} · ${yr(i)} (${o.length})`,shortLabel:`QA ${yr(i).toLowerCase()}`,cardId:e.id,cardName:e.name,payload:o.map(e=>Ur(e,n)).join(`
4
+ `),fenceLanguage:Wr(n)};return P(Q,{title:yr(i),count:o.length,countTone:`default`,sublabel:i===`violations`?r(`needs a decision`,`требуют решения`):void 0,attachItem:s,defaultOpen:i===`violations`,children:P(`div`,{className:`flex flex-col gap-1 pt-1`,children:o.map(r=>P(Gr,{card:e,qaCase:r,flavor:n,onShowNode:t},r.id))})},`${i}-${n}`)})]})}function qr(e){return new Date(e).toLocaleTimeString(y(),{hour:`2-digit`,minute:`2-digit`})}function Jr(e){return new Date(e).toLocaleDateString(y(),{day:`2-digit`,month:`2-digit`,year:`numeric`})}function Yr(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=qr(e);return r?i:`${t.toLocaleDateString(y(),{day:`2-digit`,month:`2-digit`})} ${i}`}const Xr=e=>e.trim()===``?{kind:`error`}:{kind:`loaded`,svg:e};function Zr(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}function Qr(e){return e.kind===`loaded`?Zr(e.svg):e.kind===`png`?`data:image/png;base64,${e.base64}`:null}function $r({state:e,alt:t,className:n,natural:i=!1,fit:a=`contain`,focus:o=`center`}){let s=a===`cover`?(0,H.cn)(`size-full object-cover`,o===`top`&&`object-top`):`max-h-full max-w-full object-contain`,c=Qr(e);return F(`div`,{className:(0,H.cn)(`relative flex items-center justify-center overflow-hidden bg-muted/40`,n),children:[e.kind===`loading`&&P(`div`,{"data-testid":`pixso-preview-placeholder`,className:`absolute inset-0`}),e.kind===`error`&&F(`div`,{className:`flex flex-col items-center gap-1 text-muted-foreground/60`,children:[P(Ve,{className:`size-4`}),P(`span`,{className:`text-xs`,children:r(`image unavailable`,`изображение недоступно`)})]}),c!==null&&P(`img`,{src:c,alt:t,className:i?`max-h-[calc(100vh-120px)] max-w-[calc(100vw-80px)]`:s,draggable:!1})]})}function ei(){let e=B(e=>e.selectedCardId),t=B(e=>e.selectedCardId===null?null:e.cards.find(t=>t.id===e.selectedCardId)??null),n=B(e=>e.selectedCardId===null?null:e.details[e.selectedCardId]??null),r=B(e=>e.selectedCardId===null?!1:e.detailErrors.has(e.selectedCardId)),i=B(e=>e.selectedCardId===null?void 0:e.raws[e.selectedCardId]),a=B(e=>e.selectedCardId===null?void 0:e.images[e.selectedCardId]),o=n?.catalogHash??null,s=B(e=>o===null?void 0:e.catalogs[o]);return{card:A(()=>t===null||n===null?null:{id:t.id,nodeId:t.nodeId,name:n.name,type:n.nodeType,dslVersion:n.dslVersion??``,...n.versionUnverified===!0?{versionUnverified:!0}:{},importedAt:Yr(n.importedAtIso),pagePath:n.pagePath,root:n.root,preview:Xr(t.previewSvg),...n.imageAvailable===void 0?{}:{imageAvailable:n.imageAvailable},...a===void 0?{}:{imagePngBase64:a},...n.rawAvailable===void 0?{}:{rawAvailable:n.rawAvailable},...i===void 0?{}:{rawDsl:i},...n.catalogHash===null?{}:{catalogHash:n.catalogHash},...n.component===null?{}:{component:n.component},componentsUsed:n.componentsUsed,...s===void 0?{}:{catalog:s},...n.source===void 0?{}:{source:n.source}},[t,n,i,a,s]),loading:e!==null&&t!==null&&n===null&&!r,failed:e!==null&&t!==null&&n===null&&r}}const ti=[{value:`overview`,icon:Pe,label:()=>r(`Overview`,`Обзор`)},{value:`structure`,icon:Ke,label:()=>r(`Structure`,`Структура`)},{value:`styles`,icon:Ze,label:()=>r(`Styles`,`Стили`)},{value:`components`,icon:we,label:()=>r(`Components`,`Компоненты`)},{value:`qa`,icon:Fe,label:()=>`QA`},{value:`analytics`,icon:Te,label:()=>r(`Analytics`,`Аналитика`)},{value:`prompt`,icon:Je,label:()=>r(`Prompt`,`Промпт`)}];I.createHandle;const ni=I.Root;I.Portal;function ri({className:e,children:t,...n}){return P(I.Trigger,{className:e,"data-slot":`menu-trigger`,...n,children:t})}function ii({children:e,className:t,sideOffset:n=4,align:r=`center`,alignOffset:i,side:a=`bottom`,anchor:o,...s}){return P(I.Portal,{children:P(I.Positioner,{align:r,alignOffset:i,anchor:o,className:`z-50`,"data-slot":`menu-positioner`,side:a,sideOffset:n,children:P(I.Popup,{className:(0,H.cn)(`relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] focus:outline-none dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,t),"data-slot":`menu-popup`,...s,children:P(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1`,children:e})})})})}function $({className:e,inset:t,variant:n=`default`,...r}){return P(I.Item,{className:(0,H.cn)(`[&>svg]:-mx-0.5 flex min-h-8 cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-inset:ps-8 data-[variant=destructive]:text-destructive-foreground data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&>svg:not([class*='opacity-'])]:opacity-80 [&>svg:not([class*='size-'])]:size-4.5 sm:[&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:[&>svg:not([class*='text-'])]:text-current [&>svg]:pointer-events-none [&>svg]:shrink-0`,e),"data-inset":t,"data-slot":`menu-item`,"data-variant":n,...r})}function ai({className:e,...t}){return P(I.Separator,{className:(0,H.cn)(`mx-2 my-1 h-px bg-border`,e),"data-slot":`menu-separator`,...t})}function oi(e){return P(I.SubmenuRoot,{"data-slot":`menu-sub`,...e})}function si({className:e,inset:t,children:n,...r}){return F(I.SubmenuTrigger,{className:(0,H.cn)(`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-popup-open:bg-accent data-inset:ps-8 data-highlighted:text-accent-foreground data-popup-open:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none`,e),"data-inset":t,"data-slot":`menu-sub-trigger`,...r,children:[n,P(Oe,{className:`-me-0.5 ms-auto opacity-80`})]})}function ci({className:e,sideOffset:t=0,alignOffset:n,align:r=`start`,...i}){return P(ii,{align:r,alignOffset:n??(r===`center`?void 0:-5),className:e,"data-slot":`menu-sub-content`,side:`inline-end`,sideOffset:t,...i})}function li({open:e,onOpenChange:t,assignCardId:n}){let i=B(e=>e.createGroup),a=B(e=>e.moveCardToGroup),[o,s]=j(``),c=()=>{let e=o.trim();if(e===``)return;let r=i(e);n!==void 0&&a(n,r),s(``),t(!1)};return P(xn,{open:e,onOpenChange:t,children:F(En,{className:`max-w-sm`,showCloseButton:!1,children:[F(Dn,{children:[P(kn,{children:r(`New group`,`Новая группа`)}),P(An,{children:r(`Groups keep the gallery tidy — drag cards in or assign them from a card's detail view.`,`Группы наводят порядок в галерее — перетаскивайте карточки или назначайте их из детального вида.`)})]}),P(`div`,{className:`px-6 pb-2`,children:P(q.Input,{autoFocus:!0,value:o,onValueChange:s,placeholder:r(`Group name`,`Название группы`),onKeyDown:e=>{e.key===`Enter`&&c()},"aria-label":r(`Group name`,`Название группы`),"data-testid":`pixso-new-group-name`})}),F(On,{children:[P(U,{variant:`ghost`,onClick:()=>t(!1),children:r(`Cancel`,`Отмена`)}),P(U,{onClick:c,disabled:o.trim()===``,"data-testid":`pixso-new-group-create`,children:r(`Create`,`Создать`)})]})]})})}function ui({group:e,cardCount:t,open:n,onOpenChange:i}){let a=B(e=>e.deleteGroup),o=t=>{a(e.id,{deleteCards:t}),i(!1)};return P(xn,{open:n,onOpenChange:i,children:F(En,{className:`max-w-md`,showCloseButton:!1,children:[F(Dn,{children:[F(kn,{children:[r(`Delete group`,`Удалить группу`),` «`,e.name,`»?`]}),P(An,{children:t===0?r(`The group is empty.`,`Группа пуста.`):`${r(`It holds`,`В ней`)} ${t} ${r(`cards. What should happen to them?`,`карточек. Что с ними сделать?`)}`})]}),F(On,{className:`flex-wrap`,children:[P(U,{variant:`ghost`,onClick:()=>i(!1),children:r(`Cancel`,`Отмена`)}),t>0?F(N,{children:[P(U,{variant:`outline`,onClick:()=>o(!1),children:r(`Move to Unsorted`,`Переместить в «Неразобранное»`)}),P(U,{variant:`destructive`,onClick:()=>o(!0),children:r(`Delete with cards`,`Удалить вместе с карточками`)})]}):P(U,{variant:`destructive`,onClick:()=>o(!1),children:r(`Delete`,`Удалить`)})]})]})})}function di({card:e}){let t=B(e=>e.groups),n=B(e=>e.groupByCardId),i=B(e=>e.moveCardToGroup),[a,o]=j(!1),s=n[e.id]??null,c=t.find(e=>e.id===s)??null;return F(`div`,{className:`flex items-center gap-2 px-0.5 pt-2`,children:[P(Ie,{className:`size-3.5 shrink-0 text-muted-foreground/70`}),F(`span`,{className:`text-xs text-muted-foreground/60`,children:[r(`Group`,`Группа`),`:`]}),F(ni,{children:[F(ri,{render:P(U,{variant:`outline`,size:`xs`}),children:[c?.name??r(`Unsorted`,`Неразобранное`),P(Ee,{})]}),F(ii,{align:`start`,children:[t.map(t=>F($,{onClick:()=>i(e.id,t.id),children:[t.id===s?P(E,{}):P(Ie,{}),t.name]},t.id)),t.length>0&&F($,{onClick:()=>i(e.id,null),children:[P(s===null?E:Ue,{}),r(`Unsorted`,`Неразобранное`)]}),t.length>0&&P(ai,{}),F($,{onClick:()=>o(!0),children:[P(Re,{}),r(`New group…`,`Новая группа…`)]})]})]}),P(li,{open:a,onOpenChange:o,assignCardId:e.id})]})}function fi({card:e,onOpenPrompt:t}){let n=B(e=>e.toggleTrayItem),i=A(()=>s(e,{includeComponentDefs:!0,includeCopy:!0}),[e]),a={key:`${e.id}:node`,label:`${r(`UI spec`,`Спека UI`)} «${e.name}»`,shortLabel:r(`UI spec`,`спека UI`),cardId:e.id,cardName:e.name,payload:i,fenceLanguage:`markdown`};return F(`div`,{className:`flex items-center gap-2 px-0.5 pt-2`,children:[P(Er,{attached:un(a.key),label:a.label,onToggle:()=>n(a)}),F(`span`,{className:`text-[13px] text-muted-foreground/60`,children:[r(`attach the converted spec to your prompt`,`прикрепить конвертированную спеку к запросу`),` · `,P(`button`,{type:`button`,onClick:t,className:`cursor-pointer text-primary hover:underline`,children:r(`preview the spec`,`посмотреть спеку`)})]})]})}function pi({card:e,stickyCount:t,maskCount:n,hiddenCount:i,deprecatedUsed:a,componentsUsed:o,designerLinks:s,onOpenPrompt:c}){let l=dr(s.map(e=>e.url)),u=B(e=>e.loadImage),d=e.imageAvailable===!0,[f,p]=j(`png`);k(()=>{d&&u(e.id)},[d,e.id,u]);let m=e.imagePngBase64,h=d&&f===`png`?m===void 0?{kind:`loading`}:{kind:`png`,base64:m}:e.preview,g=(e,t)=>P(`button`,{type:`button`,"data-testid":`pixso-preview-source-${e}`,"aria-pressed":f===e,onClick:()=>p(e),className:(0,H.cn)(`cursor-pointer rounded-md px-2 py-0.5 text-xs transition-colors`,f===e?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),children:t});return F(N,{children:[F(`div`,{className:`pt-2.5`,children:[F(xn,{children:[P(Cn,{render:P(`button`,{type:`button`,title:r(`Open full size`,`Открыть в полном размере`),className:`block w-full cursor-zoom-in`}),children:P($r,{state:h,alt:e.name,className:`h-64 w-full rounded-lg border border-border transition-colors hover:border-primary/40`})}),P(En,{className:`w-fit max-w-none`,children:F(`div`,{className:`flex flex-col gap-2 p-4`,children:[F(`div`,{className:`flex items-baseline gap-2 pr-8`,children:[P(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),F(`span`,{className:(0,H.cn)(`shrink-0 tabular-nums text-[13px]`,Y.geometry),children:[Math.round(e.root.width),` × `,Math.round(e.root.height)]})]}),P($r,{state:h,alt:e.name,natural:!0,className:`w-fit rounded-lg border border-border bg-transparent`})]})})]}),d?P(`div`,{className:`flex items-center justify-end px-0.5 pt-1`,children:F(`div`,{"data-testid":`pixso-preview-source`,className:`flex shrink-0 items-center gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5`,children:[g(`png`,r(`Screenshot`,`Скриншот`)),g(`svg`,r(`Render`,`Рендер`))]})}):P(`p`,{className:`px-0.5 pt-1 text-xs text-muted-foreground/50`,children:r(`Preview is computed from the DSL (algorithmic render, not a screenshot) — click to enlarge.`,`Превью построено из DSL (алгоритмический рендер, не скриншот) — клик открывает в полном размере.`)})]}),P(di,{card:e}),P(fi,{card:e,onOpenPrompt:c}),(t>0||n>0||i>0||a>0)&&F(`div`,{className:`flex flex-wrap items-center gap-1.5 px-0.5 pt-2.5`,children:[t>0&&F(`span`,{className:`rounded-md border border-info/40 bg-info/10 px-1.5 py-px text-xs text-info`,children:[r(`fixed on scroll`,`закреплены при скролле`),` ×`,t]}),n>0&&F(`span`,{className:`rounded-md border border-border bg-muted px-1.5 py-px text-xs text-muted-foreground`,children:[r(`masks`,`маски`),` ×`,n]}),i>0&&F(`span`,{className:`rounded-md border border-border bg-muted px-1.5 py-px text-xs text-muted-foreground`,children:[r(`hidden layers`,`скрытые слои`),` ×`,i]}),a>0&&F(`span`,{className:`rounded-md border border-warning/40 bg-warning/10 px-1.5 py-px text-xs text-warning`,children:[r(`deprecated components`,`устаревшие компоненты`),` ×`,a]})]}),o.length>0&&F(`p`,{className:`px-0.5 pt-2 text-[13px] text-muted-foreground/70`,children:[r(`Built from`,`Собран из`),` `,o.reduce((e,t)=>e+t.count,0),` `,r(`component instances`,`экземпляров компонентов`),` ·`,` `,new Set(o.map(e=>e.library).filter(Boolean)).size,` `,r(`libraries`,`библиотек`)]}),s.length>0&&P(`div`,{className:`pt-2.5`,children:P(Q,{title:r(`Designer links`,`Ссылки дизайнера`),sublabel:r(`from the layers' url field`,`из поля url на слоях`),count:l.length,defaultOpen:!0,children:P(`div`,{className:`flex flex-col gap-1 pt-1`,children:l.map(e=>{let t=hr(e.url);return t===null?F(`span`,{title:e.url,className:`flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5 text-[13px] text-muted-foreground/70`,children:[P(D,{className:`size-3.5 shrink-0`}),P(`span`,{className:`min-w-0 truncate`,children:mr(e.url)}),e.count>1&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs tabular-nums`,Y.geometry),children:[`×`,e.count]})]},e.url):F(`a`,{href:t,target:`_blank`,rel:`noreferrer`,title:e.url,className:`flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5 text-[13px] text-primary transition-colors hover:bg-accent/40 hover:underline`,children:[P(D,{className:`size-3.5 shrink-0`}),P(`span`,{className:`min-w-0 truncate`,children:mr(e.url)}),e.count>1&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs tabular-nums`,Y.geometry),children:[`×`,e.count]})]},e.url)})})})})]})}const mi={frame:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},group:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},instance:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},symbol:{fill:`fill-primary/8`,stroke:`stroke-primary/70`},rect:{fill:`fill-muted-foreground/10`,stroke:`stroke-muted-foreground/70`},ellipse:{fill:`fill-success/10`,stroke:`stroke-success/70`},text:{fill:`fill-info/12`,stroke:`stroke-info/70`},vector:{fill:`fill-warning/12`,stroke:`stroke-warning/70`},paragraph:{fill:`fill-info/12`,stroke:`stroke-info/70`},span:{fill:`fill-info/8`,stroke:`stroke-info/50`},line:{fill:`fill-warning/12`,stroke:`stroke-warning/70`},mask:{fill:`fill-muted-foreground/8`,stroke:`stroke-muted-foreground/50`}};function hi({node:e,className:t,interactive:n,onClick:i}){let a={className:(0,H.cn)(t,n&&`cursor-pointer`),vectorEffect:`non-scaling-stroke`,...n?{onClick:e=>{e.stopPropagation(),i?.()}}:{pointerEvents:`none`}},o=e.placeholder===void 0?null:`[stroke-dasharray:3_2]`,s=F(`title`,{children:[e.name,e.placeholder===void 0?``:` — ${r(`no vector geometry in the DSL; box drawn at the node's real size`,`векторной геометрии в DSL нет; рамка в реальном размере слоя`)}`]});return he(e).kind===`ellipse`?P(`ellipse`,{cx:e.x+e.width/2,cy:e.y+e.height/2,rx:e.width/2,ry:e.height/2,...a,className:(0,H.cn)(a.className,o),children:s}):P(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:gi(e),...a,className:(0,H.cn)(a.className,o),children:s})}function gi(e){let t=e.radii;return t===void 0?e.radius??0:Math.max(t.topLeft,t.topRight,t.bottomRight,t.bottomLeft)}function _i({root:e,focusId:t,onFocusChange:n,selectedId:i,onSelect:a}){let[o,s]=j(null),c=S(e,t)??e,l=w(e,c.id),u=l.length>=2?l[l.length-2]??null:null,d=c.children??[],f=Math.max(4,Math.max(c.width,c.height)*.04),p=`${c.x-f} ${c.y-f} ${c.width+f*2} ${c.height+f*2}`,m=(o===null?null:S(c,o))??(i===null?null:S(e,i)),h=m===null?null:C(e,m.id),g=m===null?null:ue(m,h),_=m===null?null:oe(m),v=m===null?null:te(m),y=e=>{let t=(e.children??[]).length>0;if(i===e.id&&t){n(e.id);return}a(e.id)};return F(`div`,{children:[F(`div`,{className:`flex flex-wrap items-center gap-1 pb-1.5 text-xs`,children:[u!==null&&P(`button`,{type:`button`,title:r(`Up one level`,`На уровень вверх`),onClick:()=>n(u.id),className:`flex size-4 cursor-pointer items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,children:P(je,{className:`size-3`})}),l.map((e,t)=>F(`span`,{className:`flex items-center gap-1`,children:[t>0&&P(`span`,{className:`text-muted-foreground/40`,children:`▸`}),t===l.length-1?P(`span`,{className:`font-medium text-foreground`,children:e.name}):P(`button`,{type:`button`,onClick:()=>n(e.id),className:`cursor-pointer text-muted-foreground/70 transition-colors hover:text-foreground`,children:e.name})]},e.id))]}),F(`svg`,{viewBox:p,className:`max-h-64 w-full rounded-md border border-border/60 bg-background`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":c.name,onMouseLeave:()=>s(null),children:[P(hi,{node:c,interactive:!1,className:`fill-transparent stroke-foreground/25 [stroke-dasharray:4_3]`}),d.flatMap(e=>(e.children??[]).map(e=>P(hi,{node:e,interactive:!1,className:`fill-transparent stroke-border [stroke-dasharray:2_2]`},e.id))),d.map(e=>{let t=mi[e.type],n=i===e.id,r=o===e.id;return P(`g`,{onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(t=>t===e.id?null:t),children:P(hi,{node:e,interactive:!0,onClick:()=>y(e),className:(0,H.cn)(t.fill,n?`stroke-primary [stroke-width:2]`:t.stroke,r&&!n&&`[stroke-width:1.75]`)})},e.id)}),d.length===0&&P(`text`,{x:c.x+c.width/2,y:c.y+c.height/2,textAnchor:`middle`,className:`fill-muted-foreground/50`,style:{fontSize:Math.max(c.width,c.height)*.06},children:r(`leaf node — no children`,`конечный слой — без вложенности`)})]}),P(`div`,{className:`h-11 overflow-hidden pt-1.5 text-[13px] leading-[1.4]`,children:m===null||g===null?P(`span`,{className:`text-muted-foreground/60`,children:r(`Click a layer to measure it; click a selected container again to enter it.`,`Кликните слой — размеры и отступы; повторный клик по выбранному контейнеру — вход внутрь.`)}):F(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:[P(`span`,{className:Y.name,children:m.name}),P(`span`,{className:(0,H.cn)(`text-xs`,Y.type),children:gr(m.type)}),F(`span`,{className:(0,H.cn)(`tabular-nums`,Y.value),children:[Math.round(m.width),`×`,Math.round(m.height)]}),F(`span`,{className:(0,H.cn)(`tabular-nums`,Y.geometry),children:[`@`,Math.round(g.x),`,`,Math.round(g.y),` `,r(`from parent`,`от родителя`)]}),_!==null&&F(`span`,{className:(0,H.cn)(`tabular-nums`,Y.geometry),children:[r(`padding`,`отступы`),`: `,_.top,` `,_.right,` `,_.bottom,` `,_.left]}),v!==null&&v.gaps.length>0&&F(`span`,{className:(0,H.cn)(`tabular-nums`,Y.geometry),children:[r(`gaps`,`интервалы`),` (`,v.axis,`): `,v.gaps.join(` `)]}),m.layout!==void 0&&F(`span`,{className:(0,H.cn)(`text-xs`,Y.type),children:[r(`declared auto-layout`,`автолейаут`),`: `,m.layout.summary]}),m.radii!==void 0&&F(`span`,{className:(0,H.cn)(`tabular-nums`,Y.geometry),children:[r(`corners`,`углы`),`: `,m.radii.topLeft,` `,m.radii.topRight,` `,m.radii.bottomRight,` `,m.radii.bottomLeft]}),m.placeholder!==void 0&&P(`span`,{className:`text-xs text-warning`,"data-testid":`pixso-geometry-placeholder`,children:r(`vector placeholder — the DSL carries no path geometry`,`вектор-заглушка — геометрии контура в DSL нет`)})]})})]})}function vi({color:e,size:t=`md`,className:n}){return P(`span`,{className:(0,H.cn)(`inline-block shrink-0 rounded-[4px] ring-1 ring-inset ring-foreground/15`,t===`sm`?`size-2.5`:`size-4`,n),style:{backgroundColor:e},"aria-hidden":!0})}function yi({colors:e,className:t}){return P(`div`,{className:(0,H.cn)(`flex items-center gap-1`,t),children:e.map(e=>P(vi,{color:e,size:`sm`,className:`rounded-[3px]`},e))})}const bi=`shrink-0 rounded border border-border bg-muted px-1 text-xs leading-4`;function xi(e){let t=e.radii;if(t===void 0)return null;let n=[t.topLeft,t.topRight,t.bottomRight,t.bottomLeft],r=e=>String(Math.round(e*100)/100);return n.every(e=>e===n[0])?n[0]===void 0||n[0]===0?null:`r${r(n[0])}`:`r${n.map(r).join(`/`)}`}function Si(e){let t=e.tokens;return t===void 0?[]:[t.fill,t.text,t.effect,t.stroke].flatMap(e=>e!==void 0&&!e.resolved?[e.id]:[])}function Ci({root:e,selectedId:t,onSelect:n,revealTick:i=0}){let a=T(e),o=yt(null);return k(()=>{i===0||t===null||o.current?.querySelector(`[data-node-id="${CSS.escape(t)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,t]),P(`div`,{ref:o,className:`flex w-max min-w-full flex-col py-0.5`,children:a.map(({node:e,parent:i,depth:a,isLast:o})=>{let s=ue(e,i),c=e.type===`text`||e.type===`paragraph`||e.type===`span`,l=xi(e),u=Si(e),d=e.expansion,f=e.textRuns??[];return F(`button`,{"data-node-id":e.id,type:`button`,onClick:()=>n(e.id),className:(0,H.cn)(`flex min-w-max items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left text-[13px] leading-5 transition-colors`,t===e.id?`bg-accent`:`hover:bg-accent/50`,e.visible===!1&&`opacity-50`),children:[a>0&&P(`span`,{className:`shrink-0 whitespace-pre font-mono text-muted-foreground/40`,"aria-hidden":!0,children:` `.repeat(a-1)+(o?`└`:`├`)}),P(`span`,{className:(0,H.cn)(`truncate`,c?Y.string:Y.name),children:c?`"${e.name}"`:e.name}),P(`span`,{className:(0,H.cn)(`shrink-0 text-xs`,Y.type),children:gr(e.type)}),e.text!==void 0&&e.text!==``&&F(`span`,{"data-testid":`pixso-layer-text`,title:e.text,className:(0,H.cn)(`max-w-[28ch] truncate shrink-0 text-xs`,Y.string),children:[`«`,e.text,`»`,f.length>1&&` ¶${String(f.length)}`]}),e.component?.displayName!==void 0&&P(`span`,{"data-testid":`pixso-layer-component`,title:[e.component.variantGroup,e.component.page===void 0?null:`${r(`page`,`стр.`)} ${e.component.page}`,e.component.resolved===!0?r(`resolved from the catalogue`,`определён по каталогу`):r(`no catalogue row — name from the DSL`,`строки каталога нет — имя из DSL`)].filter(e=>e!=null&&e!==``).join(` · `),className:(0,H.cn)(`max-w-[24ch] shrink-0 truncate rounded border px-1 text-xs leading-4`,e.component.resolved===!0?`border-primary/30 bg-primary/8 text-primary`:`border-border bg-muted text-muted-foreground`),children:e.component.displayName}),F(`span`,{className:(0,H.cn)(`shrink-0 text-xs tabular-nums`,Y.geometry),children:[Math.round(e.width),`×`,Math.round(e.height),i!==null&&` @${Math.round(s.x)},${Math.round(s.y)}`,l===null?e.radius!==void 0&&` · r${e.radius}`:` · ${l}`]}),e.layout!==void 0&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs`,Y.type),title:e.layout.summary,children:[e.layout.mode===`horizontal`?`⇆`:e.layout.mode===`vertical`?`⇅`:`▦`,e.layout.gap!==null&&` gap ${e.layout.gap}`,e.layout.padding!==null&&` pad ${e.layout.padding.top}/${e.layout.padding.right}/${e.layout.padding.bottom}/${e.layout.padding.left}`]}),e.fill!==void 0&&F(`span`,{className:(0,H.cn)(`flex shrink-0 items-center gap-1 text-xs`,Y.value),children:[P(vi,{color:e.fill,size:`sm`}),b(e.fill)]}),e.stroke!==void 0&&F(`span`,{className:(0,H.cn)(`flex shrink-0 items-center gap-1 text-xs`,Y.value),title:`stroke ${e.stroke.weight}px${e.stroke.align===void 0?``:` ${e.stroke.align}`}${e.stroke.dashed===!0?` dashed`:``}`,children:[P(`span`,{className:(0,H.cn)(`inline-block size-2.5 shrink-0 rounded-[3px] border-2 bg-transparent`,e.stroke.dashed===!0&&`border-dashed`),style:{borderColor:e.stroke.color},"aria-hidden":!0}),b(e.stroke.color),`·`,e.stroke.weight,e.stroke.dashed===!0&&`┅`]}),e.font!==void 0&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs`,Y.value),children:[e.font.family,` `,e.font.style,` `,e.font.size,le(e.textMeta)!==null&&`/${le(e.textMeta)}`,e.textMeta?.letterSpacing!==void 0&&` ls ${e.textMeta.letterSpacing.value}${e.textMeta.letterSpacing.unit}`,e.textMeta?.upperCase===!0&&` AA`]}),e.sticky===!0&&P(`span`,{className:`shrink-0 rounded border border-info/40 bg-info/10 px-1 text-xs leading-4 text-info`,children:r(`fixed`,`закреплён`)}),e.mask===!0&&P(`span`,{className:`shrink-0 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:r(`mask`,`маска`)}),e.visible===!1&&P(`span`,{className:`shrink-0 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:r(`hidden`,`скрыт`)}),d!==void 0&&F(`span`,{"data-testid":`pixso-layer-expansion`,title:[`${r(`expanded`,`раскрыт`)}: ${String(d.nodeCount)} ${r(`nodes`,`слоёв`)}`,`${String(d.appliedOverrides)} ${r(`overrides applied`,`переопределений применено`)}`,d.stoppedBy===void 0?null:`${r(`stopped by`,`остановлено по`)}: ${d.stoppedBy}`,(d.unresolvedOverrides??[]).length===0?null:`${String((d.unresolvedOverrides??[]).length)} ${r(`overrides addressed nothing`,`переопределений ни к чему не привязались`)}`].filter(e=>e!==null).join(` · `),className:(0,H.cn)(bi,d.stoppedBy!==void 0||(d.unresolvedOverrides??[]).length>0||!d.resolved?`border-warning/40 bg-warning/10 text-warning`:`text-muted-foreground`),children:[`⤷`,d.nodeCount,d.stoppedBy!==void 0&&` ${d.stoppedBy}`,(d.unresolvedOverrides??[]).length>0&&` ?${String((d.unresolvedOverrides??[]).length)}`]}),e.origin===`expanded-instance`&&P(`span`,{className:(0,H.cn)(bi,`text-muted-foreground/70`),title:r(`Content of the component instance, expanded from its master.`,`Содержимое экземпляра компонента, раскрытое из мастера.`),children:r(`from component`,`из компонента`)}),e.placeholder!==void 0&&P(`span`,{"data-testid":`pixso-layer-placeholder`,className:(0,H.cn)(bi,`border-dashed border-warning/50 bg-warning/5 text-warning/90`),title:r(`No vector geometry in the DSL — the box is drawn at the node's real size.`,`Векторной геометрии в DSL нет — рамка нарисована в реальном размере слоя.`),children:r(`vector placeholder`,`вектор-заглушка`)}),u.length>0&&P(`span`,{"data-testid":`pixso-layer-unresolved-token`,className:(0,H.cn)(bi,`text-muted-foreground/70`),title:`${r(`Unresolved style reference`,`Неразрешённая ссылка на стиль`)}: ${u.join(`, `)}`,children:r(`unresolved ref`,`ссылка не найдена`)}),e.textColor!==void 0&&F(`span`,{className:(0,H.cn)(`flex shrink-0 items-center gap-1 text-xs`,Y.value),children:[P(vi,{color:e.textColor,size:`sm`}),b(e.textColor)]})]},e.id)})})}function wi({card:e,flatCount:t,selectedNodeId:n,onTreeSelect:i,revealTick:a,effectiveFocusId:o,onFocusChange:s,onRevealSelect:c,cssNode:l,cssText:u,cssItem:d,rawDslText:f,onLoadRaw:p,resolvedTheme:m}){let h=B(t=>t.rawErrors.has(e.id)),g=B(e=>e.retryRaw);return F(`div`,{className:`flex flex-col gap-2 pt-2`,children:[P(Q,{title:r(`Layers`,`Слои`),count:t,defaultOpen:!0,children:P(`div`,{className:`mt-1 overflow-hidden rounded-md border border-border/60 bg-background`,children:P(W.ScrollArea,{className:`max-h-72`,children:P(Ci,{root:e.root,selectedId:n,onSelect:i,revealTick:a})})})}),P(Q,{title:r(`Geometry`,`Геометрия`),sublabel:r(`click to measure`,`клик для измерения`),count:`${Math.round(e.root.width)}×${Math.round(e.root.height)}`,defaultOpen:!0,children:P(_i,{root:e.root,focusId:o,onFocusChange:s,selectedId:n,onSelect:c})}),P(Q,{title:`CSS`,sublabel:l?.name??``,count:u===``?0:u.split(`
5
+ `).length,attachItem:d,headerActions:P(X,{value:u,label:r(`Copy CSS`,`Скопировать CSS`)}),flush:!0,defaultOpen:!0,children:P(W.ScrollArea,{className:`max-h-72`,children:P(kr,{code:u,language:`css`,theme:m})})}),e.rawAvailable===!1?P(`p`,{"data-testid":`pixso-raw-rotated`,className:`px-0.5 pt-1 text-xs text-muted-foreground/50`,children:r(`The raw DSL was removed by storage rotation.`,`Сырой DSL удалён ротацией хранилища.`)}):P(Q,{title:r(`Raw DSL`,`Сырой DSL`),sublabel:`JSON`,count:f===null?`—`:`${Math.max(1,Math.round(f.length/1024))} KB`,headerActions:f===null?void 0:P(X,{value:f,label:r(`Copy JSON`,`Скопировать JSON`)}),onOpenChange:e=>{e&&p()},flush:!0,children:f===null?h?F(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[P(`p`,{className:`text-[13px] text-muted-foreground/70`,"data-testid":`pixso-raw-error`,children:r(`Failed to load the raw DSL.`,`Не удалось загрузить сырой DSL.`)}),P(U,{variant:`outline`,size:`sm`,onClick:()=>g(e.id),children:r(`Retry`,`Повторить`)})]}):P(`p`,{className:`px-3 py-2 text-[13px] text-muted-foreground/70`,children:r(`Loading the raw dump…`,`Загружаем сырой дамп…`)}):P(W.ScrollArea,{className:`max-h-72`,children:P(kr,{code:f,language:`json`,theme:m})})})]})}function Ti(e){let t=new Map;for(let n of e){let e=n.font.family;if(e===void 0||e===``)continue;let r=n.font.style??null,i=`${e}|${r??``}`,a=t.get(i)??{family:e,style:r,sizes:new Map},o=n.font.size??null;a.sizes.set(o,(a.sizes.get(o)??0)+n.count),t.set(i,a)}return[...t.entries()].map(([e,t])=>({key:e,family:t.family,style:t.style,label:t.style===null?t.family:`${t.family} ${t.style}`,sizes:[...t.sizes.entries()].map(([e,t])=>({size:e,count:t})).toSorted((e,t)=>(e.size??1/0)-(t.size??1/0)),count:[...t.sizes.values()].reduce((e,t)=>e+t,0)}))}function Ei(e){return e.map(e=>`${e.size===null?`—`:String(e.size)} (×${e.count})`).join(`, `)}function Di({card:e}){let t=f(e.root),n=p(e.root),i=Ti(n),a=T(e.root),o=m(e.root),s=a.filter(({node:e})=>(e.effects??[]).length>0),c={key:`${e.id}:colors`,label:`${r(`Palette`,`Палитра`)} (${t.length}) ${e.id}`,shortLabel:r(`palette`,`палитра`),cardId:e.id,cardName:e.name,payload:JSON.stringify(t.map(e=>({...e,token:o.has(e.color)})),null,2),fenceLanguage:`json`},l={key:`${e.id}:fonts`,label:`${r(`Fonts`,`Шрифты`)} (${n.length}) ${e.id}`,shortLabel:r(`fonts`,`шрифты`),cardId:e.id,cardName:e.name,payload:JSON.stringify(n,null,2),fenceLanguage:`json`};return F(`div`,{className:`flex flex-col gap-2 pt-2`,children:[P(Q,{title:r(`Colors`,`Цвета`),sublabel:r(`token binding from the DSL`,`привязка к токенам из DSL`),count:t.length,attachItem:c,defaultOpen:!0,children:P(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:t.map(e=>{let t=o.has(e.color);return F(`div`,{"data-testid":`pixso-style-color`,className:`flex items-center gap-2 text-[13px]`,children:[P(vi,{color:e.color}),P(`span`,{className:Y.value,children:e.color}),t?F(`span`,{className:`rounded border border-success/40 bg-success/10 px-1 text-xs leading-4 text-success`,children:[r(`token`,`токен`),` ✓`]}):F(`span`,{className:`rounded border border-warning/40 bg-warning/10 px-1 text-xs leading-4 text-warning`,title:r(`Raw color — not bound to a library style`,`Сырой цвет — не привязан к стилю библиотеки`),children:[r(`no token`,`без токена`),` ⚠`]}),P(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground/60`,children:e.usedBy.join(`, `)}),P(X,{value:e.color,label:r(`Copy hex`,`Скопировать hex`)})]},e.color)})})}),P(Q,{title:r(`Fonts`,`Шрифты`),count:i.length,attachItem:l,defaultOpen:!0,children:P(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:i.map(e=>F(`div`,{"data-testid":`pixso-style-font`,className:`flex items-center gap-2 text-[13px]`,children:[P(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-md border border-border bg-muted font-mono text-xs text-muted-foreground`,children:`Aa`}),P(`span`,{className:(0,H.cn)(`shrink-0`,Y.name),children:e.label}),P(`span`,{className:(0,H.cn)(`ml-auto min-w-0 truncate tabular-nums`,Y.value),children:Ei(e.sizes)})]},e.key))})}),s.length>0&&P(Q,{title:r(`Effects`,`Эффекты`),count:s.length,children:P(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:s.map(({node:e})=>(e.effects??[]).map((t,n)=>F(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[P(`span`,{className:Y.name,children:e.name}),P(`span`,{className:Y.type,children:t.kind===`drop-shadow`?r(`shadow`,`тень`):t.kind===`foreground-blur`?r(`layer blur`,`блюр слоя`):r(`background blur`,`блюр фона`)}),t.color!==void 0&&P(vi,{color:t.color,size:`sm`}),F(`span`,{className:(0,H.cn)(`text-xs tabular-nums`,Y.geometry),children:[t.offsetX!==void 0&&`→${t.offsetX},${t.offsetY??0}`,t.spread!==void 0&&` spread ${t.spread}`]})]},`${e.id}-${n}`)))})})]})}function Oi({axis:e}){return F(`div`,{"data-testid":`pixso-catalog-set-axis`,className:`flex w-full min-w-0 flex-wrap items-start gap-x-2 gap-y-0.5`,children:[P(`span`,{"data-testid":`pixso-catalog-set-axis-label`,className:`shrink-0 basis-24 py-0.5 text-xs text-muted-foreground/70`,children:e.name}),P(`div`,{className:`flex min-w-0 flex-1 basis-40 flex-wrap items-center gap-1`,children:e.optionDetails.map(e=>F(ar.Badge,{"data-testid":`pixso-catalog-set-axis-option`,"data-deprecated":e.deprecated?`true`:`false`,size:`sm`,variant:e.deprecated?`warning`:`outline`,children:[e.deprecated&&P(O,{"aria-label":r(`deprecated`,`устарел`)}),e.value]},e.value))})]})}function ki({label:e,testId:t,children:n}){return F(`div`,{"data-testid":t,className:`flex w-full min-w-0 flex-wrap items-start gap-x-2 gap-y-0.5`,children:[P(`span`,{className:`shrink-0 basis-24 text-xs text-muted-foreground/70`,children:e}),P(`span`,{className:`min-w-0 flex-1 basis-40 break-words text-xs text-muted-foreground`,children:n})]})}var Ai=class{listeners=new Set;container=null;scrollTop=0;viewportHeight=0;rowHeight=0;epoch=0;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));emit(){for(let e of this.listeners)e()}get containerEl(){return this.container}setContainer(e){this.container=e,e!==null&&(this.scrollTop=e.scrollTop)}handleScroll(){let e=this.container?.scrollTop??0;e!==this.scrollTop&&(this.scrollTop=e,this.emit())}setViewportHeight(e){e!==this.viewportHeight&&(this.viewportHeight=e,this.emit())}setRowHeight(e){e<=0||e===this.rowHeight||(this.rowHeight=e,this.emit())}bumpEpoch(){this.epoch+=1,this.emit()}};const ji=ht(null);function Mi(){let e=_t(ji);if(e===null)throw Error(`useScrollViewportStore must be used inside <ScrollViewport>`);return e}function Ni({layoutKey:e,className:t,children:n}){let[r]=j(()=>new Ai),i=gt(e=>r.setContainer(e),[r]);return vt(()=>{let e=r.containerEl;if(e===null)return;let t=new ResizeObserver(()=>r.setViewportHeight(e.clientHeight));return t.observe(e),r.setViewportHeight(e.clientHeight),()=>t.disconnect()},[r]),vt(()=>{r.bumpEpoch()},[r,e,bt(r.subscribe,()=>r.rowHeight,()=>r.rowHeight)]),P(ji.Provider,{value:r,children:P(`div`,{ref:i,onScroll:()=>r.handleScroll(),className:t,children:n})})}const Pi=`https://pixso.cn`;function Fi(e,t,n,r){let i=new URLSearchParams;n!==void 0&&i.set(`item-id`,n),r!==void 0&&i.set(`page-id`,r);let a=i.toString();return`${e.replace(/\/$/,``)}/app/design/${t}${a===``?``:`?${a}`}`}function Ii(e,t,n,r){return e===null?null:hr(Fi(e,t,n,r))}function Li({href:e}){return P(`a`,{"data-testid":`pixso-catalog-link`,href:e,target:`_blank`,rel:`noreferrer`,title:r(`Open on the Pixso host`,`Открыть на хосте Pixso`),className:`shrink-0 text-muted-foreground/60 transition-colors hover:text-primary`,children:P(D,{className:`size-3.5`})})}function Ri({expanded:e}){return P(Ee,{"data-testid":`pixso-catalog-chevron`,className:(0,H.cn)(`size-3 shrink-0 transition-transform duration-150`,e&&`rotate-180`)})}function zi(){return F(`span`,{"data-testid":`pixso-catalog-deprecated-chip`,className:`flex shrink-0 items-center gap-0.5 rounded border border-warning/40 bg-warning/10 px-1 text-xs leading-4 text-warning`,children:[P(O,{className:`size-3`}),r(`deprecated`,`устарел`)]})}function Bi(){return P(`span`,{"aria-hidden":!0,className:`text-muted-foreground/40`,children:`·`})}function Vi({libraryName:e,libraryFileKey:t,place:n,size:r,updatedAt:i}){return F(`span`,{"data-testid":`pixso-catalog-meta-line`,className:`flex w-full min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground/70`,children:[P(`span`,{title:t,children:e}),n!==null&&F(N,{children:[P(Bi,{}),P(`span`,{className:`break-words`,children:n})]}),P(Bi,{}),P(`span`,{className:(0,H.cn)(`tabular-nums`,Y.geometry),children:r}),i!==null&&F(N,{children:[P(Bi,{}),P(`span`,{className:`tabular-nums`,children:Jr(i)})]})]})}function Hi(e){return e.sizeAxis!==null&&e.sizeDifferences.length>0?P(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:e.sizeDifferences.map(e=>F(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[e.label,P(`span`,{"aria-hidden":!0,children:`→`}),P(`span`,{className:(0,H.cn)(`tabular-nums`,Y.geometry),children:e.value})]},e.label))}):e.sizeAxisPair===null?null:i(`depend on {0} and {1}`,`зависят от {0} и {1}`,[e.sizeAxisPair[0],e.sizeAxisPair[1]])}function Ui({group:e}){let t=Hi(e);return F(`div`,{"data-testid":`pixso-catalog-set-body`,className:`flex flex-col gap-1 border-t border-border/40 px-2 pb-1.5 pt-1.5 text-xs`,children:[e.axes.length===0?P(`div`,{"data-testid":`pixso-catalog-set-axes-empty`,className:`text-muted-foreground/70`,children:r(`No structured variant data for this set.`,`Нет структурированных данных о вариантах этого набора.`)}):e.axes.map(e=>P(Oi,{axis:e},e.name)),e.unattributedVariants>0&&P(ki,{testId:`pixso-catalog-set-unattributed`,label:r(`Outside the matrix`,`Вне матрицы`),children:P(`span`,{className:`tabular-nums`,children:e.unattributedVariants})}),t!==null&&P(ki,{testId:`pixso-catalog-set-size-axis`,label:r(`Sizes`,`Размеры`),children:t}),e.unattributedDeprecated>0&&P(ki,{testId:`pixso-catalog-set-unattributed-deprecated`,label:r(`Deprecated`,`Устарело`),children:F(`span`,{className:`flex items-center gap-1 text-warning`,children:[P(O,{className:`size-3 shrink-0`}),P(`span`,{className:`tabular-nums`,children:e.unattributedDeprecated})]})}),e.description!==null&&P(ki,{testId:`pixso-catalog-set-description`,label:r(`Description`,`Описание`),children:F(`span`,{className:(0,H.cn)(`break-words`,Y.string),children:[`«`,e.description,`»`]})})]})}function Wi({body:e}){return F(`div`,{"data-testid":`pixso-catalog-row-body`,className:`flex flex-col gap-1 border-t border-border/40 px-2 pb-1.5 pt-1.5 text-xs`,children:[e.description!==null&&P(ki,{testId:`pixso-catalog-row-description`,label:r(`Description`,`Описание`),children:F(`span`,{className:(0,H.cn)(`break-words`,Y.string),children:[`«`,e.description,`»`]})}),e.rawName!==null&&P(ki,{testId:`pixso-catalog-row-raw-name`,label:r(`Full name`,`Полное имя`),children:P(`span`,{className:(0,H.cn)(`break-words`,Y.id),children:e.rawName})})]})}function Gi({entry:e,libraryName:t,host:n,scanUsage:i,expanded:a,onToggle:o}){let s=ne(e),c=ge(e),l=Ii(n,e.file_key,e.node_id,e.containing_frame.pageId),u=F(N,{children:[F(`span`,{className:`flex w-full min-w-0 items-start gap-1.5`,children:[P(`span`,{className:`min-w-0 break-words text-[13px] font-medium`,children:ee(e)}),s&&P(zi,{}),e.containing_frame.containingStateGroup!==void 0&&P(`span`,{className:`shrink-0 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:e.containing_frame.containingStateGroup.name}),i!==void 0&&P(`span`,{className:`shrink-0 rounded border border-primary/30 bg-primary/8 px-1 text-xs leading-4 text-primary`,children:r(`in scan`,`в скане`)}),c!==null&&P(`span`,{className:`ml-auto flex shrink-0 items-center pt-0.5 text-muted-foreground/60`,children:P(Ri,{expanded:a})})]}),P(Vi,{libraryName:t,libraryFileKey:e.file_key,place:e.containing_frame.pageName,size:_e(e.min_node_width,e.min_node_height),updatedAt:e.updated_at})]});return F(`div`,{"data-testid":`pixso-catalog-row`,className:(0,H.cn)(`flex flex-col rounded-md border bg-background`,s?`border-warning/40`:`border-border/60`),children:[F(`div`,{className:`flex w-full min-w-0 items-start gap-1.5 pr-2`,children:[c===null?P(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 px-2 py-1`,children:u}):P(`button`,{type:`button`,"data-testid":`pixso-catalog-row-header`,"aria-expanded":a,onClick:o,className:`flex min-w-0 flex-1 flex-col gap-0.5 rounded-md px-2 py-1 text-left transition-colors hover:bg-accent/30`,children:u}),l!==null&&P(`span`,{className:`flex shrink-0 items-center pt-1.5`,children:P(Li,{href:l})})]}),a&&c!==null&&P(Wi,{body:c})]})}function Ki({group:e,expanded:t,libraryName:n,host:i,onToggle:a}){let o=Ii(i,e.linkTarget.fileKey,e.linkTarget.nodeId,e.linkTarget.pageId);return F(`div`,{"data-testid":`pixso-catalog-set-card`,className:(0,H.cn)(`flex flex-col rounded-md border bg-background`,e.deprecated?`border-warning/40`:`border-border/60`),children:[F(`div`,{className:`flex w-full min-w-0 items-start gap-1.5 pr-2`,children:[F(`button`,{type:`button`,"data-testid":`pixso-catalog-set-header`,"aria-expanded":t,onClick:a,className:`flex min-w-0 flex-1 flex-col gap-0.5 rounded-md px-2 py-1 text-left transition-colors hover:bg-accent/30`,children:[F(`span`,{className:`flex w-full min-w-0 items-start gap-1.5`,children:[P(`span`,{className:`min-w-0 break-words text-[13px] font-medium`,children:e.displayName}),e.deprecated&&P(zi,{}),F(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 pt-0.5 text-xs text-muted-foreground/60`,children:[F(`span`,{className:`tabular-nums`,children:[e.entries.length,` `,r(`variants`,`вариантов`)]}),P(Ri,{expanded:t})]})]}),P(Vi,{libraryName:n,libraryFileKey:e.libraryFileKey,place:e.frameName,size:me(e),updatedAt:pe(e)})]}),o!==null&&P(`span`,{className:`flex shrink-0 items-center pt-1.5`,children:P(Li,{href:o})})]}),t&&P(Ui,{group:e})]})}function qi({rowKey:e,top:t,onHeight:n,children:r}){let i=yt(null);return vt(()=>{let t=i.current;if(t===null)return;let r=()=>{let r=Math.round(t.getBoundingClientRect().height);r>0&&n(e,r)};if(r(),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[e,n]),P(`div`,{ref:i,"data-testid":`pixso-catalog-measured-row`,className:`absolute inset-x-0 px-3 py-0.5`,style:{top:t},children:r})}function Ji({items:e,expandedKeys:t,libraryLabels:n,host:i,usagesByKey:a,onToggle:o}){let s=Mi(),l=yt(null),[f,p]=j(0),[m,h]=j(()=>new Map);vt(()=>{let e=s.containerEl,t=l.current;if(e===null||t===null)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;p(e=>e===n?e:n)},[s,s.epoch]);let g=gt((e,t)=>{h(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),_=A(()=>e.map(e=>{let n=u(e),r=(e.kind===`set`||ge(e.entry)!==null)&&t.has(n);return{item:e,itemKey:n,expanded:r,key:d(e,r)}}),[e,t]),v=A(()=>c(_.map(e=>m.get(e.key)??(e.expanded?150:52))),[_,m]),y=()=>`${s.scrollTop}:${s.viewportHeight}`,[b=`0`,x=`0`]=bt(s.subscribe,y,y).split(`:`),{start:S,end:C}=ye(v,Number(b)-f,Number(x),8),w=A(()=>{let e=[],t=e=>n.get(e)?.label??r(`Library`,`Библиотека`);for(let n=S;n<C;n+=1){let r=_[n];if(r===void 0)continue;let{item:s,itemKey:c}=r;e.push(P(qi,{rowKey:r.key,top:v[n]??0,onHeight:g,children:s.kind===`singleton`?P(Gi,{entry:s.entry,libraryName:t(s.entry.file_key),host:i,scanUsage:a.get(s.entry.component_key),expanded:r.expanded,onToggle:()=>o(c)}):P(Ki,{group:s.group,expanded:r.expanded,libraryName:t(s.group.libraryFileKey),host:i,onToggle:()=>o(c)})},r.key))}return e},[_,S,C,v,g,n,i,a,o]);return P(`div`,{ref:l,"data-testid":`pixso-catalog-grid`,className:`relative`,style:{height:ve(v)},children:w})}function Yi({snapshot:e,usages:t,host:n,capturedAtLabel:i}){let[a,o]=j(``),[s,c]=j(null),[d,f]=j(!1),[p,m]=j(()=>new Set),h=gt(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),g=A(()=>new Map(t.map(e=>[e.key,e])),[t]),v=A(()=>fe(e.entries,e.libraryNames),[e]),y=A(()=>{let t=new Map;for(let n of e.entries)t.set(n.file_key,(t.get(n.file_key)??0)+1);return[...t.entries()].map(([e,t])=>({key:e,count:t,name:v.get(e)?.label??r(`Library`,`Библиотека`)}))},[e,v]),b=A(()=>de(e.entries),[e]),x=A(()=>{let t=a.trim().toLowerCase();return e.entries.filter(e=>s!==null&&e.file_key!==s||d&&!ne(e)?!1:ie(e,t,b.get(e.component_key)))},[e,a,s,d,b]),S=A(()=>ce(x,b),[x,b]),C=A(()=>l(e.entries,b),[e,b]),w=_(S),T=a.trim()!==``,ee=A(()=>{if(!T)return p;let e=new Set(p);for(let t of S)e.add(u(t));return e},[T,p,S]),te=`${S.length}:${ee.size}:${s??``}:${d?1:0}:${a}`,re=y.find(e=>e.key===s)??null;return F(`div`,{className:`-mx-3 flex min-h-0 flex-1 flex-col gap-1.5 pt-2`,children:[F(`div`,{className:`shrink-0 px-3 text-xs text-muted-foreground/70`,children:[r(`catalog at scan time`,`каталог на момент скана`),` (`,i,`) ·`,` `,y.length,` `,r(`libraries`,`библиотек`),` · `,C,` `,r(`components`,`компонентов`)]}),F(`div`,{className:`flex shrink-0 items-center gap-1.5 px-3`,children:[F(`div`,{className:`relative min-w-0 flex-1`,children:[P(ot,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/60`}),P(q.Input,{size:`sm`,value:a,onValueChange:o,placeholder:r(`Search components…`,`Поиск по компонентам…`),className:`pl-7`})]}),F(ni,{children:[F(ri,{render:P(U,{variant:`outline`,size:`sm`,className:`shrink-0`}),children:[re?.name??r(`All libraries`,`Все библиотеки`),P(Ee,{})]}),F(ii,{align:`end`,children:[P($,{onClick:()=>c(null),children:r(`All libraries`,`Все библиотеки`)}),y.map(e=>F($,{onClick:()=>c(e.key),children:[P(`span`,{title:e.key,children:e.name}),P(`span`,{className:`ml-auto pl-3 text-xs tabular-nums text-muted-foreground/60`,children:e.count})]},e.key))]})]}),P(rr.Toggle,{size:`sm`,pressed:d,onPressedChange:e=>f(e),"aria-label":r(`Deprecated only`,`Только устаревшие`),title:r(`Deprecated only`,`Только устаревшие`),children:P(O,{className:`size-3.5`})})]}),P(Ni,{layoutKey:te,className:`min-h-0 flex-1 overflow-y-auto border-t border-border/50`,children:P(Ji,{items:S,expandedKeys:ee,libraryLabels:v,host:n,usagesByKey:g,onToggle:h})},a),P(`div`,{className:`shrink-0 px-3 pb-1 text-xs tabular-nums text-muted-foreground/60`,"data-testid":`pixso-catalog-count`,children:x.length===e.entries.length?`${w} ${r(`components`,`компонентов`)}`:`${r(`found`,`найдено`)} ${w} ${r(`of`,`из`)} ${C}`})]})}const Xi=new Set([`dsl-state-group`,`norm-name`,`layer-name`,`unknown`]);function Zi({value:e,kind:t}){if(t===`visible`){let t=e===`on`;return P(`span`,{className:(0,H.cn)(`rounded border px-1 text-xs leading-4`,t?`border-success/40 bg-success/10 text-success`:`border-border bg-muted text-muted-foreground`),children:t?r(`on`,`вкл`):r(`off`,`выкл`)})}return F(`span`,{className:(0,H.cn)(`truncate`,Y.string),children:[`«`,e,`»`]})}function Qi({usage:e,host:t,catalog:n,isRemote:i}){let a=e.props.filter(e=>e.overridden).length,o=n?.entries.find(t=>t.component_key===e.key),s=t===null?null:o===void 0?e.libraryFileKey===null?null:Fi(t,e.libraryFileKey):Fi(t,o.file_key,o.node_id,o.containing_frame.pageId);return F(`div`,{"data-testid":`pixso-component-usage`,className:(0,H.cn)(`rounded-md border border-border/60 bg-background px-2 py-1.5`,e.deprecated&&`border-warning/50`),children:[F(`div`,{className:`flex items-center gap-1.5`,children:[P(ke,{className:`size-3.5 shrink-0 text-primary/70`}),P(`span`,{className:`truncate text-[13px] font-medium`,children:e.name}),e.count>1&&F(`span`,{className:(0,H.cn)(`shrink-0 text-xs tabular-nums`,Y.geometry),children:[`×`,e.count]}),e.variantGroup!==null&&!e.deprecated&&P(`span`,{className:`shrink-0 truncate rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,children:e.variantGroup}),e.deprecated&&F(`span`,{className:`flex shrink-0 items-center gap-0.5 rounded border border-warning/40 bg-warning/10 px-1 text-xs leading-4 text-warning`,children:[P(O,{className:`size-2.5`}),r(`deprecated`,`устарел`)]}),e.nameSource!==void 0&&Xi.has(e.nameSource)&&P(`span`,{"data-testid":`pixso-component-name-source`,className:`shrink-0 cursor-default text-xs leading-4 text-muted-foreground/50`,title:`${r(`Name derived from the DSL, not confirmed by a catalogue row`,`Имя выведено из DSL, а не подтверждено строкой каталога`)} (${e.nameSource})`,children:`~`}),!e.resolved&&!i&&F(`span`,{"data-testid":`pixso-component-unresolved`,className:`flex shrink-0 items-center gap-0.5 rounded border border-border bg-muted px-1 text-xs leading-4 text-muted-foreground`,title:r(`The component's library is not connected — no catalog data.`,`Библиотека компонента не подключена — данных каталога нет.`),children:[P(dt,{className:`size-2.5`}),r(`library not connected`,`библиотека не подключена`)]}),F(`span`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[s!==null&&P(`a`,{href:s,target:`_blank`,rel:`noreferrer`,title:r(`Open on the Pixso host (URL format pending one live check)`,`Открыть на хосте Pixso (формат ссылки будет сверен на живом хосте)`),className:`text-muted-foreground/50 hover:text-primary`,children:P(D,{className:`size-3`})}),P(X,{value:e.key,label:r(`Copy component key`,`Скопировать ключ компонента`)})]})]}),(e.library!==null||e.pageName!==null||e.description!==null)&&F(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 pl-5 text-xs text-muted-foreground/70`,children:[e.library!==null&&P(`span`,{className:`truncate`,children:e.library}),e.pageName!==null&&F(`span`,{className:`truncate`,children:[r(`page`,`стр.`),` «`,e.pageName,`»`]}),e.description!==null&&e.description!==``&&P(`span`,{className:(0,H.cn)(`truncate`,Y.string),children:e.description}),e.updatedAt!==null&&P(`span`,{className:`shrink-0 tabular-nums`,children:Jr(e.updatedAt)})]}),e.props.length>0&&F(Z.Collapsible,{className:`mt-1 pl-5`,children:[F(Z.CollapsibleTrigger,{className:`group flex items-center gap-1 text-xs text-muted-foreground/70 transition-colors hover:text-foreground`,children:[P(Oe,{className:`size-2.5 transition-transform duration-150 group-data-panel-open:rotate-90`}),e.props.length,` `,r(`props`,`свойств`),e.count>1&&P(`span`,{"data-testid":`pixso-props-first-instance`,className:`truncate text-muted-foreground/50`,title:r(`Values of the first instance — other instances may differ.`,`Значения первого экземпляра — у остальных они могут отличаться.`),children:r(`(first instance)`,`(первого экземпляра)`)}),a>0&&F(`span`,{className:`rounded border border-primary/30 bg-primary/8 px-1 text-xs leading-4 text-primary`,children:[a,` `,r(`overridden`,`переопределено`)]})]}),P(Z.CollapsiblePanel,{children:P(`div`,{className:`mt-1 flex flex-col gap-0.5`,children:e.props.map(e=>F(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[P(`span`,{className:(0,H.cn)(`shrink-0`,Y.name),children:e.name}),P(Zi,{value:e.value,kind:e.kind}),e.overridden&&F(`span`,{className:`truncate text-muted-foreground/50`,title:r(`Default value`,`Значение по умолчанию`),children:[`(`,r(`default`,`по умолч.`),` `,e.kind===`visible`?e.defaultValue===`on`?r(`on`,`вкл`):r(`off`,`выкл`):`«${e.defaultValue}»`,`)`]})]},e.name))})})]})]})}function $i({usages:e,host:t,catalog:n,isRemote:i=!1}){let a=new Set(e.filter(e=>e.libraryFileKey!==null).map(e=>e.libraryFileKey)),o=e.filter(e=>e.deprecated).length,s=e.filter(e=>!e.resolved).length;return F(`div`,{className:`flex flex-col gap-1.5 pt-1`,children:[F(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 px-0.5 text-xs text-muted-foreground/70`,children:[F(`span`,{children:[e.reduce((e,t)=>e+t.count,0),` `,r(`instances`,`экземпляров`),` ·`,` `,e.length,` `,r(`components`,`компонентов`),` · `,a.size,` `,r(`libraries`,`библиотек`)]}),o>0&&F(`span`,{className:`flex items-center gap-0.5 text-warning`,children:[P(O,{className:`size-2.5`}),o,` `,r(`deprecated`,`устаревших`)]}),s>0&&!i&&F(`span`,{className:`text-muted-foreground/60`,children:[s,` `,r(`outside connected libraries`,`вне подключённых библиотек`)]})]}),e.map(e=>P(Qi,{usage:e,host:t,catalog:n,isRemote:i},e.key))]})}function ea({card:e}){let[t,n]=j(`used`),i=B(e=>e.loadCatalog),a=B(e=>e.retryCatalog),o=B(t=>e.catalogHash===void 0?!1:t.catalogErrors.has(e.catalogHash)),s=e.componentsUsed??[],c=e.catalogHash,u=e.catalog,d=A(()=>u===void 0?null:l(u.entries),[u]);k(()=>{t===`catalog`&&c!==void 0&&i(c)},[t,c,i]);let f=(e,r)=>P(`button`,{type:`button`,"data-testid":`pixso-components-view-${e}`,onClick:()=>n(e),className:(0,H.cn)(`cursor-pointer rounded-md px-2 py-1 text-[13px] transition-colors`,t===e?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),children:r});return F(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-2`,children:[F(`div`,{className:`flex w-fit shrink-0 items-center gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5`,children:[f(`used`,`${r(`In this selection`,`В выборке`)} · ${s.length}`),c!==void 0&&f(`catalog`,d===null?r(`Catalog`,`Каталог`):`${r(`Catalog`,`Каталог`)} · ${d}`)]}),t===`used`?P(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-3`,children:s.length>0?P($i,{usages:s,host:Pi,catalog:e.catalog,isRemote:e.source===`remote`}):P(`p`,{className:`px-0.5 pt-2 text-xs text-muted-foreground/70`,children:r(`No component instances in this selection.`,`В выборке нет экземпляров компонентов.`)})}):e.catalog===void 0?o?F(`div`,{className:`flex items-center gap-2 pt-2`,children:[P(`p`,{className:`px-0.5 text-xs text-muted-foreground/70`,"data-testid":`pixso-catalog-error`,children:r(`Failed to load the catalog.`,`Не удалось загрузить каталог.`)}),c!==void 0&&P(U,{variant:`outline`,size:`sm`,onClick:()=>a(c),children:r(`Retry`,`Повторить`)})]}):P(`p`,{className:`px-0.5 pt-2 text-xs text-muted-foreground/70`,children:r(`Loading the catalog…`,`Загружаем каталог…`)}):P(Yi,{snapshot:e.catalog,usages:s,host:Pi,capturedAtLabel:e.importedAt})]})}function ta(){let e=B(e=>e.backToTabs),t=B(e=>e.loadRaw),n=Kt(),{card:i,loading:a,failed:o}=ei(),s=B(e=>e.retryDetail),c=B(e=>e.selectedCardId),[l,u]=j(null),[d,f]=j(null),[p,m]=j(0),[g,_]=j(`overview`);k(()=>{i===null&&!a&&!o&&e()},[i,a,o,e]);let y=i===null?null:l===null?i.root:S(i.root,l)??i.root,b=i===null||y===null?``:v(y,C(i.root,y.id)),x={key:`${i?.id??`-`}:css:${y?.id??`-`}`,label:`CSS «${y?.name??``}»`,shortLabel:`css ${y?.name??``}`,cardId:i?.id??``,cardName:i?.name??``,payload:b,fenceLanguage:`css`};if(i===null)return o?F(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[P(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:F(U,{variant:`ghost`,size:`sm`,onClick:e,children:[P(De,{className:`size-4`}),r(`Back`,`Назад`)]})}),F(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-4 text-center`,children:[P(`p`,{className:`text-[13px] text-muted-foreground`,children:r(`Could not load the card.`,`Не удалось загрузить карточку.`)}),P(U,{variant:`outline`,size:`sm`,onClick:()=>{c!==null&&s(c)},children:r(`Retry`,`Повторить`)})]})]}):a?F(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[P(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:F(U,{variant:`ghost`,size:`sm`,onClick:e,children:[P(De,{className:`size-4`}),r(`Back`,`Назад`)]})}),P(`div`,{className:`flex flex-1 items-center justify-center`,children:P(G.Spinner,{className:`size-4 text-muted-foreground/60`})})]}):null;let w=h(i.root),ee=vr(i),te=T(i.root),ne=te.filter(e=>e.node.sticky===!0).length,re=te.filter(e=>e.node.mask===!0).length,ie=te.filter(e=>e.node.visible===!1).length,ae=i.componentsUsed??[],oe=ae.filter(e=>e.deprecated).length,se=d??i.root.id,ce=e=>{u(e);let t=C(i.root,e);f(t===null?i.root.id:t.id)},le=e=>{u(e),m(e=>e+1)},ue=i.rawDsl??null,de=te.flatMap(({node:e})=>(e.links??[]).map(t=>({name:e.name,url:t.url}))),fe=`block min-h-0 flex-1 overflow-y-auto px-3 pb-3`;return F(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[P(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:F(U,{variant:`ghost`,size:`sm`,onClick:e,children:[P(De,{className:`size-4`}),r(`Back`,`Назад`)]})}),P(`div`,{className:`shrink-0 px-3 pt-2.5`,children:F(`div`,{className:`min-w-0`,"data-testid":`pixso-detail-header`,children:[F(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[P(`h3`,{className:`truncate text-sm font-semibold`,children:i.name}),P(ar.Badge,{variant:`outline`,size:`sm`,className:`shrink-0 text-xs`,children:ee.label}),ee.library!==null&&P(`span`,{className:`shrink-0 truncate text-xs text-muted-foreground/60`,children:ee.library})]}),F(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-[13px]`,children:[F(`span`,{title:`id ${i.id}`,className:(0,H.cn)(`tabular-nums`,Y.geometry),children:[Math.round(i.root.width),` × `,Math.round(i.root.height)]}),F(`span`,{className:Y.geometry,children:[w.layers,` `,r(`layers`,`слоёв`)]}),F(`span`,{className:Y.geometry,children:[`DSL `,i.dslVersion,i.versionUnverified===!0&&` · ${r(`unverified`,`не подтверждена`)}`]})]})]})}),F(J.Tabs,{value:g,onValueChange:e=>_(e),className:`mt-2 flex min-h-0 flex-1 flex-col`,children:[F(J.TabsList,{className:`shrink-0 gap-0.5 overflow-x-auto border-b border-border/60 px-3 py-1 [scrollbar-width:none]`,children:[ti.map(e=>{let t=g===e.value;return F(sr.Tooltip,{children:[P(sr.TooltipTrigger,{render:F(J.TabsTab,{value:e.value,className:(0,H.cn)(`z-10 h-7 shrink-0 gap-0 px-2 text-[13px] transition-colors`,!t&&`hover:bg-muted/60`),children:[F(`span`,{className:`relative shrink-0`,children:[P(e.icon,{className:(0,H.cn)(`size-3.5 transition-[color,transform] duration-300`,t&&`scale-110 text-primary`)}),e.value===`components`&&oe>0&&P(`span`,{className:`absolute -right-1 -top-1 size-1.5 rounded-full bg-warning`,"aria-label":r(`uses deprecated components`,`есть устаревшие компоненты`)})]}),P(`span`,{className:(0,H.cn)(`grid transition-[grid-template-columns] duration-300 ease-[cubic-bezier(0.3,1.4,0.5,1)]`,t?`grid-cols-[1fr]`:`grid-cols-[0fr]`),children:P(`span`,{className:`min-w-0 overflow-hidden`,children:P(`span`,{className:(0,H.cn)(`block whitespace-nowrap pl-1.5 font-medium transition-opacity duration-200`,t?`opacity-100 delay-100`:`opacity-0`),children:e.label()})})})]})}),P(sr.TooltipPopup,{side:`bottom`,children:e.label()})]},e.value)}),P(J.TabsIndicator,{className:`inset-y-1 h-auto rounded-md bg-accent shadow-sm ring-1 ring-border/60 duration-300 ease-[cubic-bezier(0.3,1.4,0.5,1)]`})]}),P(J.TabsPanel,{value:`overview`,className:fe,"data-testid":`pixso-tab-overview`,children:P(pi,{card:i,stickyCount:ne,maskCount:re,hiddenCount:ie,deprecatedUsed:oe,componentsUsed:ae,designerLinks:de,onOpenPrompt:()=>_(`prompt`)})}),P(J.TabsPanel,{value:`structure`,className:fe,"data-testid":`pixso-tab-structure`,children:P(wi,{card:i,flatCount:te.length,selectedNodeId:l,onTreeSelect:ce,revealTick:p,effectiveFocusId:se,onFocusChange:f,onRevealSelect:le,cssNode:y,cssText:b,cssItem:x,rawDslText:ue,onLoadRaw:()=>t(i.id),resolvedTheme:n})}),P(J.TabsPanel,{value:`styles`,className:fe,"data-testid":`pixso-tab-styles`,children:P(Di,{card:i})}),P(J.TabsPanel,{value:`components`,className:`min-h-0 flex-1 overflow-hidden`,"data-testid":`pixso-tab-components`,children:P(ea,{card:i})}),P(J.TabsPanel,{value:`qa`,className:fe,"data-testid":`pixso-tab-qa`,children:P(Kr,{card:i,onShowNode:e=>{ce(e),m(e=>e+1),_(`structure`)}})}),P(J.TabsPanel,{value:`analytics`,className:fe,"data-testid":`pixso-tab-analytics`,children:P(Fr,{card:i})}),P(J.TabsPanel,{value:`prompt`,className:fe,"data-testid":`pixso-tab-prompt`,children:P(Br,{card:i})})]})]})}function na({savedTo:e,deviations:t}){let n=t.at(-1)??null;return e===``?F(`p`,{className:`mt-2 break-words rounded-md border border-destructive/30 bg-destructive/6 px-2.5 py-1.5 text-xs text-destructive`,"data-testid":`pixso-debug-full-probe-not-saved`,children:[r(`Dump not saved.`,`Дамп не сохранён.`),n===null?``:` ${n}`]}):F(`p`,{className:`mt-2 text-xs text-muted-foreground/60`,children:[r(`Report saved to: `,`Отчёт сохранён: `),e]})}function ra({ok:e,detail:t,okMessage:n,failMessage:r,testId:i}){return e?F(`p`,{className:`mt-2 rounded-md border border-success/25 bg-success/6 px-2.5 py-1.5 text-[13px] text-success`,"data-testid":i,children:[n,t===null?null:P(`span`,{className:(0,H.cn)(`ml-1.5 font-mono text-xs text-success/80`),children:t})]}):P(`p`,{className:`mt-2 break-words rounded-md border border-destructive/30 bg-destructive/6 px-2.5 py-1.5 font-mono text-[13px] text-destructive`,"data-testid":i,children:t??r})}var ia=t({});import*as aa from"@smart-tools/qwen-cli-ui-kit";e(ia,aa);const oa={ok:{en:`OK`,ru:`OK`,className:`bg-success/10 text-success`},dead:{en:`DEAD`,ru:`DEAD`,className:`bg-destructive/10 text-destructive`},empty:{en:`empty`,ru:`пусто`,className:`bg-muted text-muted-foreground/70`},"needs-args":{en:`contract`,ru:`контракт`,className:`bg-warning/10 text-warning`},skip:{en:`skip`,ru:`skip`,className:`bg-muted text-muted-foreground/70`}};function sa(){let e=B(e=>e.probePhase),t=B(e=>e.runProbe),n=B(e=>e.lastProbe),i=B(e=>e.lastProbeError),[a,o]=j(!0),s=n===null?[]:n.rows.filter(e=>e.status!==`skip`);return F(Q,{title:r(`Diagnostics probe`,`Диагностическая проба`),sublabel:r(`over the current selection`,`по текущему выделению`),count:n===null?`—`:qr(n.atIso),countTone:n===null?`na`:`default`,defaultOpen:!0,children:[F(`div`,{className:`flex items-center gap-2 pt-1`,children:[F(U,{variant:`outline`,size:`sm`,onClick:t,disabled:e===`running`,className:`shrink-0`,children:[e===`running`?P(G.Spinner,{className:`size-3.5`}):P(nt,{}),r(`Run diagnostics`,`Запустить диагностику`)]}),P(`span`,{className:`text-xs text-muted-foreground/60`,children:r(`read tools only; results are saved`,`только read-инструменты; результаты сохраняются`)})]}),e===`running`&&P(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:Array.from({length:4},(e,t)=>P(ia.Skeleton,{className:`h-6 w-full rounded-md`},t))}),e===`failed`&&P(`p`,{className:`mt-2 rounded-md border border-destructive/30 bg-destructive/6 px-2.5 py-1.5 text-[13px] text-destructive`,children:i??r(`Probe failed.`,`Проба не удалась.`)}),e===`done`&&n!==null&&F(`div`,{className:`mt-2 flex flex-col`,children:[s.map(e=>F(`div`,{className:`flex items-center gap-2 border-b border-border/50 py-1.5 text-[13px] last:border-0`,children:[P(`code`,{className:`font-mono text-foreground`,children:e.tool}),P(`span`,{className:(0,H.cn)(`ml-auto shrink-0 rounded-full px-2 py-px font-mono text-xs leading-4`,oa[e.status].className),children:r(oa[e.status].en,oa[e.status].ru)}),P(`span`,{className:`w-32 shrink-0 truncate text-right font-mono text-xs tabular-nums text-muted-foreground/60`,children:e.detail})]},e.tool)),n.deviations.length>0?F(`div`,{className:`mt-2 rounded-md border border-warning/30 bg-warning/8 px-2.5 py-1.5`,children:[F(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1 text-left text-[13px] font-medium text-warning`,children:[P(a?Ee:Oe,{className:`size-3.5 shrink-0`}),r(`Contract deviations`,`Отклонения от контракта`),` ·`,` `,n.deviations.length]}),a&&P(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4 text-xs text-foreground/80`,children:n.deviations.map(e=>P(`li`,{children:e},e))})]}):P(`p`,{className:`mt-2 rounded-md border border-success/25 bg-success/6 px-2.5 py-1.5 text-[13px] text-success`,children:r(`No contract deviations detected.`,`Отклонений от контракта не обнаружено.`)}),P(na,{savedTo:n.savedTo,deviations:n.deviations})]})]})}function ca({tools:e}){return P(`div`,{className:`flex flex-col gap-1.5`,children:e.map(e=>F(Z.Collapsible,{className:`overflow-hidden rounded-lg border border-border bg-card`,children:[F(Z.CollapsibleTrigger,{className:`group flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-accent/40`,children:[P(`code`,{className:`truncate font-mono text-[13px] text-foreground`,children:e.name}),e.write&&P(`span`,{className:`shrink-0 rounded-md border border-warning/40 bg-warning/8 px-1 font-mono text-xs leading-4 text-warning`,children:r(`write`,`запись`)}),F(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[e.params.length>0&&P(jr,{children:e.params.length}),P(Ee,{className:`size-3 text-muted-foreground/60 transition-transform duration-150 group-data-panel-open:rotate-180`})]})]}),P(Z.CollapsiblePanel,{children:F(`div`,{className:`border-t border-border/60 px-2.5 pb-2 pt-1.5`,children:[P(`p`,{className:`text-[13px] text-muted-foreground`,children:e.description}),e.params.length===0?P(`p`,{className:`pt-1 text-xs text-muted-foreground/60`,children:r(`No parameters.`,`Без параметров.`)}):P(`div`,{className:`flex flex-col pt-1`,children:e.params.map(e=>F(`div`,{className:`flex items-baseline gap-2 py-0.5 text-[13px]`,children:[P(`code`,{className:`font-mono text-foreground`,children:e.name}),P(`span`,{className:(0,H.cn)(`text-xs`,Y.type),children:e.type}),e.required?P(`span`,{className:`rounded-md border border-warning/40 px-1 font-mono text-xs leading-4 text-warning`,children:r(`required`,`обязательный`)}):P(`span`,{className:`font-mono text-xs text-muted-foreground/50`,children:r(`optional`,`необязательный`)}),e.description!==void 0&&P(`span`,{className:`ml-auto max-w-40 text-right text-xs text-muted-foreground/60`,children:e.description})]},e.name))})]})})]},e.name))})}function la(e,t,n){return[`# Pixso scan report — ${e.cardName??`—`} · ${t}`,`DSL ${e.dslVersion??`—`} · converter ${e.converterVersion??`—`} · envelope: MCP content[0].text`,n,``]}function ua(e,t){return t.length===0?[]:[`## ${e}`,...t,``]}function da(e){let t=e.data,n=qr(e.atIso);if(t.nodesParsed===0&&t.diagnostics.length===0&&t.rootGuids.length===0){let e=t.failedStep===null?null:Jt[t.failedStep];return[...la(t,n,`разбор не выполнялся`),`## Скан прервался до разбора`,`- шаг: ${e==null?`—`:e.label()}`,...t.toolTimings.filter(e=>!e.ok).map(e=>`- ${e.tool}: ${e.detail??`ошибка`}`),`- данных для отчёта парсера нет`,...t.byteDiff===null?[]:[``,`Пересканирование: ${t.byteDiff.note}`]].join(`
6
+ `)}let r=[...la(t,n,[`nodes: ${t.nodesParsed} parsed / ${t.nodesWithIssues} with issues`,`unknown keys: ${t.unknownKeys.length}`,`unknown enums: ${t.unknownEnums.length}`,...t.catalogStatus===`failed`?[`catalog: НЕДОСТУПЕН`]:[],...t.catalogStatus===`skipped`?[`catalog: не запрашивался`]:[]].join(` · `))];return t.rootGuids.length>1&&r.push(`## Несколько корней в pixDslNodes`,`- guids: ${t.rootGuids.join(`, `)}`,`- импорт отклонён по правилу «один фрейм за скан»`,``),r.push(...ua(`Unknown enum values`,t.unknownEnums.map(e=>`- ${e.field}: ${e.value} · ${e.count} узлов${e.exampleGuid===null?``:` · e.g. ${e.exampleGuid}`}`)),...ua(`Unknown keys (sanitized sample)`,t.unknownKeys.map(e=>`- node.${e.key} = ${e.sample} · ${e.count} узлов${e.exampleGuid===null?``:` · e.g. ${e.exampleGuid}`}`)),...ua(`Unresolved component libraries`,t.unresolvedLibraries.map(e=>`- library \`${e.fileKey}\` отсутствует в get_all_components · ${e.count} экземпляров${e.exampleGuid===null?``:` · e.g. ${e.exampleGuid}`}`)),...ua(`Diagnostics`,t.diagnostics.map(e=>`- ${e.severity} ${e.code}${e.path===void 0?``:` @${e.path}`} — ${e.message}`))),t.excerpts.length>0&&r.push(`## Node excerpts (sanitized)`,"```json",...t.excerpts,"```",``),r.push(...ua(`Tool timings`,t.toolTimings.map(e=>{let t=e.detail??(e.ok?null:`ошибка`);return`- ${e.tool}: ${String(e.ms)} ms${t===null?``:` · ${t}`}`}))),t.unknownEnums.length===0&&t.unknownKeys.length===0&&t.unresolvedLibraries.length===0&&t.diagnostics.length===0&&r.push(`## Аномалий не обнаружено`,`Все узлы разобраны по подтверждённому контракту; неизвестных полей и значений нет.`,``),t.duplicate&&r.push(`Примечание: узел уже был импортирован — дубликат не создавался.`,``),t.byteDiff!==null&&r.push(`Пересканирование: ${t.byteDiff.note}`,``),r.join(`
7
+ `).replace(/\n+$/,``)}function fa({active:e,icon:t,label:n,onSelect:r,testId:i}){return F(`button`,{type:`button`,role:`radio`,"aria-checked":e,"data-testid":i,onClick:r,className:(0,H.cn)(`flex h-7 min-w-0 cursor-pointer items-center justify-center gap-1.5 rounded-md border text-xs font-medium transition-colors`,e?`border-border/70 bg-background text-foreground shadow-xs`:`border-transparent text-muted-foreground hover:text-foreground`),children:[P(t,{className:(0,H.cn)(`size-3.5 shrink-0`,e?`text-primary`:`text-muted-foreground/70`)}),P(`span`,{className:`truncate`,children:n})]})}function pa({value:e,onChange:t,className:n,ariaLabel:i,testIdPrefix:a=`pixso-source`}){return F(`div`,{role:`radiogroup`,"aria-label":i??r(`Scan source`,`Источник скана`),"data-testid":`${a}-switch`,className:(0,H.cn)(`grid grid-cols-2 gap-0.5 rounded-lg border border-border/70 bg-muted/30 p-0.5`,n),children:[P(fa,{active:e===`local`,icon:Ye,label:r(`Local`,`Локально`),onSelect:()=>t(`local`),testId:`${a}-local`}),P(fa,{active:e===`remote`,icon:ze,label:r(`Remote`,`Удалённо`),onSelect:()=>t(`remote`),testId:`${a}-remote`})]})}const ma={unchecked:{tone:`neutral`,pulse:!1},checking:{tone:`info`,pulse:!0},connected:{tone:`success`,pulse:!1},error:{tone:`danger`,pulse:!1}};function ha(){let e=B(e=>e.connection),t=B(e=>e.lastCheck),n=B(e=>e.lastCheckError),i=B(e=>e.recheck),o=t?.tools.length??0,s=ma[e]??ma.unchecked,c=e===`unchecked`?r(`Not checked`,`Не проверено`):e===`checking`?r(`Checking…`,`Проверка…`):e===`connected`?r(`Connected`,`Подключено`):r(`Connection error`,`Ошибка подключения`),l=e===`connected`?`${o} ${r(`tools discovered`,`инструментов обнаружено`)}`:e===`checking`?`…`:r(`press «Check»`,`нажмите «Проверить»`);return F(N,{children:[F(`div`,{className:`rounded-lg border border-border bg-card px-3 py-2.5`,"data-testid":`pixso-debug-status-local`,children:[F(`div`,{className:`flex items-center gap-2`,children:[P(Fn.StatusDot,{tone:s.tone,pulse:s.pulse,size:`sm`,label:c}),P(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground/60`,children:l})]}),F(`div`,{className:`mt-2 flex items-center gap-2`,children:[P(q.Input,{value:a,readOnly:!0,spellCheck:!1,className:`flex-1 font-mono text-[13px] text-muted-foreground`,"aria-label":r(`MCP endpoint (read-only)`,`Адрес MCP (только чтение)`)}),F(U,{variant:`outline`,size:`sm`,onClick:i,disabled:e===`checking`,className:`shrink-0`,children:[P(it,{className:(0,H.cn)(e===`checking`&&`animate-spin`)}),r(`Check`,`Проверить`)]})]})]}),e===`error`&&P(K,{title:r(`Connection error`,`Ошибка подключения`),message:n??r(`Connection failed.`,`Не удалось подключиться.`),recommendations:[r(`Start Pixso and enable MCP in the file menu`,`Запустите Pixso и включите MCP в меню файла`),r(`Make sure port 3667 is free`,`Убедитесь, что порт 3667 свободен`)],actions:P(U,{variant:`outline`,size:`xs`,onClick:i,children:r(`Retry`,`Повторить`)})})]})}function ga(){let e=V(e=>e.remoteCheck),t=V(e=>e.runRemoteCheck),n=z(e=>e.tokenStatus)!==`none`,i=e.phase===`checking`?ma.checking:e.phase===`ok`?ma.connected:e.phase===`fail`?ma.error:ma.unchecked,a=e.phase===`idle`?r(`Not checked`,`Не проверено`):e.phase===`checking`?r(`Checking…`,`Проверка…`):e.phase===`ok`?r(`Connected`,`Подключено`):r(`Check failed`,`Проверка не прошла`),s=e.phase===`ok`?`tools/list · ${String(e.toolCount??0)} ${r(`tools`,`инструментов`)} · ${String(e.latencyMs??0)} ms`:e.phase===`checking`?`…`:n?r(`press «Check»`,`нажмите «Проверить»`):r(`no token`,`токена нет`);return F(`div`,{className:`rounded-lg border border-border bg-card px-3 py-2.5`,"data-testid":`pixso-debug-status-remote`,children:[F(`div`,{className:`flex items-center gap-2`,children:[P(Fn.StatusDot,{tone:i.tone,pulse:i.pulse,size:`sm`,label:a}),P(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground/60`,children:s})]}),F(`div`,{className:`mt-2 flex items-center gap-2`,children:[P(q.Input,{value:o,readOnly:!0,spellCheck:!1,className:`flex-1 font-mono text-[13px] text-muted-foreground`,"aria-label":r(`Remote MCP endpoint (read-only)`,`Адрес удалённого MCP (только чтение)`)}),F(U,{variant:`outline`,size:`sm`,onClick:t,disabled:e.phase===`checking`||!n,className:`shrink-0`,"data-testid":`pixso-debug-remote-check`,children:[P(it,{className:(0,H.cn)(e.phase===`checking`&&`animate-spin`)}),r(`Check`,`Проверить`)]})]}),P(`p`,{className:`mt-1.5 text-xs leading-snug text-muted-foreground/60`,children:n?r(`Auth: the token from the Pixso settings (gear) — debug has no token of its own.`,`Авторизация: токен из настроек Pixso (шестерёнка) — своего токена у отладки нет.`):r(`No token — create one in the Pixso settings (gear); debug has no token of its own.`,`Токен не задан — создайте его в настройках Pixso (шестерёнка); своего токена у отладки нет.`)}),e.phase===`fail`?P(`p`,{className:`mt-2 break-words rounded-md border border-destructive/30 bg-destructive/6 px-2.5 py-1.5 font-mono text-[13px] leading-relaxed text-destructive/80`,"data-testid":`pixso-debug-remote-check-error`,children:e.raw??``}):null]})}function _a(){let e=z(e=>e.probeUrl),t=z(e=>e.setProbeUrl),n=V(e=>e.scanProbe),i=V(e=>e.runRemoteScanProbe),a=se(e),o=n.phase===`running`;return F(`div`,{className:`rounded-lg border border-border bg-card px-3 py-2.5`,"data-testid":`pixso-debug-scan-probe`,children:[F(`div`,{className:`space-y-1.5`,children:[P(Mn.Label,{htmlFor:`pixso-probe-url`,className:`text-[13px]`,children:r(`Design URL for the probe`,`Ссылка для probe`)}),P(q.Input,{id:`pixso-probe-url`,"data-testid":`pixso-probe-url-input`,spellCheck:!1,autoComplete:`off`,className:`font-mono text-[13px]`,placeholder:`https://…/app/editor/…?item-id=…`,value:e,disabled:o,onChange:e=>t(e.target.value)}),a.kind===`ok`?F(`p`,{className:`flex flex-wrap items-center gap-1.5 font-mono text-[11px] text-success-foreground`,"data-testid":`pixso-probe-url-parsed`,children:[P(E,{className:`size-3`}),`file_key: ${a.fileKey} · item-id: ${a.itemId}`]}):null,a.kind===`invalid`||a.kind===`no-file-key`?P(`p`,{className:`text-xs leading-snug text-destructive`,children:r(`This does not look like a pixso frame link.`,`Не похоже на ссылку pixso с фреймом.`)}):null,a.kind===`no-item-id`?P(`p`,{className:`text-xs leading-snug text-warning`,children:r(`The link has no item-id — copy it from the frame itself.`,`В ссылке нет item-id — скопируйте её именно с фрейма.`)}):null]}),F(`div`,{className:`mt-2.5 flex items-center gap-2`,children:[F(U,{variant:`outline`,size:`sm`,onClick:i,disabled:a.kind!==`ok`||o,className:`shrink-0`,"data-testid":`pixso-debug-remote-scan-probe`,children:[o?P(G.Spinner,{className:`size-3.5`}):P(nt,{}),r(`Probe scan by link`,`Пробный скан по ссылке`)]}),P(`span`,{className:`text-xs text-muted-foreground/60`,children:r(`no card is saved — report only`,`карточка не сохраняется — только отчёт`)})]}),n.phase===`settled`?P(ra,{ok:n.ok,detail:n.detail,okMessage:r(`Probe finished — see «Latest scan report» above.`,`Проба завершена — отчёт в блоке «Отчёт последнего скана» выше.`),failMessage:r(`Probe failed.`,`Проба не удалась.`),testId:`pixso-debug-scan-probe-result`}):null]})}function va(){let e=z(e=>e.probeUrl),t=V(e=>e.fullProbe),n=V(e=>e.runRemoteFullProbe),i=se(e),a=t.phase===`running`;return F(Q,{title:r(`Diagnostics probe`,`Диагностическая проба`),sublabel:r(`all tools · by the probe link`,`все инструменты · по ссылке для probe`),count:t.phase===`done`?t.rows.length:`—`,countTone:t.phase===`done`?`default`:`na`,defaultOpen:!0,children:[F(`div`,{className:`flex items-center gap-2 pt-1`,children:[F(U,{variant:`outline`,size:`sm`,onClick:n,disabled:i.kind!==`ok`||a,className:`shrink-0`,"data-testid":`pixso-debug-remote-full-probe`,children:[a?P(G.Spinner,{className:`size-3.5`}):P(nt,{}),r(`Run diagnostics`,`Запустить диагностику`)]}),P(`span`,{className:`text-xs text-muted-foreground/60`,children:r(`uses the probe link above — params+raw are saved`,`по ссылке для probe выше — params+raw сохраняются`)})]}),i.kind!==`ok`&&t.phase===`idle`?P(`p`,{className:`mt-2 text-xs leading-snug text-muted-foreground/60`,children:r(`Paste a design URL into the probe block above — per-node tools read file_key and item-id from that one link.`,`Вставьте ссылку в блок probe выше — per-node инструменты берут file_key и item-id из этой одной ссылки.`)}):null,a&&P(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:Array.from({length:4},(e,t)=>P(ia.Skeleton,{className:`h-6 w-full rounded-md`},t))}),t.phase===`failed`&&P(`p`,{className:`mt-2 break-words rounded-md border border-destructive/30 bg-destructive/6 px-2.5 py-1.5 font-mono text-[13px] text-destructive`,children:t.raw}),t.phase===`done`&&F(`div`,{className:`mt-2 flex flex-col`,children:[t.rows.map(e=>F(`div`,{className:`flex items-center gap-2 border-b border-border/50 py-1.5 text-[13px] last:border-0`,children:[P(`code`,{className:`font-mono text-foreground`,children:e.tool}),P(`span`,{className:(0,H.cn)(`ml-auto shrink-0 rounded-full px-2 py-px font-mono text-xs leading-4`,e.status===`ok`?`bg-success/10 text-success`:`bg-destructive/10 text-destructive`),children:e.status===`ok`?`OK`:`DEAD`}),P(`span`,{className:`w-32 shrink-0 break-words text-right font-mono text-xs tabular-nums text-muted-foreground/60`,children:e.detail})]},e.tool)),P(na,{savedTo:t.savedTo,deviations:t.deviations})]})]})}function ya(){let e=B(e=>e.backToTabs),t=B(e=>e.lastCheck),n=B(e=>e.latestReport),i=B(e=>e.debugRescanning),a=B(e=>e.debugRescanResult),o=B(e=>e.debugRescan),s=B(e=>e.reparsing),c=B(e=>e.lastReparse),l=B(e=>e.runReparse),u=B(e=>e.supportsReparse),d=Kt(),f=V(e=>e.mode),p=V(e=>e.setMode),m=V(e=>e.remoteCheck),h=V(e=>e.remoteTools),g=A(()=>n===null?null:da(n),[n]),_=t!==null,v=t?.tools.length??0;return F(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[P(`div`,{className:`shrink-0 border-b border-border px-2 py-2`,children:F(U,{variant:`ghost`,size:`sm`,onClick:e,children:[P(De,{className:`size-4`}),r(`Back`,`Назад`)]})}),F(`div`,{className:`block min-h-0 flex-1 overflow-y-auto p-3`,"data-testid":`pixso-diagnostics-view`,"data-debug-mode":f,children:[P(`h3`,{className:`text-sm font-semibold`,children:r(`Pixso debug`,`Отладка Pixso`)}),F(`div`,{className:`mt-3 flex flex-col gap-2`,children:[F(`div`,{children:[P(pa,{value:f,onChange:p,ariaLabel:r(`Debug mode`,`Режим отладки`),testIdPrefix:`pixso-debug-mode`}),P(`p`,{className:`mt-1 text-xs leading-snug text-muted-foreground/60`,children:r(`Debug-only mode — independent of the switch on the Import tab and of the settings default.`,`Режим только для отладки — не связан с переключателем на вкладке «Импорт» и с настройкой по умолчанию.`)})]}),P(f===`local`?ha:ga,{}),f===`local`?P(Q,{title:r(`Tools`,`Инструменты`),sublabel:`tools/list`,count:_?v:`—`,countTone:_?`default`:`na`,children:t===null?P(`p`,{className:`py-1 text-[13px] text-muted-foreground/70`,children:r(`Tools are unknown until the first check — press «Check» above.`,`Инструменты неизвестны до первой проверки — нажмите «Проверить» выше.`)}):P(`div`,{className:`pt-1`,children:P(ca,{tools:t.tools})})}):P(Q,{title:r(`Tools`,`Инструменты`),sublabel:r(`tools/list · remote`,`tools/list · удалённый режим`),count:h===null?m.toolCount??`—`:h.length,countTone:h!==null||m.phase===`ok`?`default`:`na`,children:h===null?P(`p`,{className:`py-1 text-[13px] text-muted-foreground/70`,children:r(`Tools are unknown until the first check — press «Check» above.`,`Инструменты неизвестны до первой проверки — нажмите «Проверить» выше.`)}):P(`div`,{className:`pt-1`,children:P(ca,{tools:h})})}),P(Q,{title:r(`Latest scan report`,`Отчёт последнего скана`),sublabel:n?.origin===`remote`?r(`for improving the parser · remote`,`для доработки парсера · удалённый`):n?.origin===`local`?r(`for improving the parser · local`,`для доработки парсера · локальный`):r(`for improving the parser`,`для доработки парсера`),count:n===null?`—`:qr(n.atIso),countTone:n===null?`na`:`default`,headerActions:g===null?void 0:P(X,{value:g,label:r(`Copy the report`,`Скопировать отчёт`)}),flush:!0,defaultOpen:!0,children:g===null?P(`p`,{className:`px-3 py-2 text-[13px] text-muted-foreground/70`,children:r(`No scans yet — run one from the Import tab; only anomalies land here (unknown fields, enum values, parser diagnostics).`,`Сканов ещё не было — запустите на вкладке «Импорт»; сюда попадают только аномалии (неизвестные поля, значения enum, диагностика парсера).`)}):P(W.ScrollArea,{className:`max-h-80`,children:P(kr,{code:g,language:`markdown`,theme:d})})}),f===`local`?F(`div`,{children:[F(`div`,{className:`flex items-center gap-2`,children:[F(U,{variant:`outline`,size:`sm`,onClick:o,disabled:i,className:`shrink-0`,"data-testid":`pixso-debug-rescan`,children:[i&&P(G.Spinner,{className:`size-3.5`}),r(`Rescan the selection`,`Пересканировать выделение`)]}),P(`span`,{className:`text-xs text-muted-foreground/60`,children:r(`no card is saved — report only`,`карточка не сохраняется — только отчёт`)})]}),a===null?null:P(ra,{ok:a.ok,detail:a.detail,okMessage:r(`Rescan finished`,`Пересканирование завершено`),failMessage:r(`Rescan failed.`,`Пересканирование не удалось.`),testId:`pixso-debug-rescan-result`})]}):P(_a,{}),u&&F(`div`,{className:`flex items-center gap-2`,children:[F(U,{variant:`outline`,size:`sm`,onClick:l,disabled:s,className:`shrink-0`,children:[s&&P(G.Spinner,{className:`size-3.5`}),r(`Re-parse stored cards`,`Перечитать карточки из raw`)]}),P(`span`,{className:`text-xs text-muted-foreground/60`,children:c===null?r(`re-decodes cards that still have raw DSL`,`перечитывает карточки, у которых сохранён сырой DSL`):`${c.reparsed}/${c.total} · ${r(`no raw`,`без raw`)}: ${c.skippedNoRaw}${c.skippedNoCatalog!==void 0&&c.skippedNoCatalog>0?` · ${r(`no catalog`,`без каталога`)}: ${c.skippedNoCatalog}`:``} · ${r(`failed`,`с ошибкой`)}: ${c.failed}`})]}),P(f===`local`?sa:va,{})]})]})]})}function ba(e,t,n,r,i){let a=r.trim().toLowerCase(),o=a===``?t:t.filter(e=>e.name.toLowerCase().includes(a)||e.id.includes(a)),s=new Set(e.map(e=>e.id)),c=new Map;for(let e of o){let t=n[e.id],r=t!==void 0&&s.has(t)?t:null,i=c.get(r)??[];i.push(e),c.set(r,i)}let l=a!==``,u=e.map(e=>({group:e,cards:c.get(e.id)??[]})).filter(e=>!l||e.cards.length>0),d=c.get(null)??[];if(!(d.length>0||i.includeEmptyUnsorted&&!l))return u;let f={group:null,cards:d};return i.unsortedPinned?[f,...u]:[...u,f]}const xa=Vt.Root;function Sa(e){return P(Vt.Trigger,{"data-slot":`context-menu-trigger`,...e})}function Ca({children:e,className:t,...n}){return P(Vt.Portal,{children:P(Vt.Positioner,{className:`z-50`,"data-slot":`context-menu-positioner`,children:P(Vt.Popup,{className:(0,H.cn)(`relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] focus:outline-none dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,t),"data-slot":`context-menu-popup`,...n,children:P(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1`,children:e})})})})}const wa={simple:`bg-success`,medium:`bg-warning`,complex:`bg-destructive`};function Ta({band:e,filled:t,className:n}){return P(`div`,{className:(0,H.cn)(`flex gap-[3px]`,n),role:`img`,"aria-label":e,children:Array.from({length:5},(n,r)=>P(`span`,{className:(0,H.cn)(`h-1 flex-1 rounded-full`,r<t?wa[e]:`bg-border`)},r))})}function Ea({card:e,onDelete:t}){let n=B(e=>e.groups),i=B(e=>e.groupByCardId),a=B(e=>e.moveCardToGroup),o=i[e.id]??null;return F(N,{children:[n.length>0&&F(oi,{children:[F(si,{children:[P(Le,{}),r(`Move to group`,`В группу`)]}),P(ci,{children:n.map(t=>F($,{onClick:()=>a(e.id,t.id),children:[t.id===o?P(E,{}):P(Ie,{}),t.name]},t.id))})]}),o!==null&&F($,{onClick:()=>a(e.id,null),children:[P(Ue,{}),r(`Move to Unsorted`,`В «Неразобранное»`)]}),(n.length>0||o!==null)&&P(ai,{}),F($,{variant:`destructive`,"data-testid":`pixso-card-delete`,onClick:t,children:[P(ut,{}),r(`Delete card`,`Удалить карточку`)]})]})}function Da({card:e,open:t,onOpenChange:n}){let i=B(e=>e.removeCard);return P(xn,{open:t,onOpenChange:n,children:F(En,{className:`max-w-sm`,showCloseButton:!1,children:[F(Dn,{children:[F(kn,{children:[r(`Delete card`,`Удалить карточку`),` «`,e.name,`»?`]}),P(An,{children:r(`The decoded card and its stored DSL are removed for good — there is no undo. Re-scanning the node in Pixso imports it again.`,`Разобранная карточка и её сохранённый DSL удаляются безвозвратно — отменить нельзя. Повторный скан узла в Pixso импортирует её заново.`)})]}),F(On,{children:[P(U,{variant:`ghost`,onClick:()=>n(!1),children:r(`Cancel`,`Отмена`)}),P(U,{variant:`destructive`,"data-testid":`pixso-card-delete-confirm`,onClick:()=>{i(e.id),n(!1)},children:r(`Delete`,`Удалить`)})]})]})})}const Oa=e=>({simple:r(`Simple`,`Простой`),medium:r(`Medium`,`Средний`),complex:r(`Complex`,`Сложный`)})[e]??e;function ka({card:e,onOpen:t,className:n}){let i={band:e.complexityBand,filled:e.complexityFilled},a=e.instanceTotal,o=e.deprecatedUsed,[s,c]=j(!1),l=e.imageAvailable===!0,u=B(e=>e.loadImage),d=B(t=>t.images[e.id]),f=B(t=>t.imageErrors.has(e.id));k(()=>{l&&u(e.id)},[l,e.id,u]);let p=!l||f?Xr(e.previewSvg):d===void 0?{kind:`loading`}:{kind:`png`,base64:d};return F(xa,{children:[F(Sa,{render:P(`div`,{role:`button`,tabIndex:0,"data-testid":`pixso-card`,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:(0,H.cn)(`group cursor-pointer overflow-hidden rounded-lg border border-border bg-card text-left transition-colors hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,n)}),children:[F(`div`,{className:`relative`,children:[P($r,{state:p,alt:e.name,fit:`cover`,focus:e.height>e.width*1.2?`top`:`center`,className:`h-24 w-full border-b border-border/60`}),P(`span`,{onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:F(ni,{children:[P(ri,{render:P(U,{size:`icon-xs`,variant:`ghost`,"aria-label":`${r(`Card actions`,`Действия карточки`)} ${e.name}`,className:`absolute right-1 top-1 bg-card/80 opacity-0 backdrop-blur-sm transition-opacity focus-visible:opacity-100 group-hover:opacity-100 data-popup-open:opacity-100`}),children:P(Ne,{className:`size-3.5`})}),P(ii,{align:`end`,children:P(Ea,{card:e,onDelete:()=>c(!0)})})]})})]}),F(`div`,{className:`px-2.5 pb-2.5 pt-2`,children:[F(`div`,{className:`flex items-center gap-1.5`,children:[P(`span`,{className:`truncate text-xs font-semibold`,children:e.name}),P(ar.Badge,{variant:`outline`,size:`sm`,className:`shrink-0 text-xs`,children:_r(e).label}),o>0&&P(`span`,{title:`${r(`Uses deprecated components`,`Использует устаревшие компоненты`)}: ${o}`,className:`flex shrink-0 items-center text-warning`,children:P(O,{className:`size-3`})})]}),F(`div`,{className:`mt-0.5 truncate font-mono text-xs tabular-nums text-muted-foreground/70`,children:[Math.round(e.width),`×`,Math.round(e.height),` · `,e.layerCount,` `,r(`layers`,`слоёв`),a>0&&` · ${a} ${r(`comp.`,`комп.`)}`,` ·`,` `,Yr(e.importedAtIso)]}),F(`div`,{className:`mt-2 flex items-center gap-2`,children:[P(Ta,{band:i.band,filled:i.filled,className:`flex-1`}),P(`span`,{className:`shrink-0 text-xs text-muted-foreground/70`,children:Oa(i.band)})]}),P(yi,{colors:[...e.colors],className:`mt-2`})]})]}),P(Ca,{children:P(Ea,{card:e,onDelete:()=>c(!0)})}),P(Da,{card:e,open:s,onOpenChange:c})]})}function Aa({card:e,className:t}){let n=B(e=>e.openDetail),{attributes:r,listeners:i,setNodeRef:a,isDragging:o}=Nt({id:`card:${e.id}`,data:{type:`card`,cardId:e.id}});return P(`div`,{ref:a,...r,...i,className:(0,H.cn)(`touch-none transition-opacity`,o&&`opacity-30 grayscale-[30%]`,t),children:P(ka,{card:e,onOpen:()=>n(e.id),className:`h-full`})})}function ja(e){return e.rowHeight+e.rowGap}function Ma(e,t){return e===0?0:Math.ceil(e/t)}function Na(e,t){return e===0?0:e*t.rowHeight+(e-1)*t.rowGap}function Pa(e,t){return e*ja(t)}function Fa(e){let t=ja(e.metrics),n=e.scrollTop-e.gridTop,r=Math.floor(n/t)-e.overscan,i=Math.ceil((n+e.viewportHeight)/t)+e.overscan,a=Math.min(Math.max(r,0),e.rowCount);return{start:a,end:Math.min(Math.max(i,a),e.rowCount)}}function Ia(e){let t=`calc(50% - 4px)`,n=`<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><rect y="0" height="${e.rowHeight}" rx="8" ry="8" style="width:${t}"/><rect y="0" height="${e.rowHeight}" rx="8" ry="8" style="width:${t};x:calc(50% + 4px)"/></svg>`,r=`url("data:image/svg+xml;utf8,${encodeURIComponent(n)}")`,i=`100% ${ja(e)}px`;return{maskImage:r,maskSize:i,maskRepeat:`repeat-y`,WebkitMaskImage:r,WebkitMaskSize:i,WebkitMaskRepeat:`repeat-y`}}function La(e,t,n,r){let i=Mi(),[a,o]=j(0);vt(()=>{let t=i.containerEl,n=e.current;if(t===null||n===null)return;let r=n.getBoundingClientRect(),a=t.getBoundingClientRect(),s=r.top-a.top+t.scrollTop;o(e=>e===s?e:s)},[i,i.epoch,e]);let s=()=>{let e=i.rowHeight>0?{...n,rowHeight:i.rowHeight}:n,{start:o,end:s}=Fa({gridTop:a,scrollTop:i.scrollTop,viewportHeight:i.viewportHeight,rowCount:t,metrics:e,overscan:r});return`${o}:${s}:${e.rowHeight}`},[c=`0`,l=`0`,u=`0`]=bt(i.subscribe,s,s).split(`:`),d=Number(u),f=A(()=>d>0?{...n,rowHeight:d}:n,[n,d]);return{start:Number(c),end:Number(l),metrics:f}}const Ra={columns:2,rowHeight:182,rowGap:8};function za({cards:e}){let t=yt(null),n=Ma(e.length,Ra.columns),{start:r,end:i,metrics:a}=La(t,n,Ra,6),o=A(()=>{let t=[];for(let n=r;n<i;n+=1){let r=n*a.columns;t.push(P(`div`,{className:`absolute inset-x-0 grid grid-cols-2 grid-rows-1 gap-2`,style:{top:Pa(n,a),height:a.rowHeight},children:e.slice(r,r+a.columns).map(e=>P(Aa,{card:e,className:`h-full`},e.id))},n))}return t},[e,r,i,a]),s=Math.floor(e.length/a.columns),c=e.length%a.columns!==0;return F(`div`,{ref:t,className:`relative`,style:{height:Na(n,a)},children:[s>0&&P(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 bg-muted`,style:{height:Na(s,a),...Ia(a)}}),c&&P(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 rounded-lg bg-muted`,style:{top:Pa(s,a),height:a.rowHeight,width:`calc(50% - 4px)`}}),o]})}function Ba({group:e,onRename:t,onDelete:n}){let i=B(e=>e.toggleGroupPinned),a=B(e=>e.groups),o=B(e=>e.moveGroup),s=a.findIndex(t=>t.id===e.id),c=s<=0,l=s===a.length-1;return F(N,{children:[F($,{onClick:t,children:[P($e,{}),r(`Rename`,`Переименовать`)]}),F($,{onClick:()=>i(e.id),children:[e.pinned?P(tt,{}):P(et,{}),e.pinned?r(`Unpin`,`Открепить`):r(`Pin`,`Закрепить`)]}),P(ai,{}),F($,{disabled:c,onClick:()=>o(e.id,`top`),children:[P(Ce,{}),r(`Move to top`,`В начало`)]}),F($,{disabled:c,onClick:()=>o(e.id,`up`),children:[P(Se,{}),r(`Move up`,`Выше`)]}),F($,{disabled:l,onClick:()=>o(e.id,`down`),children:[P(xe,{}),r(`Move down`,`Ниже`)]}),P(ai,{}),F($,{variant:`destructive`,onClick:n,children:[P(ut,{}),r(`Delete group…`,`Удалить группу…`)]})]})}function Va(){let e=B(e=>e.unsortedPinned);return F($,{onClick:B(e=>e.toggleUnsortedPinned),children:[P(e?tt:et,{}),e?r(`Unpin (move below groups)`,`Открепить (вниз, под группы)`):r(`Pin to top`,`Закрепить сверху`)]})}function Ha({group:e,cards:t,cardDragActive:n}){let i=B(e=>e.renameGroup),a=B(e=>e.toggleGroupCollapsed),o=B(e=>e.unsortedPinned),s=B(e=>e.unsortedCollapsed),c=B(e=>e.toggleUnsortedCollapsed),[l,u]=j(!1),[d,f]=j(``),[p,m]=j(!1),h=Rt({id:e?.id??`unsorted-sortable-placeholder`,data:{type:`group`},disabled:e===null}),g=Pt({id:`drop:${e?.id??`unsorted`}`,data:{type:`card-drop`,groupId:e?.id??null}}),_=e?.collapsed??s,v=e?.pinned??o,y=g.isOver&&n,b=()=>{e!==null&&(f(e.name),u(!0))},x=()=>{if(e===null)return;let t=d.trim();t!==``&&t!==e.name&&i(e.id,t),u(!1)},S=()=>{e===null?c():a(e.id)};return F(`section`,{ref:h.setNodeRef,"data-testid":`pixso-group-section`,style:{transform:Bt.Transform.toString(h.transform),transition:h.transition},className:(0,H.cn)(`group/section`,h.isDragging&&`z-10 opacity-60`),children:[F(`div`,{ref:g.setNodeRef,className:(0,H.cn)(`rounded-xl border border-transparent transition-all duration-150`,n&&`border-border/60 bg-muted/20`,y&&`border-primary/50 bg-primary/6 ring-2 ring-primary/30`),children:[F(xa,{children:[F(Sa,{render:P(`div`,{className:`flex h-8 select-none items-center gap-1 px-1`}),children:[e===null?P(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground/50`,children:P(Ue,{className:`size-3.5`})}):P(`button`,{type:`button`,"aria-label":r(`Reorder group`,`Изменить порядок группы`),...h.attributes,...h.listeners,className:`flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/40 opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover/section:opacity-100 active:cursor-grabbing`,children:P(Be,{className:`size-3.5`})}),l&&e!==null?F(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 px-1 py-0.5`,children:[P(Ee,{className:(0,H.cn)(`size-3.5 shrink-0 text-muted-foreground/60 transition-transform duration-150`,_&&`-rotate-90`)}),P(q.Input,{autoFocus:!0,size:`sm`,value:d,onValueChange:f,onKeyDown:e=>{e.key===`Enter`&&x(),e.key===`Escape`&&u(!1)},onBlur:x,className:`h-6 max-w-48`,"aria-label":r(`Group name`,`Название группы`)}),v&&P(et,{className:`size-3 shrink-0 fill-primary/20 text-primary`}),P(jr,{tone:t.length===0?`zero`:`default`,children:t.length})]}):F(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent/40`,onClick:S,"aria-expanded":!_,children:[P(Ee,{className:(0,H.cn)(`size-3.5 shrink-0 text-muted-foreground/60 transition-transform duration-150`,_&&`-rotate-90`)}),P(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e?.name??r(`Unsorted`,`Неразобранное`)}),v&&P(et,{className:`size-3 shrink-0 fill-primary/20 text-primary`}),P(jr,{tone:t.length===0?`zero`:`default`,children:t.length})]}),F(ni,{children:[P(ri,{render:P(U,{size:`icon-xs`,variant:`ghost`,"aria-label":`${r(`Group actions`,`Действия группы`)} ${e?.name??r(`Unsorted`,`Неразобранное`)}`,className:`opacity-0 focus-visible:opacity-100 group-hover/section:opacity-100 data-popup-open:opacity-100`}),children:P(Ne,{className:`size-3.5`})}),P(ii,{align:`end`,children:e===null?P(Va,{}):P(Ba,{group:e,onRename:b,onDelete:()=>m(!0)})})]})]}),P(Ca,{children:e===null?P(Va,{}):P(Ba,{group:e,onRename:b,onDelete:()=>m(!0)})})]}),!_&&P(`div`,{className:`px-1 pb-1.5`,children:t.length===0?P(`div`,{"data-testid":`pixso-group-dropzone`,className:(0,H.cn)(`flex h-16 items-center justify-center rounded-lg border border-dashed border-border/70 text-[13px] text-muted-foreground/50 transition-colors`,y&&`border-primary/60 text-primary`),children:y?r(`Drop here`,`Отпустите здесь`):e===null?r(`No unsorted cards`,`Неразобранных карточек нет`):r(`Empty group — drag cards here`,`Пустая группа — перетащите карточки сюда`)}):P(za,{cards:t})}),_&&y&&P(`div`,{className:`px-2 pb-1.5 text-[13px] text-primary`,children:r(`Drop to add to the collapsed group`,`Отпустите — карточка попадёт в свёрнутую группу`)})]}),e!==null&&P(ui,{group:e,cardCount:t.length,open:p,onOpenChange:m})]})}function Ua({card:e}){let t=Mi(),n=yt(null);return vt(()=>{let e=n.current;if(e===null)return;let r=()=>t.setRowHeight(Math.round(e.getBoundingClientRect().height)),i=new ResizeObserver(r);return i.observe(e),r(),()=>i.disconnect()},[t]),P(`div`,{"aria-hidden":!0,className:`pointer-events-none relative h-0 overflow-hidden`,children:P(`div`,{ref:n,className:`absolute w-48`,children:P(ka,{card:e,onOpen:()=>{}})})})}var Wa=t({});import*as Ga from"@smart-tools/qwen-cli-ui-kit";e(Wa,Ga);const Ka=e=>{if(e.active.data.current?.type===`card`){let t=e.droppableContainers.filter(e=>e.data.current?.type===`card-drop`),n=jt({...e,droppableContainers:t});return n.length>0?n:Mt({...e,droppableContainers:t})}return At({...e,droppableContainers:e.droppableContainers.filter(e=>e.data.current?.type===`group`)})};function qa(){let e=B(e=>e.cards),t=B(e=>e.snapshotPhase),n=B(e=>e.snapshotError),i=B(e=>e.refreshSnapshot),a=B(e=>e.groups),o=B(e=>e.groupByCardId),s=B(e=>e.searchQuery),c=B(e=>e.setSearchQuery),l=B(e=>e.setTab),u=B(e=>e.moveCardToGroup),d=B(e=>e.reorderGroups),[f,p]=j(null),[m,h]=j(!1),g=It(Ft(kt,{activationConstraint:{distance:4}})),_=B(e=>e.unsortedPinned),v=B(e=>e.unsortedCollapsed),y=f?.type===`card`,b=A(()=>ba(a,e,o,s,{unsortedPinned:_,includeEmptyUnsorted:y}),[a,e,o,s,_,y]),x=A(()=>a.map(e=>e.id),[a]),S=A(()=>b.map(e=>e.group===null?`unsorted:${v?1:0}:${e.cards.length}`:`${e.group.id}:${e.group.collapsed?1:0}:${e.cards.length}`).join(`|`),[b,v]);if(t!==`loaded`)return n===null?P(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:Array.from({length:4},(e,t)=>P(ia.Skeleton,{className:`h-36 w-full rounded-lg`},t))}):P(`div`,{className:`p-3`,"data-testid":`pixso-gallery-error`,children:P(K,{title:r(`Failed to load the gallery`,`Не удалось загрузить галерею`),message:n,recommendations:[r(`The imported cards are on disk — only this load failed`,`Импортированные карточки на диске — не удалась только загрузка`),r(`If the app is still starting up, the panel refreshes itself`,`Если приложение ещё запускается, панель обновится сама`)],actions:P(U,{variant:`outline`,size:`xs`,onClick:i,children:r(`Retry`,`Повторить`)})})});if(e.length===0&&a.length===0)return F(Wa.Empty,{className:`py-10`,children:[F(Wa.EmptyHeader,{children:[P(Wa.EmptyMedia,{variant:`icon`,children:P(He,{})}),P(Wa.EmptyTitle,{className:`text-base`,children:r(`Gallery is empty`,`Галерея пуста`)}),P(Wa.EmptyDescription,{className:`text-xs`,children:r(`Imported nodes appear here as cards with structure, colors and fonts.`,`Импортированные узлы появятся здесь карточками со структурой, цветами и шрифтами.`)})]}),P(U,{variant:`outline`,size:`sm`,onClick:()=>l(`import`),children:r(`Import a node`,`Импортировать узел`)})]});let C=t=>{let n=t.active.data.current;if(n?.type===`card`){let t=e.find(e=>e.id===n.cardId)??null;t!==null&&p({type:`card`,card:t});return}let r=a.find(e=>e.id===t.active.id)??null;r!==null&&p({type:`group`,group:r})},w=e=>{let{active:t,over:n}=e;if(p(null),n===null)return;let r=t.data.current;if(r?.type===`card`){let e=n.data.current;if(e?.type!==`card-drop`)return;let t=String(r.cardId),i=e.groupId??null;i!==(o[t]??null)&&u(t,i);return}r?.type===`group`&&n.id!==t.id&&d(String(t.id),String(n.id))};return F(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[F(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2.5`,children:[P(q.Input,{type:`search`,value:s,onValueChange:e=>c(e),placeholder:r(`Search imported nodes…`,`Поиск по импортированным узлам…`),size:`sm`,className:`flex-1 text-xs`,"aria-label":r(`Search the gallery`,`Поиск по галерее`)}),F(U,{variant:`outline`,size:`sm`,className:`shrink-0`,"data-testid":`pixso-new-group-button`,onClick:()=>h(!0),children:[P(Re,{}),r(`Group`,`Группа`)]})]}),F(Ni,{layoutKey:S,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[e.length>0&&P(Ua,{card:e[0]}),F(Dt,{sensors:g,collisionDetection:Ka,onDragStart:C,onDragEnd:w,onDragCancel:()=>p(null),children:[P(`div`,{className:`flex flex-col gap-1.5`,children:P(Lt,{items:x,strategy:zt,children:b.map(e=>P(Ha,{group:e.group,cards:e.cards,cardDragActive:y},e.group?.id??`unsorted`))})}),b.length===0&&P(`p`,{className:`py-6 text-center text-xs text-muted-foreground/60`,children:r(`Nothing matches the search.`,`По запросу ничего не найдено.`)}),F(Ot,{dropAnimation:{duration:180,easing:`ease-out`},children:[f?.type===`card`&&P(`div`,{className:`w-48 rotate-2 cursor-grabbing shadow-2xl shadow-black/25`,children:P(ka,{card:f.card,onOpen:()=>{}})}),f?.type===`group`&&F(`div`,{className:(0,H.cn)(`flex h-8 w-64 cursor-grabbing items-center gap-1.5 rounded-lg border border-primary/40 bg-card px-2 shadow-xl shadow-black/20`),children:[P(Be,{className:`size-3.5 text-muted-foreground/60`}),P(`span`,{className:`truncate text-xs font-semibold`,children:f.group.name})]})]})]})]}),P(li,{open:m,onOpenChange:h})]})}function Ja(e,t,n,r){return r===null?t?e<n?`done`:e===n?`active`:`pending`:`done`:e<r?`done`:e===r?`failed`:`pending`}function Ya({state:e}){return e===`done`?P(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-success/10 text-success-foreground`,children:P(E,{className:`size-3`})}):e===`active`?P(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary`,children:P(qe,{className:`size-3 animate-spin`})}):e===`failed`?P(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-destructive/10 text-destructive`,children:P(mt,{className:`size-3`})}):P(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted/30`,children:P(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/30`})})}function Xa({running:e,currentStep:t,failedStep:n,steps:r=Jt}){return F(`div`,{className:`relative rounded-xl border border-border/70 bg-background p-3`,"data-testid":`pixso-import-stepper`,children:[P(`span`,{"aria-hidden":!0,className:`absolute bottom-6 left-[21.5px] top-6 w-px bg-border/70`}),P(`div`,{className:`relative flex flex-col gap-3`,children:r.map((r,i)=>{let a=Ja(i,e,t,n);return F(`div`,{className:`flex items-center gap-2.5`,children:[P(`span`,{className:`relative z-10 shrink-0 bg-background py-0.5`,children:P(Ya,{state:a})}),P(`span`,{className:(0,H.cn)(`min-w-0 text-[13px] transition-colors`,a===`pending`&&`text-muted-foreground/60`,a===`active`&&`font-medium text-foreground`,a===`done`&&`text-foreground/80`,a===`failed`&&`font-medium text-destructive`),children:r.label()})]},r.detail)})})]})}function Za({resolvedNodes:e,onRetry:t,retrying:n,className:a}){return e.failed.length===0?null:P(`div`,{"data-testid":`pixso-nodes-warning`,className:a,children:P(K,{tone:`warning`,title:r(`Some nodes did not load`,`Часть узлов не загрузилась`),message:i(`{0} additional node(s) failed to load — the scan may be incomplete`,`Не загрузилось дополнительных узлов: {0} — скан может быть неполным`,[e.failed.length]),recommendations:[r(`Nested component overrides may show default values until the missing nodes load`,`Переопределения вложенных компонентов могут отображаться значениями по умолчанию, пока недостающие узлы не загружены`),r(`“Retry” re-requests ONLY the failed nodes`,`«Повторить» запросит заново только недозагруженные узлы`)],actions:P(U,{variant:`outline`,size:`xs`,onClick:t,disabled:n,"data-testid":`pixso-nodes-retry`,children:r(`Retry`,`Повторить`)})})})}function Qa({visible:e,onCancel:t}){return e?P(`div`,{className:`mt-2 flex justify-center`,children:F(U,{variant:`outline`,size:`xs`,onClick:t,"data-testid":`pixso-scan-cancel`,children:[P(mt,{className:`size-3.5`}),r(`Cancel the scan`,`Отменить скан`)]})}):null}function $a({index:e,icon:t,title:n,detail:r}){return F(`div`,{className:`flex items-start gap-2.5`,children:[P(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-primary/10 text-xs font-semibold text-primary`,children:e}),F(`div`,{className:`min-w-0`,children:[F(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[P(t,{className:`size-3.5 shrink-0 text-muted-foreground`}),n]}),P(`p`,{className:`mt-0.5 text-[13px] leading-snug text-muted-foreground/70`,children:r})]})]})}function eo(){return F(`div`,{className:`rounded-xl border border-border/70 bg-muted/20 p-3`,children:[F(`div`,{className:`flex flex-col gap-3`,children:[P($a,{index:1,icon:be,title:r(`Open Pixso`,`Откройте Pixso`),detail:r(`Launch the desktop app and enable Pixso MCP in the file menu.`,`Запустите десктоп-приложение и включите Pixso MCP в меню файла.`)}),P($a,{index:2,icon:Xe,title:r(`Select ONE frame`,`Выделите ОДИН фрейм`),detail:r(`Click the frame you need on the canvas — everything inside it is scanned automatically.`,`Кликните нужный фрейм на холсте — всё, что внутри него, попадёт в скан автоматически.`)}),P($a,{index:3,icon:at,title:r(`Press “Scan”`,`Нажмите «Сканировать»`),detail:r(`The panel connects for the duration of the scan, reads the selection and builds the card.`,`Панель подключится на время скана, прочитает выделение и соберёт карточку.`)})]}),F(`div`,{className:`mt-3 flex items-start gap-1.5 rounded-md border border-warning/30 bg-warning/8 px-2 py-1.5 text-[13px] leading-snug text-foreground/80`,children:[P(O,{className:`mt-px size-3.5 shrink-0 text-warning`}),r(`Select exactly one frame. If several frames are selected, the scan is rejected and asks you to pick one.`,`Выделяйте ровно один фрейм: при нескольких выделенных скан будет отклонён с просьбой выбрать один.`)]})]})}const to=e=>({tone:`danger`,title:r(`Could not parse the DSL`,`Не удалось разобрать ответ Pixso`),message:e??``,recommendations:[r(`Retry the scan`,`Повторите скан`),r(`If it repeats, contact the developers for diagnostics`,`Если повторяется — свяжитесь с разработчиками для диагностики`)]}),no={local:e=>({tone:`danger`,title:r(`Could not connect to Pixso MCP`,`Не удалось подключиться к Pixso MCP`),message:e??``,recommendations:[r(`Start the Pixso app on this machine`,`Запустите приложение Pixso на этой машине`),r(`Enable Pixso MCP in the file menu`,`Включите Pixso MCP в меню файла`),r(`Make sure port 3667 is not taken by another process`,`Убедитесь, что порт 3667 не занят другим процессом`)]}),remote:e=>({tone:`danger`,title:r(`Could not reach the server`,`Сервер недоступен`),message:e??``,recommendations:[r(`Check the network and that the pixso server is reachable (VPN, proxy)`,`Проверьте сеть и доступность сервера pixso (VPN, прокси)`),r(`The token was not judged — retry once the connection is back`,`Токен ни при чём — сервер не ответил; повторите, когда связь появится`)]})},ro={"mcp-down":no,cancelled:no,"tool-timeout":{local:e=>({tone:`danger`,title:r(`The selection read timed out`,`Чтение выделения не уложилось в таймаут`),message:e??``,recommendations:[r(`The selection is probably too large — select a smaller frame or a single block`,`Скорее всего, выделение слишком большое — выделите фрейм поменьше или отдельный блок`),r(`Retry — every scan opens a fresh connection`,`Повторите скан — каждая попытка открывает новое соединение`),r(`If it keeps happening, restart Pixso`,`Если повторяется — перезапустите Pixso`)]}),remote:e=>({tone:`danger`,title:r(`The link read timed out`,`Чтение по ссылке не уложилось в таймаут`),message:e??``,recommendations:[r(`The frame is probably too large, or the server is slow right now`,`Скорее всего, фрейм слишком большой, либо сервер сейчас отвечает медленно`),r(`Retry — every scan opens a fresh connection`,`Повторите скан — каждая попытка открывает новое соединение`)]})},"dsl-error":{local:e=>({tone:`danger`,title:r(`Pixso returned an error for the selection`,`Pixso вернул ошибку на чтение выделения`),message:e??``,recommendations:[r(`Re-select the frame and retry`,`Выделите фрейм заново и повторите скан`),r(`Re-open the file in Pixso if it repeats`,`Если повторяется — переоткройте файл в Pixso`)]}),remote:e=>({tone:`danger`,title:r(`Pixso returned an error for this link`,`Pixso вернул ошибку по этой ссылке`),message:e??``,recommendations:[r(`Copy a fresh link from the frame itself`,`Скопируйте свежую ссылку прямо с фрейма`),r(`Check that the frame still exists in that file`,`Убедитесь, что фрейм всё ещё существует в этом файле`)]})},"empty-selection":{local:e=>({tone:`danger`,title:r(`Nothing is selected in Pixso`,`В Pixso ничего не выделено`),message:e??``,recommendations:[r(`Click a frame on the canvas — its border should highlight`,`Кликните фрейм на холсте — его рамка должна подсветиться`),r(`Then press “Scan” again`,`Затем нажмите «Сканировать» ещё раз`)]}),remote:e=>({tone:`danger`,title:r(`Nothing to scan via this link`,`Нечего сканировать по этой ссылке`),message:e??``,recommendations:[r(`Check that the link points to a specific frame and the access token is saved`,`Проверьте, что ссылка ведёт на конкретный фрейм и токен доступа сохранён`),r(`Copy a fresh link and retry`,`Скопируйте свежую ссылку и повторите`)]})},"multi-selection":{local:e=>({tone:`danger`,title:r(`Several frames are selected`,`Выделено несколько фреймов`),message:e??``,recommendations:[r(`Select exactly ONE frame and rescan`,`Выделите ровно ОДИН фрейм и повторите скан`),r(`Icons and small elements inside the frame need no separate selection — they are scanned automatically`,`Иконки и мелкие элементы внутри фрейма выделять не нужно — они попадут в скан автоматически`)]}),remote:e=>({tone:`danger`,title:r(`The link points at several objects`,`Ссылка ведёт на несколько объектов`),message:e??``,recommendations:[r(`Copy the link to exactly ONE frame and retry`,`Скопируйте ссылку на ОДИН конкретный фрейм и повторите`)]})},"parse-error":{local:to,remote:to},"components-error":{local:e=>({tone:`danger`,title:r(`Could not fetch the components catalog`,`Не удалось получить каталог компонентов`),message:e??``,recommendations:[r(`Retry — the card is not created without the components catalog`,`Повторите скан — карточка не создаётся без каталога компонентов`),r(`Every scan opens a fresh connection`,`Каждая попытка открывает новое соединение`)]}),remote:e=>({tone:`danger`,title:r(`Could not finish assembling the card`,`Не удалось собрать карточку`),message:e??``,recommendations:[r(`Retry the scan`,`Повторите скан`),r(`If it repeats, contact the developers for diagnostics`,`Если повторяется — свяжитесь с разработчиками для диагностики`)]})},"internal-error":{local:e=>({tone:`danger`,title:r(`Internal scan error`,`Внутренняя ошибка скана`),message:e??``,recommendations:[r(`Select a simpler frame and retry`,`Выделите более простой фрейм и повторите скан`),r(`If it repeats, contact the developers for diagnostics`,`Если повторяется — свяжитесь с разработчиками для диагностики`)]}),remote:e=>({tone:`danger`,title:r(`Internal scan error`,`Внутренняя ошибка скана`),message:e??``,recommendations:[r(`Retry`,`Повторите попытку`),r(`If it repeats, contact the developers for diagnostics`,`Если повторяется — свяжитесь с разработчиками для диагностики`)]})},"access-denied":{remote:e=>({tone:`danger`,title:r(`No access to the file`,`Нет доступа к файлу`),message:e??``,recommendations:[r(`Check that the link opens in a browser`,`Проверьте, что ссылка открывается в браузере`),r(`The access token may be stale`,`Возможно, токен доступа устарел`)],action:`replace-token`}),local:e=>({tone:`danger`,title:r(`Pixso denied access to the file`,`Pixso отказал в доступе к файлу`),message:e??``,recommendations:[r(`Reopen the file in Pixso`,`Переоткройте файл в Pixso`)]})}};function io(e){return e!==`success`&&e!==`success-warnings`&&e!==`reimport`}function ao(){return{tone:`info`,title:r(`Scan finished`,`Скан завершён`),message:r(`The card was added to the gallery`,`Карточка добавлена в галерею`),recommendations:[]}}function oo(e,t,n,i=`local`,a=[]){if(e===`success`||e===`success-warnings`)return ao();if(io(e))return ro[e][i](t);let o=[];return a.includes(`image`)&&o.push(r(`Added the missing image`,`добавлено изображение`)),a.includes(`components`)&&o.push(r(`Added the missing components`,`добавлены компоненты`)),{tone:`info`,title:ao().title,message:n===null?r(`The card is already in the gallery`,`Карточка уже есть в галерее`):`${n} ${r(`is already in the gallery`,`уже есть в галерее`)}`,recommendations:[r(`Open the existing card`,`Откройте существующую карточку`),r(`A changed node (even by one bit) becomes a NEW card on scan`,`Изменённый узел (даже на один бит) при скане станет НОВОЙ карточкой`),...o]}}function so({outcome:e,outcomeGroup:t,settledCardId:n,onOpenDetail:i,onNewScan:a,onRetry:o,onOpenDiagnostics:s,onReplaceToken:c,className:l}){if(e===null)return null;let u=t===`success`||t===`warning`||t===`duplicate`;return P(K,{className:l??``,tone:e.tone,title:e.title,message:e.message,recommendations:e.recommendations,actions:u?F(N,{children:[n===null?null:P(U,{variant:`outline`,size:`xs`,onClick:()=>i(n),children:r(`Open the card`,`Открыть карточку`)}),P(U,{variant:`outline`,size:`xs`,onClick:a,children:r(`New scan`,`Новый скан`)})]}):F(N,{children:[P(U,{variant:`outline`,size:`xs`,onClick:o,children:r(`Retry`,`Повторить`)}),s===null?null:P(U,{variant:`outline`,size:`xs`,onClick:s,children:r(`Open diagnostics`,`Открыть диагностику`)}),e.action===`replace-token`&&c!==void 0?P(U,{variant:`outline`,size:`xs`,onClick:c,"data-testid":`pixso-outcome-replace-token`,children:r(`Replace token`,`Заменить токен`)}):null]})})}const co=[{label:()=>r(`Connect to pixso`,`Подключение к pixso`),detail:o},{label:()=>r(`Read the frame`,`Чтение фрейма`),detail:`get_node_dsl`},{label:()=>r(`Parse & assemble the card`,`Разбор и сборка карточки`),detail:`parser`}];function lo(e){return Math.min(e,co.length-1)}function uo({index:e,icon:t,title:n,detail:r,dimmed:i=!1,children:a}){return F(`div`,{className:(0,H.cn)(`flex items-start gap-2.5`,i&&`opacity-45`),children:[P(`span`,{className:(0,H.cn)(`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full text-xs font-semibold`,i?`border border-border/60 bg-muted/30 text-muted-foreground`:`bg-primary/10 text-primary`),children:e}),F(`div`,{className:`min-w-0 flex-1`,children:[F(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[P(t,{className:`size-3.5 shrink-0 text-muted-foreground`}),n]}),P(`p`,{className:`mt-0.5 text-[13px] leading-snug text-muted-foreground/70`,children:r}),a]})]})}function fo({wasReset:e}){let t=z(e=>e.openWizard);return F(`div`,{className:`flex flex-col gap-2`,"data-testid":`pixso-remote-onboarding`,children:[e?P(`div`,{"data-testid":`pixso-token-reset-notice`,children:P(K,{tone:`info`,title:r(`Token deleted`,`Токен удалён`),message:``,recommendations:[r(`The remote setup was reset — create a new token to continue.`,`Настройка удалённого доступа сброшена — создайте новый токен, чтобы продолжить.`)]})}):null,P(`div`,{className:`rounded-xl border border-border/70 bg-muted/20 p-3`,children:F(`div`,{className:`flex flex-col gap-3`,children:[P(uo,{index:1,icon:We,title:r(`Create an access token`,`Создайте access token`),detail:r(`One token, created once — the panel connects to pixso on your behalf.`,`Токен создаётся один раз — панель будет подключаться к pixso от вашего имени.`),children:F(U,{size:`sm`,className:`mt-2`,onClick:t,"data-testid":`pixso-create-token`,children:[P(We,{}),r(`Create an access token`,`Создать access token`)]})}),P(uo,{index:2,icon:Xe,dimmed:!0,title:r(`Copy a frame link`,`Скопируйте ссылку на фрейм`),detail:r(`In pixso, right-click the frame and copy its URL.`,`В pixso кликните правой кнопкой по фрейму и скопируйте ссылку.`)}),P(uo,{index:3,icon:at,dimmed:!0,title:r(`Press “Scan”`,`Нажмите «Сканировать»`),detail:r(`The panel connects for the duration of the scan and builds the card.`,`Панель подключится на время скана и соберёт карточку.`)})]})})]})}function po({label:e,value:t,testId:n}){return F(`span`,{className:`inline-flex min-w-0 items-baseline gap-1.5 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,"data-testid":n,children:[P(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground`,children:e}),P(`span`,{className:`min-w-0 break-all font-mono text-xs text-foreground/85`,children:t})]})}function mo(){let e=z(e=>e.designUrl),t=z(e=>e.setDesignUrl),n=z(e=>e.scan),i=z(e=>e.runRemoteScan),a=z(e=>e.cancelRemoteScan),o=z(e=>e.resetScan),s=z(e=>e.tokenTail),c=z(e=>e.deleteToken),l=z(e=>e.openWizard),u=B(e=>e.openDetail),d=B(e=>e.openDiagnostics),f=B(e=>e.cards),p=se(e),m=n.phase===`running`,h=n.phase===`settled`?n:null,g=h?.cardId==null?null:f.find(e=>e.id===h.cardId)??null,_=h===null?null:oo(h.outcome,h.detail,g?.name??null,`remote`),v=h===null?null:$t(h.outcome);return F(`div`,{className:`flex flex-col gap-2`,"data-testid":`pixso-remote-url-step`,children:[F(`div`,{className:`flex items-center gap-2 rounded-lg border border-success/24 bg-success/6 px-3 py-2`,children:[P(Fn.StatusDot,{tone:`success`,size:`sm`,label:r(`Token active`,`Токен активен`)}),P(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground/60`,children:`pix_••••${s??``}`})]}),F(`div`,{className:`rounded-xl border border-border/70 bg-muted/20 p-3`,children:[F(`div`,{className:`flex flex-col gap-3`,children:[P(uo,{index:1,icon:be,title:r(`Open pixso`,`Откройте pixso`),detail:r(`The web app, in the file with the frame you need.`,`Веб-приложение, в файле с нужным фреймом.`)}),P(uo,{index:2,icon:Xe,title:r(`Copy the frame URL`,`Скопируйте ссылку на фрейм`),detail:r(`Right-click the frame on the canvas and choose “Copy link”.`,`Кликните правой кнопкой по фрейму на холсте и выберите «Скопировать ссылку».`)}),P(uo,{index:3,icon:Ge,title:r(`Paste the link here`,`Вставьте ссылку сюда`),detail:r(`The link works for one scan — copy a fresh one for the next frame.`,`Ссылка действует на один скан — для следующего фрейма скопируйте новую.`)})]}),F(`div`,{className:`mt-3 space-y-1.5`,children:[P(Mn.Label,{htmlFor:`pixso-design-url`,className:`sr-only`,children:r(`Frame link`,`Ссылка на фрейм`)}),P(q.Input,{id:`pixso-design-url`,"data-testid":`pixso-design-url-input`,spellCheck:!1,autoComplete:`off`,className:`font-mono text-[13px]`,placeholder:`https://…/app/design/…?item-id=…`,value:e,disabled:m,onChange:e=>t(e.target.value)}),p.kind===`invalid`?P(`p`,{className:`text-xs leading-snug text-destructive`,"data-testid":`pixso-url-invalid`,children:r(`This does not look like a link — copy the frame address from pixso.`,`Не похоже на ссылку — скопируйте адрес фрейма из pixso.`)}):null,p.kind===`no-file-key`?P(`p`,{className:`text-xs leading-snug text-destructive`,"data-testid":`pixso-url-no-file-key`,children:r(`The link has no file key — copy the URL from the pixso editor.`,`В ссылке нет ключа файла — скопируйте адрес из редактора pixso.`)}):null,p.kind===`no-item-id`?F(`div`,{className:`space-y-1.5`,"data-testid":`pixso-url-no-item-id`,children:[P(`p`,{className:`text-xs leading-snug text-warning`,children:r(`The link has no item-id — right-click the frame itself and choose “Copy link”.`,`В ссылке нет item-id — кликните правой кнопкой именно по фрейму и выберите «Скопировать ссылку».`)}),P(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:P(po,{label:`file_key`,value:p.fileKey,testId:`pixso-parsed-file-key`})})]}):null,p.kind===`ok`?F(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`pixso-url-parsed`,children:[P(E,{className:`size-3.5 shrink-0 text-success-foreground`}),P(po,{label:`file_key`,value:p.fileKey,testId:`pixso-parsed-file-key`}),P(po,{label:`item-id`,value:p.itemId,testId:`pixso-parsed-item-id`})]}):null]})]}),P(`div`,{className:`mt-3 flex flex-col items-center gap-1.5`,children:F(U,{size:`lg`,className:`px-7 shadow-lg shadow-primary/20`,"data-testid":`pixso-remote-scan-button`,disabled:p.kind!==`ok`||m,onClick:i,children:[m?P(G.Spinner,{className:`size-4`}):P(at,{}),m?r(`Scanning…`,`Сканируем…`):r(`Scan the frame`,`Сканировать фрейм`)]})}),(m||h!==null)&&P(`div`,{className:`mt-2`,children:(()=>{let e=n.phase===`running`?n.nodes??null:h?.resolvedNodes===void 0?null:Qt(h.resolvedNodes),t=e!==null,r=Xt(co,e),i=(e,n)=>{let r=lo(e);return t?Zt(r,n):r},o=h?.failedStep??null,s=o===null?null:i(o,!1);return F(N,{children:[P(Xa,{running:m,currentStep:n.phase===`running`?i(n.step,n.nodes!==void 0):s??r.length-1,failedStep:s,steps:r}),P(Qa,{visible:n.phase===`running`&&n.nodes!==void 0,onCancel:a})]})})()}),!m&&h?.resolvedNodes!==void 0&&P(Za,{className:`mt-2`,resolvedNodes:h.resolvedNodes,onRetry:i,retrying:m}),P(so,{className:`mt-1`,outcome:_,outcomeGroup:v,settledCardId:g?.id??null,onOpenDetail:u,onNewScan:o,onRetry:i,onOpenDiagnostics:pn()?d:null,onReplaceToken:()=>{c(),l()}})]})}function ho(){return F(`div`,{className:`flex items-center gap-2 rounded-xl border border-border/70 bg-muted/20 px-3 py-3 text-[13px] text-muted-foreground`,"data-testid":`pixso-token-verifying`,children:[P(G.Spinner,{className:`size-4`}),r(`Checking the token…`,`Проверяем токен…`),P(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground/50`,children:`tools/list`})]})}function go(){let e=z(e=>e.authRaw),t=z(e=>e.recheckToken),n=z(e=>e.openWizard);return P(`div`,{"data-testid":`pixso-auth-death`,children:P(K,{title:r(`Access denied — the token no longer works`,`Доступ отклонён — токен больше не работает`),message:e??`401 Unauthorized`,recommendations:[r(`The token may have been revoked or expired — generate a new one in pixso`,`Токен могли отозвать, или он истёк — сгенерируйте новый в pixso`),r(`If you just changed the token, run the check again`,`Если токен только что меняли — запустите проверку ещё раз`)],actions:F(N,{children:[F(U,{size:`xs`,onClick:n,"data-testid":`pixso-auth-death-renew`,children:[P(We,{}),r(`Update the token`,`Обновить токен`)]}),P(U,{variant:`outline`,size:`xs`,onClick:t,"data-testid":`pixso-auth-death-recheck`,children:r(`Check again`,`Проверить снова`)})]})})})}function _o(){let e=z(e=>e.tokenStatus),t=z(e=>e.tokenWasReset);return e===`none`?P(fo,{wasReset:t}):P(e===`verifying`?ho:e===`dead`?go:mo,{})}function vo({children:e}){return P(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:e})}function yo(){return F(`div`,{className:`overflow-hidden rounded-lg border border-border bg-card`,children:[P(ia.Skeleton,{className:`h-24 w-full rounded-none`}),F(`div`,{className:`flex flex-col gap-2 px-2.5 pb-2.5 pt-2`,children:[P(ia.Skeleton,{className:`h-3.5 w-2/5 rounded-full`}),P(ia.Skeleton,{className:`h-2.5 w-3/5 rounded-full`}),P(ia.Skeleton,{className:`h-1.5 w-full rounded-full`})]})]})}function bo(){let e=z(e=>e.source),t=z(e=>e.setSource),n=B(e=>e.scanJob),i=B(e=>e.runImport),a=B(e=>e.cancelImport),o=B(e=>e.openDetail),s=B(e=>e.openDiagnostics),c=B(e=>e.recents),l=B(e=>e.cards),u=B(e=>e.dismissedSettledAtIso),d=B(e=>e.dismissLocalOutcome),f=n.phase===`running`,p=n.phase===`settled`?n:null,m=c.map(e=>l.find(t=>t.id===e)).filter(e=>e!==void 0),h=m[0]??null,g=p?.cardId==null?null:l.find(e=>e.id===p.cardId)??null,_=p!==null&&p.settledAtIso===u,v=p===null||_?null:oo(p.outcome,p.detail,g?.name??h?.name??null,`local`,p.enriched??[]),y=p===null?null:$t(p.outcome),b=p!==null&&(y===`success`||y===`warning`),x=f?n.nodes??null:p?.resolvedNodes===void 0?null:Qt(p.resolvedNodes),S=x!==null,C=Xt(Jt,x),w=f?n.step:p?.failedStep??Jt.length-1,T=S?Zt(w,f&&n.nodes!==void 0):w,ee=p?.failedStep==null?null:S?Zt(p.failedStep,!1):p.failedStep;return F(`div`,{className:`flex min-h-full flex-col`,children:[P(pa,{value:e,onChange:t,className:`mb-3`}),e===`remote`?P(_o,{}):F(N,{children:[P(eo,{}),P(`div`,{className:`mt-5 flex flex-col items-center gap-1.5`,children:F(U,{size:`lg`,onClick:i,disabled:f,className:`px-7 shadow-lg shadow-primary/20`,"data-testid":`pixso-scan-button`,children:[f?P(G.Spinner,{className:`size-4`}):P(at,{}),f?r(`Scanning…`,`Сканируем…`):r(`Scan the selection`,`Сканировать выделенное`)]})})]}),e===`local`&&(f||p!==null)&&F(`div`,{className:`mt-4`,children:[P(Xa,{running:f,currentStep:T,failedStep:ee,steps:C}),P(Qa,{visible:f&&n.phase===`running`&&n.nodes!==void 0,onCancel:a})]}),e===`local`&&!f&&p?.resolvedNodes!==void 0&&P(Za,{className:`mt-3`,resolvedNodes:p.resolvedNodes,onRetry:i,retrying:f}),e===`local`&&P(so,{className:`mt-3`,outcome:v,outcomeGroup:y,settledCardId:g?.id??null,onOpenDetail:o,onNewScan:d,onRetry:i,onOpenDiagnostics:pn()?s:null}),(e===`local`||m.length>0)&&F(`div`,{className:`mt-5`,children:[P(vo,{children:f?r(`Importing…`,`Импортируем…`):b?r(`Imported — the assembled card`,`Импортировано — собранная карточка`):r(`Recent scans`,`Недавние сканы`)}),f?F(`div`,{className:`grid grid-cols-2 gap-2`,children:[P(yo,{}),h!==null&&P(ka,{card:h,onOpen:()=>o(h.id)})]}):m.length>0?P(`div`,{className:`grid grid-cols-2 gap-2`,children:m.map(e=>P(ka,{card:e,onOpen:()=>o(e.id)},e.id))}):P(`p`,{className:`text-[13px] text-muted-foreground/60`,children:r(`Nothing imported yet — select a frame in Pixso and scan.`,`Пока ничего не импортировано — выделите фрейм в Pixso и сканируйте.`)})]})]})}function xo({children:e}){return P(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:e})}function So({onClose:e,mode:t=`sidebar`}){let n=B(e=>e.view),i=B(e=>e.activeTab),a=B(e=>e.setTab),o=B(e=>e.openDiagnostics),s=B(e=>e.backToTabs),c=B(e=>e.refreshSnapshot),l=B(e=>e.applyScanJobState),u=B(e=>e.gallerySyncing),d=z(e=>e.settingsOpen),f=z(e=>e.openSettings),p=z(e=>e.closeSettings);return k(()=>(c(),L().client.subscribeScan(l)),[c,l]),P(er.DiffPanelShell,{mode:t,header:F(N,{children:[F(`div`,{className:`flex min-w-0 items-center gap-2`,children:[P(Qe,{className:`size-4 text-muted-foreground`}),P(`h2`,{className:`truncate text-sm font-semibold`,children:`Pixso`})]}),F(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[P(rr.Toggle,{variant:`outline`,size:`xs`,pressed:d,onPressedChange:()=>{d?p():(f(),n===`diagnostics`&&s())},"aria-label":r(`Pixso settings`,`Настройки Pixso`),"data-testid":`pixso-settings-toggle`,children:P(st,{className:`size-3`})}),pn()?P(rr.Toggle,{variant:`outline`,size:`xs`,pressed:n===`diagnostics`,onPressedChange:()=>{n===`diagnostics`?s():(p(),o())},"aria-label":r(`Debug`,`Отладка`),"data-testid":`pixso-diagnostics-toggle`,children:P(pt,{className:`size-3`})}):null,P(rr.Toggle,{variant:`outline`,size:`xs`,pressed:!1,onPressedChange:e,"aria-label":r(`Close the Pixso panel`,`Закрыть панель Pixso`),children:P(mt,{className:`size-3`})})]})]}),className:`bg-card`,children:F(`div`,{style:{display:`contents`},"data-testid":`pixso-panel-root`,"data-pixso-syncing":u?`true`:`false`,children:[P(fn,{}),P($n,{}),d?P(Un,{}):n===`diagnostics`?P(ya,{}):F(J.Tabs,{value:i,onValueChange:e=>a(e),className:`min-h-0 flex-1`,children:[F(J.TabsList,{className:`shrink-0 border-b border-border px-2`,children:[P(J.TabsTab,{value:`import`,onClick:()=>a(`import`),children:r(`Import`,`Импорт`)}),P(J.TabsTab,{value:`gallery`,onClick:()=>a(`gallery`),children:r(`Gallery`,`Галерея`)}),P(J.TabsIndicator,{})]}),n===`detail`?P(ta,{}):F(N,{children:[P(J.TabsPanel,{value:`import`,children:P(xo,{children:P(bo,{})})}),P(J.TabsPanel,{value:`gallery`,children:P(qa,{})})]})]})]})})}export{So as PixsoAssistantPanel,g as configurePixsoAssistantLocale,Gt as configurePixsoAssistantPorts,ln as resetPixsoAuthority};