@uicopilot/storybook-addon 0.5.26 → 0.5.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/manager.mjs +41 -41
  2. package/package.json +1 -1
package/dist/manager.mjs CHANGED
@@ -1,33 +1,33 @@
1
- var qF=Object.create;var Wa=Object.defineProperty;var YF=Object.getOwnPropertyDescriptor;var KF=Object.getOwnPropertyNames;var XF=Object.getPrototypeOf,QF=Object.prototype.hasOwnProperty;var JF=(e,t,n)=>t in e?Wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var ar=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Se=(e,t)=>{for(var n in t)Wa(e,n,{get:t[n],enumerable:!0})},ZF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of KF(t))!QF.call(e,o)&&o!==n&&Wa(e,o,{get:()=>t[o],enumerable:!(r=YF(t,o))||r.enumerable});return e};var Va=(e,t,n)=>(n=e!=null?qF(XF(e)):{},ZF(t||!e||!e.__esModule?Wa(n,"default",{value:e,enumerable:!0}):n,e));var lr=(e,t,n)=>JF(e,typeof t!="symbol"?t+"":t,n);function fy(){try{return typeof window<"u"&&localStorage.getItem(rE)==="true"}catch{return!1}}var rE,b,_e=$(()=>{"use strict";rE="uicopilot:debug";b={debug:(...e)=>{fy()&&console.log(...e)},info:(...e)=>{fy()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import oE,{createContext as iE,useContext as sE,useReducer as aE,useMemo as my}from"react";function lE(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"RESET_AUTH":return typeof localStorage<"u"&&Object.keys(localStorage).filter(n=>n.startsWith("uicopilot_")).forEach(n=>localStorage.removeItem(n)),typeof sessionStorage<"u"&&Object.keys(sessionStorage).filter(n=>n.startsWith("uicopilot_")||n.startsWith("uicopilot-")).forEach(n=>sessionStorage.removeItem(n)),typeof localStorage<"u"&&localStorage.setItem("uicopilot_force_sign_in","true"),b.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function yu({children:e}){let[t,n]=aE(lE,dE),r=my(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{b.debug("[AuthContext] setSessionToken:",i?i.substring(0,20)+"...":"null"),typeof localStorage<"u"&&(i?localStorage.setItem("uicopilot_session_token",i):localStorage.removeItem("uicopilot_session_token")),n({type:"SET_STATE",payload:{sessionToken:i,isConnected:!!i,...i?{authError:null}:{}}})},setApiKey:i=>{typeof localStorage<"u"&&localStorage.setItem("uicopilot_api_key",i),n({type:"SET_STATE",payload:{apiKey:i}})},setAuthMethod:i=>n({type:"SET_STATE",payload:{authMethod:i}}),setDeviceCode:i=>n({type:"SET_STATE",payload:{deviceCode:i}}),setUserCode:i=>n({type:"SET_STATE",payload:{userCode:i}}),setVerificationUri:i=>n({type:"SET_STATE",payload:{verificationUri:i}}),setPollingInterval:i=>n({type:"SET_STATE",payload:{pollingInterval:i}}),setUsageData:i=>n({type:"SET_STATE",payload:{usageData:i,usageLastFetched:Date.now()}}),setAuthError:i=>n({type:"SET_STATE",payload:{authError:i}}),resetAuth:()=>n({type:"RESET_AUTH"})}),[]),o=my(()=>({...t,...r}),[t,r]);return oE.createElement(xy.Provider,{value:o},e)}function ke(){let e=sE(xy);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var cE,uE,pE,hy,dE,xy,bu=$(()=>{"use strict";_e();cE=()=>{if(typeof localStorage>"u")return;let e=localStorage.getItem("uicopilot-session-token");e&&!localStorage.getItem("uicopilot_session_token")&&(localStorage.setItem("uicopilot_session_token",e),localStorage.removeItem("uicopilot-session-token"));let t=localStorage.getItem("uicopilot-api-key");t&&!localStorage.getItem("uicopilot_api_key")&&(localStorage.setItem("uicopilot_api_key",t),localStorage.removeItem("uicopilot-api-key"))};cE();uE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),pE=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",hy=uE(),dE={isConnected:!!hy,sessionToken:hy,apiKey:pE(),authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},xy=iE(null)});import gE,{createContext as fE,useContext as mE,useReducer as hE,useMemo as yy,useRef as xE,useEffect as yE}from"react";function bE(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"SET_PROJECTS":return{...e,projects:t.payload};case"ADD_PROJECT":return{...e,projects:[...e.projects,t.payload]};case"UPDATE_PROJECT":return{...e,projects:e.projects.map(n=>n.id===t.payload.id?{...n,...t.payload.updates}:n)};case"DELETE_PROJECT":return{...e,projects:e.projects.filter(n=>n.id!==t.payload),selectedProjectId:e.selectedProjectId===t.payload?null:e.selectedProjectId};default:return e}}function Su({children:e}){let[t,n]=hE(bE,wE),r=xE(t);yE(()=>{r.current=t},[t]);let o=yy(()=>({setProjects:s=>n({type:"SET_PROJECTS",payload:s}),setSelectedProjectId:s=>{typeof localStorage<"u"&&(s?localStorage.setItem("uicopilot_selected_project_id",s):localStorage.removeItem("uicopilot_selected_project_id")),n({type:"SET_STATE",payload:{selectedProjectId:s}})},setLoadingProjects:s=>n({type:"SET_STATE",payload:{loadingProjects:s}}),setCurrentStorybookPath:s=>n({type:"SET_STATE",payload:{currentStorybookPath:s}}),addProject:s=>n({type:"ADD_PROJECT",payload:s}),updateProject:(s,a)=>n({type:"UPDATE_PROJECT",payload:{id:s,updates:a}}),deleteProject:s=>n({type:"DELETE_PROJECT",payload:s}),getSelectedProject:()=>{let s=r.current;return s.projects.find(a=>a.id===s.selectedProjectId)},getMatchingProject:()=>{let s=r.current;if(s.currentStorybookPath)return s.projects.find(a=>a.storybookRoot===s.currentStorybookPath)}}),[]),i=yy(()=>({...t,...o}),[t,o]);return gE.createElement(by.Provider,{value:i},e)}function Je(){let e=mE(by);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var SE,wE,by,wu=$(()=>{"use strict";SE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),wE={projects:[],selectedProjectId:SE(),loadingProjects:!1,currentStorybookPath:null},by=fE(null)});import vE,{createContext as kE,useContext as CE,useReducer as TE,useMemo as Sy}from"react";function IE(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"REFRESH_MAPPINGS":return{...e,mappingsRefreshKey:e.mappingsRefreshKey+1};case"UPDATE_FRAMES_THUMBNAILS":return e.framesCache?{...e,framesCache:{...e.framesCache,thumbnails:{...e.framesCache.thumbnails,...t.payload}}}:e;case"SET_VARIANT_THUMBNAILS":{let n={...e.variantThumbnailsCache,[t.payload.componentSetId]:t.payload.thumbnails},r=Object.keys(n);if(r.length>wy)for(let o of r.slice(0,r.length-wy))delete n[o];return{...e,variantThumbnailsCache:n}}case"CLEAR_VARIANT_THUMBNAILS_FOR_SET":{let{[t.payload]:n,...r}=e.variantThumbnailsCache;return{...e,variantThumbnailsCache:r}}case"CLEAR_ALL_VARIANT_THUMBNAILS":return{...e,variantThumbnailsCache:{}};default:return e}}function vu({children:e}){let[t,n]=TE(IE,FE),r=Sy(()=>({setShowComponentBrowser:i=>n({type:"SET_STATE",payload:{showComponentBrowser:i}}),setFigmaFileUrl:i=>n({type:"SET_STATE",payload:{figmaFileUrl:i}}),setCurrentStoryId:i=>n({type:"SET_STATE",payload:{currentStoryId:i}}),setCurrentStoryName:i=>n({type:"SET_STATE",payload:{currentStoryName:i}}),setCurrentMapping:i=>{n({type:"SET_STATE",payload:{currentMapping:i}})},setMappingsByStoryId:i=>n({type:"SET_STATE",payload:{mappingsByStoryId:i}}),refreshMappings:()=>n({type:"REFRESH_MAPPINGS"}),setReviewFigmaUrl:i=>n({type:"SET_STATE",payload:{reviewFigmaUrl:i}}),setMappingSource:i=>n({type:"SET_STATE",payload:{mappingSource:i}}),setLoadingMapping:i=>n({type:"SET_STATE",payload:{loadingMapping:i}}),setShowFigmaQuality:i=>n({type:"SET_STATE",payload:{showFigmaQuality:i}}),setFramesCache:i=>n({type:"SET_STATE",payload:{framesCache:i}}),setIsLoadingFrames:i=>n({type:"SET_STATE",payload:{isLoadingFrames:i}}),updateFramesThumbnails:i=>n({type:"UPDATE_FRAMES_THUMBNAILS",payload:i}),setVariantThumbnails:(i,s)=>n({type:"SET_VARIANT_THUMBNAILS",payload:{componentSetId:i,thumbnails:s}}),clearVariantThumbnailsForSet:i=>n({type:"CLEAR_VARIANT_THUMBNAILS_FOR_SET",payload:i}),clearAllVariantThumbnails:()=>n({type:"CLEAR_ALL_VARIANT_THUMBNAILS"})}),[]),o=Sy(()=>({...t,...r}),[t,r]);return vE.createElement(vy.Provider,{value:o},e)}function nt(){let e=CE(vy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var wy,FE,vy,ku=$(()=>{"use strict";wy=200;FE={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,mappingsByStoryId:{},reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},vy=kE(null)});var Pt,Cu=$(()=>{"use strict";Pt={NAME:"UI Parity",SHORT:"Parity",DOMAIN:"uiparity.com",MARKETING_URL:"https://uiparity.com",APP_URL:"https://app.uiparity.com",API_URL:"https://api.uiparity.com",SUPPORT_EMAIL:"feedback@uiparity.com",TAGLINE:"Pixel-perfect isn't a feeling. It's a score."}});function EE(){if(typeof process<"u"&&process.env)return process.env.UICOPILOT_DEBUG==="1";if(typeof globalThis<"u"&&"localStorage"in globalThis)try{return globalThis.localStorage.getItem("uicopilot_debug")==="1"}catch{return!1}return!1}var Ka,Tu,ky=$(()=>{"use strict";Cu();Ka=`[${Pt.NAME}]`,Tu={debug:(...e)=>{EE()&&console.log(Ka,...e)},info:(...e)=>{console.log(Ka,...e)},warn:(...e)=>{console.warn(Ka,...e)},error:(...e)=>{console.error(Ka,...e)}}});var Cy=$(()=>{"use strict"});var Iu=$(()=>{"use strict"});function Ht(e){return e>=48&&e<=57}function Rn(e){return Ht(e)||e>=65&&e<=70||e>=97&&e<=102}function Qa(e){return e>=65&&e<=90}function PE(e){return e>=97&&e<=122}function LE(e){return Qa(e)||PE(e)}function ME(e){return e>=128}function Xa(e){return LE(e)||ME(e)||e===95}function Ja(e){return Xa(e)||Ht(e)||e===45}function BE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function ms(e){return e===10||e===13||e===12}function Or(e){return ms(e)||e===32||e===9}function Dn(e,t){return!(e!==92||ms(t)||t===0)}function yi(e,t,n){return e===45?Xa(t)||t===45||Dn(t,n):Xa(e)?!0:e===92?Dn(e,t):!1}function Za(e,t,n){return e===43||e===45?Ht(t)?2:t===46&&Ht(n)?3:0:e===46?Ht(t)?2:0:Ht(e)?1:0}function el(e){return e===65279||e===65534?1:0}function nl(e){return e<128?Fu[e]:tl}var Fu,DE,hs,Eu,tl,Au,xs=$(()=>{"use strict";Fu=new Array(128),DE=128,hs=130,Eu=131,tl=132,Au=133;for(let e=0;e<Fu.length;e++)Fu[e]=Or(e)&&hs||Ht(e)&&Eu||Xa(e)&&tl||BE(e)&&Au||e||DE});function bi(e,t){return t<e.length?e.charCodeAt(t):0}function rl(e,t,n){return n===13&&bi(e,t+1)===10?2:1}function Kr(e,t,n){let r=e.charCodeAt(t);return Qa(r)&&(r=r|32),r===n}function Xr(e,t,n,r){if(n-t!==r.length||t<0||n>e.length)return!1;for(let o=t;o<n;o++){let i=r.charCodeAt(o-t),s=e.charCodeAt(o);if(Qa(s)&&(s=s|32),s!==i)return!1}return!0}function Ty(e,t){for(;t>=0&&Or(e.charCodeAt(t));t--);return t+1}function ys(e,t){for(;t<e.length&&Or(e.charCodeAt(t));t++);return t}function Pu(e,t){for(;t<e.length&&Ht(e.charCodeAt(t));t++);return t}function Qr(e,t){if(t+=2,Rn(bi(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Rn(bi(e,t));t++);let n=bi(e,t);Or(n)&&(t+=rl(e,t,n))}return t}function bs(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Ja(n)){if(Dn(n,bi(e,t+1))){t=Qr(e,t)-1;continue}break}}return t}function qo(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),Ht(n)&&(t=Pu(e,t+1),n=e.charCodeAt(t)),n===46&&Ht(e.charCodeAt(t+1))&&(t+=2,t=Pu(e,t)),Kr(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),Ht(n)&&(t=Pu(e,t+1+r+1))}return t}function ol(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}Dn(n,bi(e,t+1))&&(t=Qr(e,t))}return t}function il(e){if(e.length===1&&!Rn(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var sl=$(()=>{"use strict";xs()});var Si,Lu=$(()=>{"use strict";Si=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"]});function wi(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Mu=$(()=>{"use strict"});function Ey(e){let t=e.source,n=t.length,r=t.length>0?el(t.charCodeAt(0)):0,o=wi(e.lines,n),i=wi(e.columns,n),s=e.startLine,a=e.startColumn;for(let u=r;u<n;u++){let c=t.charCodeAt(u);o[u]=s,i[u]=a++,(c===Iy||c===Fy||c===RE)&&(c===Fy&&u+1<n&&t.charCodeAt(u+1)===Iy&&(u++,o[u]=s,i[u]=a),s++,a=1)}o[n]=s,i[n]=a,e.lines=o,e.columns=i,e.computed=!0}var Iy,RE,Fy,al,Ay=$(()=>{"use strict";Mu();xs();Iy=10,RE=12,Fy=13;al=class{constructor(t,n,r,o){this.setSource(t,n,r,o),this.lines=null,this.columns=null}setSource(t="",n=0,r=1,o=1){this.source=t,this.startOffset=n,this.startLine=r,this.startColumn=o,this.computed=!1}getLocation(t,n){return this.computed||Ey(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||Ey(this),{source:r,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}});function Py(e,t,n){return e<t?t:e>n?n:e}var wr,vr,Ss,cl,wo,kr,ll,Ly=$(()=>{"use strict";Mu();sl();Lu();wr=16777215,vr=24,Ss=1,cl=2,wo=new Uint8Array(32);wo[2]=22;wo[21]=22;wo[19]=20;wo[23]=24;kr=new Uint8Array(32);kr[2]=Ss;kr[21]=Ss;kr[19]=Ss;kr[23]=Ss;kr[22]=cl;kr[20]=cl;kr[24]=cl;ll=class{constructor(t,n){this.setSource(t,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",n=()=>{}){t=String(t||"");let r=t.length,o=wi(this.offsetAndType,t.length+1),i=wi(this.balance,t.length+1),s=0,a=-1,u=0,c=t.length;this.offsetAndType=null,this.balance=null,i.fill(0),n(t,(l,d,g)=>{let p=s++;if(o[p]=l<<vr|g,a===-1&&(a=d),i[p]=c,l===u){let m=i[c];i[c]=p,c=m,u=wo[o[m]>>vr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=wo[l])}),o[s]=0<<vr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let g=i[d];g!==l&&(i[l]=g)}else d>s&&(i[l]=s)}this.source=t,this.firstCharOffset=a===-1?0:a,this.tokenCount=s,this.offsetAndType=o,this.balance=i,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>vr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>vr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&wr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>vr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Xr(this.source,this.offsetAndType[t-1]&wr,this.offsetAndType[t]&wr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&wr:this.offsetAndType[this.tokenCount]&wr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[Py(t,0,this.tokenCount)]&wr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[Py(t,0,this.tokenCount)]>>vr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return kr[t]===Ss}isBlockCloserTokenType(t){return kr[t]===cl}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(kr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return wo[n]===o?r:-1}else if(kr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return wo[o]===n?r:-1}return-1}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,n){return n?this.lookupType(n)===9&&this.source.charCodeAt(this.lookupOffset(n))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let n=this.tokenIndex+t;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&wr,n=this.offsetAndType[n],this.tokenType=n>>vr,this.tokenEnd=n&wr):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>vr,this.tokenEnd=t&wr):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,n){let r=t,o=0,i=0;e:for(;r<this.tokenCount;r++){if(o=this.balance[r],o<t)break e;switch(i=r>0?this.offsetAndType[r-1]&wr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>vr)&&(r=o)}}this.skip(r-this.tokenIndex)}forEachToken(t){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){let o=r,i=this.offsetAndType[n],s=i&wr,a=i>>vr;r=s,t(a,o,s,n)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((n,r,o,i)=>{t[i]={idx:i,type:Si[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function vo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=qo(e,c),yi(n(c),n(c+1),n(c+2))){l=12,c=bs(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=bs(e,c),Xr(e,d,c,"url")&&n(c)===40){if(c=ys(e,c+1),n(c)===34||n(c)===39){l=2,c=d+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(d){for(d||(d=n(c++)),l=5;c<e.length;c++){let g=e.charCodeAt(c);switch(nl(g)){case d:c++;return;case hs:if(ms(g)){c+=rl(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);ms(p)?c+=rl(e,c+1,p):Dn(g,p)&&(c=Qr(e,c)-1);break}}}function s(){for(l=7,c=ys(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch(nl(d)){case 41:c++;return;case hs:if(c=ys(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=ol(e,c),l=8;return;case 34:case 39:case 40:case Au:c=ol(e,c),l=8;return;case 92:if(Dn(d,n(c+1))){c=Qr(e,c)-1;break}c=ol(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=el(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch(nl(d)){case hs:l=13,c=ys(e,c+1);break;case 34:i();break;case 35:Ja(n(c+1))||Dn(n(c+1),n(c+2))?(l=4,c=bs(e,c+1)):(l=9,c++);break;case 39:i();break;case 40:l=21,c++;break;case 41:l=22,c++;break;case 43:Za(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Za(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):yi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Za(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 47:n(c+1)===42?(l=25,c=e.indexOf("*/",c+2),c=c===-1?e.length:c+2):(l=9,c++);break;case 58:l=16,c++;break;case 59:l=17,c++;break;case 60:n(c+1)===33&&n(c+2)===45&&n(c+3)===45?(l=14,c=c+4):(l=9,c++);break;case 64:yi(n(c+1),n(c+2),n(c+3))?(l=3,c=bs(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:Dn(d,n(c+1))?o():(l=9,c++);break;case 93:l=20,c++;break;case 123:l=23,c++;break;case 125:l=24,c++;break;case Eu:r();break;case tl:o();break;default:l=9,c++}t(l,u,u=c)}}var ur=$(()=>{"use strict";xs();sl();Iu();Iu();Lu();xs();sl();Ay();Ly()});var vi,er,vs=$(()=>{"use strict";vi=null,er=class e{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return e.createItem(t)}allocateCursor(t,n){let r;return vi!==null?(r=vi,vi=vi.cursor,r.prev=t,r.next=n,r.cursor=this.cursor):r={prev:t,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=vi,vi=t}updateCursors(t,n,r,o){let{cursor:i}=this;for(;i!==null;)i.prev===t&&(i.prev=n),i.next===r&&(i.next=o),i=i.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let n=this.head;n!==null;n=n.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let n=null;this.head=null;for(let r of t){let o=e.createItem(r);n!==null?n.next=o:this.head=o,o.prev=n,n=o}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,n=this){let r=this.allocateCursor(null,this.head);for(;r.next!==null;){let o=r.next;r.next=o.next,t.call(n,o.data,o,this)}this.releaseCursor()}forEachRight(t,n=this){let r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){let o=r.prev;r.prev=o.prev,t.call(n,o.data,o,this)}this.releaseCursor()}reduce(t,n,r=this){let o=this.allocateCursor(null,this.head),i=n,s;for(;o.next!==null;)s=o.next,o.next=s.next,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}reduceRight(t,n,r=this){let o=this.allocateCursor(this.tail,null),i=n,s;for(;o.prev!==null;)s=o.prev,o.prev=s.prev,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}some(t,n=this){for(let r=this.head;r!==null;r=r.next)if(t.call(n,r.data,r,this))return!0;return!1}map(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)r.appendData(t.call(n,o.data,o,this));return r}filter(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)t.call(n,o.data,o,this)&&r.appendData(o.data);return r}nextUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(null,t);for(;o.next!==null;){let i=o.next;if(o.next=i.next,n.call(r,i.data,i,this))break}this.releaseCursor()}prevUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(t,null);for(;o.prev!==null;){let i=o.prev;if(o.prev=i.prev,n.call(r,i.data,i,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new e;for(let n of this)t.appendData(n);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(e.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(e.createItem(t))}insert(t,n=null){if(n!==null)if(this.updateCursors(n.prev,t,n,t),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=t,n.prev=t,t.next=n,this.updateCursors(null,t)}else n.prev.next=t,t.prev=n.prev,n.prev=t,t.next=n;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,n){return this.insert(e.createItem(t),n)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(e.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(e.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,n){return t.head===null?this:(n!=null?(this.updateCursors(n.prev,t.tail,n,t.head),n.prev!==null?(n.prev.next=t.head,t.head.prev=n.prev):this.head=t.head,n.prev=t.tail,t.tail.next=n):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,n){"head"in n?this.insertList(n,t):this.insert(n,t),this.remove(t)}}});function Ko(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
2
- `)}})}var pl=$(()=>{"use strict"});function Dy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(m,k){return c.slice(m,k).map((I,A)=>String(m+A+1).padStart(g)+" |"+I).join(`
1
+ var YF=Object.create;var Wa=Object.defineProperty;var KF=Object.getOwnPropertyDescriptor;var XF=Object.getOwnPropertyNames;var QF=Object.getPrototypeOf,JF=Object.prototype.hasOwnProperty;var ZF=(e,t,n)=>t in e?Wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var ar=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Se=(e,t)=>{for(var n in t)Wa(e,n,{get:t[n],enumerable:!0})},eE=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of XF(t))!JF.call(e,o)&&o!==n&&Wa(e,o,{get:()=>t[o],enumerable:!(r=KF(t,o))||r.enumerable});return e};var Va=(e,t,n)=>(n=e!=null?YF(QF(e)):{},eE(t||!e||!e.__esModule?Wa(n,"default",{value:e,enumerable:!0}):n,e));var lr=(e,t,n)=>ZF(e,typeof t!="symbol"?t+"":t,n);function fy(){try{return typeof window<"u"&&localStorage.getItem(oE)==="true"}catch{return!1}}var oE,b,_e=$(()=>{"use strict";oE="uicopilot:debug";b={debug:(...e)=>{fy()&&console.log(...e)},info:(...e)=>{fy()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import iE,{createContext as sE,useContext as aE,useReducer as lE,useMemo as my}from"react";function cE(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"RESET_AUTH":return typeof localStorage<"u"&&Object.keys(localStorage).filter(n=>n.startsWith("uicopilot_")).forEach(n=>localStorage.removeItem(n)),typeof sessionStorage<"u"&&Object.keys(sessionStorage).filter(n=>n.startsWith("uicopilot_")||n.startsWith("uicopilot-")).forEach(n=>sessionStorage.removeItem(n)),typeof localStorage<"u"&&localStorage.setItem("uicopilot_force_sign_in","true"),b.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function yu({children:e}){let[t,n]=lE(cE,gE),r=my(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{b.debug("[AuthContext] setSessionToken:",i?i.substring(0,20)+"...":"null"),typeof localStorage<"u"&&(i?localStorage.setItem("uicopilot_session_token",i):localStorage.removeItem("uicopilot_session_token")),n({type:"SET_STATE",payload:{sessionToken:i,isConnected:!!i,...i?{authError:null}:{}}})},setApiKey:i=>{typeof localStorage<"u"&&localStorage.setItem("uicopilot_api_key",i),n({type:"SET_STATE",payload:{apiKey:i}})},setAuthMethod:i=>n({type:"SET_STATE",payload:{authMethod:i}}),setDeviceCode:i=>n({type:"SET_STATE",payload:{deviceCode:i}}),setUserCode:i=>n({type:"SET_STATE",payload:{userCode:i}}),setVerificationUri:i=>n({type:"SET_STATE",payload:{verificationUri:i}}),setPollingInterval:i=>n({type:"SET_STATE",payload:{pollingInterval:i}}),setUsageData:i=>n({type:"SET_STATE",payload:{usageData:i,usageLastFetched:Date.now()}}),setAuthError:i=>n({type:"SET_STATE",payload:{authError:i}}),resetAuth:()=>n({type:"RESET_AUTH"})}),[]),o=my(()=>({...t,...r}),[t,r]);return iE.createElement(xy.Provider,{value:o},e)}function ke(){let e=aE(xy);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var uE,pE,dE,hy,gE,xy,bu=$(()=>{"use strict";_e();uE=()=>{if(typeof localStorage>"u")return;let e=localStorage.getItem("uicopilot-session-token");e&&!localStorage.getItem("uicopilot_session_token")&&(localStorage.setItem("uicopilot_session_token",e),localStorage.removeItem("uicopilot-session-token"));let t=localStorage.getItem("uicopilot-api-key");t&&!localStorage.getItem("uicopilot_api_key")&&(localStorage.setItem("uicopilot_api_key",t),localStorage.removeItem("uicopilot-api-key"))};uE();pE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),dE=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",hy=pE(),gE={isConnected:!!hy,sessionToken:hy,apiKey:dE(),authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},xy=sE(null)});import fE,{createContext as mE,useContext as hE,useReducer as xE,useMemo as yy,useRef as yE,useEffect as bE}from"react";function SE(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"SET_PROJECTS":return{...e,projects:t.payload};case"ADD_PROJECT":return{...e,projects:[...e.projects,t.payload]};case"UPDATE_PROJECT":return{...e,projects:e.projects.map(n=>n.id===t.payload.id?{...n,...t.payload.updates}:n)};case"DELETE_PROJECT":return{...e,projects:e.projects.filter(n=>n.id!==t.payload),selectedProjectId:e.selectedProjectId===t.payload?null:e.selectedProjectId};default:return e}}function Su({children:e}){let[t,n]=xE(SE,vE),r=yE(t);bE(()=>{r.current=t},[t]);let o=yy(()=>({setProjects:s=>n({type:"SET_PROJECTS",payload:s}),setSelectedProjectId:s=>{typeof localStorage<"u"&&(s?localStorage.setItem("uicopilot_selected_project_id",s):localStorage.removeItem("uicopilot_selected_project_id")),n({type:"SET_STATE",payload:{selectedProjectId:s}})},setLoadingProjects:s=>n({type:"SET_STATE",payload:{loadingProjects:s}}),setCurrentStorybookPath:s=>n({type:"SET_STATE",payload:{currentStorybookPath:s}}),addProject:s=>n({type:"ADD_PROJECT",payload:s}),updateProject:(s,a)=>n({type:"UPDATE_PROJECT",payload:{id:s,updates:a}}),deleteProject:s=>n({type:"DELETE_PROJECT",payload:s}),getSelectedProject:()=>{let s=r.current;return s.projects.find(a=>a.id===s.selectedProjectId)},getMatchingProject:()=>{let s=r.current;if(s.currentStorybookPath)return s.projects.find(a=>a.storybookRoot===s.currentStorybookPath)}}),[]),i=yy(()=>({...t,...o}),[t,o]);return fE.createElement(by.Provider,{value:i},e)}function Je(){let e=hE(by);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var wE,vE,by,wu=$(()=>{"use strict";wE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),vE={projects:[],selectedProjectId:wE(),loadingProjects:!1,currentStorybookPath:null},by=mE(null)});import kE,{createContext as CE,useContext as TE,useReducer as IE,useMemo as Sy}from"react";function FE(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"REFRESH_MAPPINGS":return{...e,mappingsRefreshKey:e.mappingsRefreshKey+1};case"UPDATE_FRAMES_THUMBNAILS":return e.framesCache?{...e,framesCache:{...e.framesCache,thumbnails:{...e.framesCache.thumbnails,...t.payload}}}:e;case"SET_VARIANT_THUMBNAILS":{let n={...e.variantThumbnailsCache,[t.payload.componentSetId]:t.payload.thumbnails},r=Object.keys(n);if(r.length>wy)for(let o of r.slice(0,r.length-wy))delete n[o];return{...e,variantThumbnailsCache:n}}case"CLEAR_VARIANT_THUMBNAILS_FOR_SET":{let{[t.payload]:n,...r}=e.variantThumbnailsCache;return{...e,variantThumbnailsCache:r}}case"CLEAR_ALL_VARIANT_THUMBNAILS":return{...e,variantThumbnailsCache:{}};default:return e}}function vu({children:e}){let[t,n]=IE(FE,EE),r=Sy(()=>({setShowComponentBrowser:i=>n({type:"SET_STATE",payload:{showComponentBrowser:i}}),setFigmaFileUrl:i=>n({type:"SET_STATE",payload:{figmaFileUrl:i}}),setCurrentStoryId:i=>n({type:"SET_STATE",payload:{currentStoryId:i}}),setCurrentStoryName:i=>n({type:"SET_STATE",payload:{currentStoryName:i}}),setCurrentMapping:i=>{n({type:"SET_STATE",payload:{currentMapping:i}})},setMappingsByStoryId:i=>n({type:"SET_STATE",payload:{mappingsByStoryId:i}}),refreshMappings:()=>n({type:"REFRESH_MAPPINGS"}),setReviewFigmaUrl:i=>n({type:"SET_STATE",payload:{reviewFigmaUrl:i}}),setMappingSource:i=>n({type:"SET_STATE",payload:{mappingSource:i}}),setLoadingMapping:i=>n({type:"SET_STATE",payload:{loadingMapping:i}}),setShowFigmaQuality:i=>n({type:"SET_STATE",payload:{showFigmaQuality:i}}),setFramesCache:i=>n({type:"SET_STATE",payload:{framesCache:i}}),setIsLoadingFrames:i=>n({type:"SET_STATE",payload:{isLoadingFrames:i}}),updateFramesThumbnails:i=>n({type:"UPDATE_FRAMES_THUMBNAILS",payload:i}),setVariantThumbnails:(i,s)=>n({type:"SET_VARIANT_THUMBNAILS",payload:{componentSetId:i,thumbnails:s}}),clearVariantThumbnailsForSet:i=>n({type:"CLEAR_VARIANT_THUMBNAILS_FOR_SET",payload:i}),clearAllVariantThumbnails:()=>n({type:"CLEAR_ALL_VARIANT_THUMBNAILS"})}),[]),o=Sy(()=>({...t,...r}),[t,r]);return kE.createElement(vy.Provider,{value:o},e)}function nt(){let e=TE(vy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var wy,EE,vy,ku=$(()=>{"use strict";wy=200;EE={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,mappingsByStoryId:{},reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},vy=CE(null)});var Pt,Cu=$(()=>{"use strict";Pt={NAME:"UI Parity",SHORT:"Parity",DOMAIN:"uiparity.com",MARKETING_URL:"https://uiparity.com",APP_URL:"https://app.uiparity.com",API_URL:"https://api.uiparity.com",SUPPORT_EMAIL:"feedback@uiparity.com",TAGLINE:"Pixel-perfect isn't a feeling. It's a score."}});function AE(){if(typeof process<"u"&&process.env)return process.env.UICOPILOT_DEBUG==="1";if(typeof globalThis<"u"&&"localStorage"in globalThis)try{return globalThis.localStorage.getItem("uicopilot_debug")==="1"}catch{return!1}return!1}var Ka,Tu,ky=$(()=>{"use strict";Cu();Ka=`[${Pt.NAME}]`,Tu={debug:(...e)=>{AE()&&console.log(Ka,...e)},info:(...e)=>{console.log(Ka,...e)},warn:(...e)=>{console.warn(Ka,...e)},error:(...e)=>{console.error(Ka,...e)}}});var Cy=$(()=>{"use strict"});var Iu=$(()=>{"use strict"});function Ht(e){return e>=48&&e<=57}function Rn(e){return Ht(e)||e>=65&&e<=70||e>=97&&e<=102}function Qa(e){return e>=65&&e<=90}function LE(e){return e>=97&&e<=122}function ME(e){return Qa(e)||LE(e)}function BE(e){return e>=128}function Xa(e){return ME(e)||BE(e)||e===95}function Ja(e){return Xa(e)||Ht(e)||e===45}function DE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function ms(e){return e===10||e===13||e===12}function Or(e){return ms(e)||e===32||e===9}function Dn(e,t){return!(e!==92||ms(t)||t===0)}function yi(e,t,n){return e===45?Xa(t)||t===45||Dn(t,n):Xa(e)?!0:e===92?Dn(e,t):!1}function Za(e,t,n){return e===43||e===45?Ht(t)?2:t===46&&Ht(n)?3:0:e===46?Ht(t)?2:0:Ht(e)?1:0}function el(e){return e===65279||e===65534?1:0}function nl(e){return e<128?Fu[e]:tl}var Fu,RE,hs,Eu,tl,Au,xs=$(()=>{"use strict";Fu=new Array(128),RE=128,hs=130,Eu=131,tl=132,Au=133;for(let e=0;e<Fu.length;e++)Fu[e]=Or(e)&&hs||Ht(e)&&Eu||Xa(e)&&tl||DE(e)&&Au||e||RE});function bi(e,t){return t<e.length?e.charCodeAt(t):0}function rl(e,t,n){return n===13&&bi(e,t+1)===10?2:1}function Kr(e,t,n){let r=e.charCodeAt(t);return Qa(r)&&(r=r|32),r===n}function Xr(e,t,n,r){if(n-t!==r.length||t<0||n>e.length)return!1;for(let o=t;o<n;o++){let i=r.charCodeAt(o-t),s=e.charCodeAt(o);if(Qa(s)&&(s=s|32),s!==i)return!1}return!0}function Ty(e,t){for(;t>=0&&Or(e.charCodeAt(t));t--);return t+1}function ys(e,t){for(;t<e.length&&Or(e.charCodeAt(t));t++);return t}function Pu(e,t){for(;t<e.length&&Ht(e.charCodeAt(t));t++);return t}function Qr(e,t){if(t+=2,Rn(bi(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Rn(bi(e,t));t++);let n=bi(e,t);Or(n)&&(t+=rl(e,t,n))}return t}function bs(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Ja(n)){if(Dn(n,bi(e,t+1))){t=Qr(e,t)-1;continue}break}}return t}function qo(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),Ht(n)&&(t=Pu(e,t+1),n=e.charCodeAt(t)),n===46&&Ht(e.charCodeAt(t+1))&&(t+=2,t=Pu(e,t)),Kr(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),Ht(n)&&(t=Pu(e,t+1+r+1))}return t}function ol(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}Dn(n,bi(e,t+1))&&(t=Qr(e,t))}return t}function il(e){if(e.length===1&&!Rn(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var sl=$(()=>{"use strict";xs()});var Si,Lu=$(()=>{"use strict";Si=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"]});function wi(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Mu=$(()=>{"use strict"});function Ey(e){let t=e.source,n=t.length,r=t.length>0?el(t.charCodeAt(0)):0,o=wi(e.lines,n),i=wi(e.columns,n),s=e.startLine,a=e.startColumn;for(let u=r;u<n;u++){let c=t.charCodeAt(u);o[u]=s,i[u]=a++,(c===Iy||c===Fy||c===zE)&&(c===Fy&&u+1<n&&t.charCodeAt(u+1)===Iy&&(u++,o[u]=s,i[u]=a),s++,a=1)}o[n]=s,i[n]=a,e.lines=o,e.columns=i,e.computed=!0}var Iy,zE,Fy,al,Ay=$(()=>{"use strict";Mu();xs();Iy=10,zE=12,Fy=13;al=class{constructor(t,n,r,o){this.setSource(t,n,r,o),this.lines=null,this.columns=null}setSource(t="",n=0,r=1,o=1){this.source=t,this.startOffset=n,this.startLine=r,this.startColumn=o,this.computed=!1}getLocation(t,n){return this.computed||Ey(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||Ey(this),{source:r,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}});function Py(e,t,n){return e<t?t:e>n?n:e}var wr,vr,Ss,cl,wo,kr,ll,Ly=$(()=>{"use strict";Mu();sl();Lu();wr=16777215,vr=24,Ss=1,cl=2,wo=new Uint8Array(32);wo[2]=22;wo[21]=22;wo[19]=20;wo[23]=24;kr=new Uint8Array(32);kr[2]=Ss;kr[21]=Ss;kr[19]=Ss;kr[23]=Ss;kr[22]=cl;kr[20]=cl;kr[24]=cl;ll=class{constructor(t,n){this.setSource(t,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",n=()=>{}){t=String(t||"");let r=t.length,o=wi(this.offsetAndType,t.length+1),i=wi(this.balance,t.length+1),s=0,a=-1,u=0,c=t.length;this.offsetAndType=null,this.balance=null,i.fill(0),n(t,(l,d,g)=>{let p=s++;if(o[p]=l<<vr|g,a===-1&&(a=d),i[p]=c,l===u){let m=i[c];i[c]=p,c=m,u=wo[o[m]>>vr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=wo[l])}),o[s]=0<<vr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let g=i[d];g!==l&&(i[l]=g)}else d>s&&(i[l]=s)}this.source=t,this.firstCharOffset=a===-1?0:a,this.tokenCount=s,this.offsetAndType=o,this.balance=i,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>vr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>vr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&wr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>vr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Xr(this.source,this.offsetAndType[t-1]&wr,this.offsetAndType[t]&wr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&wr:this.offsetAndType[this.tokenCount]&wr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[Py(t,0,this.tokenCount)]&wr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[Py(t,0,this.tokenCount)]>>vr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return kr[t]===Ss}isBlockCloserTokenType(t){return kr[t]===cl}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(kr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return wo[n]===o?r:-1}else if(kr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return wo[o]===n?r:-1}return-1}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,n){return n?this.lookupType(n)===9&&this.source.charCodeAt(this.lookupOffset(n))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let n=this.tokenIndex+t;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&wr,n=this.offsetAndType[n],this.tokenType=n>>vr,this.tokenEnd=n&wr):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>vr,this.tokenEnd=t&wr):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,n){let r=t,o=0,i=0;e:for(;r<this.tokenCount;r++){if(o=this.balance[r],o<t)break e;switch(i=r>0?this.offsetAndType[r-1]&wr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>vr)&&(r=o)}}this.skip(r-this.tokenIndex)}forEachToken(t){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){let o=r,i=this.offsetAndType[n],s=i&wr,a=i>>vr;r=s,t(a,o,s,n)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((n,r,o,i)=>{t[i]={idx:i,type:Si[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function vo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=qo(e,c),yi(n(c),n(c+1),n(c+2))){l=12,c=bs(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=bs(e,c),Xr(e,d,c,"url")&&n(c)===40){if(c=ys(e,c+1),n(c)===34||n(c)===39){l=2,c=d+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(d){for(d||(d=n(c++)),l=5;c<e.length;c++){let g=e.charCodeAt(c);switch(nl(g)){case d:c++;return;case hs:if(ms(g)){c+=rl(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);ms(p)?c+=rl(e,c+1,p):Dn(g,p)&&(c=Qr(e,c)-1);break}}}function s(){for(l=7,c=ys(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch(nl(d)){case 41:c++;return;case hs:if(c=ys(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=ol(e,c),l=8;return;case 34:case 39:case 40:case Au:c=ol(e,c),l=8;return;case 92:if(Dn(d,n(c+1))){c=Qr(e,c)-1;break}c=ol(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=el(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch(nl(d)){case hs:l=13,c=ys(e,c+1);break;case 34:i();break;case 35:Ja(n(c+1))||Dn(n(c+1),n(c+2))?(l=4,c=bs(e,c+1)):(l=9,c++);break;case 39:i();break;case 40:l=21,c++;break;case 41:l=22,c++;break;case 43:Za(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Za(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):yi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Za(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 47:n(c+1)===42?(l=25,c=e.indexOf("*/",c+2),c=c===-1?e.length:c+2):(l=9,c++);break;case 58:l=16,c++;break;case 59:l=17,c++;break;case 60:n(c+1)===33&&n(c+2)===45&&n(c+3)===45?(l=14,c=c+4):(l=9,c++);break;case 64:yi(n(c+1),n(c+2),n(c+3))?(l=3,c=bs(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:Dn(d,n(c+1))?o():(l=9,c++);break;case 93:l=20,c++;break;case 123:l=23,c++;break;case 125:l=24,c++;break;case Eu:r();break;case tl:o();break;default:l=9,c++}t(l,u,u=c)}}var ur=$(()=>{"use strict";xs();sl();Iu();Iu();Lu();xs();sl();Ay();Ly()});var vi,er,vs=$(()=>{"use strict";vi=null,er=class e{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return e.createItem(t)}allocateCursor(t,n){let r;return vi!==null?(r=vi,vi=vi.cursor,r.prev=t,r.next=n,r.cursor=this.cursor):r={prev:t,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=vi,vi=t}updateCursors(t,n,r,o){let{cursor:i}=this;for(;i!==null;)i.prev===t&&(i.prev=n),i.next===r&&(i.next=o),i=i.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let n=this.head;n!==null;n=n.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let n=null;this.head=null;for(let r of t){let o=e.createItem(r);n!==null?n.next=o:this.head=o,o.prev=n,n=o}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,n=this){let r=this.allocateCursor(null,this.head);for(;r.next!==null;){let o=r.next;r.next=o.next,t.call(n,o.data,o,this)}this.releaseCursor()}forEachRight(t,n=this){let r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){let o=r.prev;r.prev=o.prev,t.call(n,o.data,o,this)}this.releaseCursor()}reduce(t,n,r=this){let o=this.allocateCursor(null,this.head),i=n,s;for(;o.next!==null;)s=o.next,o.next=s.next,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}reduceRight(t,n,r=this){let o=this.allocateCursor(this.tail,null),i=n,s;for(;o.prev!==null;)s=o.prev,o.prev=s.prev,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}some(t,n=this){for(let r=this.head;r!==null;r=r.next)if(t.call(n,r.data,r,this))return!0;return!1}map(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)r.appendData(t.call(n,o.data,o,this));return r}filter(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)t.call(n,o.data,o,this)&&r.appendData(o.data);return r}nextUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(null,t);for(;o.next!==null;){let i=o.next;if(o.next=i.next,n.call(r,i.data,i,this))break}this.releaseCursor()}prevUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(t,null);for(;o.prev!==null;){let i=o.prev;if(o.prev=i.prev,n.call(r,i.data,i,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new e;for(let n of this)t.appendData(n);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(e.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(e.createItem(t))}insert(t,n=null){if(n!==null)if(this.updateCursors(n.prev,t,n,t),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=t,n.prev=t,t.next=n,this.updateCursors(null,t)}else n.prev.next=t,t.prev=n.prev,n.prev=t,t.next=n;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,n){return this.insert(e.createItem(t),n)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(e.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(e.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,n){return t.head===null?this:(n!=null?(this.updateCursors(n.prev,t.tail,n,t.head),n.prev!==null?(n.prev.next=t.head,t.head.prev=n.prev):this.head=t.head,n.prev=t.tail,t.tail.next=n):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,n){"head"in n?this.insertList(n,t):this.insert(n,t),this.remove(t)}}});function Ko(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
2
+ `)}})}var pl=$(()=>{"use strict"});function Dy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(m,v){return c.slice(m,v).map((I,A)=>String(m+A+1).padStart(g)+" |"+I).join(`
3
3
  `)}let a=`
4
4
  `.repeat(Math.max(r-1,0)),u=" ".repeat(Math.max(o-1,0)),c=(a+u+e).split(/\r\n?|\n|\f/),l=Math.max(1,t-i)-1,d=Math.min(t+i,c.length+1),g=Math.max(4,String(d).length)+1,p=0;n+=(By.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>Bu&&(p=n-My+3,n=My-2);for(let m=l;m<=d;m++)m>=0&&m<c.length&&(c[m]=c[m].replace(/\t/g,By),c[m]=(p>0&&c[m].length>p?"\u2026":"")+c[m].substr(p,Bu-2)+(c[m].length>p+Bu-1?"\u2026":""));return[s(l,t),new Array(n+g+2).join("-")+"^",s(t,d)].filter(Boolean).join(`
5
5
  `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Du(e,t,n,r,o,i=1,s=1){return Object.assign(Ko("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return Dy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
- `+Dy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Bu,My,By,Ry=$(()=>{"use strict";pl();Bu=100,My=60,By=" "});function zy(e){let t=this.createList(),n=!1,r={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let o=e.getNode.call(this,r);if(o===void 0)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,r),n=!1),t.push(o)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,r),t}var Ny=$(()=>{"use strict"});function $E(e){return function(){return this[e]()}}function zu(e){let t=Object.create(null);for(let n of Object.keys(e)){let r=e[n],o=r.parse||r;o&&(t[n]=o)}return t}function UE(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:zu(e.atrule),pseudo:zu(e.pseudo),node:zu(e.node)};for(let[n,r]of Object.entries(e.parseContext))switch(typeof r){case"function":t.context[n]=r;break;case"string":t.context[n]=$E(r);break}return{config:t,...t,...t.node}}function $y(e){let t="",n="<unknown>",r=!1,o=ki,i=!1,s=new al,a=Object.assign(new ll,UE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:zy,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Oy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Oy||l===Ru?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===zE||l===Ru?1:0},consumeUntilSemicolonIncluded(l){return l===Ru?2:0},createList:ki,createSingleNodeList:ki,getFirstListNode:ki,getLastListNode:ki,parseWithFallback(l,d){let g=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(g-this.tokenIndex);let m=d.call(this);return i=!0,o(p,m),i=!1,m}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==_y);return _y},charCodeAt(l){return l>=0&&l<t.length?t.charCodeAt(l):0},substring(l,d){return t.substring(l,d)},substrToCursor(l){return this.source.substring(l,this.tokenStart)},cmpChar(l,d){return Kr(t,l,d)},cmpStr(l,d,g){return Xr(t,l,d,g)},consume(l){let d=this.tokenStart;return this.eat(l),this.substrToCursor(d)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let d=t.substring(this.tokenStart,qo(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=Si[l].slice(0,-6).replace(/-/g," ").replace(/^./,m=>m.toUpperCase()),g=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,g="Identifier is expected but function found"):g="Identifier is expected";break;case 4:this.isDelim(NE)&&(this.next(),p++,g="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,g="Percent sign is expected");break}this.error(g,p)}this.next()},eatIdent(l){(this.tokenType!==1||this.lookupValue(0,l)===!1)&&this.error(`Identifier "${l}" is expected`),this.next()},eatDelim(l){this.isDelim(l)||this.error(`Delim "${String.fromCharCode(l)}" is expected`),this.next()},getLocation(l,d){return r?s.getLocationRange(l,d,n):null},getLocationFromList(l){if(r){let d=this.getFirstListNode(l),g=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,g!==null?g.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let g=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(Ty(t,t.length-1)):s.getLocation(this.tokenStart);throw new Du(l||"Unexpected input",t,g.offset,g.line,g.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>Si[a.getTokenType(l)],getTokenStart:l=>a.getTokenStart(l),getTokenEnd:l=>a.getTokenEnd(l),getTokenValue:l=>a.source.substring(a.getTokenStart(l),a.getTokenEnd(l)),substring:(l,d)=>a.source.substring(l,d),balance:a.balance.subarray(0,a.tokenCount+1),isBlockOpenerTokenType:a.isBlockOpenerTokenType,isBlockCloserTokenType:a.isBlockCloserTokenType,getBlockTokenPairIndex:l=>a.getBlockTokenPairIndex(l),getLocation:l=>s.getLocation(l,n),getRangeLocation:(l,d)=>s.getLocationRange(l,d,n)});return Object.assign(function(l,d){t=l,d=d||{},a.setSource(t,vo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:ki,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in d?!!d.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in d?!!d.parseRulePrelude:!0,a.parseValue="parseValue"in d?!!d.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in d?!!d.parseCustomProperty:!1;let{context:g="default",list:p=!0,onComment:m,onToken:k}=d;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,p?_E:OE),Array.isArray(k)?a.forEachToken((A,C,D)=>{k.push({type:A,start:C,end:D})}):typeof k=="function"&&a.forEachToken(k.bind(u())),typeof m=="function"&&a.forEachToken((A,C,D)=>{if(A===25){let R=a.getLocation(C,D),_=Xr(t,D-2,D,"*/")?t.slice(C+2,D-2):t.slice(C+2,D);m(_,R)}});let I=a.context[g].call(a,d);return a.eof||a.error(),I},{SyntaxError:Du,config:a.config})}var ki,zE,NE,Ru,Oy,_y,OE,_E,Uy=$(()=>{"use strict";vs();Ry();ur();Ny();ki=()=>{},zE=33,NE=35,Ru=59,Oy=123,_y=0,OE={createList(){return[]},createSingleNodeList(e){return[e]},getFirstListNode(e){return e&&e[0]||null},getLastListNode(e){return e&&e.length>0?e[e.length-1]:null}},_E={createList(){return new er},createSingleNodeList(e){return new er().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Hy=ar(Nu=>{"use strict";var jy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Nu.encode=function(e){if(0<=e&&e<jy.length)return jy[e];throw new TypeError("Must be between 0 and 63: "+e)};Nu.decode=function(e){var t=65,n=90,r=97,o=122,i=48,s=57,a=43,u=47,c=26,l=52;return t<=e&&e<=n?e-t:r<=e&&e<=o?e-r+c:i<=e&&e<=s?e-i+l:e==a?62:e==u?63:-1}});var Yy=ar(_u=>{"use strict";var Wy=Hy(),Ou=5,Vy=1<<Ou,Gy=Vy-1,qy=Vy;function jE(e){return e<0?(-e<<1)+1:(e<<1)+0}function HE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}_u.encode=function(t){var n="",r,o=jE(t);do r=o&Gy,o>>>=Ou,o>0&&(r|=qy),n+=Wy.encode(r);while(o>0);return n};_u.decode=function(t,n,r){var o=t.length,i=0,s=0,a,u;do{if(n>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(u=Wy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&qy),u&=Gy,i=i+(u<<s),s+=Ou}while(a);r.value=HE(i),r.rest=n}});var dl=ar(an=>{"use strict";function WE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}an.getArg=WE;var Ky=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,VE=/^data:.+\,.+$/;function ks(e){var t=e.match(Ky);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}an.urlParse=ks;function Ci(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}an.urlGenerate=Ci;var GE=32;function qE(e){var t=[];return function(n){for(var r=0;r<t.length;r++)if(t[r].input===n){var o=t[0];return t[0]=t[r],t[r]=o,t[0].result}var i=e(n);return t.unshift({input:n,result:i}),t.length>GE&&t.pop(),i}}var $u=qE(function(t){var n=t,r=ks(t);if(r){if(!r.path)return t;n=r.path}for(var o=an.isAbsolute(n),i=[],s=0,a=0;;)if(s=a,a=n.indexOf("/",s),a===-1){i.push(n.slice(s));break}else for(i.push(n.slice(s,a));a<n.length&&n[a]==="/";)a++;for(var u,c=0,a=i.length-1;a>=0;a--)u=i[a],u==="."?i.splice(a,1):u===".."?c++:c>0&&(u===""?(i.splice(a+1,c),c=0):(i.splice(a,2),c--));return n=i.join("/"),n===""&&(n=o?"/":"."),r?(r.path=n,Ci(r)):n});an.normalize=$u;function Xy(e,t){e===""&&(e="."),t===""&&(t=".");var n=ks(t),r=ks(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),Ci(n);if(n||t.match(VE))return t;if(r&&!r.host&&!r.path)return r.host=t,Ci(r);var o=t.charAt(0)==="/"?t:$u(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,Ci(r)):o}an.join=Xy;an.isAbsolute=function(e){return e.charAt(0)==="/"||Ky.test(e)};function YE(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var n=0;t.indexOf(e+"/")!==0;){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r),e.match(/^([^\/]+:\/)?\/*$/)))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)}an.relative=YE;var Qy=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Jy(e){return e}function KE(e){return Zy(e)?"$"+e:e}an.toSetString=Qy?Jy:KE;function XE(e){return Zy(e)?e.slice(1):e}an.fromSetString=Qy?Jy:XE;function Zy(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var n=t-10;n>=0;n--)if(e.charCodeAt(n)!==36)return!1;return!0}function QE(e,t,n){var r=Jr(e.source,t.source);return r!==0||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:Jr(e.name,t.name)}an.compareByOriginalPositions=QE;function JE(e,t,n){var r;return r=e.originalLine-t.originalLine,r!==0||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:Jr(e.name,t.name)}an.compareByOriginalPositionsNoSource=JE;function ZE(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=Jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Jr(e.name,t.name)}an.compareByGeneratedPositionsDeflated=ZE;function eA(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=Jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Jr(e.name,t.name)}an.compareByGeneratedPositionsDeflatedNoLine=eA;function Jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function tA(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=Jr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:Jr(e.name,t.name)}an.compareByGeneratedPositionsInflated=tA;function nA(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}an.parseSourceMapInput=nA;function rA(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ks(n);if(!r)throw new Error("sourceMapURL could not be parsed");if(r.path){var o=r.path.lastIndexOf("/");o>=0&&(r.path=r.path.substring(0,o+1))}t=Xy(Ci(r),t)}return $u(t)}an.computeSourceURL=rA});var tb=ar(eb=>{"use strict";var Uu=dl(),ju=Object.prototype.hasOwnProperty,Xo=typeof Map<"u";function Zr(){this._array=[],this._set=Xo?new Map:Object.create(null)}Zr.fromArray=function(t,n){for(var r=new Zr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Zr.prototype.size=function(){return Xo?this._set.size:Object.getOwnPropertyNames(this._set).length};Zr.prototype.add=function(t,n){var r=Xo?t:Uu.toSetString(t),o=Xo?this.has(t):ju.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Xo?this._set.set(t,i):this._set[r]=i)};Zr.prototype.has=function(t){if(Xo)return this._set.has(t);var n=Uu.toSetString(t);return ju.call(this._set,n)};Zr.prototype.indexOf=function(t){if(Xo){var n=this._set.get(t);if(n>=0)return n}else{var r=Uu.toSetString(t);if(ju.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Zr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Zr.prototype.toArray=function(){return this._array.slice()};eb.ArraySet=Zr});var ob=ar(rb=>{"use strict";var nb=dl();function oA(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||nb.compareByGeneratedPositionsInflated(e,t)<=0}function gl(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}gl.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};gl.prototype.add=function(t){oA(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};gl.prototype.toArray=function(){return this._sorted||(this._array.sort(nb.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};rb.MappingList=gl});var sb=ar(ib=>{"use strict";var Cs=Yy(),Wt=dl(),fl=tb().ArraySet,iA=ob().MappingList;function pr(e){e||(e={}),this._file=Wt.getArg(e,"file",null),this._sourceRoot=Wt.getArg(e,"sourceRoot",null),this._skipValidation=Wt.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Wt.getArg(e,"ignoreInvalidMapping",!1),this._sources=new fl,this._names=new fl,this._mappings=new iA,this._sourcesContents=null}pr.prototype._version=3;pr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new pr(Object.assign(n||{},{file:t.file,sourceRoot:r}));return t.eachMapping(function(i){var s={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(s.source=i.source,r!=null&&(s.source=Wt.relative(r,s.source)),s.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(s.name=i.name)),o.addMapping(s)}),t.sources.forEach(function(i){var s=i;r!==null&&(s=Wt.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};pr.prototype.addMapping=function(t){var n=Wt.getArg(t,"generated"),r=Wt.getArg(t,"original",null),o=Wt.getArg(t,"source",null),i=Wt.getArg(t,"name",null);!this._skipValidation&&this._validateMapping(n,r,o,i)===!1||(o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:r!=null&&r.line,originalColumn:r!=null&&r.column,source:o,name:i}))};pr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Wt.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Wt.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Wt.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};pr.prototype.applySourceMap=function(t,n,r){var o=n;if(n==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file}var i=this._sourceRoot;i!=null&&(o=Wt.relative(i,o));var s=new fl,a=new fl;this._mappings.unsortedForEach(function(u){if(u.source===o&&u.originalLine!=null){var c=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});c.source!=null&&(u.source=c.source,r!=null&&(u.source=Wt.join(r,u.source)),i!=null&&(u.source=Wt.relative(i,u.source)),u.originalLine=c.line,u.originalColumn=c.column,c.name!=null&&(u.name=c.name))}var l=u.source;l!=null&&!s.has(l)&&s.add(l);var d=u.name;d!=null&&!a.has(d)&&a.add(d)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){var c=t.sourceContentFor(u);c!=null&&(r!=null&&(u=Wt.join(r,u)),i!=null&&(u=Wt.relative(i,u)),this.setSourceContent(u,c))},this)};pr.prototype._validateMapping=function(t,n,r,o){if(n&&typeof n.line!="number"&&typeof n.column!="number"){var i="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!n&&!r&&!o)){if(t&&"line"in t&&"column"in t&&n&&"line"in n&&"column"in n&&t.line>0&&t.column>=0&&n.line>0&&n.column>=0&&r)return;var i="Invalid mapping: "+JSON.stringify({generated:t,source:r,original:n,name:o});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}};pr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,g=this._mappings.toArray(),p=0,m=g.length;p<m;p++){if(c=g[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!Wt.compareByGeneratedPositionsInflated(c,g[p-1]))continue;u+=","}u+=Cs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=Cs.encode(d-s),s=d,u+=Cs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=Cs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=Cs.encode(l-i),i=l)),a+=u}return a};pr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Wt.relative(n,r));var o=Wt.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};pr.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};pr.prototype.toString=function(){return JSON.stringify(this.toJSON())};ib.SourceMapGenerator=pr});function cb(e){let t=new lb.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,a=0,u=!1,c=e.node;e.node=function(g){if(g.loc&&g.loc.start&&ab.has(g.type)){let p=g.loc.start.line,m=g.loc.start.column-1;(r.line!==p||r.column!==m)&&(r.line=p,r.column=m,n.line=s,n.column=a,u&&(u=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(i)),u=!0,t.addMapping({source:g.loc.source,original:r,generated:n}))}c.call(this,g),u&&ab.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,p,m){for(let k=0;k<g.length;k++)g.charCodeAt(k)===10?(s++,a=0):a++;l(g,p,m)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var lb,ab,ub=$(()=>{"use strict";lb=Va(sb(),1),ab=new Set(["Atrule","Selector","Declaration"])});var ml={};Se(ml,{safe:()=>Wu,spec:()=>cA});function db(e){let t=new Set(e.map(([n,r])=>Hu(n)<<16|Hu(r)));return function(n,r,o){let i=Hu(r,o),s=o.charCodeAt(0),a=s===aA&&r!==1&&r!==2&&r!==15||s===sA?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var sA,aA,Hu,pb,lA,cA,Wu,gb=$(()=>{"use strict";sA=43,aA=45,Hu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),pb=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],lA=pb.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);cA=db(pb),Wu=db(lA)});function pA(e,t){if(typeof t=="function"){let n=null;e.children.forEach(r=>{n!==null&&t.call(this,n),this.node(r),n=r});return}e.children.forEach(this.node,this)}function fb(e){let t=new Map;for(let[n,r]of Object.entries(e.node))typeof(r.generate||r)=="function"&&t.set(n,r.generate||r);return function(n,r){let o="",i=0,s={node(u){if(t.has(u.type))t.get(u.type).call(a,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:Wu,token(u,c,l){i=this.tokenBefore(i,u,c),!l&&i&1&&this.emit(" ",13,!0),this.emit(c,u,!1),u===9&&c.charCodeAt(0)===uA&&this.emit(`
7
- `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=cb(s)),r.mode in ml&&(s.tokenBefore=ml[r.mode]));let a={node:u=>s.node(u),children:pA,token:(u,c)=>s.token(u,c),tokenize:u=>vo(u,(c,l,d)=>{s.token(c,u.slice(l,d),l!==0)})};return s.node(n),s.result()}}var uA,mb=$(()=>{"use strict";ur();ub();gb();uA=92});function hb(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof er)&&(n.children=new er().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof er&&(n.children=n.children.toArray())}}),t}}}var xb=$(()=>{"use strict";vs()});function yb(e){return typeof e=="function"?e:Ts}function bb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function dA(e,t){let n=t.structure,r=[];for(let o in n){if(Vu.call(n,o)===!1)continue;let i=n[o],s={name:o,type:!1,nullable:!1};Array.isArray(i)||(i=[i]);for(let a of i)a===null?s.nullable=!0:typeof a=="string"?s.type="node":Array.isArray(a)&&(s.type="list");s.type&&r.push(s)}return r.length?{context:t.walkContext,fields:r}:null}function gA(e){let t={};for(let n in e.node)if(Vu.call(e.node,n)){let r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=dA(n,r)}return t}function Sb(e,t){let n=e.fields.slice(),r=e.context,o=typeof r=="string";return t&&n.reverse(),function(i,s,a,u){let c;o&&(c=s[r],s[r]=i);for(let l of n){let d=i[l.name];if(!l.nullable||d){if(l.type==="list"){if(t?d.reduceRight(u,!1):d.reduce(u,!1))return!0}else if(a(d))return!0}}o&&(s[r]=c)}}function wb({StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Rule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Declaration:{StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}}}function vb(e){let t=gA(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Vu.call(t,c)&&t[c]!==null&&(n[c]=Sb(t[c],!1),r[c]=Sb(t[c],!0));let s=wb(n),a=wb(r),u=function(c,l){function d(A,C,D){let R=g.call(I,A,C,D);return R===o?!0:R===i?!1:!!(m.hasOwnProperty(A.type)&&m[A.type](A,I,d,k)||p.call(I,A,C,D)===o)}let g=Ts,p=Ts,m=n,k=(A,C,D,R)=>A||d(C,D,R),I={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")g=l;else if(l&&(g=yb(l.enter),p=yb(l.leave),l.reverse&&(m=r),l.visit)){if(s.hasOwnProperty(l.visit))m=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");g=bb(g,l.visit),p=bb(p,l.visit)}if(g===Ts&&p===Ts)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");d(c)};return u.break=o,u.skip=i,u.find=function(c,l){let d=null;return u(c,function(g,p,m){if(l.call(this,g,p,m))return d=g,o}),d},u.findLast=function(c,l){let d=null;return u(c,{reverse:!0,enter(g,p,m){if(l.call(this,g,p,m))return d=g,o}}),d},u.findAll=function(c,l){let d=[];return u(c,function(g,p,m){l.call(this,g,p,m)&&d.push(g)}),d},u}var Vu,Ts,kb=$(()=>{"use strict";({hasOwnProperty:Vu}=Object.prototype),Ts=function(){}});function fA(e){return e}function mA(e){let{min:t,max:n,comma:r}=e;return t===0&&n===0?r?"#?":"*":t===0&&n===1?"?":t===1&&n===0?r?"#":"+":t===1&&n===1?"":(r?"#":"")+(t===n?"{"+t+"}":"{"+t+","+(n!==0?n:"")+"}")}function hA(e){if(e.type==="Range")return" ["+(e.min===null?"-\u221E":e.min)+","+(e.max===null?"\u221E":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}function xA(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>hl(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function hl(e,t,n,r){let o;switch(e.type){case"Group":o=xA(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return hl(e.term,t,n,r)+t(mA(e),e);case"Boolean":o="<boolean-expr["+hl(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(hA(e.opts),e.opts):"")+">";break;case"Property":o="<'"+e.name+"'>";break;case"Keyword":o=e.name;break;case"AtKeyword":o="@"+e.name;break;case"Function":o=e.name+"(";break;case"String":case"Token":o=e.value;break;case"Comma":o=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(o,e)}function Ti(e,t){let n=fA,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),hl(e,n,r,o)}var Gu=$(()=>{"use strict"});function yA(e,t){let n=e.tokens,r=e.longestMatch,o=r<n.length&&n[r].node||null,i=o!==t?o:null,s=0,a=0,u=0,c="",l,d;for(let g=0;g<n.length;g++){let p=n[g].value;g===r&&(a=p.length,s=c.length),i!==null&&n[g].node===i&&(g<=r?u++:u=0),c+=p}return r===n.length||u>1?(l=xl(i||t,"end")||Is(Cb,c),d=Is(l)):(l=xl(i,"start")||Is(xl(t,"start")||Cb,c.slice(0,s)),d=xl(i,"end")||Is(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:d}}function xl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?Is(n):n:null}function Is({offset:e,line:t,column:n},r){let o={offset:e,line:t,column:n};if(r){let i=r.split(/\n|\r\n?|\f/);o.offset+=r.length,o.line+=i.length-1,o.column=i.length===1?o.column+r.length:i.pop().length+1}return o}var Cb,Ii,Tb,Ib=$(()=>{"use strict";pl();Gu();Cb={offset:0,line:1,column:1};Ii=function(e,t){let n=Ko("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Tb=function(e,t,n,r){let o=Ko("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=yA(r,n);return o.rawMessage=e,o.syntax=t?Ti(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
6
+ `+Dy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Bu,My,By,Ry=$(()=>{"use strict";pl();Bu=100,My=60,By=" "});function zy(e){let t=this.createList(),n=!1,r={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let o=e.getNode.call(this,r);if(o===void 0)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,r),n=!1),t.push(o)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,r),t}var Ny=$(()=>{"use strict"});function UE(e){return function(){return this[e]()}}function zu(e){let t=Object.create(null);for(let n of Object.keys(e)){let r=e[n],o=r.parse||r;o&&(t[n]=o)}return t}function jE(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:zu(e.atrule),pseudo:zu(e.pseudo),node:zu(e.node)};for(let[n,r]of Object.entries(e.parseContext))switch(typeof r){case"function":t.context[n]=r;break;case"string":t.context[n]=UE(r);break}return{config:t,...t,...t.node}}function $y(e){let t="",n="<unknown>",r=!1,o=ki,i=!1,s=new al,a=Object.assign(new ll,jE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:zy,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Oy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Oy||l===Ru?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===NE||l===Ru?1:0},consumeUntilSemicolonIncluded(l){return l===Ru?2:0},createList:ki,createSingleNodeList:ki,getFirstListNode:ki,getLastListNode:ki,parseWithFallback(l,d){let g=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(g-this.tokenIndex);let m=d.call(this);return i=!0,o(p,m),i=!1,m}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==_y);return _y},charCodeAt(l){return l>=0&&l<t.length?t.charCodeAt(l):0},substring(l,d){return t.substring(l,d)},substrToCursor(l){return this.source.substring(l,this.tokenStart)},cmpChar(l,d){return Kr(t,l,d)},cmpStr(l,d,g){return Xr(t,l,d,g)},consume(l){let d=this.tokenStart;return this.eat(l),this.substrToCursor(d)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let d=t.substring(this.tokenStart,qo(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=Si[l].slice(0,-6).replace(/-/g," ").replace(/^./,m=>m.toUpperCase()),g=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,g="Identifier is expected but function found"):g="Identifier is expected";break;case 4:this.isDelim(OE)&&(this.next(),p++,g="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,g="Percent sign is expected");break}this.error(g,p)}this.next()},eatIdent(l){(this.tokenType!==1||this.lookupValue(0,l)===!1)&&this.error(`Identifier "${l}" is expected`),this.next()},eatDelim(l){this.isDelim(l)||this.error(`Delim "${String.fromCharCode(l)}" is expected`),this.next()},getLocation(l,d){return r?s.getLocationRange(l,d,n):null},getLocationFromList(l){if(r){let d=this.getFirstListNode(l),g=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,g!==null?g.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let g=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(Ty(t,t.length-1)):s.getLocation(this.tokenStart);throw new Du(l||"Unexpected input",t,g.offset,g.line,g.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>Si[a.getTokenType(l)],getTokenStart:l=>a.getTokenStart(l),getTokenEnd:l=>a.getTokenEnd(l),getTokenValue:l=>a.source.substring(a.getTokenStart(l),a.getTokenEnd(l)),substring:(l,d)=>a.source.substring(l,d),balance:a.balance.subarray(0,a.tokenCount+1),isBlockOpenerTokenType:a.isBlockOpenerTokenType,isBlockCloserTokenType:a.isBlockCloserTokenType,getBlockTokenPairIndex:l=>a.getBlockTokenPairIndex(l),getLocation:l=>s.getLocation(l,n),getRangeLocation:(l,d)=>s.getLocationRange(l,d,n)});return Object.assign(function(l,d){t=l,d=d||{},a.setSource(t,vo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:ki,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in d?!!d.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in d?!!d.parseRulePrelude:!0,a.parseValue="parseValue"in d?!!d.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in d?!!d.parseCustomProperty:!1;let{context:g="default",list:p=!0,onComment:m,onToken:v}=d;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,p?$E:_E),Array.isArray(v)?a.forEachToken((A,C,D)=>{v.push({type:A,start:C,end:D})}):typeof v=="function"&&a.forEachToken(v.bind(u())),typeof m=="function"&&a.forEachToken((A,C,D)=>{if(A===25){let R=a.getLocation(C,D),_=Xr(t,D-2,D,"*/")?t.slice(C+2,D-2):t.slice(C+2,D);m(_,R)}});let I=a.context[g].call(a,d);return a.eof||a.error(),I},{SyntaxError:Du,config:a.config})}var ki,NE,OE,Ru,Oy,_y,_E,$E,Uy=$(()=>{"use strict";vs();Ry();ur();Ny();ki=()=>{},NE=33,OE=35,Ru=59,Oy=123,_y=0,_E={createList(){return[]},createSingleNodeList(e){return[e]},getFirstListNode(e){return e&&e[0]||null},getLastListNode(e){return e&&e.length>0?e[e.length-1]:null}},$E={createList(){return new er},createSingleNodeList(e){return new er().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Hy=ar(Nu=>{"use strict";var jy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Nu.encode=function(e){if(0<=e&&e<jy.length)return jy[e];throw new TypeError("Must be between 0 and 63: "+e)};Nu.decode=function(e){var t=65,n=90,r=97,o=122,i=48,s=57,a=43,u=47,c=26,l=52;return t<=e&&e<=n?e-t:r<=e&&e<=o?e-r+c:i<=e&&e<=s?e-i+l:e==a?62:e==u?63:-1}});var Yy=ar(_u=>{"use strict";var Wy=Hy(),Ou=5,Vy=1<<Ou,Gy=Vy-1,qy=Vy;function HE(e){return e<0?(-e<<1)+1:(e<<1)+0}function WE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}_u.encode=function(t){var n="",r,o=HE(t);do r=o&Gy,o>>>=Ou,o>0&&(r|=qy),n+=Wy.encode(r);while(o>0);return n};_u.decode=function(t,n,r){var o=t.length,i=0,s=0,a,u;do{if(n>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(u=Wy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&qy),u&=Gy,i=i+(u<<s),s+=Ou}while(a);r.value=WE(i),r.rest=n}});var dl=ar(an=>{"use strict";function VE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}an.getArg=VE;var Ky=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,GE=/^data:.+\,.+$/;function ks(e){var t=e.match(Ky);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}an.urlParse=ks;function Ci(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}an.urlGenerate=Ci;var qE=32;function YE(e){var t=[];return function(n){for(var r=0;r<t.length;r++)if(t[r].input===n){var o=t[0];return t[0]=t[r],t[r]=o,t[0].result}var i=e(n);return t.unshift({input:n,result:i}),t.length>qE&&t.pop(),i}}var $u=YE(function(t){var n=t,r=ks(t);if(r){if(!r.path)return t;n=r.path}for(var o=an.isAbsolute(n),i=[],s=0,a=0;;)if(s=a,a=n.indexOf("/",s),a===-1){i.push(n.slice(s));break}else for(i.push(n.slice(s,a));a<n.length&&n[a]==="/";)a++;for(var u,c=0,a=i.length-1;a>=0;a--)u=i[a],u==="."?i.splice(a,1):u===".."?c++:c>0&&(u===""?(i.splice(a+1,c),c=0):(i.splice(a,2),c--));return n=i.join("/"),n===""&&(n=o?"/":"."),r?(r.path=n,Ci(r)):n});an.normalize=$u;function Xy(e,t){e===""&&(e="."),t===""&&(t=".");var n=ks(t),r=ks(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),Ci(n);if(n||t.match(GE))return t;if(r&&!r.host&&!r.path)return r.host=t,Ci(r);var o=t.charAt(0)==="/"?t:$u(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,Ci(r)):o}an.join=Xy;an.isAbsolute=function(e){return e.charAt(0)==="/"||Ky.test(e)};function KE(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var n=0;t.indexOf(e+"/")!==0;){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r),e.match(/^([^\/]+:\/)?\/*$/)))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)}an.relative=KE;var Qy=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Jy(e){return e}function XE(e){return Zy(e)?"$"+e:e}an.toSetString=Qy?Jy:XE;function QE(e){return Zy(e)?e.slice(1):e}an.fromSetString=Qy?Jy:QE;function Zy(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var n=t-10;n>=0;n--)if(e.charCodeAt(n)!==36)return!1;return!0}function JE(e,t,n){var r=Jr(e.source,t.source);return r!==0||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:Jr(e.name,t.name)}an.compareByOriginalPositions=JE;function ZE(e,t,n){var r;return r=e.originalLine-t.originalLine,r!==0||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:Jr(e.name,t.name)}an.compareByOriginalPositionsNoSource=ZE;function eA(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=Jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Jr(e.name,t.name)}an.compareByGeneratedPositionsDeflated=eA;function tA(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=Jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Jr(e.name,t.name)}an.compareByGeneratedPositionsDeflatedNoLine=tA;function Jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function nA(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=Jr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:Jr(e.name,t.name)}an.compareByGeneratedPositionsInflated=nA;function rA(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}an.parseSourceMapInput=rA;function oA(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ks(n);if(!r)throw new Error("sourceMapURL could not be parsed");if(r.path){var o=r.path.lastIndexOf("/");o>=0&&(r.path=r.path.substring(0,o+1))}t=Xy(Ci(r),t)}return $u(t)}an.computeSourceURL=oA});var tb=ar(eb=>{"use strict";var Uu=dl(),ju=Object.prototype.hasOwnProperty,Xo=typeof Map<"u";function Zr(){this._array=[],this._set=Xo?new Map:Object.create(null)}Zr.fromArray=function(t,n){for(var r=new Zr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Zr.prototype.size=function(){return Xo?this._set.size:Object.getOwnPropertyNames(this._set).length};Zr.prototype.add=function(t,n){var r=Xo?t:Uu.toSetString(t),o=Xo?this.has(t):ju.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Xo?this._set.set(t,i):this._set[r]=i)};Zr.prototype.has=function(t){if(Xo)return this._set.has(t);var n=Uu.toSetString(t);return ju.call(this._set,n)};Zr.prototype.indexOf=function(t){if(Xo){var n=this._set.get(t);if(n>=0)return n}else{var r=Uu.toSetString(t);if(ju.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Zr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Zr.prototype.toArray=function(){return this._array.slice()};eb.ArraySet=Zr});var ob=ar(rb=>{"use strict";var nb=dl();function iA(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||nb.compareByGeneratedPositionsInflated(e,t)<=0}function gl(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}gl.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};gl.prototype.add=function(t){iA(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};gl.prototype.toArray=function(){return this._sorted||(this._array.sort(nb.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};rb.MappingList=gl});var sb=ar(ib=>{"use strict";var Cs=Yy(),Wt=dl(),fl=tb().ArraySet,sA=ob().MappingList;function pr(e){e||(e={}),this._file=Wt.getArg(e,"file",null),this._sourceRoot=Wt.getArg(e,"sourceRoot",null),this._skipValidation=Wt.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Wt.getArg(e,"ignoreInvalidMapping",!1),this._sources=new fl,this._names=new fl,this._mappings=new sA,this._sourcesContents=null}pr.prototype._version=3;pr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new pr(Object.assign(n||{},{file:t.file,sourceRoot:r}));return t.eachMapping(function(i){var s={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(s.source=i.source,r!=null&&(s.source=Wt.relative(r,s.source)),s.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(s.name=i.name)),o.addMapping(s)}),t.sources.forEach(function(i){var s=i;r!==null&&(s=Wt.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};pr.prototype.addMapping=function(t){var n=Wt.getArg(t,"generated"),r=Wt.getArg(t,"original",null),o=Wt.getArg(t,"source",null),i=Wt.getArg(t,"name",null);!this._skipValidation&&this._validateMapping(n,r,o,i)===!1||(o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:r!=null&&r.line,originalColumn:r!=null&&r.column,source:o,name:i}))};pr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Wt.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Wt.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Wt.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};pr.prototype.applySourceMap=function(t,n,r){var o=n;if(n==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file}var i=this._sourceRoot;i!=null&&(o=Wt.relative(i,o));var s=new fl,a=new fl;this._mappings.unsortedForEach(function(u){if(u.source===o&&u.originalLine!=null){var c=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});c.source!=null&&(u.source=c.source,r!=null&&(u.source=Wt.join(r,u.source)),i!=null&&(u.source=Wt.relative(i,u.source)),u.originalLine=c.line,u.originalColumn=c.column,c.name!=null&&(u.name=c.name))}var l=u.source;l!=null&&!s.has(l)&&s.add(l);var d=u.name;d!=null&&!a.has(d)&&a.add(d)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){var c=t.sourceContentFor(u);c!=null&&(r!=null&&(u=Wt.join(r,u)),i!=null&&(u=Wt.relative(i,u)),this.setSourceContent(u,c))},this)};pr.prototype._validateMapping=function(t,n,r,o){if(n&&typeof n.line!="number"&&typeof n.column!="number"){var i="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!n&&!r&&!o)){if(t&&"line"in t&&"column"in t&&n&&"line"in n&&"column"in n&&t.line>0&&t.column>=0&&n.line>0&&n.column>=0&&r)return;var i="Invalid mapping: "+JSON.stringify({generated:t,source:r,original:n,name:o});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}};pr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,g=this._mappings.toArray(),p=0,m=g.length;p<m;p++){if(c=g[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!Wt.compareByGeneratedPositionsInflated(c,g[p-1]))continue;u+=","}u+=Cs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=Cs.encode(d-s),s=d,u+=Cs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=Cs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=Cs.encode(l-i),i=l)),a+=u}return a};pr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Wt.relative(n,r));var o=Wt.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};pr.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};pr.prototype.toString=function(){return JSON.stringify(this.toJSON())};ib.SourceMapGenerator=pr});function cb(e){let t=new lb.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,a=0,u=!1,c=e.node;e.node=function(g){if(g.loc&&g.loc.start&&ab.has(g.type)){let p=g.loc.start.line,m=g.loc.start.column-1;(r.line!==p||r.column!==m)&&(r.line=p,r.column=m,n.line=s,n.column=a,u&&(u=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(i)),u=!0,t.addMapping({source:g.loc.source,original:r,generated:n}))}c.call(this,g),u&&ab.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,p,m){for(let v=0;v<g.length;v++)g.charCodeAt(v)===10?(s++,a=0):a++;l(g,p,m)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var lb,ab,ub=$(()=>{"use strict";lb=Va(sb(),1),ab=new Set(["Atrule","Selector","Declaration"])});var ml={};Se(ml,{safe:()=>Wu,spec:()=>uA});function db(e){let t=new Set(e.map(([n,r])=>Hu(n)<<16|Hu(r)));return function(n,r,o){let i=Hu(r,o),s=o.charCodeAt(0),a=s===lA&&r!==1&&r!==2&&r!==15||s===aA?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var aA,lA,Hu,pb,cA,uA,Wu,gb=$(()=>{"use strict";aA=43,lA=45,Hu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),pb=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],cA=pb.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);uA=db(pb),Wu=db(cA)});function dA(e,t){if(typeof t=="function"){let n=null;e.children.forEach(r=>{n!==null&&t.call(this,n),this.node(r),n=r});return}e.children.forEach(this.node,this)}function fb(e){let t=new Map;for(let[n,r]of Object.entries(e.node))typeof(r.generate||r)=="function"&&t.set(n,r.generate||r);return function(n,r){let o="",i=0,s={node(u){if(t.has(u.type))t.get(u.type).call(a,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:Wu,token(u,c,l){i=this.tokenBefore(i,u,c),!l&&i&1&&this.emit(" ",13,!0),this.emit(c,u,!1),u===9&&c.charCodeAt(0)===pA&&this.emit(`
7
+ `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=cb(s)),r.mode in ml&&(s.tokenBefore=ml[r.mode]));let a={node:u=>s.node(u),children:dA,token:(u,c)=>s.token(u,c),tokenize:u=>vo(u,(c,l,d)=>{s.token(c,u.slice(l,d),l!==0)})};return s.node(n),s.result()}}var pA,mb=$(()=>{"use strict";ur();ub();gb();pA=92});function hb(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof er)&&(n.children=new er().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof er&&(n.children=n.children.toArray())}}),t}}}var xb=$(()=>{"use strict";vs()});function yb(e){return typeof e=="function"?e:Ts}function bb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function gA(e,t){let n=t.structure,r=[];for(let o in n){if(Vu.call(n,o)===!1)continue;let i=n[o],s={name:o,type:!1,nullable:!1};Array.isArray(i)||(i=[i]);for(let a of i)a===null?s.nullable=!0:typeof a=="string"?s.type="node":Array.isArray(a)&&(s.type="list");s.type&&r.push(s)}return r.length?{context:t.walkContext,fields:r}:null}function fA(e){let t={};for(let n in e.node)if(Vu.call(e.node,n)){let r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=gA(n,r)}return t}function Sb(e,t){let n=e.fields.slice(),r=e.context,o=typeof r=="string";return t&&n.reverse(),function(i,s,a,u){let c;o&&(c=s[r],s[r]=i);for(let l of n){let d=i[l.name];if(!l.nullable||d){if(l.type==="list"){if(t?d.reduceRight(u,!1):d.reduce(u,!1))return!0}else if(a(d))return!0}}o&&(s[r]=c)}}function wb({StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Rule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Declaration:{StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}}}function vb(e){let t=fA(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Vu.call(t,c)&&t[c]!==null&&(n[c]=Sb(t[c],!1),r[c]=Sb(t[c],!0));let s=wb(n),a=wb(r),u=function(c,l){function d(A,C,D){let R=g.call(I,A,C,D);return R===o?!0:R===i?!1:!!(m.hasOwnProperty(A.type)&&m[A.type](A,I,d,v)||p.call(I,A,C,D)===o)}let g=Ts,p=Ts,m=n,v=(A,C,D,R)=>A||d(C,D,R),I={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")g=l;else if(l&&(g=yb(l.enter),p=yb(l.leave),l.reverse&&(m=r),l.visit)){if(s.hasOwnProperty(l.visit))m=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");g=bb(g,l.visit),p=bb(p,l.visit)}if(g===Ts&&p===Ts)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");d(c)};return u.break=o,u.skip=i,u.find=function(c,l){let d=null;return u(c,function(g,p,m){if(l.call(this,g,p,m))return d=g,o}),d},u.findLast=function(c,l){let d=null;return u(c,{reverse:!0,enter(g,p,m){if(l.call(this,g,p,m))return d=g,o}}),d},u.findAll=function(c,l){let d=[];return u(c,function(g,p,m){l.call(this,g,p,m)&&d.push(g)}),d},u}var Vu,Ts,kb=$(()=>{"use strict";({hasOwnProperty:Vu}=Object.prototype),Ts=function(){}});function mA(e){return e}function hA(e){let{min:t,max:n,comma:r}=e;return t===0&&n===0?r?"#?":"*":t===0&&n===1?"?":t===1&&n===0?r?"#":"+":t===1&&n===1?"":(r?"#":"")+(t===n?"{"+t+"}":"{"+t+","+(n!==0?n:"")+"}")}function xA(e){if(e.type==="Range")return" ["+(e.min===null?"-\u221E":e.min)+","+(e.max===null?"\u221E":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}function yA(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>hl(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function hl(e,t,n,r){let o;switch(e.type){case"Group":o=yA(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return hl(e.term,t,n,r)+t(hA(e),e);case"Boolean":o="<boolean-expr["+hl(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(xA(e.opts),e.opts):"")+">";break;case"Property":o="<'"+e.name+"'>";break;case"Keyword":o=e.name;break;case"AtKeyword":o="@"+e.name;break;case"Function":o=e.name+"(";break;case"String":case"Token":o=e.value;break;case"Comma":o=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(o,e)}function Ti(e,t){let n=mA,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),hl(e,n,r,o)}var Gu=$(()=>{"use strict"});function bA(e,t){let n=e.tokens,r=e.longestMatch,o=r<n.length&&n[r].node||null,i=o!==t?o:null,s=0,a=0,u=0,c="",l,d;for(let g=0;g<n.length;g++){let p=n[g].value;g===r&&(a=p.length,s=c.length),i!==null&&n[g].node===i&&(g<=r?u++:u=0),c+=p}return r===n.length||u>1?(l=xl(i||t,"end")||Is(Cb,c),d=Is(l)):(l=xl(i,"start")||Is(xl(t,"start")||Cb,c.slice(0,s)),d=xl(i,"end")||Is(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:d}}function xl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?Is(n):n:null}function Is({offset:e,line:t,column:n},r){let o={offset:e,line:t,column:n};if(r){let i=r.split(/\n|\r\n?|\f/);o.offset+=r.length,o.line+=i.length-1,o.column=i.length===1?o.column+r.length:i.pop().length+1}return o}var Cb,Ii,Tb,Ib=$(()=>{"use strict";pl();Gu();Cb={offset:0,line:1,column:1};Ii=function(e,t){let n=Ko("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Tb=function(e,t,n,r){let o=Ko("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=bA(r,n);return o.rawMessage=e,o.syntax=t?Ti(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
8
8
  syntax: `+o.syntax+`
9
9
  value: `+(i||"<empty string>")+`
10
- --------`+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,u),o.loc={source:n&&n.loc&&n.loc.source||"<unknown>",start:u,end:c},o}});function wl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===bl&&e.charCodeAt(t+1)===bl}function Fb(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===bl&&e.charCodeAt(t+1)!==bl){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function bA(e){if(yl.has(e))return yl.get(e);let t=e.toLowerCase(),n=yl.get(t);if(n===void 0){let r=wl(t,0),o=r?"":Fb(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return yl.set(e,n),n}function SA(e){if(Fi.has(e))return Fi.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=wl(t,n.length);if(!r&&(t=t.toLowerCase(),Fi.has(t))){let a=Fi.get(t);return Fi.set(e,a),a}let o=r?"":Fb(t,n.length),i=t.substr(0,n.length+o.length),s=Object.freeze({basename:t.substr(i.length),name:t.substr(n.length),hack:n,vendor:o,prefix:i,custom:r});return Fi.set(e,s),s}var yl,Fi,bl,Sl,qu,vl=$(()=>{"use strict";yl=new Map,Fi=new Map,bl=45,Sl=bA,qu=SA});var Ei,kl=$(()=>{"use strict";Ei=["initial","inherit","unset","revert","revert-layer"]});function Xu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function Fs(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function ko(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===Es||o===_r){if(n)return 0;t++}for(;t<e.value.length;t++)if(!Ht(e.value.charCodeAt(t)))return 0;return r+1}function Ku(e,t,n){let r=!1,o=Fs(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Xu(e,Es)||Xu(e,_r)){if(r=!0,o=Fs(n(++o),o,n),e=n(o),e===null||e.type!==10)return 0}else return t;if(!r){let i=e.value.charCodeAt(0);if(i!==Es&&i!==_r)return 0}return ko(e,r?0:1,r,o)}function Qu(e,t){let n=0;if(!e)return 0;if(e.type===10)return ko(e,0,vA,n);if(e.type===1&&e.value.charCodeAt(0)===_r){if(!Kr(e.value,1,Yu))return 0;switch(e.value.length){case 2:return Ku(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==_r?0:(n=Fs(t(++n),n,t),e=t(n),ko(e,0,Ai,n));default:return e.value.charCodeAt(2)!==_r?0:ko(e,3,Ai,n)}}else if(e.type===1||Xu(e,Es)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Kr(e.value,0,Yu))return 0;switch(e.value.length){case 1:return Ku(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==_r?0:(n=Fs(t(++n),n,t),e=t(n),ko(e,0,Ai,n));default:return e.value.charCodeAt(1)!==_r?0:ko(e,2,Ai,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===Es||r===_r?1:0,i=o;for(;i<e.value.length&&Ht(e.value.charCodeAt(i));i++);return i===o||!Kr(e.value,i,Yu)?0:i+1===e.value.length?Ku(t(++n),n,t):e.value.charCodeAt(i+1)!==_r?0:i+2===e.value.length?(n=Fs(t(++n),n,t),e=t(n),ko(e,0,Ai,n)):ko(e,i+2,Ai,n)}return 0}var Es,_r,Yu,Ai,vA,Eb=$(()=>{"use strict";ur();Es=43,_r=45,Yu=110,Ai=!0,vA=!1});function Ju(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function TA(e,t){return e.value.charCodeAt(0)===t}function As(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===Ab&&n&&r!==0)return As(e,t+r+1,!1),6;if(!Rn(i)||++r>6)return 0}return r}function Cl(e,t,n){if(!e)return 0;for(;Ju(n(t),Pb);){if(++e>6)return 0;t++}return t}function Zu(e,t){let n=0;if(e===null||e.type!==1||!Kr(e.value,0,CA)||(e=t(++n),e===null))return 0;if(Ju(e,kA))return e=t(++n),e===null?0:e.type===1?Cl(As(e,0,!0),++n,t):Ju(e,Pb)?Cl(1,++n,t):0;if(e.type===10){let r=As(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!TA(e,Ab)||!As(e,1,!1)?0:n+1:Cl(r,n,t))}return e.type===12?Cl(As(e,1,!0),++n,t):0}var kA,Ab,Pb,CA,Lb=$(()=>{"use strict";ur();kA=43,Ab=45,Pb=63,CA=117});function Tr(e,t){return t<e.length?e.charCodeAt(t):0}function Bb(e,t){return Xr(e,0,e.length,t)}function Db(e,t){for(let n=0;n<t.length;n++)if(Bb(e,t[n]))return!0;return!1}function Rb(e,t){return t!==e.length-2?!1:Tr(e,t)===92&&Ht(Tr(e,t+1))}function Tl(e,t,n){if(e&&e.type==="Range"){let r=Number(n!==void 0&&n!==t.length?t.substr(0,n):t);if(isNaN(r)||e.min!==null&&r<e.min&&typeof e.min!="string"||e.max!==null&&r>e.max&&typeof e.max!="string")return!0}return!1}function PA(e,t){let n=0,r=[],o=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==n)break e;if(n=r.pop(),r.length===0){o++;break e}break;case 2:case 21:case 19:case 23:r.push(n),n=ip.get(e.type);break}o++}while(e=t(o));return o}function dr(e,t){return function(n,r,o){return n===null?0:n.type===2&&Db(n.value,t)?PA(n,r):e(n,r,o)}}function Lt(e){return function(t){return t===null||t.type!==e?0:1}}function LA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return Db(t,Ei)||Bb(t,"default")?0:1}function zb(e){return e===null||e.type!==1||Tr(e.value,0)!==45||Tr(e.value,1)!==45?0:1}function MA(e){return!zb(e)||e.value==="--"?0:1}function BA(e){if(e===null||e.type!==4)return 0;let t=e.value.length;if(t!==4&&t!==5&&t!==7&&t!==9)return 0;for(let n=1;n<t;n++)if(!Rn(Tr(e.value,n)))return 0;return 1}function DA(e){return e===null||e.type!==4||!yi(Tr(e.value,1),Tr(e.value,2),Tr(e.value,3))?0:1}function RA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 17:if(n===0)break e;break;case 9:if(n===0&&e.value==="!")break e;break;case 2:case 21:case 19:case 23:r.push(n),n=ip.get(e.type);break}o++}while(e=t(o));return o}function zA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 2:case 21:case 19:case 23:r.push(n),n=ip.get(e.type);break}o++}while(e=t(o));return o}function to(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=qo(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Rb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Tl(r,t.value,o)?0:1}}function NA(e,t,n){return e===null||e.type!==11||Tl(n,e.value,e.value.length-1)?0:1}function Nb(e){return typeof e!="function"&&(e=function(){return 0}),function(t,n,r){return t!==null&&t.type===10&&Number(t.value)===0?1:e(t,n,r)}}function OA(e,t,n){if(e===null)return 0;let r=qo(e.value,0);return!(r===e.value.length)&&!Rb(e.value,r)||Tl(n,e.value,r)?0:1}function _A(e,t,n){if(e===null||e.type!==10)return 0;let r=Tr(e.value,0)===43||Tr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!Ht(Tr(e.value,r)))return 0;return Tl(n,e.value,r)?0:1}function HA(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:dr(to(null),eo),angle:dr(to(t),eo),decibel:dr(to(n),eo),frequency:dr(to(r),eo),flex:dr(to(o),eo),length:dr(Nb(to(i)),eo),resolution:dr(to(s),eo),semitones:dr(to(a),eo),time:dr(to(u),eo)}}function WA(e){let t=new Set;for(let n of jA)if(Array.isArray(e[n]))for(let r of e[n])t.add(r.toLowerCase());return function(r){return r===null?0:r.type===9&&r.value==="%"||r.type===1&&t.has(r.value.toLowerCase())?1:0}}function Ob(e){return{...$A,...UA,...HA(e),"attr-unit":WA(e)}}var ep,tp,np,IA,FA,EA,rp,op,Mb,AA,eo,ip,$A,UA,jA,_b=$(()=>{"use strict";kl();Eb();Lb();ur();ep=["calc(","-moz-calc(","-webkit-calc("],tp=["min(","max(","clamp("],np=["round(","mod(","rem("],IA=["sin(","cos(","tan("],FA=["asin(","acos(","atan(","atan2("],EA=["pow(","sqrt(","log(","exp(","sign("],rp=["hypot("],op=["abs("],Mb=[...ep,...tp,...np,...IA,...EA,...rp,...op],AA=[...ep,...tp,...np,...rp,...op],eo=[...ep,...tp,...np,...FA,...rp,...op],ip=new Map([[2,22],[21,22],[19,20],[23,24]]);$A={"ident-token":Lt(1),"function-token":Lt(2),"at-keyword-token":Lt(3),"hash-token":Lt(4),"string-token":Lt(5),"bad-string-token":Lt(6),"url-token":Lt(7),"bad-url-token":Lt(8),"delim-token":Lt(9),"number-token":Lt(10),"percentage-token":Lt(11),"dimension-token":Lt(12),"whitespace-token":Lt(13),"CDO-token":Lt(14),"CDC-token":Lt(15),"colon-token":Lt(16),"semicolon-token":Lt(17),"comma-token":Lt(18),"[-token":Lt(19),"]-token":Lt(20),"(-token":Lt(21),")-token":Lt(22),"{-token":Lt(23),"}-token":Lt(24)},UA={string:Lt(5),ident:Lt(1),percentage:dr(NA,AA),zero:Nb(),number:dr(OA,Mb),integer:dr(_A,Mb),"custom-ident":LA,"dashed-ident":zb,"custom-property-name":MA,"hex-color":BA,"id-selector":DA,"an-plus-b":Qu,urange:Zu,"declaration-value":RA,"any-value":zA},jA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var Il={};Se(Il,{angle:()=>GA,decibel:()=>QA,flex:()=>XA,frequency:()=>YA,length:()=>VA,resolution:()=>KA,semitones:()=>JA,time:()=>qA});var VA,GA,qA,YA,KA,XA,QA,JA,$b=$(()=>{"use strict";VA=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],GA=["deg","grad","rad","turn"],qA=["s","ms"],YA=["hz","khz"],KA=["dpi","dpcm","dppx","x"],XA=["fr"],QA=["db"],JA=["st"]});function Ub(e,t,n){return Object.assign(Ko("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
10
+ --------`+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,u),o.loc={source:n&&n.loc&&n.loc.source||"<unknown>",start:u,end:c},o}});function wl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===bl&&e.charCodeAt(t+1)===bl}function Fb(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===bl&&e.charCodeAt(t+1)!==bl){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function SA(e){if(yl.has(e))return yl.get(e);let t=e.toLowerCase(),n=yl.get(t);if(n===void 0){let r=wl(t,0),o=r?"":Fb(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return yl.set(e,n),n}function wA(e){if(Fi.has(e))return Fi.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=wl(t,n.length);if(!r&&(t=t.toLowerCase(),Fi.has(t))){let a=Fi.get(t);return Fi.set(e,a),a}let o=r?"":Fb(t,n.length),i=t.substr(0,n.length+o.length),s=Object.freeze({basename:t.substr(i.length),name:t.substr(n.length),hack:n,vendor:o,prefix:i,custom:r});return Fi.set(e,s),s}var yl,Fi,bl,Sl,qu,vl=$(()=>{"use strict";yl=new Map,Fi=new Map,bl=45,Sl=SA,qu=wA});var Ei,kl=$(()=>{"use strict";Ei=["initial","inherit","unset","revert","revert-layer"]});function Xu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function Fs(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function ko(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===Es||o===_r){if(n)return 0;t++}for(;t<e.value.length;t++)if(!Ht(e.value.charCodeAt(t)))return 0;return r+1}function Ku(e,t,n){let r=!1,o=Fs(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Xu(e,Es)||Xu(e,_r)){if(r=!0,o=Fs(n(++o),o,n),e=n(o),e===null||e.type!==10)return 0}else return t;if(!r){let i=e.value.charCodeAt(0);if(i!==Es&&i!==_r)return 0}return ko(e,r?0:1,r,o)}function Qu(e,t){let n=0;if(!e)return 0;if(e.type===10)return ko(e,0,kA,n);if(e.type===1&&e.value.charCodeAt(0)===_r){if(!Kr(e.value,1,Yu))return 0;switch(e.value.length){case 2:return Ku(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==_r?0:(n=Fs(t(++n),n,t),e=t(n),ko(e,0,Ai,n));default:return e.value.charCodeAt(2)!==_r?0:ko(e,3,Ai,n)}}else if(e.type===1||Xu(e,Es)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Kr(e.value,0,Yu))return 0;switch(e.value.length){case 1:return Ku(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==_r?0:(n=Fs(t(++n),n,t),e=t(n),ko(e,0,Ai,n));default:return e.value.charCodeAt(1)!==_r?0:ko(e,2,Ai,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===Es||r===_r?1:0,i=o;for(;i<e.value.length&&Ht(e.value.charCodeAt(i));i++);return i===o||!Kr(e.value,i,Yu)?0:i+1===e.value.length?Ku(t(++n),n,t):e.value.charCodeAt(i+1)!==_r?0:i+2===e.value.length?(n=Fs(t(++n),n,t),e=t(n),ko(e,0,Ai,n)):ko(e,i+2,Ai,n)}return 0}var Es,_r,Yu,Ai,kA,Eb=$(()=>{"use strict";ur();Es=43,_r=45,Yu=110,Ai=!0,kA=!1});function Ju(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function IA(e,t){return e.value.charCodeAt(0)===t}function As(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===Ab&&n&&r!==0)return As(e,t+r+1,!1),6;if(!Rn(i)||++r>6)return 0}return r}function Cl(e,t,n){if(!e)return 0;for(;Ju(n(t),Pb);){if(++e>6)return 0;t++}return t}function Zu(e,t){let n=0;if(e===null||e.type!==1||!Kr(e.value,0,TA)||(e=t(++n),e===null))return 0;if(Ju(e,CA))return e=t(++n),e===null?0:e.type===1?Cl(As(e,0,!0),++n,t):Ju(e,Pb)?Cl(1,++n,t):0;if(e.type===10){let r=As(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!IA(e,Ab)||!As(e,1,!1)?0:n+1:Cl(r,n,t))}return e.type===12?Cl(As(e,1,!0),++n,t):0}var CA,Ab,Pb,TA,Lb=$(()=>{"use strict";ur();CA=43,Ab=45,Pb=63,TA=117});function Tr(e,t){return t<e.length?e.charCodeAt(t):0}function Bb(e,t){return Xr(e,0,e.length,t)}function Db(e,t){for(let n=0;n<t.length;n++)if(Bb(e,t[n]))return!0;return!1}function Rb(e,t){return t!==e.length-2?!1:Tr(e,t)===92&&Ht(Tr(e,t+1))}function Tl(e,t,n){if(e&&e.type==="Range"){let r=Number(n!==void 0&&n!==t.length?t.substr(0,n):t);if(isNaN(r)||e.min!==null&&r<e.min&&typeof e.min!="string"||e.max!==null&&r>e.max&&typeof e.max!="string")return!0}return!1}function LA(e,t){let n=0,r=[],o=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==n)break e;if(n=r.pop(),r.length===0){o++;break e}break;case 2:case 21:case 19:case 23:r.push(n),n=ip.get(e.type);break}o++}while(e=t(o));return o}function dr(e,t){return function(n,r,o){return n===null?0:n.type===2&&Db(n.value,t)?LA(n,r):e(n,r,o)}}function Lt(e){return function(t){return t===null||t.type!==e?0:1}}function MA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return Db(t,Ei)||Bb(t,"default")?0:1}function zb(e){return e===null||e.type!==1||Tr(e.value,0)!==45||Tr(e.value,1)!==45?0:1}function BA(e){return!zb(e)||e.value==="--"?0:1}function DA(e){if(e===null||e.type!==4)return 0;let t=e.value.length;if(t!==4&&t!==5&&t!==7&&t!==9)return 0;for(let n=1;n<t;n++)if(!Rn(Tr(e.value,n)))return 0;return 1}function RA(e){return e===null||e.type!==4||!yi(Tr(e.value,1),Tr(e.value,2),Tr(e.value,3))?0:1}function zA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 17:if(n===0)break e;break;case 9:if(n===0&&e.value==="!")break e;break;case 2:case 21:case 19:case 23:r.push(n),n=ip.get(e.type);break}o++}while(e=t(o));return o}function NA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 2:case 21:case 19:case 23:r.push(n),n=ip.get(e.type);break}o++}while(e=t(o));return o}function to(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=qo(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Rb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Tl(r,t.value,o)?0:1}}function OA(e,t,n){return e===null||e.type!==11||Tl(n,e.value,e.value.length-1)?0:1}function Nb(e){return typeof e!="function"&&(e=function(){return 0}),function(t,n,r){return t!==null&&t.type===10&&Number(t.value)===0?1:e(t,n,r)}}function _A(e,t,n){if(e===null)return 0;let r=qo(e.value,0);return!(r===e.value.length)&&!Rb(e.value,r)||Tl(n,e.value,r)?0:1}function $A(e,t,n){if(e===null||e.type!==10)return 0;let r=Tr(e.value,0)===43||Tr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!Ht(Tr(e.value,r)))return 0;return Tl(n,e.value,r)?0:1}function WA(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:dr(to(null),eo),angle:dr(to(t),eo),decibel:dr(to(n),eo),frequency:dr(to(r),eo),flex:dr(to(o),eo),length:dr(Nb(to(i)),eo),resolution:dr(to(s),eo),semitones:dr(to(a),eo),time:dr(to(u),eo)}}function VA(e){let t=new Set;for(let n of HA)if(Array.isArray(e[n]))for(let r of e[n])t.add(r.toLowerCase());return function(r){return r===null?0:r.type===9&&r.value==="%"||r.type===1&&t.has(r.value.toLowerCase())?1:0}}function Ob(e){return{...UA,...jA,...WA(e),"attr-unit":VA(e)}}var ep,tp,np,FA,EA,AA,rp,op,Mb,PA,eo,ip,UA,jA,HA,_b=$(()=>{"use strict";kl();Eb();Lb();ur();ep=["calc(","-moz-calc(","-webkit-calc("],tp=["min(","max(","clamp("],np=["round(","mod(","rem("],FA=["sin(","cos(","tan("],EA=["asin(","acos(","atan(","atan2("],AA=["pow(","sqrt(","log(","exp(","sign("],rp=["hypot("],op=["abs("],Mb=[...ep,...tp,...np,...FA,...AA,...rp,...op],PA=[...ep,...tp,...np,...rp,...op],eo=[...ep,...tp,...np,...EA,...rp,...op],ip=new Map([[2,22],[21,22],[19,20],[23,24]]);UA={"ident-token":Lt(1),"function-token":Lt(2),"at-keyword-token":Lt(3),"hash-token":Lt(4),"string-token":Lt(5),"bad-string-token":Lt(6),"url-token":Lt(7),"bad-url-token":Lt(8),"delim-token":Lt(9),"number-token":Lt(10),"percentage-token":Lt(11),"dimension-token":Lt(12),"whitespace-token":Lt(13),"CDO-token":Lt(14),"CDC-token":Lt(15),"colon-token":Lt(16),"semicolon-token":Lt(17),"comma-token":Lt(18),"[-token":Lt(19),"]-token":Lt(20),"(-token":Lt(21),")-token":Lt(22),"{-token":Lt(23),"}-token":Lt(24)},jA={string:Lt(5),ident:Lt(1),percentage:dr(OA,PA),zero:Nb(),number:dr(_A,Mb),integer:dr($A,Mb),"custom-ident":MA,"dashed-ident":zb,"custom-property-name":BA,"hex-color":DA,"id-selector":RA,"an-plus-b":Qu,urange:Zu,"declaration-value":zA,"any-value":NA},HA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var Il={};Se(Il,{angle:()=>qA,decibel:()=>JA,flex:()=>QA,frequency:()=>KA,length:()=>GA,resolution:()=>XA,semitones:()=>ZA,time:()=>YA});var GA,qA,YA,KA,XA,QA,JA,ZA,$b=$(()=>{"use strict";GA=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],qA=["deg","grad","rad","turn"],YA=["s","ms"],KA=["hz","khz"],XA=["dpi","dpcm","dppx","x"],QA=["fr"],JA=["db"],ZA=["st"]});function Ub(e,t,n){return Object.assign(Ko("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
11
11
  `+t+`
12
- --`+new Array((n||t.length)+1).join("-")+"^"})}var jb=$(()=>{"use strict";pl()});var ZA,eP,tP,nP,rP,Hb,Fl,Wb=$(()=>{"use strict";jb();ZA=9,eP=10,tP=12,nP=13,rP=32,Hb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),Fl=class{constructor(t){this.str=t,this.pos=0}charCodeAt(t){return t<this.str.length?this.str.charCodeAt(t):0}charCode(){return this.charCodeAt(this.pos)}isNameCharCode(t=this.charCode()){return t<128&&Hb[t]===1}nextCharCode(){return this.charCodeAt(this.pos+1)}nextNonWsCode(t){return this.charCodeAt(this.findWsEnd(t))}skipWs(){this.pos=this.findWsEnd(this.pos)}findWsEnd(t){for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n!==nP&&n!==eP&&n!==tP&&n!==rP&&n!==ZA)break}return t}substringToPos(t){return this.str.substring(this.pos,this.pos=t)}eat(t){this.charCode()!==t&&this.error("Expect `"+String.fromCharCode(t)+"`"),this.pos++}peek(){return this.pos<this.str.length?this.str.charAt(this.pos++):""}error(t){throw new Ub(t,this.str,this.pos)}scanSpaces(){return this.substringToPos(this.findWsEnd(this.pos))}scanWord(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n>=128||Hb[n]===0)break}return this.pos===t&&this.error("Expect a keyword"),this.substringToPos(t)}scanNumber(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n<48||n>57)break}return this.pos===t&&this.error("Expect a number"),this.substringToPos(t)}scanString(){let t=this.str.indexOf("'",this.pos+1);return t===-1&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(t+1)}}});function Xb(e){let t=null,n=null;return e.eat(Pl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===pp?(e.pos++,e.skipWs(),e.charCode()!==lp&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(lp),{min:Number(t),max:n?Number(n):0}}function uP(e){let t=null,n=!1;switch(e.charCode()){case e0:e.pos++,t={min:0,max:0};break;case up:e.pos++,t={min:1,max:0};break;case Al:e.pos++,t={min:0,max:1};break;case cp:e.pos++,n=!0,e.charCode()===Pl?t=Xb(e):e.charCode()===Al?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Pl:t=Xb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function no(e,t){let n=uP(e);return n!==null?(n.term=t,e.charCode()===cp&&e.charCodeAt(e.pos-1)===up||e.charCode()===Al&&e.charCodeAt(e.pos-1)===lp?no(e,n):n):t}function sp(e){let t=e.peek();return t===""?null:no(e,{type:"Token",value:t})}function pP(e){let t;return e.eat(dp),e.eat(El),t=e.scanWord(),e.eat(El),e.eat(ap),no(e,{type:"Property",name:t})}function dP(e){let t=null,n=null,r=1;return e.eat(Ps),e.charCode()===Gb&&(e.peek(),r=-1),r==-1&&e.charCode()===Yb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(pp),e.skipWs(),e.charCode()===Yb?e.peek():(r=1,e.charCode()===Gb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Pi),{type:"Range",min:t,max:n}}function gP(e){let t,n=null;if(e.eat(dp),t=e.scanWord(),t==="boolean-expr"){e.eat(Ps);let r=Ll(e,Pi);return e.eat(Pi),e.eat(ap),no(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Jb&&e.nextCharCode()===Zb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Ps&&(e.skipWs(),n=dP(e)),e.eat(ap),no(e,{type:"Type",name:t,opts:n})}function fP(e){let t=e.scanWord();return e.charCode()===Jb?(e.pos++,{type:"Function",name:t}):no(e,{type:"Keyword",name:t})}function mP(e,t){function n(o,i){return{type:"Group",terms:o,combinator:i,disallowEmpty:!1,explicit:!1}}let r;for(t=Object.keys(t).sort((o,i)=>Kb[o]-Kb[i]);t.length>0;){r=t.shift();let o=0,i=0;for(;o<e.length;o++){let s=e[o];s.type==="Combinator"&&(s.value===r?(i===-1&&(i=o-1),e.splice(o,1),o--):(i!==-1&&o-i>1&&(e.splice(i,o-i,n(e.slice(i,o),r)),o=i+1),i=-1))}i!==-1&&t.length&&e.splice(i,o-i,n(e.slice(i,o),r))}return r}function Ll(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?Ll(e,Zb):xP(e);if(!a)break;if(a.type!=="Spaces"){if(s){if(a.terms.length===0){s=!1;continue}if(a.combinator===" "){for(;a.terms.length>1;)n[" "]=!0,r.push({type:"Combinator",value:" "},a.terms.shift());a=a.terms[0]}}a.type==="Combinator"?((o===null||o.type==="Combinator")&&(e.pos=i,e.error("Unexpected combinator")),n[a.value]=!0):o!==null&&o.type!=="Combinator"&&(n[" "]=!0,r.push({type:"Combinator",value:" "})),r.push(a),o=a,i=e.pos,s=a.type==="Function"}}return o!==null&&o.type==="Combinator"&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:r,combinator:mP(r,n)||" ",disallowEmpty:!1,explicit:!1}}function hP(e){let t;return e.eat(Ps),t=Ll(e,Pi),e.eat(Pi),t.explicit=!0,e.charCode()===Qb&&(e.pos++,t.disallowEmpty=!0),t}function xP(e){let t=e.charCode();switch(t){case Pi:break;case Ps:return no(e,hP(e));case dp:return e.nextCharCode()===El?pP(e):gP(e);case qb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===qb?2:1))};case Vb:return e.pos++,e.eat(Vb),{type:"Combinator",value:"&&"};case pp:return e.pos++,{type:"Comma"};case El:return no(e,{type:"String",value:e.scanString()});case lP:case oP:case iP:case aP:case sP:return{type:"Spaces",value:e.scanSpaces()};case cP:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):sp(e);case e0:case up:case Al:case cp:case Qb:break;case Pl:if(t=e.nextCharCode(),t<48||t>57)return sp(e);break;default:return e.isNameCharCode(t)?fP(e):sp(e)}}function Ls(e){let t=new Fl(e),n=Ll(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var oP,iP,sP,aP,lP,Qb,cp,Vb,El,Jb,Zb,e0,up,pp,Gb,dp,ap,Al,cP,Ps,Pi,Pl,qb,lp,Yb,Kb,gp=$(()=>{"use strict";Wb();oP=9,iP=10,sP=12,aP=13,lP=32,Qb=33,cp=35,Vb=38,El=39,Jb=40,Zb=41,e0=42,up=43,pp=44,Gb=45,dp=60,ap=62,Al=63,cP=64,Ps=91,Pi=93,Pl=123,qb=124,lp=125,Yb=8734,Kb={" ":1,"&&":2,"||":3,"|":4}});function t0(e){return typeof e=="function"?e:Ms}function fp(e,t,n){function r(s){switch(o.call(n,s),s.type){case"Group":s.terms.forEach(r);break;case"Multiplier":case"Boolean":r(s.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+s.type)}i.call(n,s)}let o=Ms,i=Ms;if(typeof t=="function"?o=t:t&&(o=t0(t.enter),i=t0(t.leave)),o===Ms&&i===Ms)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ms,n0=$(()=>{"use strict";Ms=function(){}});var mp=$(()=>{"use strict";Gu();gp();n0()});function SP(e){let t=[];return vo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function r0(e,t){return typeof e=="string"?SP(e):t.generate(e,bP)}var bP,o0=$(()=>{"use strict";ur();bP={decorator(e){let t=[],n=null;return{...e,node(r){let o=n;n=r,e.node.call(this,r),n=o},emit(r,o,i){t.push({type:o,value:r,node:i?null:n})},result(){return t}}}}});function vn(e,t,n){return t===gt&&n===kt||e===gt&&t===gt&&n===gt?e:(e.type==="If"&&e.else===kt&&t===gt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function s0(e){return e.length>2&&e.charCodeAt(e.length-2)===wP&&e.charCodeAt(e.length-1)===vP}function i0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&s0(e.name)}function Co(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Bs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Bs(e.match,t,n),e.then=Bs(e.then,t,n),e.else=Bs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function hp(e,t,n){switch(e){case" ":{let r=gt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=vn(i,r,kt)}return r}case"|":{let r=kt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(i0(s)&&(o===null&&i>0&&i0(t[i-1])&&(o=Object.create(null),r=vn({type:"Enum",map:o},gt,r)),o!==null)){let a=(s0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=vn(s,gt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=hp(e,t.filter(function(a){return a!==i}),!1):s=gt,r=vn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?gt:kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=hp(e,t.filter(function(a){return a!==i}),!0):s=gt,r=vn(i,s,r)}return r}}}function kP(e){let t=gt,n=Li(e.term);if(e.max===0)n=vn(n,Ml,kt),t=vn(n,null,kt),t.then=vn(gt,gt,t),e.comma&&(t.then.else=vn({type:"Comma",syntax:e},t,kt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==gt&&(t=vn({type:"Comma",syntax:e},t,kt)),t=vn(n,vn(gt,gt,t),kt);if(e.min===0)t=vn(gt,gt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==gt&&(t=vn({type:"Comma",syntax:e},t,kt)),t=vn(n,t,kt);return t}function Li(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=hp(e.combinator,e.terms.map(Li),!1);return e.disallowEmpty&&(t=vn(t,Ml,kt)),t}case"Multiplier":return kP(e);case"Boolean":{let t=Li(e.term),n=Li(Co([Co([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Co([{type:"Type",name:"!boolean-group"},Co([{type:"Multiplier",comma:!1,min:0,max:0,term:Co([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Co([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=Li(Co([{type:"Type",name:"!term"},Co([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Bs(r,{"!term":t,"!self":n}),Bs(n,{"!boolean-group":r}),n}case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return e.value.length===3?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}function Ds(e,t){return typeof e=="string"&&(e=Ls(e)),{type:"MatchGraph",match:Li(e),syntax:t||null,source:e}}var gt,kt,Ml,wP,vP,xp=$(()=>{"use strict";gp();gt={type:"Match"},kt={type:"Mismatch"},Ml={type:"DisallowEmpty"},wP=40,vP=41});function AP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function yp(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=t.charCodeAt(n),o=e.charCodeAt(n);if(o>=65&&o<=90&&(o=o|32),o!==r)return!1}return!0}function PP(e){return e.type!==9?!1:e.value!=="?"}function u0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||PP(e)}function p0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function LP(e,t,n){function r(){do C++,A=C<e.length?e[C]:null;while(A!==null&&(A.type===13||A.type===25))}function o(_){let P=C+_;return P<e.length?e[P]:null}function i(_,P){return{nextState:_,matchStack:R,syntaxStack:d,thenStack:g,tokenIndex:C,prev:P}}function s(_){g={nextState:_,matchStack:R,syntaxStack:d,prev:g}}function a(_){p=i(_,p)}function u(){R={type:TP,syntax:t.syntax,token:A,prev:R},r(),m=null,C>D&&(D=C)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},R={type:bp,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===bp?R=R.prev:R={type:d0,syntax:d.syntax,token:R.token,prev:R},d=d.prev}let d=null,g=null,p=null,m=null,k=0,I=null,A=null,C=-1,D=0,R={type:CP,syntax:null,token:null,prev:null};for(r();I===null&&++k<c0;)switch(t.type){case"Match":if(g===null){if(A!==null&&(C!==e.length-1||A.value!=="\\0"&&A.value!=="\\9")){t=kt;break}I=l0;break}if(t=g.nextState,t===Ml)if(g.matchStack===R){t=kt;break}else t=gt;for(;g.syntaxStack!==d;)l();g=g.prev;break;case"Mismatch":if(m!==null&&m!==!1)(p===null||C>p.tokenIndex)&&(p=m,m=!1);else if(p===null){I=IP;break}t=p.nextState,g=p.thenStack,d=p.syntaxStack,R=p.matchStack,C=p.tokenIndex,A=C<e.length?e[C]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==kt&&a(t.else),t.then!==gt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let N=t.syntax.terms;if(t.index===N.length){if(t.mask===0||t.syntax.all){t=kt;break}t=gt;break}if(t.mask===(1<<N.length)-1){t=gt;break}for(;t.index<N.length;t.index++){let x=1<<t.index;if((t.mask&x)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|x}),t=N[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(A!==null){let N=A.value.toLowerCase();if(N.indexOf("\\")!==-1&&(N=N.replace(/\\[09].*$/,"")),a0.call(t.map,N)){t=t.map[N];break}}t=kt;break;case"Generic":{let N=d!==null?d.opts:null,x=C+Math.floor(t.fn(A,o,N));if(!isNaN(x)&&x>C){for(;C<x;)u();t=gt}else t=kt;break}case"Type":case"Property":{let N=t.type==="Type"?"types":"properties",x=a0.call(n,N)?n[N][t.name]:null;if(!x||!x.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(m!==!1&&A!==null&&t.type==="Type"&&(t.name==="custom-ident"&&A.type===1||t.name==="length"&&A.value==="0")){m===null&&(m=i(t,p)),t=kt;break}c(),t=x.matchRef||x.match;break}case"Keyword":{let N=t.name;if(A!==null){let x=A.value;if(x.indexOf("\\")!==-1&&(x=x.replace(/\\[09].*$/,"")),yp(x,N)){u(),t=gt;break}}t=kt;break}case"AtKeyword":case"Function":if(A!==null&&yp(A.value,t.name)){u(),t=gt;break}t=kt;break;case"Token":if(A!==null&&A.value===t.value){u(),t=gt;break}t=kt;break;case"Comma":A!==null&&A.type===18?u0(R.token)?t=kt:(u(),t=p0(A)?kt:gt):t=u0(R.token)||p0(A)?gt:kt;break;case"String":let _="",P=C;for(;P<e.length&&_.length<t.value.length;P++)_+=e[P].value;if(yp(_,t.value)){for(;C<P;)u();t=gt}else t=kt;break;default:throw new Error("Unknown node type: "+t.type)}switch(EP+=k,I){case null:console.warn("[csstree-match] BREAK after "+c0+" iterations"),I=FP,R=null;break;case l0:for(;d!==null;)l();break;default:R=null}return{tokens:e,reason:I,iterations:k,match:R,longestMatch:D}}function Sp(e,t,n){let r=LP(e,t,n||{});if(r.match===null)return r;let o=r.match,i=r.match={syntax:t.syntax||null,match:[]},s=[i];for(o=AP(o).prev;o!==null;){switch(o.type){case bp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case d0:s.pop(),i=s[s.length-1];break;default:i.match.push({syntax:o.syntax||null,token:o.token.value,node:o.token.node})}o=o.prev}return r}var a0,CP,TP,bp,d0,l0,IP,FP,c0,EP,g0=$(()=>{"use strict";xp();({hasOwnProperty:a0}=Object.prototype),CP=0,TP=1,bp=2,d0=3,l0="Match",IP="Mismatch",FP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",c0=15e3,EP=0});var vp={};Se(vp,{getTrace:()=>f0,isKeyword:()=>DP,isProperty:()=>BP,isType:()=>MP});function f0(e){function t(o){return o===null?!1:o.type==="Type"||o.type==="Property"||o.type==="Keyword"}function n(o){if(Array.isArray(o.match)){for(let i=0;i<o.match.length;i++)if(n(o.match[i]))return t(o.syntax)&&r.unshift(o.syntax),!0}else if(o.node===e)return r=t(o.syntax)?[o.syntax]:[],!0;return!1}let r=null;return this.matched!==null&&n(this.matched),r}function MP(e,t){return wp(this,e,n=>n.type==="Type"&&n.name===t)}function BP(e,t){return wp(this,e,n=>n.type==="Property"&&n.name===t)}function DP(e){return wp(this,e,t=>t.type==="Keyword")}function wp(e,t,n){let r=f0.call(e,t);return r===null?!1:r.some(n)}var m0=$(()=>{"use strict"});function h0(e){return"node"in e?e.node:h0(e.match[0])}function x0(e){return"node"in e?e.node:x0(e.match[e.match.length-1])}function kp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=h0(a),c=x0(a);e.syntax.walk(t,function(l,d,g){if(l===u){let p=new er;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:g,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var y0=$(()=>{"use strict";vs()});function Cp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function b0(e){return!!e&&Cp(e.offset)&&Cp(e.line)&&Cp(e.column)}function RP(e,t){return function(r,o){if(!r||r.constructor!==Object)return o(r,"Type of node should be an Object");for(let i in r){let s=!0;if(Rs.call(r,i)!==!1){if(i==="type")r.type!==e&&o(r,"Wrong node type `"+r.type+"`, expected `"+e+"`");else if(i==="loc"){if(r.loc===null)continue;if(r.loc&&r.loc.constructor===Object)if(typeof r.loc.source!="string")i+=".source";else if(!b0(r.loc.start))i+=".start";else if(!b0(r.loc.end))i+=".end";else continue;s=!1}else if(t.hasOwnProperty(i)){s=!1;for(let a=0;!s&&a<t[i].length;a++){let u=t[i][a];switch(u){case String:s=typeof r[i]=="string";break;case Boolean:s=typeof r[i]=="boolean";break;case null:s=r[i]===null;break;default:typeof u=="string"?s=r[i]&&r[i].type===u:Array.isArray(u)&&(s=r[i]instanceof er)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Rs.call(t,i)&&Rs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function S0(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o===String||o===Boolean)n.push(o.name.toLowerCase());else if(o===null)n.push("null");else if(typeof o=="string")n.push(o);else if(Array.isArray(o))n.push("List<"+(S0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function zP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Rs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=S0(s,e+"."+i)}return{docs:o,check:RP(e,r)}}function w0(e){let t={};if(e.node){for(let n in e.node)if(Rs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=zP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Rs,v0=$(()=>{"use strict";vs();({hasOwnProperty:Rs}=Object.prototype)});function Tp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:Ti(e[o].syntax,{compact:t}));return r}function NP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:Ti(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Tp(i.descriptors,t,n)};return r}function OP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function _P(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function Ir(e,t,n){return{matched:e,iterations:n,error:t,...vp}}function Mi(e,t,n,r){let o=r0(n,e.syntax),i;return OP(o)?Ir(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=Sp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=Sp(o,t.match,e),!i.match)?Ir(null,new Tb(i.reason,t.syntax,n,i),i.iterations):Ir(i.match,null,i.iterations))}var zs,k0=$(()=>{"use strict";Ib();vl();kl();_b();$b();mp();o0();xp();g0();m0();y0();v0();zs=class{constructor(t,n,r){if(this.cssWideKeywords=Ei,this.syntax=n,this.generic=!1,this.units={...Il},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||w0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(Il))Array.isArray(t.units[o])&&(this.units[o]=t.units[o]);if(t.types)for(let[o,i]of Object.entries(t.types))this.addType_(o,i);if(t.generic){this.generic=!0;for(let[o,i]of Object.entries(Ob(this.units)))this.addType_(o,i)}if(t.atrules)for(let[o,i]of Object.entries(t.atrules))this.addAtrule_(o,i);if(t.properties)for(let[o,i]of Object.entries(t.properties))this.addProperty_(o,i)}this.cssWideKeywordsSyntax=Ds(this.cssWideKeywords.join(" | "))}checkStructure(t){function n(i,s){o.push({node:i,message:s})}let r=this.structure,o=[];return this.syntax.walk(t,function(i){r.hasOwnProperty(i.type)?r[i.type].check(i,n):n(i,"Unknown node type `"+i.type+"`")}),o.length?o:!1}createDescriptor(t,n,r,o=null){let i={type:n,name:r},s={type:n,name:r,parent:o,serializable:typeof t=="string"||t&&typeof t.type=="string",syntax:null,match:null,matchRef:null};return typeof t=="function"?s.match=Ds(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ls(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Ds(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=_P(a)?Ds({...a,terms:[a.terms[0].term]},i):null;return Object.defineProperty(s,"matchRef",{value:u}),u}})),s}addAtrule_(t,n){n&&(this.atrules[t]={type:"Atrule",name:t,prelude:n.prelude?this.createDescriptor(n.prelude,"AtrulePrelude",t):null,descriptors:n.descriptors?Object.keys(n.descriptors).reduce((r,o)=>(r[o]=this.createDescriptor(n.descriptors[o],"AtruleDescriptor",o,t),r),Object.create(null)):null})}addProperty_(t,n){n&&(this.properties[t]=this.createDescriptor(n,"Property",t))}addType_(t,n){n&&(this.types[t]=this.createDescriptor(n,"Type",t))}checkAtruleName(t){if(!this.getAtrule(t))return new Ii("Unknown at-rule","@"+t)}checkAtrulePrelude(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t);if(!o.prelude&&n)return new SyntaxError("At-rule `@"+t+"` should not contain a prelude");if(o.prelude&&!n&&!Mi(this,o.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+t+"` should contain a prelude")}checkAtruleDescriptorName(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t),i=Sl(n);if(!o.descriptors)return new SyntaxError("At-rule `@"+t+"` has no known descriptors");if(!o.descriptors[i.name]&&!o.descriptors[i.basename])return new Ii("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new Ii("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Ir(null,r);let o=this.getAtrule(t);return o.prelude?Mi(this,o.prelude,n||"",!1):Ir(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Ir(null,o);let i=this.getAtrule(t),s=Sl(n);return Mi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Ir(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(qu(t).custom)return Ir(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Ir(null,r):Mi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Mi(this,r,n,!1):Ir(null,new Ii("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Ir(null,new Ii("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Mi(this,t,n,!1))}findValueFragments(t,n,r,o){return kp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return kp(this,t.value,this.matchDeclaration(t),n,r)}findAllFragments(t,n,r){let o=[];return this.syntax.walk(t,{visit:"Declaration",enter:i=>{o.push.apply(o,this.findDeclarationValueFragments(i,n,r))}}),o}getAtrule(t,n=!0){let r=Sl(t);return(r.vendor&&n?this.atrules[r.name]||this.atrules[r.basename]:this.atrules[r.name])||null}getAtrulePrelude(t,n=!0){let r=this.getAtrule(t,n);return r&&r.prelude||null}getAtruleDescriptor(t,n){return this.atrules.hasOwnProperty(t)&&this.atrules.declarators&&this.atrules[t].declarators[n]||null}getProperty(t,n=!0){let r=qu(t);return(r.vendor&&n?this.properties[r.name]||this.properties[r.basename]:this.properties[r.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(u,c){return c?`<${u}>`:`<'${u}'>`}function n(u,c,l,d){if(l.has(c))return l.get(c);l.set(c,!1),d.syntax!==null&&fp(d.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let p=g.type==="Type"?u.types:u.properties,m=g.type==="Type"?o:i;hasOwnProperty.call(p,g.name)?n(u,g.name,m,p[g.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:Tp(this.types,!n,t),properties:Tp(this.properties,!n,t),atrules:NP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function Ip(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function $P(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function Fp(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?$P(i,n):i};return r}function Ns(e,t){let n={...e};for(let[r,o]of Object.entries(t))switch(r){case"generic":n[r]=!!o;break;case"cssWideKeywords":n[r]=e[r]?[...e[r],...o]:o||[];break;case"units":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=Array.isArray(s)?s:[];break;case"atrules":n[r]={...e[r]};for(let[i,s]of Object.entries(o)){let a=n[r][i]||{},u=n[r][i]={prelude:a.prelude||null,descriptors:{...a.descriptors}};if(s){u.prelude=s.prelude?Ip(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?Ip(u.descriptors[c],l):null;Object.keys(u.descriptors).length||(u.descriptors=null)}}break;case"types":case"properties":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=Ip(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Fp(e[r],o);break;case"atrule":case"pseudo":n[r]=Fp(e[r],o,["parse"]);break;case"node":n[r]=Fp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var C0=$(()=>{"use strict"});function T0(e){let t=$y(e),n=vb(e),r=fb(e),{fromPlainObject:o,toPlainObject:i}=hb(n),s={lexer:null,createLexer:a=>new zs(a,s,s.lexer.structure),tokenize:vo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Ns({},e);return T0(typeof a=="function"?a(u):Ns(u,a))}};return s.lexer=new zs({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var I0,F0=$(()=>{"use strict";ur();Uy();mb();xb();kb();k0();C0();I0=e=>T0(Ns({},e))});var E0,A0=$(()=>{"use strict";E0={generic:!0,cssWideKeywords:["initial","inherit","unset","revert","revert-layer"],units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","an+b":"odd|even|<integer>|<n-dimension>|'+'? \u2020 n|-n|<ndashdigit-dimension>|'+'? \u2020 <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? \u2020 n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? \u2020 n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? \u2020 n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>","anchor()":"anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )","anchor-name":"<dashed-ident>","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [<anchor-name>||<anchor-size>]? , <length-percentage>? )","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>|<zero>","angular-color-stop":"<color> <color-stop-angle>?","angular-color-stop-list":"<angular-color-stop> , [<angular-color-hint>? , <angular-color-stop>]#?","animateable-feature":"scroll-position|contents|<custom-ident>","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <attr-type>? , <declaration-value>? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( <syntax> )|raw-string|number|<attr-unit>","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>","basic-shape-rect":"<inset()>|<rect()>|<xywh()>","bg-clip":"<visual-box>|border-area|text","bg-image":"<image>|none","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage [0,\u221E]>|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( <length>? )","brightness()":"brightness( [<number>|<percentage>]? )","calc()":"calc( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-size()":"calc-size( <calc-size-basis> , <calc-sum> )","calc-size-basis":"<intrinsic-size-keyword>|<calc-size()>|any|<calc-sum>","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( <radial-size>? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>","color()":"color( <colorspace-params> [/ [<alpha-value>|none]]? )","color-base":"<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent","color-function":"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>","color-interpolation-method":"in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]","color-mix()":"color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"[<angle-percentage>|<zero>]{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"<linear-color-stop> , [<linear-color-hint>? , <linear-color-stop>]#?","colorspace-params":"[<predefined-rgb-params>|<xyz-params>]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":"<complex-selector-unit> [<combinator>? <complex-selector-unit>]*","complex-selector-list":"<complex-selector>#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>*]!","compound-selector-list":"<compound-selector>#","conic-gradient()":"conic-gradient( [<conic-gradient-syntax>] )","conic-gradient-syntax":"[[[from [<angle>|<zero>]]? [at <position>]?]||<color-interpolation-method>]? , <angular-color-stop-list>","container-condition":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","container-name":"<custom-ident>","container-query":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [<number>|<percentage>]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|<superellipse()>","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier()":"cubic-bezier( [<number [0,1]> , <number>]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"<dashed-ident>","custom-params":"<dashed-ident> [<number>|<percentage>|none]+",dasharray:"[[<length-percentage>|<number>]+]#","dashndashdigit-ident":"<ident-token>","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [<color>?&&<length>{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&<percentage [0,100]>]#{2,} )","easing-function":"<linear-easing-function>|<cubic-bezier-easing-function>|<step-easing-function>","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( <radial-size>? [at <position>]? )","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-value-list":"[<filter-function>|<url>]+","final-bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>||<'background-color'>","fit-content()":"fit-content( <length-percentage [0,\u221E]> )","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|<number [1,1000]>","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"<frequency>|<percentage>","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[<function-token> <any-value>? )]|[( <any-value>? )]","generic-family":"<generic-script-specific>|<generic-complete>|<generic-incomplete>|<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( [<number>|<percentage>]? )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hsla()":"hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",hue:"<number>|<angle>","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [<angle>|<zero>]? )","hwb()":"hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( [<number>|<percentage>]? )","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-selector":"from|to|<percentage [0,100]>|<timeline-range-name> <percentage>","keyframes-name":"<custom-ident>|<string>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","light-dark()":"light-dark( <color> , <color> )","line-name-list":"[<line-names>|<name-repeat>]+","line-names":"'[' <custom-ident>* ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear()":"linear( [<number>&&<percentage>{0,2}]# )","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-easing-function":"linear|<linear()>","linear-gradient()":"linear-gradient( [<linear-gradient-syntax>] )","linear-gradient-syntax":"[[<angle>|<zero>|to <side-or-corner>]||<color-interpolation-method>]? , <color-stop-list>","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","n-dimension":"<dimension-token>","name-repeat":"repeat( [<integer [1,\u221E]>|auto-fill] , <line-names>+ )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"<ident>","ndash-dimension":"<dimension-token>","ndashdigit-dimension":"<dimension-token>","ndashdigit-ident":"<ident-token>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"<ray()>|<url>|<basic-shape>","oklab()":"oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","oklch()":"oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","opacity()":"opacity( [<number>|<percentage>]? )","opacity-value":"<number>|<percentage>","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"<length>|<percentage>","overflow-position":"unsafe|safe","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-selector-list":"[<page-selector>#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke","paint()":"paint( <ident> , <declaration-value>? )","paint-box":"<visual-box>|fill-box|stroke-box","palette-identifier":"<dashed-ident>","palette-mix()":"palette-mix( <color-interpolation-method> , [[normal|light|dark|<palette-identifier>|<palette-mix()>]&&<percentage [0,100]>?]#{2} )","path()":"path( <'fill-rule'>? , <string> )","perspective()":"perspective( [<length [0,\u221E]>|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( <calc-sum> , <calc-sum> )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":"<predefined-rgb> [<number>|<percentage>|none]{3}","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>|<legacy-pseudo-element-selector>","pseudo-page":": [left|right|first|blank]","query-in-parens":"( <container-condition> )|( <size-feature> )|style( <style-query> )|<general-enclosed>",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [<radial-gradient-syntax>] )","radial-gradient-syntax":"[[[<radial-shape>||<radial-size>]? [at <position>]?]||<color-interpolation-method>]? , <color-stop-list>","radial-shape":"circle|ellipse","radial-size":"<radial-extent>|<length [0,\u221E]>|<length-percentage [0,\u221E]>{2}",ratio:"<number [0,\u221E]> [/ <number [0,\u221E]>]?","ray()":"ray( <angle>&&<ray-size>?&&contain?&&[at <position>]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [<length-percentage>|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [<conic-gradient-syntax>] )","repeating-linear-gradient()":"repeating-linear-gradient( [<linear-gradient-syntax>] )","repeating-radial-gradient()":"repeating-radial-gradient( [<radial-gradient-syntax>] )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rgba()":"rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [<number>|<percentage>]? )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )","scope-end":"<forgiving-selector-list>","scope-start":"<forgiving-selector-list>","scroll()":"scroll( [<scroller>||<axis>]? )",scroller:"root|nearest|self","scroll-state-feature":"<media-query-list>","scroll-state-in-parens":"( <scroll-state-query> )|( <scroll-state-feature> )|<general-enclosed>","scroll-state-query":"not <scroll-state-in-parens>|<scroll-state-in-parens> [[and <scroll-state-in-parens>]*|[or <scroll-state-in-parens>]*]|<scroll-state-feature>","selector-list":"<complex-selector-list>","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [<number>|<percentage>]? )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<visual-box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( <calc-sum> )","signed-integer":"<number-token>","signless-integer":"<number-token>","sin()":"sin( <calc-sum> )","single-animation":"<'animation-duration'>||<easing-function>||<'animation-delay'>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]||<single-animation-timeline>","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<dashed-ident>|<scroll()>|<view()>","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>||<transition-behavior-value>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","size-feature":"<mf-plain>|<mf-boolean>|<mf-range>","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-easing-function":"step-start|step-end|<steps()>","steps()":"steps( <integer> , <step-position>? )","style-feature":"<declaration>","style-in-parens":"( <style-condition> )|( <style-feature> )|<general-enclosed>","style-query":"<style-condition>|<style-feature>","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","superellipse()":"superellipse( [<number>|infinity|-infinity] )","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-decl":"( <declaration> )","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","symbols()":"symbols( <symbols-type>? [<string>|<image>]+ )","symbols-type":"cyclic|numeric|alphabetic|symbolic|fixed","system-color":"AccentColor|AccentColorText|ActiveText|ButtonBorder|ButtonFace|ButtonText|Canvas|CanvasText|Field|FieldText|GrayText|Highlight|HighlightText|LinkText|Mark|MarkText|SelectedItem|SelectedItemText|VisitedText","system-family-name":"caption|icon|menu|message-box|small-caption|status-bar","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","text-edge":"[text|cap|ex|ideographic|ideographic-ink] [text|alphabetic|ideographic|ideographic-ink]?","time-percentage":"<time>|<percentage>","timeline-range-name":"cover|contain|entry|exit|entry-crossing|exit-crossing","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","transition-behavior-value":"normal|allow-discrete","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","try-size":"most-width|most-height|most-block-size|most-inline-size","try-tactic":"flip-block||flip-inline||flip-start","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","view()":"view( [<axis>||<'view-timeline-inset'>]? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","xywh()":"xywh( <length-percentage>{2} <length-percentage [0,\u221E]>{2} [round <'border-radius'>]? )",xyz:"xyz|xyz-d50|xyz-d65","xyz-params":"<xyz-space> [<number>|<percentage>|none]{3}","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"overlay|-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-size":"intrinsic|min-intrinsic|-webkit-fill-available|-webkit-fit-content|-webkit-min-content|-webkit-max-content|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>",autospace:"no-autospace|[ideograph-alpha||ideograph-numeric||punctuation]||[insert|replace]",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral","generic-script-specific":"generic( kai )|generic( fangsong )|generic( nastaliq )","-non-standard-generic-family":"-apple-system|BlinkMacSystemFont","intrinsic-size-keyword":"min-content|max-content|fit-content",left:"<length>|auto","device-cmyk()":"<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>","legacy-device-cmyk-syntax":"device-cmyk( <number>#{4} )","modern-device-cmyk-syntax":"device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )","cmyk-component":"<number>|<percentage>|none","color-space":"<rectangular-color-space>|<polar-color-space>|<custom-color-space>",right:"<length>|auto","forgiving-selector-list":"<complex-real-selector-list>","forgiving-relative-selector-list":"<relative-real-selector-list>","complex-real-selector-list":"<complex-real-selector>#","simple-selector-list":"<simple-selector>#","relative-real-selector-list":"<relative-real-selector>#","complex-selector-unit":"[<compound-selector>? <pseudo-compound-selector>*]!","complex-real-selector":"<compound-selector> [<combinator>? <compound-selector>]*","relative-real-selector":"<combinator>? <complex-real-selector>","pseudo-compound-selector":"<pseudo-element-selector> <pseudo-class-selector>*","simple-selector":"<type-selector>|<subclass-selector>","legacy-pseudo-element-selector":"':' [before|after|first-line|first-letter]","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,\u221E]>","xyz-space":"xyz|xyz-d50|xyz-d65","style-condition":"not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box","inset-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]",syntax:"'*'|<syntax-component> [<syntax-combinator> <syntax-component>]*|<syntax-string>","syntax-component":"<syntax-single-component> <syntax-multiplier>?|'<' transform-list '>'","syntax-single-component":"'<' <syntax-type-name> '>'|<ident>","syntax-type-name":"angle|color|custom-ident|image|integer|length|length-percentage|number|percentage|resolution|string|time|url|transform-function","syntax-combinator":"'|'","syntax-multiplier":"'#'|'+'","syntax-string":"<string>"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-content-zooming":"none|zoom","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<visual-box>|border|padding|content|text]||[<visual-box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<coord-box>|no-clip|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<coord-box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","-webkit-user-select":"auto|none|text|all","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]|anchor-center","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>|anchor-center","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",all:"initial|inherit|unset|revert|revert-layer","anchor-name":"none|<dashed-ident>#","anchor-scope":"none|all|<dashed-ident>#",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"[auto|<time [0s,\u221E]>]#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-range":"[<'animation-range-start'> <'animation-range-end'>?]#","animation-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-timeline":"<single-animation-timeline>#","animation-timing-function":"<easing-function>#","animation-trigger":"[none|[<dashed-ident> <animation-action>+]+]#",appearance:"none|auto|<compat-auto>|<compat-special>","aspect-ratio":"auto||<ratio>","backdrop-filter":"none|<filter-value-list>","backface-visibility":"visible|hidden",background:"<bg-layer>#? , <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<visual-box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline|sub|super|<svg-length>","baseline-source":"auto|first|last","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-block-start'>","border-block-color":"<'border-top-color'>{1,2}","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-block-style":"<'border-top-style'>{1,2}","border-block-width":"<'border-top-width'>{1,2}","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"separate|collapse","border-color":"<color>{1,4}","border-end-end-radius":"<'border-top-left-radius'>","border-end-start-radius":"<'border-top-left-radius'>","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length [0,\u221E]>|<number [0,\u221E]>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"[<number [0,\u221E]>|<percentage [0,\u221E]>]{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage [0,\u221E]>|<number [0,\u221E]>|auto]{1,4}","border-inline":"<'border-block-start'>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-inline-style":"<'border-top-style'>{1,2}","border-inline-width":"<'border-top-width'>{1,2}","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage [0,\u221E]>{1,4} [/ <length-percentage [0,\u221E]>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length>{1,2}","border-start-end-radius":"<'border-top-left-radius'>","border-start-start-radius":"<'border-top-left-radius'>","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"auto|<length-percentage>|<anchor()>|<anchor-size()>","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom",caret:"<'caret-color'>||<'caret-animation'>||<'caret-shape'>","caret-animation":"auto|manual","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none","clip-rule":"nonzero|evenodd",color:"<color>","color-interpolation-filters":"auto|sRGB|linearRGB","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance","column-gap":"normal|<length-percentage>","column-height":"auto|<length [0,\u221E]>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"auto|<length [0,\u221E]>","column-wrap":"auto|nowrap|wrap",columns:"[<'column-width'>||<'column-count'>] [/ <'column-height'>]?",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-block-size":"auto? [none|<length>]","contain-intrinsic-height":"auto? [none|<length>]","contain-intrinsic-inline-size":"auto? [none|<length>]","contain-intrinsic-size":"[auto? [none|<length>]]{1,2}","contain-intrinsic-width":"auto? [none|<length>]",container:"<'container-name'> [/ <'container-type'>]?","container-name":"none|<custom-ident>+","container-type":"normal||[size|inline-size]",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>|<attr()>]+]?","content-visibility":"visible|auto|hidden","corner-block-end-shape":"<corner-shape-value>{1,2}","corner-block-start-shape":"<corner-shape-value>{1,2}","corner-bottom-shape":"<corner-shape-value>{1,2}","corner-bottom-left-shape":"<corner-shape-value>","corner-bottom-right-shape":"<corner-shape-value>","corner-end-end-shape":"<corner-shape-value>","corner-end-start-shape":"<corner-shape-value>","corner-inline-end-shape":"<corner-shape-value>{1,2}","corner-inline-start-shape":"<corner-shape-value>{1,2}","corner-left-shape":"<corner-shape-value>{1,2}","corner-right-shape":"<corner-shape-value>{1,2}","corner-shape":"<corner-shape-value>{1,4}","corner-start-start-shape":"<corner-shape-value>","corner-start-end-shape":"<corner-shape-value>","corner-top-shape":"<corner-shape-value>{1,2}","corner-top-left-shape":"<corner-shape-value>","corner-top-right-shape":"<corner-shape-value>","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",cx:"<length>|<percentage>",cy:"<length>|<percentage>",d:"none|path( <string> )",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge","dynamic-range-limit":"standard|no-limit|constrained|<dynamic-range-limit-mix()>","empty-cells":"show|hide","field-sizing":"content|fixed",fill:"<paint>","fill-opacity":"<number-zero-one>|<percentage>","fill-rule":"nonzero|evenodd",filter:"none|<filter-value-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end","flood-color":"<color>","flood-opacity":"<'opacity'>",font:"[[<'font-style'>||<font-variant-css2>||<'font-weight'>||<font-width-css3>]? <'font-size'> [/ <'line-height'>]? <'font-family'>#]|<system-family-name>|<-non-standard-font>","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-palette":"normal|light|dark|<palette-identifier>|<palette-mix()>","font-size":"<absolute-size>|<relative-size>|<length-percentage [0,\u221E]>|math","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps||position]","font-synthesis-position":"auto|none","font-synthesis-small-caps":"auto|none","font-synthesis-style":"auto|none","font-synthesis-weight":"auto|none","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-emoji":"normal|text|emoji|unicode","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>|bolder|lighter","font-width":"normal|<percentage [0,\u221E]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","forced-color-adjust":"auto|none|preserve-parent-color",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","hyphenate-character":"auto|<string>","hyphenate-limit-chars":"[auto|<integer>]{1,3}",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|smooth|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>","interpolate-size":"numeric-only|allow-keywords",isolation:"auto|isolate",interactivity:"auto|inert","interest-delay":"<'interest-delay-start'>{1,2}","interest-delay-end":"normal|<time>","interest-delay-start":"normal|<time>","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]|anchor-center","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|anchor-center","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"auto|<length-percentage>|<anchor()>|<anchor-size()>","letter-spacing":"normal|<length-percentage>","lighting-color":"<color>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"<'margin-top'>{1,4}","margin-block":"<'margin-top'>{1,2}","margin-block-end":"<'margin-top'>","margin-block-start":"<'margin-top'>","margin-bottom":"<length-percentage>|auto|<anchor-size()>","margin-inline":"<'margin-top'>{1,2}","margin-inline-end":"<'margin-top'>","margin-inline-start":"<'margin-top'>","margin-left":"<length-percentage>|auto|<anchor-size()>","margin-right":"<length-percentage>|auto|<anchor-size()>","margin-top":"<length-percentage>|auto|<anchor-size()>","margin-trim":"none|in-flow|all",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<coord-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<coord-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-block-size":"<'min-width'>","min-height":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-inline-size":"<'min-width'>","min-width":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","mix-blend-mode":"<blend-mode>|plus-darker|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>","object-view-box":"none|<basic-shape-rect>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|<offset-path>||<coord-box>","offset-position":"normal|auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<opacity-value>",order:"<integer>",orphans:"<integer>",outline:"<'outline-width'>||<'outline-style'>||<'outline-color'>","outline-color":"auto|<color>","outline-offset":"<length>","outline-style":"auto|<outline-line-style>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,\u221E]>","overflow-inline":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-y":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>",overlay:"none|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"<'padding-top'>{1,4}","padding-block":"<'padding-top'>{1,2}","padding-block-end":"<'padding-top'>","padding-block-start":"<'padding-top'>","padding-bottom":"<length-percentage [0,\u221E]>","padding-inline":"<'padding-top'>{1,2}","padding-inline-end":"<'padding-top'>","padding-inline-start":"<'padding-top'>","padding-left":"<length-percentage [0,\u221E]>","padding-right":"<length-percentage [0,\u221E]>","padding-top":"<length-percentage [0,\u221E]>",page:"auto|<custom-ident>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky","position-anchor":"auto|none|<anchor-name>","position-area":"none|<position-area>","position-try":"<'position-try-order'>? <'position-try-fallbacks'>","position-try-fallbacks":"none|[[<dashed-ident>||<try-tactic>]|<'position-area'>]#","position-try-order":"normal|<try-size>","position-visibility":"always|[anchors-valid||anchors-visible||no-overflow]","print-color-adjust":"economy|exact",quotes:"none|auto|[<string> <string>]+",r:"<length>|<percentage>","reading-flow":"normal|source-order|flex-visual|flex-flow|grid-rows|grid-columns|grid-order","reading-order":"<integer>",resize:"none|both|horizontal|vertical|block|inline",right:"auto|<length-percentage>|<anchor()>|<anchor-size()>",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-overhang":"auto|none","ruby-position":"[alternate||[over|under]]|inter-character",rx:"<length>|<percentage>",ry:"<length>|<percentage>",scale:"none|[<number>|<percentage>]{1,3}","scroll-behavior":"auto|smooth","scroll-initial-target":"none|nearest","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-end":"<length>","scroll-margin-block-start":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-end":"<length>","scroll-margin-inline-start":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-marker-group":"none|before|after","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-target-group":"none|auto","scroll-timeline":"[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#","scroll-timeline-axis":"[block|inline|x|y]#","scroll-timeline-name":"[none|<dashed-ident>]#","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","shape-image-threshold":"<opacity-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]","stop-color":"<'color'>","stop-opacity":"<'opacity'>",stroke:"<paint>","stroke-color":"<color>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<'opacity'>","stroke-width":"<svg-length>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-anchor":"start|middle|end","text-autospace":"normal|<autospace>|auto","text-box":"normal|<'text-box-trim'>||<'text-box-edge'>","text-box-edge":"auto|<text-edge>","text-box-trim":"none|trim-start|trim-end|trim-both","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-inset":"<length>{1,2}|auto","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"auto|[over|under]&&[right|left]?","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-spacing-trim":"space-all|normal|space-first|trim-start","text-transform":"none|[capitalize|uppercase|lowercase]||full-width||full-size-kana|math-auto","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]","text-wrap":"<'text-wrap-mode'>||<'text-wrap-style'>","text-wrap-mode":"wrap|nowrap","text-wrap-style":"auto|balance|stable|pretty","timeline-scope":"none|<dashed-ident>#","timeline-trigger":"none|[<'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-range'> ['/' <'timeline-trigger-exit-range'>]?]#","timeline-trigger-name":"none|<dashed-ident>#","timeline-trigger-exit-range":"[<'timeline-trigger-exit-range-start'> <'timeline-trigger-exit-range-end'>?]#","timeline-trigger-exit-range-end":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-exit-range-start":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range":"[<'timeline-trigger-range-start'> <'timeline-trigger-range-end'>?]#","timeline-trigger-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-source":"<single-animation-timeline>#",top:"auto|<length-percentage>|<anchor()>|<anchor-size()>","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-behavior":"<transition-behavior-value>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","trigger-scope":"none|all|<dashed-ident>#","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|all","vector-effect":"none|non-scaling-stroke|non-scaling-size|non-rotation|fixed-position","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>","view-timeline":"[<'view-timeline-name'> [<'view-timeline-axis'>||<'view-timeline-inset'>]?]#","view-timeline-axis":"[block|inline|x|y]#","view-timeline-inset":"[[auto|<length-percentage>]{1,2}]#","view-timeline-name":"[none|<dashed-ident>]#","view-transition-class":"none|<custom-ident>+","view-transition-name":"none|<custom-ident>|match-element",visibility:"visible|hidden|collapse","white-space":"normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>","white-space-collapse":"collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",widows:"<integer>",width:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word|auto-phrase","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",x:"<length>|<percentage>",y:"<length>|<percentage>","z-index":"auto|<integer>",zoom:"normal|reset|<number [0,\u221E]>||<percentage [0,\u221E]>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<visual-box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto",behavior:"<url>+",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong","position-try-options":"<'position-try-fallbacks'>",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong",speak:"auto|never|always","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]","white-space-trim":"none|discard-before||discard-after||discard-inner"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer [0,\u221E]>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer [0,\u221E]>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},container:{prelude:"[<container-name>]? <container-condition>",descriptors:null},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"auto|block|swap|fallback|optional","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>{1,2}","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},"font-palette-values":{prelude:"<dashed-ident>",descriptors:{"base-palette":"light|dark|<integer [0,\u221E]>","font-family":"<family-name>#","override-colors":"[<integer [0,\u221E]> <color>]#"}},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]","page-orientation":"upright|rotate-left|rotate-right",size:"<length [0,\u221E]>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},"position-try":{prelude:"<dashed-ident>",descriptors:{top:"<'top'>",left:"<'left'>",bottom:"<'bottom'>",right:"<'right'>","inset-block-start":"<'inset-block-start'>","inset-block-end":"<'inset-block-end'>","inset-inline-start":"<'inset-inline-start'>","inset-inline-end":"<'inset-inline-end'>","inset-block":"<'inset-block'>","inset-inline":"<'inset-inline'>",inset:"<'inset'>","margin-top":"<'margin-top'>","margin-left":"<'margin-left'>","margin-bottom":"<'margin-bottom'>","margin-right":"<'margin-right'>","margin-block-start":"<'margin-block-start'>","margin-block-end":"<'margin-block-end'>","margin-inline-start":"<'margin-inline-start'>","margin-inline-end":"<'margin-inline-end'>",margin:"<'margin'>","margin-block":"<'margin-block'>","margin-inline":"<'margin-inline'>",width:"<'width'>",height:"<'height'>","min-width":"<'min-width'>","min-height":"<'min-height'>","max-width":"<'max-width'>","max-height":"<'max-height'>","block-size":"<'block-size'>","inline-size":"<'inline-size'>","min-block-size":"<'min-block-size'>","min-inline-size":"<'min-inline-size'>","max-block-size":"<'max-block-size'>","max-inline-size":"<'max-inline-size'>","align-self":"<'align-self'>|anchor-center","justify-self":"<'justify-self'>|anchor-center"}},property:{prelude:"<custom-property-name>",descriptors:{inherits:"true|false","initial-value":"<declaration-value>?",syntax:"<string>"}},scope:{prelude:"[( <scope-start> )]? [to ( <scope-end> )]?",descriptors:null},"starting-style":{prelude:null,descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},"view-transition":{prelude:null,descriptors:{navigation:"auto|none",types:"none|<custom-ident>+"}},"font-features-values":{prelude:"[<string>|<custom-ident>]+",descriptors:{"font-display":"auto|block|swap|fallback|optional"}}}}});var Pp={};Se(Pp,{generate:()=>WP,name:()=>jP,parse:()=>Ap,structure:()=>HP});function Dl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===$r||r===tr)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Ht(this.charCodeAt(n))||this.error("Integer is expected",n)}function Bi(e){return Dl.call(this,0,e)}function To(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Bl:n="N is expected";break;case tr:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Ep(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim($r,e)||this.isDelim(tr,e)){t=this.isDelim($r,e)?$r:tr;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Bi.call(this,Qo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==$r&&n!==tr&&this.error("Number sign is expected")),Bi.call(this,t!==0),t===tr?"-"+this.consume(10):this.consume(10)}function Ap(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Bi.call(this,UP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,tr))switch(t="-1",To.call(this,1,Bl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Ep.call(this);break;case 3:To.call(this,2,tr),this.next(),this.skipSC(),Bi.call(this,Qo),n="-"+this.consume(10);break;default:To.call(this,2,tr),Dl.call(this,3,Qo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim($r)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim($r)&&(r=1,this.next()),To.call(this,0,Bl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Ep.call(this);break;case 2:To.call(this,1,tr),this.next(),this.skipSC(),Bi.call(this,Qo),n="-"+this.consume(10);break;default:To.call(this,1,tr),Dl.call(this,2,Qo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===$r||r===tr,i=this.tokenStart+o;for(;i<this.tokenEnd&&Ht(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),To.call(this,i-this.tokenStart,Bl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Ep.call(this)):(To.call(this,i-this.tokenStart+1,tr),i+2===this.tokenEnd?(this.next(),this.skipSC(),Bi.call(this,Qo),n="-"+this.consume(10)):(Dl.call(this,i-this.tokenStart+2,Qo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===$r&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===$r&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function WP(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let n=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+n)}else this.tokenize(t)}else this.tokenize(e.b)}var $r,tr,Bl,Qo,UP,jP,HP,Lp=$(()=>{"use strict";ur();$r=43,tr=45,Bl=110,Qo=!0,UP=!1;jP="AnPlusB",HP={a:[String,null],b:[String,null]}});var Bp={};Se(Bp,{generate:()=>KP,name:()=>GP,parse:()=>Mp,structure:()=>YP,walkContext:()=>qP});function P0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function VP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function Mp(e=!1){let t=this.tokenStart,n,r,o=null,i=null;switch(this.eat(3),n=this.substrToCursor(t+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,n,e),P0):o=P0.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?i=this.atrule[r].block.call(this,e):i=this.Block(VP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function KP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var GP,qP,YP,Dp=$(()=>{"use strict";GP="Atrule",qP="atrule",YP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var zp={};Se(zp,{generate:()=>ZP,name:()=>XP,parse:()=>Rp,structure:()=>JP,walkContext:()=>QP});function Rp(e){let t=null;return e!==null&&(e=e.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,e)&&typeof this.atrule[e].prelude=="function"?t=this.atrule[e].prelude.call(this):t=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==23&&this.tokenType!==17&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function ZP(e){this.children(e)}var XP,QP,JP,Np=$(()=>{"use strict";XP="AtrulePrelude",QP="atrulePrelude",JP={children:[[]]}});var $p={};Se($p,{generate:()=>a2,name:()=>i2,parse:()=>_p,structure:()=>s2});function r2(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(L0)?(t=!0,this.next()):this.isDelim(Op)||this.eat(1),this.isDelim(Op)?this.charCodeAt(this.tokenStart+1)!==Rl?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function o2(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Rl&&t!==n2&&t!==t2&&t!==e2&&t!==L0&&t!==Op&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Rl&&(this.isDelim(Rl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function _p(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=r2.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=o2.call(this),this.skipSC(),r=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:n,value:r,flags:o}}function a2(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}var e2,L0,Rl,t2,Op,n2,i2,s2,Up=$(()=>{"use strict";e2=36,L0=42,Rl=61,t2=94,Op=124,n2=126;i2="AttributeSelector",s2={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Hp={};Se(Hp,{generate:()=>g2,name:()=>u2,parse:()=>jp,structure:()=>d2,walkContext:()=>p2});function D0(){return this.Raw(null,!0)}function M0(){return this.parseWithFallback(this.Rule,D0)}function B0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function c2(){if(this.tokenType===17)return B0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,B0);return this.tokenType===17&&this.next(),e}function jp(e){let t=e?c2:M0,n=this.tokenStart,r=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:r.push(this.parseWithFallback(this.Atrule.bind(this,e),D0));break;default:e&&this.isDelim(l2)?r.push(M0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function g2(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var l2,u2,p2,d2,Wp=$(()=>{"use strict";l2=38;u2="Block",p2="block",d2={children:[["Atrule","Rule","Declaration"]]}});var Gp={};Se(Gp,{generate:()=>h2,name:()=>f2,parse:()=>Vp,structure:()=>m2});function Vp(e,t){let n=this.tokenStart,r=null;return this.eat(19),r=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function h2(e){this.token(9,"["),this.children(e),this.token(9,"]")}var f2,m2,qp=$(()=>{"use strict";f2="Brackets",m2={children:[[]]}});var Kp={};Se(Kp,{generate:()=>b2,name:()=>x2,parse:()=>Yp,structure:()=>y2});function Yp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function b2(){this.token(15,"-->")}var x2,y2,Xp=$(()=>{"use strict";x2="CDC",y2=[]});var Jp={};Se(Jp,{generate:()=>v2,name:()=>S2,parse:()=>Qp,structure:()=>w2});function Qp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function v2(){this.token(14,"<!--")}var S2,w2,Zp=$(()=>{"use strict";S2="CDO",w2=[]});var td={};Se(td,{generate:()=>I2,name:()=>C2,parse:()=>ed,structure:()=>T2});function ed(){return this.eatDelim(k2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function I2(e){this.token(9,"."),this.token(1,e.name)}var k2,C2,T2,nd=$(()=>{"use strict";k2=46,C2="ClassSelector",T2={name:String}});var od={};Se(od,{generate:()=>M2,name:()=>P2,parse:()=>rd,structure:()=>L2});function rd(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case E2:case F2:case A2:this.next();break;case R0:this.next(),this.eatIdent("deep"),this.eatDelim(R0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function M2(e){this.tokenize(e.name)}var F2,R0,E2,A2,P2,L2,id=$(()=>{"use strict";F2=43,R0=47,E2=62,A2=126,P2="Combinator",L2={name:String}});var ad={};Se(ad,{generate:()=>N2,name:()=>R2,parse:()=>sd,structure:()=>z2});function sd(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===B2&&this.charCodeAt(t-1)===D2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function N2(e){this.token(25,"/*"+e.value+"*/")}var B2,D2,R2,z2,ld=$(()=>{"use strict";B2=42,D2=47,R2="Comment",z2={value:String}});var ud={};Se(ud,{generate:()=>j2,name:()=>_2,parse:()=>cd,structure:()=>$2});function z0(e){return this.lookupTypeNonSC(1)===1&&O2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function cd(e="media"){let t=this.createList();e:for(;!this.eof;)switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t.push(this.Identifier());break;case 21:{let n=this.parseWithFallback(()=>U2[e].call(this,e),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(21);let r=this.Condition(e);return this.eat(22),r},()=>this.GeneralEnclosed(e))),t.push(n);break}case 2:{let n=this.parseWithFallback(()=>this.FeatureFunction(e),()=>null);n||(n=this.GeneralEnclosed(e)),t.push(n);break}default:break e}return t.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(t),kind:e,children:t}}function j2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var O2,_2,$2,U2,pd=$(()=>{"use strict";O2=new Set([16,22,0]),_2="Condition",$2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};U2={media:z0,container:z0,supports(){return this.SupportsDeclaration()}}});var gd={};Se(gd,{generate:()=>eL,name:()=>Q2,parse:()=>dd,structure:()=>Z2,walkContext:()=>J2});function Y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function K2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function X2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(O0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function dd(){let e=this.tokenStart,t=this.tokenIndex,n=tL.call(this),r=wl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?K2:Y2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(X2,i):a=i.call(this,this.tokenIndex),r&&a.type==="Value"&&a.children.isEmpty){for(let c=u-this.tokenIndex;c<=0;c++)if(this.lookupType(c)===13){a.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(O0)&&(s=nL.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==17&&this.isBalanceEdge(t)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:s,property:n,value:a}}function eL(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function tL(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case G2:case W2:case q2:case H2:case V2:this.next();break;case N0:this.next(),this.isDelim(N0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function nL(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var O0,H2,W2,V2,G2,q2,N0,Q2,J2,Z2,fd=$(()=>{"use strict";vl();O0=33,H2=35,W2=36,V2=38,G2=42,q2=43,N0=47;Q2="Declaration",J2="declaration",Z2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var xd={};Se(xd,{generate:()=>sL,name:()=>oL,parse:()=>hd,structure:()=>iL});function md(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function hd(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;case 3:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),md));break;default:this.isDelim(rL)?e.push(this.parseWithFallback(this.Rule,md)):e.push(this.parseWithFallback(this.Declaration,md))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function sL(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var rL,oL,iL,yd=$(()=>{"use strict";rL=38;oL="DeclarationList",iL={children:[["Declaration","Atrule","Rule"]]}});var Sd={};Se(Sd,{generate:()=>cL,name:()=>aL,parse:()=>bd,structure:()=>lL});function bd(){let e=this.tokenStart,t=this.consumeNumber(12);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function cL(e){this.token(12,e.value+e.unit)}var aL,lL,wd=$(()=>{"use strict";aL="Dimension",lL={value:String,unit:String}});var kd={};Se(kd,{generate:()=>gL,name:()=>pL,parse:()=>vd,structure:()=>dL});function vd(e){let t=this.tokenStart,n,r=null;if(this.eat(21),this.skipSC(),n=this.consume(1),this.skipSC(),this.tokenType!==22){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:this.lookupNonWSType(1)===9?r=this.Ratio():r=this.Number();break;case 12:r=this.Dimension();break;case 1:r=this.Identifier();break;case 2:r=this.parseWithFallback(()=>{let o=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(uL)&&this.error(),o},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(22),{type:"Feature",loc:this.getLocation(t,this.tokenStart),kind:e,name:n,value:r}}function gL(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var uL,pL,dL,Cd=$(()=>{"use strict";uL=47,pL="Feature",dL={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var Id={};Se(Id,{generate:()=>xL,name:()=>fL,parse:()=>Td,structure:()=>mL});function hL(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function Td(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=hL.call(this,e,n.toLowerCase());this.skipSC();let o=this.parseWithFallback(()=>{let i=this.tokenIndex,s=r.call(this);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),s},()=>this.Raw(null,!1));return this.eof||this.eat(22),{type:"FeatureFunction",loc:this.getLocation(t,this.tokenStart),kind:e,feature:n,value:o}}function xL(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var fL,mL,Fd=$(()=>{"use strict";fL="FeatureFunction",mL={kind:String,feature:String,value:["Declaration","Selector"]}});var Pd={};Se(Pd,{generate:()=>vL,name:()=>SL,parse:()=>Ad,structure:()=>wL});function Ed(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(_0,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case 12:return this.Dimension();case 1:return this.Identifier();case 2:return this.parseWithFallback(()=>{let e=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(_0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function U0(e){if(this.skipSC(),this.isDelim(yL)||this.isDelim(bL)){let t=this.source[this.tokenStart];return this.next(),this.isDelim($0)?(this.next(),t+"="):t}if(this.isDelim($0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Ad(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Ed.call(this),r=U0.call(this,n.type==="Identifier"),o=Ed.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=U0.call(this),s=Ed.call(this)),this.skipSC(),this.eat(22),{type:"FeatureRange",loc:this.getLocation(t,this.tokenStart),kind:e,left:n,leftComparison:r,middle:o,rightComparison:i,right:s}}function vL(e){this.token(21,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(22,")")}var _0,yL,$0,bL,SL,wL,Ld=$(()=>{"use strict";_0=47,yL=60,$0=61,bL=62,SL="FeatureRange",wL={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]}});var Bd={};Se(Bd,{generate:()=>IL,name:()=>kL,parse:()=>Md,structure:()=>TL,walkContext:()=>CL});function Md(e,t){let n=this.tokenStart,r=this.consumeFunctionName(),o=r.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:i}}function IL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var kL,CL,TL,Dd=$(()=>{"use strict";kL="Function",CL="function",TL={name:String,children:[[]]}});var zd={};Se(zd,{generate:()=>AL,name:()=>FL,parse:()=>Rd,structure:()=>EL});function Rd(e){let t=this.tokenStart,n=null;this.tokenType===2?n=this.consumeFunctionName():this.eat(21);let r=this.parseWithFallback(()=>{let o=this.tokenIndex,i=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),i},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(22),{type:"GeneralEnclosed",loc:this.getLocation(t,this.tokenStart),kind:e,function:n,children:r}}function AL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var FL,EL,Nd=$(()=>{"use strict";FL="GeneralEnclosed",EL={kind:String,function:[String,null],children:[[]]}});var _d={};Se(_d,{generate:()=>BL,name:()=>LL,parse:()=>Od,structure:()=>ML,xxx:()=>PL});function Od(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function BL(e){this.token(4,"#"+e.value)}var PL,LL,ML,$d=$(()=>{"use strict";PL="XXX",LL="Hash",ML={value:String}});var jd={};Se(jd,{generate:()=>zL,name:()=>DL,parse:()=>Ud,structure:()=>RL});function Ud(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function zL(e){this.token(1,e.name)}var DL,RL,Hd=$(()=>{"use strict";DL="Identifier",RL={name:String}});var Vd={};Se(Vd,{generate:()=>_L,name:()=>NL,parse:()=>Wd,structure:()=>OL});function Wd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function _L(e){this.token(9,"#"+e.name)}var NL,OL,Gd=$(()=>{"use strict";NL="IdSelector",OL={name:String}});var Yd={};Se(Yd,{generate:()=>HL,name:()=>UL,parse:()=>qd,structure:()=>jL});function qd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim($L);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function HL(e){this.tokenize(e.name)}var $L,UL,jL,Kd=$(()=>{"use strict";$L=46,UL="Layer",jL={name:String}});var Qd={};Se(Qd,{generate:()=>GL,name:()=>WL,parse:()=>Xd,structure:()=>VL});function Xd(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.Layer()),this.lookupTypeNonSC(0)===18);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(e),children:e}}function GL(e){this.children(e,()=>this.token(18,","))}var WL,VL,Jd=$(()=>{"use strict";WL="LayerList",VL={children:[["Layer"]]}});var eg={};Se(eg,{generate:()=>KL,name:()=>qL,parse:()=>Zd,structure:()=>YL});function Zd(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function KL(e){e.mediaType?(e.modifier&&this.token(1,e.modifier),this.token(1,e.mediaType),e.condition&&(this.token(1,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}var qL,YL,tg=$(()=>{"use strict";qL="MediaQuery",YL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var rg={};Se(rg,{generate:()=>JL,name:()=>XL,parse:()=>ng,structure:()=>QL});function ng(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===18);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function JL(e){this.children(e,()=>this.token(18,","))}var XL,QL,og=$(()=>{"use strict";XL="MediaQueryList",QL={children:[["MediaQuery"]]}});var sg={};Se(sg,{generate:()=>nM,name:()=>eM,parse:()=>ig,structure:()=>tM});function ig(){let e=this.tokenStart;return this.eatDelim(ZL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function nM(){this.token(9,"&")}var ZL,eM,tM,ag=$(()=>{"use strict";ZL=38,eM="NestingSelector",tM={}});var cg={};Se(cg,{generate:()=>iM,name:()=>rM,parse:()=>lg,structure:()=>oM});function lg(){this.skipSC();let e=this.tokenStart,t=e,n=null,r;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?r=this.Identifier():r=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:r,selector:n}}function iM(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var rM,oM,ug=$(()=>{"use strict";rM="Nth",oM={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var dg={};Se(dg,{generate:()=>lM,name:()=>sM,parse:()=>pg,structure:()=>aM});function pg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function lM(e){this.token(10,e.value)}var sM,aM,gg=$(()=>{"use strict";sM="Number",aM={value:String}});var mg={};Se(mg,{generate:()=>pM,name:()=>cM,parse:()=>fg,structure:()=>uM});function fg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function pM(e){this.tokenize(e.value)}var cM,uM,hg=$(()=>{"use strict";cM="Operator",uM={value:String}});var yg={};Se(yg,{generate:()=>fM,name:()=>dM,parse:()=>xg,structure:()=>gM});function xg(e,t){let n=this.tokenStart,r=null;return this.eat(21),r=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function fM(e){this.token(21,"("),this.children(e),this.token(22,")")}var dM,gM,bg=$(()=>{"use strict";dM="Parentheses",gM={children:[[]]}});var wg={};Se(wg,{generate:()=>xM,name:()=>mM,parse:()=>Sg,structure:()=>hM});function Sg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function xM(e){this.token(11,e.value+"%")}var mM,hM,vg=$(()=>{"use strict";mM="Percentage",hM={value:String}});var Cg={};Se(Cg,{generate:()=>wM,name:()=>yM,parse:()=>kg,structure:()=>SM,walkContext:()=>bM});function kg(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function wM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var yM,bM,SM,Tg=$(()=>{"use strict";yM="PseudoClassSelector",bM="function",SM={name:String,children:[["Raw"],null]}});var Fg={};Se(Fg,{generate:()=>TM,name:()=>vM,parse:()=>Ig,structure:()=>CM,walkContext:()=>kM});function Ig(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function TM(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var vM,kM,CM,Eg=$(()=>{"use strict";vM="PseudoElementSelector",kM="function",CM={name:String,children:[["Raw"],null]}});var Pg={};Se(Pg,{generate:()=>EM,name:()=>IM,parse:()=>Ag,structure:()=>FM});function H0(){switch(this.skipSC(),this.tokenType){case 10:return this.Number();case 2:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}function Ag(){let e=this.tokenStart,t=H0.call(this),n=null;return this.skipSC(),this.isDelim(j0)&&(this.eatDelim(j0),n=H0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function EM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var j0,IM,FM,Lg=$(()=>{"use strict";j0=47;IM="Ratio",FM={left:["Number","Function"],right:["Number","Function",null]}});var Bg={};Se(Bg,{generate:()=>MM,name:()=>PM,parse:()=>Mg,structure:()=>LM});function AM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Mg(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=AM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function MM(e){this.tokenize(e.value)}var PM,LM,Dg=$(()=>{"use strict";PM="Raw",LM={value:String}});var zg={};Se(zg,{generate:()=>NM,name:()=>DM,parse:()=>Rg,structure:()=>zM,walkContext:()=>RM});function W0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function BM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Rg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(BM,W0):n=W0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function NM(e){this.node(e.prelude),this.node(e.block)}var DM,RM,zM,Ng=$(()=>{"use strict";DM="Rule",RM="rule",zM={prelude:["SelectorList","Raw"],block:["Block"]}});var _g={};Se(_g,{generate:()=>$M,name:()=>OM,parse:()=>Og,structure:()=>_M});function Og(){let e=null,t=null;this.skipSC();let n=this.tokenStart;return this.tokenType===21&&(this.next(),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),this.lookupNonWSType(0)===1&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(21),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:e,limit:t}}function $M(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}var OM,_M,$g=$(()=>{"use strict";OM="Scope",_M={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var jg={};Se(jg,{generate:()=>HM,name:()=>UM,parse:()=>Ug,structure:()=>jM});function Ug(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function HM(e){this.children(e)}var UM,jM,Hg=$(()=>{"use strict";UM="Selector",jM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Vg={};Se(Vg,{generate:()=>qM,name:()=>WM,parse:()=>Wg,structure:()=>GM,walkContext:()=>VM});function Wg(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function qM(e){this.children(e,()=>this.token(18,","))}var WM,VM,GM,Gg=$(()=>{"use strict";WM="SelectorList",VM="selector",GM={children:[["Selector","Raw"]]}});function zl(e){let t=e.length,n=e.charCodeAt(0),r=n===V0||n===G0?1:0,o=r===1&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,i="";for(let s=r;s<=o;s++){let a=e.charCodeAt(s);if(a===qg){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Dn(qg,a)){let u=s-1,c=Qr(e,u);s=c-1,i+=il(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function q0(e,t){let n=t?"'":'"',r=t?G0:V0,o="",i=!1;for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);if(a===0){o+="\uFFFD";continue}if(a<=31||a===127){o+="\\"+a.toString(16),i=!0;continue}a===r||a===qg?(o+="\\"+e.charAt(s),i=!1):(i&&(Rn(a)||Or(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var qg,V0,G0,Nl=$(()=>{"use strict";ur();qg=92,V0=34,G0=39});var Kg={};Se(Kg,{generate:()=>XM,name:()=>YM,parse:()=>Yg,structure:()=>KM});function Yg(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:zl(this.consume(5))}}function XM(e){this.token(5,q0(e.value))}var YM,KM,Xg=$(()=>{"use strict";Nl();YM="String",KM={value:String}});var Jg={};Se(Jg,{generate:()=>tB,name:()=>JM,parse:()=>Qg,structure:()=>eB,walkContext:()=>ZM});function K0(){return this.Raw(null,!1)}function Qg(){let e=this.tokenStart,t=this.createList(),n;for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==QM){this.next();continue}n=this.Comment();break;case 14:n=this.CDO();break;case 15:n=this.CDC();break;case 3:n=this.parseWithFallback(this.Atrule,K0);break;default:n=this.parseWithFallback(this.Rule,K0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function tB(e){this.children(e)}var QM,JM,ZM,eB,Zg=$(()=>{"use strict";QM=33;JM="StyleSheet",ZM="stylesheet",eB={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var tf={};Se(tf,{generate:()=>oB,name:()=>nB,parse:()=>ef,structure:()=>rB});function ef(){let e=this.tokenStart;this.eat(21),this.skipSC();let t=this.Declaration();return this.eof||this.eat(22),{type:"SupportsDeclaration",loc:this.getLocation(e,this.tokenStart),declaration:t}}function oB(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var nB,rB,nf=$(()=>{"use strict";nB="SupportsDeclaration",rB={declaration:"Declaration"}});var sf={};Se(sf,{generate:()=>lB,name:()=>sB,parse:()=>of,structure:()=>aB});function rf(){this.tokenType!==1&&this.isDelim(iB)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function of(){let e=this.tokenStart;return this.isDelim(X0)?(this.next(),rf.call(this)):(rf.call(this),this.isDelim(X0)&&(this.next(),rf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function lB(e){this.tokenize(e.name)}var iB,X0,sB,aB,af=$(()=>{"use strict";iB=42,X0=124;sB="TypeSelector",aB={name:String}});var uf={};Se(uf,{generate:()=>gB,name:()=>pB,parse:()=>cf,structure:()=>dB});function Os(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===J0&&t&&n!==0)return Os.call(this,e+n+1,!1),-1;Rn(o)||this.error(t&&n!==0?"Hyphen minus"+(n<6?" or hex digit":"")+" is expected":n<6?"Hex digit is expected":"Unexpected input",r),++n>6&&this.error("Too many hex digits",r)}return this.next(),n}function Ol(e){let t=0;for(;this.isDelim(lf);)++t>e&&this.error("Too many question marks"),this.next()}function cB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===Q0?"Plus sign":"Hyphen minus")+" is expected")}function uB(){let e=0;switch(this.tokenType){case 10:if(e=Os.call(this,1,!0),this.isDelim(lf)){Ol.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){cB.call(this,J0),Os.call(this,1,!1);break}break;case 12:e=Os.call(this,1,!0),e>0&&Ol.call(this,6-e);break;default:if(this.eatDelim(Q0),this.tokenType===1){e=Os.call(this,0,!0),e>0&&Ol.call(this,6-e);break}if(this.isDelim(lf)){this.next(),Ol.call(this,5);break}this.error("Hex digit or question mark is expected")}}function cf(){let e=this.tokenStart;return this.eatIdent("u"),uB.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function gB(e){this.tokenize(e.value)}var Q0,J0,lf,pB,dB,pf=$(()=>{"use strict";ur();Q0=43,J0=45,lf=63;pB="UnicodeRange",dB={value:String}});function eS(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===Z0?t-2:t-1,o="";for(;n<r&&Or(e.charCodeAt(n));)n++;for(;n<r&&Or(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===df){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Dn(df,s)){let a=i-1,u=Qr(e,a);i=u-1,o+=il(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function tS(e){let t="",n=!1;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===0){t+="\uFFFD";continue}if(o<=31||o===127){t+="\\"+o.toString(16),n=!0;continue}o===fB||o===df||o===mB||o===hB||o===xB||o===Z0?(t+="\\"+e.charAt(r),n=!1):(n&&Rn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var fB,df,mB,hB,xB,Z0,gf=$(()=>{"use strict";ur();fB=32,df=92,mB=34,hB=39,xB=40,Z0=41});var mf={};Se(mf,{generate:()=>SB,name:()=>yB,parse:()=>ff,structure:()=>bB});function ff(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=eS(this.consume(7));break;case 2:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(2),this.skipSC(),t=zl(this.consume(5)),this.skipSC(),this.eof||this.eat(22);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(e,this.tokenStart),value:t}}function SB(e){this.token(7,tS(e.value))}var yB,bB,hf=$(()=>{"use strict";gf();Nl();yB="Url",bB={value:String}});var yf={};Se(yf,{generate:()=>kB,name:()=>wB,parse:()=>xf,structure:()=>vB});function xf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function kB(e){this.children(e)}var wB,vB,bf=$(()=>{"use strict";wB="Value",vB={children:[[]]}});var wf={};Se(wf,{generate:()=>FB,name:()=>TB,parse:()=>Sf,structure:()=>IB});function Sf(){return this.eat(13),CB}function FB(e){this.token(13,e.value)}var CB,TB,IB,vf=$(()=>{"use strict";CB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),TB="WhiteSpace",IB={value:String}});var _s={};Se(_s,{AnPlusB:()=>Pp,Atrule:()=>Bp,AtrulePrelude:()=>zp,AttributeSelector:()=>$p,Block:()=>Hp,Brackets:()=>Gp,CDC:()=>Kp,CDO:()=>Jp,ClassSelector:()=>td,Combinator:()=>od,Comment:()=>ad,Condition:()=>ud,Declaration:()=>gd,DeclarationList:()=>xd,Dimension:()=>Sd,Feature:()=>kd,FeatureFunction:()=>Id,FeatureRange:()=>Pd,Function:()=>Bd,GeneralEnclosed:()=>zd,Hash:()=>_d,IdSelector:()=>Vd,Identifier:()=>jd,Layer:()=>Yd,LayerList:()=>Qd,MediaQuery:()=>eg,MediaQueryList:()=>rg,NestingSelector:()=>sg,Nth:()=>cg,Number:()=>dg,Operator:()=>mg,Parentheses:()=>yg,Percentage:()=>wg,PseudoClassSelector:()=>Cg,PseudoElementSelector:()=>Fg,Ratio:()=>Pg,Raw:()=>Bg,Rule:()=>zg,Scope:()=>_g,Selector:()=>jg,SelectorList:()=>Vg,String:()=>Kg,StyleSheet:()=>Jg,SupportsDeclaration:()=>tf,TypeSelector:()=>sf,UnicodeRange:()=>uf,Url:()=>mf,Value:()=>yf,WhiteSpace:()=>wf});var kf=$(()=>{"use strict";Lp();Dp();Np();Up();Wp();qp();Xp();Zp();nd();id();ld();pd();fd();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tg();og();ag();ug();gg();hg();bg();vg();Tg();Eg();Lg();Dg();Ng();$g();Hg();Gg();Xg();Zg();nf();af();pf();hf();bf();vf()});var rS,oS=$(()=>{"use strict";kl();A0();kf();rS={generic:!0,cssWideKeywords:Ei,...E0,node:_s}});function $s(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,MB)&&this.cmpChar(this.tokenStart+1,iS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===LB||t===AB||t===iS||t===PB)return this.Operator();t===EB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var EB,AB,iS,PB,LB,MB,Cf=$(()=>{"use strict";EB=35,AB=42,iS=43,PB=45,LB=47,MB=117});var sS,aS=$(()=>{"use strict";Cf();sS={getNode:$s}});function UB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function jB(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===lS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case zB:case OB:case $B:case NB:return this.Combinator();case lS:return this.ClassSelector();case RB:case _B:return this.TypeSelector();case BB:return this.IdSelector();case DB:return this.NestingSelector()}break}}}var BB,DB,RB,zB,NB,lS,OB,_B,$B,cS,uS=$(()=>{"use strict";BB=35,DB=38,RB=42,zB=43,NB=47,lS=46,OB=62,_B=124,$B=126;cS={onWhiteSpace:UB,getNode:jB}});function pS(){return this.createSingleNodeList(this.Raw(null,!1))}var dS=$(()=>{"use strict"});function gS(){let e=this.createList();if(this.skipSC(),e.push(this.Identifier()),this.skipSC(),this.tokenType===18){e.push(this.Operator());let t=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let r=t-this.tokenIndex;r<=0;r++)if(this.lookupType(r)===13){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}e.push(n)}return e}var fS=$(()=>{"use strict"});function mS(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var hS,xS=$(()=>{"use strict";Cf();dS();fS();hS={getNode:$s,onWhiteSpace(e,t){mS(e)&&(e.value=" "+e.value),mS(t.last)&&(t.last.value+=" ")},expression:pS,var:gS}});var Tf={};Se(Tf,{AtrulePrelude:()=>sS,Selector:()=>cS,Value:()=>hS});var yS=$(()=>{"use strict";aS();uS();xS()});var HB,bS,SS=$(()=>{"use strict";HB=new Set(["none","and","not","or"]),bS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);HB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var wS,vS=$(()=>{"use strict";wS={parse:{prelude:null,block(){return this.Block(!0)}}}});function If(e,t){return this.parseWithFallback(()=>{try{return e.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==22&&this.error()}},t||(()=>this.Raw(null,!0)))}var kS,CS,TS=$(()=>{"use strict";kS={layer(){this.skipSC();let e=this.createList(),t=If.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=If.call(this,this.Declaration,()=>If.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},CS={parse:{prelude(){let e=this.createList();switch(this.tokenType){case 5:e.push(this.String());break;case 7:case 2:e.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===1&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?e.push(this.Identifier()):this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&e.push(this.Function(null,kS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,kS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var IS,FS=$(()=>{"use strict";IS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var ES,AS=$(()=>{"use strict";ES={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var PS,LS=$(()=>{"use strict";PS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var MS,BS=$(()=>{"use strict";MS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var DS,RS=$(()=>{"use strict";DS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var zS,NS=$(()=>{"use strict";zS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var OS,_S=$(()=>{"use strict";OS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var $S,US=$(()=>{"use strict";SS();vS();TS();FS();AS();LS();BS();RS();NS();_S();$S={container:bS,"font-face":wS,import:CS,layer:IS,media:ES,nest:PS,page:MS,scope:DS,"starting-style":zS,supports:OS}});function jS(){let e=this.createList();this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 1:e.push(this.Identifier());break;case 5:e.push(this.String());break;case 18:e.push(this.Operator());break;case 22:break e;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return e}var HS=$(()=>{"use strict"});var Jo,Ff,WB,VB,_l,WS,VS=$(()=>{"use strict";HS();Jo={parse(){return this.createSingleNodeList(this.SelectorList())}},Ff={parse(){return this.createSingleNodeList(this.Selector())}},WB={parse(){return this.createSingleNodeList(this.Identifier())}},VB={parse:jS},_l={parse(){return this.createSingleNodeList(this.Nth())}},WS={dir:WB,has:Jo,lang:VB,matches:Jo,is:Jo,"-moz-any":Jo,"-webkit-any":Jo,where:Jo,not:Jo,"nth-child":_l,"nth-last-child":_l,"nth-last-of-type":_l,"nth-of-type":_l,slotted:Ff,host:Ff,"host-context":Ff}});var Ef={};Se(Ef,{AnPlusB:()=>Ap,Atrule:()=>Mp,AtrulePrelude:()=>Rp,AttributeSelector:()=>_p,Block:()=>jp,Brackets:()=>Vp,CDC:()=>Yp,CDO:()=>Qp,ClassSelector:()=>ed,Combinator:()=>rd,Comment:()=>sd,Condition:()=>cd,Declaration:()=>dd,DeclarationList:()=>hd,Dimension:()=>bd,Feature:()=>vd,FeatureFunction:()=>Td,FeatureRange:()=>Ad,Function:()=>Md,GeneralEnclosed:()=>Rd,Hash:()=>Od,IdSelector:()=>Wd,Identifier:()=>Ud,Layer:()=>qd,LayerList:()=>Xd,MediaQuery:()=>Zd,MediaQueryList:()=>ng,NestingSelector:()=>ig,Nth:()=>lg,Number:()=>pg,Operator:()=>fg,Parentheses:()=>xg,Percentage:()=>Sg,PseudoClassSelector:()=>kg,PseudoElementSelector:()=>Ig,Ratio:()=>Ag,Raw:()=>Mg,Rule:()=>Rg,Scope:()=>Og,Selector:()=>Ug,SelectorList:()=>Wg,String:()=>Yg,StyleSheet:()=>Qg,SupportsDeclaration:()=>ef,TypeSelector:()=>of,UnicodeRange:()=>cf,Url:()=>ff,Value:()=>xf,WhiteSpace:()=>Sf});var GS=$(()=>{"use strict";Lp();Dp();Np();Up();Wp();qp();Xp();Zp();nd();id();ld();pd();fd();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tg();og();ag();ug();gg();hg();bg();vg();Tg();Eg();Lg();Dg();Ng();$g();Hg();Gg();Xg();Zg();nf();af();pf();hf();bf();vf()});var qS,YS=$(()=>{"use strict";yS();US();VS();GS();qS={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(e){return this.AtrulePrelude(e.atrule?String(e.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(e){return this.Condition(e.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:Tf,atrule:$S,pseudo:WS,node:Ef}});var KS,XS=$(()=>{"use strict";kf();KS={node:_s}});var QS,JS=$(()=>{"use strict";F0();oS();YS();XS();QS=I0({...rS,...qS,...KS})});var ZS=$(()=>{"use strict"});var ew=$(()=>{"use strict"});var bY,tw,SY,wY,vY,nw,kY,CY,TY,IY,FY,EY,rw=$(()=>{"use strict";JS();ZS();mp();vl();ew();Nl();gf();({tokenize:bY,parse:tw,generate:SY,lexer:wY,createLexer:vY,walk:nw,find:kY,findLast:CY,findAll:TY,toPlainObject:IY,fromPlainObject:FY,fork:EY}=QS)});function KB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function iw(e){try{let t=tw(e.trim(),{context:"value"}),n=[];return nw(t,{enter(r){if(r.type==="Dimension"){let o=parseFloat(r.value);n.push(`${o}${r.unit}`)}else if(r.type==="Number"){let o=parseFloat(r.value);n.push(`${o}`)}else r.type==="Percentage"?n.push(`${parseFloat(r.value)}%`):r.type==="Identifier"?n.push(r.name.toLowerCase()):r.type==="Hash"?n.push(`#${r.value.toLowerCase()}`):r.type}}),n}catch{return[e.trim().toLowerCase()]}}function XB(e,t){let n=KB(e);if(!YB.has(n))return t;let r=iw(t);if(r.length<1||r.length>4)return t;let o=r.map(i=>i==="0"?"0px":i);return o.length===1?`${o[0]} ${o[0]} ${o[0]} ${o[0]}`:o.length===2?`${o[0]} ${o[1]} ${o[0]} ${o[1]}`:o.length===3?`${o[0]} ${o[1]} ${o[2]} ${o[1]}`:o.join(" ")}function ow(e,t){let n=t.trim();if(!n)return"";let r=XB(e,n);return iw(r).map(i=>i==="0"?"0px":i).join(" ")}function sw(e,t,n){let r=ow(e,t),o=ow(e,n);return r!==""&&o!==""&&r===o}var YB,aw=$(()=>{"use strict";rw();YB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function QB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function JB(e){let t=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(!t)return null;let n=parseInt(t[1],10).toString(16).padStart(2,"0"),r=parseInt(t[2],10).toString(16).padStart(2,"0"),o=parseInt(t[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`}function lw(e){let t=typeof e=="string"?e:String(e??"");if(!t||t==="[object Object]")return"";let n=t.match(/rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)/);if(n){let i=JB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return QB(r[0]);let o=t.match(/(-?\d+\.?\d*)(px|em|rem|%|pt|vw|vh)?/g);return o&&o.length>1?o.join(" ").toLowerCase():o&&o.length===1?o[0].toLowerCase():t.toLowerCase().trim().replace(/\s+/g," ")}function Zo(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),s=o.toLowerCase(),a=i.includes("none"),u=s.includes("none");if(a!==u)return!1;let c=/\b(fill|stroke)\s*:/i,l=c.test(r),d=c.test(o);if(l!==d)return!1;let g=lw(r),p=lw(o);return!!(g===p||n&&sw(n,r,o))}var Af=$(()=>{"use strict";aw()});function rD(e){let t=String(e.property||"").toLowerCase(),n=String(e.description||"").toLowerCase(),r=String(e.expected||e.suggestedValue||"").toLowerCase(),o=String(e.actual||e.currentValue||"").toLowerCase();if(t.includes("color")||t.includes("fill")||t.includes("background")||n.includes("color")||n.includes("fill"))return!0;let i=s=>/^#[0-9a-f]{3,8}$/i.test(s)||s.includes("rgb")||["white","black","red","blue","green","orange","yellow","transparent"].includes(s);return!!(i(r)||i(o)||e.relatedProperties?.some(s=>{let a=s.property?.toLowerCase()||"";return a.includes("color")||a.includes("fill")||a.includes("background")}))}function cw(e){if(e.includes("\xD7")||/\d+px\s*x\s*\d+px/i.test(e))return!1;let t=e.match(/\d+px/g);return t?t.length>1:!1}function oD(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase(),r=String(e.property||"").toLowerCase(),o=String(e.description||"").toLowerCase(),i=n.includes("margin")||t.includes("margin")||r==="margin",s=t.includes("gap")||o.includes("gap");return i&&s}function iD(e,t,n){if(!e||!t)return!1;let r=typeof e=="string"?e:String(e??""),o=typeof t=="string"?t:String(t??"");if(!r||!o||r==="[object Object]"||o==="[object Object]"||n&&rD(n)||cw(r)||cw(o)||n&&oD(n))return!1;let i=parseFloat(r),s=parseFloat(o);if(isNaN(i)||isNaN(s))return!1;let a=Math.abs(i-s);if(r.includes("px")||o.includes("px")){let u=n?.property?.toLowerCase()||"";return u==="width"||u==="height"||u.includes("width")||u.includes("height")?a<pw:a<uw}return r.includes("%")||o.includes("%")?a<1:!1}function sD(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(nD.some(s=>t.includes(s))||!eD.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Zo(o,i,e.property))}function aD(e){let t=(e.expected!==void 0?"fill":"").toLowerCase(),n=e.actual!==void 0||e.currentValue!==void 0?"fill":"";if(!(t==="fill"||n==="fill"||e.description?.toLowerCase().includes("fill")||e.title?.toLowerCase().includes("fill")))return!1;let o=String(e.expected||e.suggestedValue||"").toLowerCase();if(!(o==="none"||o==="transparent"||o.includes("no fills")||o.includes("transparent")))return!1;let s=`${e.description||""} ${e.title||""}`.toLowerCase();return s.includes("container")||s.includes("svg ")||s.includes("<svg")||s.includes("wrapper")}function lD(e){let t=`${e.description||""} ${e.title||""}`.toLowerCase(),n=e.property?.toLowerCase()||"";if(!(t.includes("text ")||t.includes("text layer")||t.includes("text span")||t.includes("span ")||t.includes("label "))||!(n==="width"||n==="height"||n.includes("width")||n.includes("height")||t.includes("width")||t.includes("height")))return!1;let i=e.expected||e.suggestedValue||"",s=e.actual||e.currentValue||"",a=parseFloat(i),u=parseFloat(s);return isNaN(a)||isNaN(u)?!1:Math.abs(a-u)<dw}function cD(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase(),n=String(e.expected||e.suggestedValue||"").toLowerCase(),r=String(e.actual||e.currentValue||"").toLowerCase();if(!tD.some(d=>t.includes(d)||n.includes(d)))return!1;let i=`${t} ${n} ${r}`;if(i.includes("min-width")||i.includes("max-width")||i.includes("min-height")||i.includes("max-height")||i.includes("explicit")||i.includes("constraint")||i.includes("forced"))return!1;let a=n.includes("hug")||n.includes("auto"),u=/\d+\.?\d*px/.test(r);if(!a||!u)return!1;let c=n.match(/(\d+\.?\d*)px/),l=r.match(/(\d+\.?\d*)px/);return!(c&&l&&Math.abs(parseFloat(c[1])-parseFloat(l[1]))>ZB)}function uD(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase();return(!n||!t||n.includes("see ")||t.includes("see ")||n.includes("image")||t.includes("image"))&&e.type==="visual"}function Us(e){if(e.programmaticallyVerified)return{dismissed:!1};let t=e.expected||e.suggestedValue,n=e.actual||e.currentValue;if(e.fixRequired===!1)return{dismissed:!0,dismissReason:"Auto-dismissed: FixRequired is false (no code change needed)",dismissedBy:"post-ai-validation"};if(Zo(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: expected equals actual (identical values)",dismissedBy:"post-ai-validation"};if(e.fixRequired===!0)return{dismissed:!1};if(lD(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${dw}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(iD(t,n,e)){let r=e.property?.toLowerCase()||"";return{dismissed:!0,dismissReason:`Auto-dismissed: negligible difference (<${r==="width"||r==="height"||r.includes("width")||r.includes("height")?pw:uw}px)`,dismissedBy:"post-ai-validation"}}return uD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:sD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:cD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:aD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var uw,pw,dw,ZB,eD,tD,nD,gw=$(()=>{"use strict";Af();uw=.5,pw=2,dw=2,ZB=5,eD=["values match","values already match","already correct","correctly implemented","implementation is correct","css matches","matches figma","identical","same value","no difference","none - ","no changes needed","no fix needed"],tD=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],nD=["duplicate","extra","missing","additional","removed","should not exist","does not exist","not in figma","not in storybook","renders 2","renders two","has 1","has one"]});function Io(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var fw=$(()=>{"use strict"});var mw=$(()=>{"use strict"});var hw=$(()=>{"use strict"});var Pf=$(()=>{"use strict";Af();gw();fw();mw();hw()});var bD,SD,VY,Lf=$(()=>{"use strict";bD=["flex","inline-flex"],SD=["grid","inline-grid"],VY=[...bD,...SD]});var yw=$(()=>{"use strict";Pf();Lf()});var bw=$(()=>{"use strict"});var _n=$(()=>{"use strict";Cu();ky();Cy();Pf();Lf();yw();bw()});function vD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function nr(e){try{let t=e.map(vD),n=JSON.stringify(t,kD);sessionStorage.setItem(Mf,n)}catch(t){b.error("[SessionStorage] Failed to save review history:",t)}}function Bf(){try{let e=sessionStorage.getItem(Mf);if(!e)return[];let t=JSON.parse(e,CD);return Array.isArray(t)?t:[]}catch(e){return b.error("[SessionStorage] Failed to load review history:",e),[]}}function Sw(){try{let e=Bf();if(e.length===0)return;let t=!1,n=e.map(r=>{if(r.aiPrompt!==void 0||r.aiResponse!==void 0){t=!0;let{aiPrompt:o,aiResponse:i,...s}=r;return s}return r});t&&(nr(n),b.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){b.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function ww(){try{sessionStorage.removeItem(Mf),b.debug("[SessionStorage] Review history cleared")}catch(e){b.error("[SessionStorage] Failed to clear review history:",e)}}function kD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function CD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Mf,Df=$(()=>{"use strict";_e();Mf="uicopilot_review_history"});import TD,{createContext as ID,useContext as FD,useReducer as ED,useMemo as vw,useRef as AD,useEffect as PD}from"react";function $l(e){let t=e.length>kw?e.slice(e.length-kw):e,n=Math.max(0,t.length-LD);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),s=r.figmaImageData?.startsWith("data:");return!i&&!s?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:s?void 0:r.figmaImageData}})}function MD(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"ADD_STREAMING_MESSAGE":return{...e,streamingMessages:[...e.streamingMessages,t.payload]};case"UPDATE_STREAMING_MESSAGE":return{...e,streamingMessages:e.streamingMessages.map((n,r)=>r===t.payload.index?{...n,content:t.payload.content}:n)};case"CLEAR_STREAMING_MESSAGES":return{...e,streamingMessages:[]};case"TOGGLE_MODEL":{let n=e.selectedModels.includes(t.payload);return n&&e.selectedModels.length===1?e:{...e,selectedModels:n?e.selectedModels.filter(r=>r!==t.payload):[...e.selectedModels,t.payload]}}case"SET_REVIEW_RESULTS":{if(!t.payload)return{...e,reviewResults:null,currentReviewId:null};let n=e.userRole==="admin",r={id:t.payload.id,componentId:t.payload.componentId,storyId:t.payload.storyId,modelId:t.payload.modelId,complianceScore:t.payload.complianceScore,issuesCount:t.payload.issuesCount,issues:t.payload.issues,createdAt:t.payload.createdAt,visualSimilarity:t.payload.visualSimilarity,storybookImageData:e.storybookImageUrl||void 0,figmaImageData:e.figmaImageUrl||void 0,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},o=e.reviewHistory.findIndex(s=>s.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((s,a)=>a===o?r:s):i=[...e.reviewHistory,r],i=$l(i),nr(i),{...e,reviewResults:t.payload,reviewHistory:i,currentReviewId:t.payload.id}}case"UPDATE_MULTI_MODEL_STREAMING":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload.modelId]:{...e.multiModelResults.byModel[t.payload.modelId],streamingMessages:t.payload.messages}}}}:{...e,multiModelResults:{byModel:{[t.payload.modelId]:{streamingMessages:t.payload.messages}},activeModelId:t.payload.modelId}};case"SET_MODEL_COMPLETED":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload]:{...e.multiModelResults.byModel[t.payload],completed:!0}}}}:e;case"BULK_ADD_REVIEWS":{let n=new Set(e.reviewHistory.map(i=>i.id)),r=t.payload.filter(i=>!n.has(i.id));if(r.length===0)return e;let o=$l([...e.reviewHistory,...r]);return nr(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=$l([...e.reviewHistory,t.payload]);return nr(n),{...e,reviewHistory:n,currentReviewId:t.payload.id}}case"TOGGLE_ISSUE_SELECTION":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,selectedForFix:!o.selectedForFix}:o)});return nr(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_STATUS":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,status:t.payload.status,error:t.payload.error}:o)});return nr(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_GENERATED_FIX":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,generatedFix:o.generatedFix?{...o.generatedFix,...t.payload.generatedFix}:t.payload.generatedFix,selectedForFix:t.payload.generatedFix?.status==="failed"?!1:o.selectedForFix}:o)});return nr(n),{...e,reviewHistory:n}}case"BATCH_UPDATE_ISSUE_GENERATED_FIXES":{if(!e.currentReviewId)return e;let n=new Map(t.payload.map(o=>[o.issueId,o.generatedFix])),r=e.reviewHistory.map(o=>o.id!==e.currentReviewId?o:{...o,issues:o.issues.map(i=>{let s=n.get(i.id);return s?{...i,generatedFix:i.generatedFix?{...i.generatedFix,...s}:s,selectedForFix:s?.status==="failed"?!1:i.selectedForFix}:i})});return nr(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload.issueId?{...c,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:Io(s,a,u),issuesCount:i.length}});return nr(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload?{...c,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:Io(s,a,u),issuesCount:i.length}});return nr(n),{...e,reviewHistory:n}}case"RECALCULATE_SCORE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.filter(c=>!c.dismissed),i=o.filter(c=>c.severity==="critical").length,s=o.filter(c=>c.severity==="major").length,a=o.filter(c=>c.severity==="minor").length,u=Io(i,s,a);return b.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return nr(n),{...e,reviewHistory:n}}case"UPDATE_REVIEW_SCORE":{let n=e.reviewHistory.map(r=>r.id!==t.payload.reviewId?r:{...r,complianceScore:t.payload.newScore});return nr(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return ww(),{...e,reviewHistory:[],currentReviewId:null};case"CLEAR_STALE_REVIEWS":return{...e,currentReviewId:null,reviewResults:null};case"RESET_REVIEW":{let n=e.isReviewing;return{...e,isReviewing:!1,reviewError:null,reviewResults:n?null:e.reviewResults,multiModelResults:null,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:n?"chat":e.reviewDetailTab,fullPrompt:"",fullResponse:"",figmaImageUrl:n?null:e.figmaImageUrl,storybookImageUrl:n?null:e.storybookImageUrl,currentReviewId:n?null:e.currentReviewId}}case"RESET_PROMPT":return{...e,isGenerating:!1,generatedPrompt:null,promptError:null};case"TRIGGER_SCREENSHOT_REFRESH":return{...e,screenshotRefreshKey:e.screenshotRefreshKey+1};default:return e}}function zf({children:e}){let[t,n]=ED(MD,ND),r=AD(t);PD(()=>{r.current=t},[t]);let o=vw(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewError:s=>n({type:"SET_STATE",payload:{reviewError:s}}),bulkAddReviews:s=>n({type:"BULK_ADD_REVIEWS",payload:s}),setReviewResults:s=>n({type:"SET_REVIEW_RESULTS",payload:s}),setMultiModelResults:s=>n({type:"SET_STATE",payload:{multiModelResults:s}}),updateMultiModelStreamingMessages:(s,a)=>n({type:"UPDATE_MULTI_MODEL_STREAMING",payload:{modelId:s,messages:a}}),setModelCompleted:s=>n({type:"SET_MODEL_COMPLETED",payload:s}),setActiveModelId:s=>{let a=r.current;a.multiModelResults&&n({type:"SET_STATE",payload:{multiModelResults:{...a.multiModelResults,activeModelId:s}}})},setShowReviewMenu:s=>n({type:"SET_STATE",payload:{showReviewMenu:s}}),setSeverityFilter:s=>n({type:"SET_STATE",payload:{severityFilter:s}}),setShowStreamingPanel:s=>n({type:"SET_STATE",payload:{showStreamingPanel:s}}),setStreamingPanelCollapsed:s=>n({type:"SET_STATE",payload:{streamingPanelCollapsed:s}}),addStreamingMessage:s=>n({type:"ADD_STREAMING_MESSAGE",payload:s}),updateStreamingMessage:(s,a)=>n({type:"UPDATE_STREAMING_MESSAGE",payload:{index:s,content:a}}),clearStreamingMessages:()=>n({type:"CLEAR_STREAMING_MESSAGES"}),setStreamingProgress:s=>n({type:"SET_STATE",payload:{streamingProgress:s}}),setStreamingStatus:s=>n({type:"SET_STATE",payload:{streamingStatus:s}}),setReviewDetailTab:s=>n({type:"SET_STATE",payload:{reviewDetailTab:s}}),setFullPrompt:s=>n({type:"SET_STATE",payload:{fullPrompt:s}}),setFullResponse:s=>n({type:"SET_STATE",payload:{fullResponse:s}}),setFigmaImageUrl:s=>n({type:"SET_STATE",payload:{figmaImageUrl:s}}),setStorybookImageUrl:s=>n({type:"SET_STATE",payload:{storybookImageUrl:s}}),setFigmaDimensions:s=>n({type:"SET_STATE",payload:{figmaDimensions:s}}),setSelectedModels:s=>n({type:"SET_STATE",payload:{selectedModels:s}}),toggleModel:s=>n({type:"TOGGLE_MODEL",payload:s}),setModelComparisonView:s=>n({type:"SET_STATE",payload:{modelComparisonView:s}}),resetReview:()=>n({type:"RESET_REVIEW"}),addReview:s=>n({type:"ADD_REVIEW",payload:s}),getCurrentReview:()=>{let s=r.current;return s.currentReviewId&&s.reviewHistory.find(a=>a.id===s.currentReviewId)||null},getReviewById:s=>r.current.reviewHistory.find(a=>a.id===s)||null,getParentReview:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return a?.parentReviewId&&s.reviewHistory.find(u=>u.id===a.parentReviewId)||null},hasAppliedFixes:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return!a||!Array.isArray(a.issues)||a.issues.length===0?!1:a.issues.some(u=>u.status==="applied"||u.generatedFix?.status==="applied")},toggleIssueSelection:s=>n({type:"TOGGLE_ISSUE_SELECTION",payload:s}),updateIssueStatus:(s,a,u)=>n({type:"UPDATE_ISSUE_STATUS",payload:{issueId:s,status:a,error:u}}),updateIssueGeneratedFix:(s,a)=>n({type:"UPDATE_ISSUE_GENERATED_FIX",payload:{issueId:s,generatedFix:a}}),batchUpdateIssueGeneratedFixes:s=>n({type:"BATCH_UPDATE_ISSUE_GENERATED_FIXES",payload:s}),dismissIssue:(s,a,u)=>n({type:"DISMISS_ISSUE",payload:{issueId:s,reason:a,dismissedBy:u}}),undismissIssue:s=>n({type:"UNDISMISS_ISSUE",payload:s}),recalculateScore:()=>n({type:"RECALCULATE_SCORE"}),updateReviewScore:(s,a)=>n({type:"UPDATE_REVIEW_SCORE",payload:{reviewId:s,newScore:a}}),clearAllReviews:()=>n({type:"CLEAR_ALL_REVIEWS"}),clearStaleReviewsForStory:s=>n({type:"CLEAR_STALE_REVIEWS",payload:s}),setIsApplying:s=>n({type:"SET_STATE",payload:{isApplying:s}}),setApplyFixesResult:s=>n({type:"SET_STATE",payload:{applyFixesResult:s}}),setIncludeComponentIssues:s=>n({type:"SET_STATE",payload:{includeComponentIssues:s}}),setIncludeTextComparison:s=>n({type:"SET_STATE",payload:{includeTextComparison:s}}),setUsePromptCache:s=>n({type:"SET_STATE",payload:{usePromptCache:s}}),setIsValidating:s=>n({type:"SET_STATE",payload:{isValidating:s}}),setValidationUsage:s=>n({type:"SET_STATE",payload:{validationUsage:s}}),setWorkspacePath:s=>n({type:"SET_STATE",payload:{workspacePath:s}}),triggerScreenshotRefresh:()=>n({type:"TRIGGER_SCREENSHOT_REFRESH"}),setHoveredIssueId:s=>n({type:"SET_STATE",payload:{hoveredIssueId:s}}),setFeatureFlags:s=>n({type:"SET_STATE",payload:{featureFlags:s}}),setUserRole:s=>n({type:"SET_STATE",payload:{userRole:s}}),setRoleOverride:s=>{try{s?localStorage.setItem("uicopilot_role_override",s):localStorage.removeItem("uicopilot_role_override")}catch{}n({type:"SET_STATE",payload:{roleOverride:s}})},setReviewAllConcurrency:s=>{let a=Math.max(1,Math.min(5,s));try{localStorage.setItem("uicopilot_review_all_concurrency",String(a))}catch{}n({type:"SET_STATE",payload:{reviewAllConcurrency:a}})},setIsGenerating:s=>n({type:"SET_STATE",payload:{isGenerating:s}}),setGeneratedPrompt:s=>n({type:"SET_STATE",payload:{generatedPrompt:s}}),setPromptError:s=>n({type:"SET_STATE",payload:{promptError:s}}),resetPrompt:()=>n({type:"RESET_PROMPT"})}),[]),i=vw(()=>({...t,...o}),[t,o]);return TD.createElement(Cw.Provider,{value:i},e)}function ce(){let e=FD(Cw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var kw,LD,BD,DD,Rf,RD,zD,ND,Cw,Nf=$(()=>{"use strict";_n();Df();_e();kw=20,LD=5;BD=()=>{if(typeof localStorage>"u")return 3;try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3},DD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Rf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},RD=()=>{if(typeof localStorage>"u")return Rf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Rf;let t=JSON.parse(e);return{enableFixGeneration:!!t.enableFixGeneration,enableFixApply:!!t.enableFixApply,enableAutoMap:!!t.enableAutoMap,enableReviewBadges:!!t.enableReviewBadges,showCosts:!!t.showCosts,enableParallelReview:!!t.enableParallelReview,enableModelSelection:!!t.enableModelSelection}}catch{}return Rf},zD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},ND={isReviewing:!1,reviewError:null,reviewResults:null,multiModelResults:null,showReviewMenu:!1,severityFilter:"all",showStreamingPanel:!1,streamingPanelCollapsed:!1,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:"chat",fullPrompt:"",fullResponse:"",figmaImageUrl:null,storybookImageUrl:null,figmaDimensions:null,selectedModels:["claude-sonnet-4-5-20250929"],modelComparisonView:"side-by-side",reviewHistory:$l(Bf()),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:zD(),roleOverride:DD(),featureFlags:RD(),reviewAllConcurrency:BD(),hoveredIssueId:null},Cw=ID(null)});import js,{useMemo as OD}from"react";function _f({children:e}){return js.createElement(yu,null,js.createElement(Su,null,js.createElement(vu,null,js.createElement(zf,null,js.createElement(_D,null),e))))}function Tw(e){let t=ke(),n=Je(),r=nt(),o=ce(),i=OD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function _D(){return Of=Tw(),null}var Of,mt,Iw=$(()=>{"use strict";bu();wu();ku();Nf();Of=null,mt=Object.assign(Tw,{getState:()=>{if(!Of)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Of}})});var Te=$(()=>{"use strict";Iw();bu();wu();ku();Nf()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||$D).replace(/\/$/,"")}var $D,Fw,He=$(()=>{"use strict";$D="https://app.uiparity.com";Fw=3.6});async function ee(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var ct=$(()=>{"use strict"});import{useEffect as ei,useState as jl,useRef as Hw,useCallback as Hf}from"react";import{addons as Wf}from"storybook/manager-api";async function jR(e,t,n){let r=`${e}:${t}`,o=Vf.get(r);if(o)return b.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ee(`${Yw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Vf.delete(r)});return Vf.set(r,i),i}function HR(e,t,n){try{sessionStorage.setItem(`${Hl}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function WR(e,t){try{let n=sessionStorage.getItem(`${Hl}${e}`);if(!n)return null;let r=JSON.parse(n);if(r.figmaNodeId===t&&Date.now()-r.timestamp<1800*1e3)return r.imageUrl;sessionStorage.removeItem(`${Hl}${e}`)}catch{}return null}function VR(e){try{let t=sessionStorage.getItem(`${Hl}${e}`);if(!t)return null;let n=JSON.parse(t);if(n.imageUrl&&Date.now()-n.timestamp<300*1e3)return n.imageUrl}catch{}return null}var Ww,Vw,Gw,qw,Ni,Yw,$n,Gf,Vf,Hl,Kw,Xw,ti,Oi=$(()=>{"use strict";Te();qf();_e();He();ct();Ww="storyArgsUpdated",Vw="storyRendered",Gw="forceRemount",qw=null,Ni=()=>qw,Yw=q(),$n=new Map,Gf=null,Vf=new Map;Hl="uicopilot-figma-image-";Kw=(e,t,n)=>{let r=$n.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):$n.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),b.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},Xw=(e,t,n)=>{Gf=t;let r=$n.get(e);r?r.figmaImageUrl=n:$n.set(e,{storybookImageUrl:null,figmaImageUrl:n}),b.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},ti=()=>{let[e,t]=jl(!1),[n,r]=jl(!1),[o,i]=jl(!1),[s,a]=jl(null),u=Hw(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ce(),d=Hf(()=>{let P=mt.getState().currentStoryId;P&&(b.debug("[useReviewScreenshots] Refreshing screenshots for story:",P),$n.delete(P),u.current=null,i(!0),l())},[l]),g=Hf(()=>{let P=mt.getState().currentStoryId;if(P){b.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",P);let N=$n.get(P);N&&(N.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=ke(),{selectedProjectId:m}=Je(),{currentStoryId:k,currentMapping:I,loadingMapping:A}=nt(),{setStorybookImageUrl:C,setFigmaImageUrl:D}=ce(),R=Hw(null);ei(()=>{k&&R.current&&R.current!==k&&(b.debug("[useReviewScreenshots] Story switched, clearing images"),C(""),D("")),R.current=k},[k,C,D]),ei(()=>{!k||A||I||D("")},[k,I,A,D]),ei(()=>{if(!k)return;let P=VR(k);P&&(b.debug("[useReviewScreenshots] Quick-restored Figma image for:",k),D(P))},[k,D]),ei(()=>{let P=!1;return(async()=>{if(!p||!m||!k){b.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==k&&(b.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),C(""),D(""));let x=mt.getState();if(u.current===k&&x.storybookImageUrl&&x.figmaImageUrl){b.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let v=I?.figmaNodeId??null;if(v!==Gf){b.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",k);let L=$n.get(k);L&&(L.figmaImageUrl=null),Gf=v,u.current=null}let w=I?.figmaNodeId;if(w&&!$n.get(k)?.figmaImageUrl){let L=WR(k,w);if(L){b.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",k),D(L);let M=$n.get(k);M?M.figmaImageUrl=L:$n.set(k,{storybookImageUrl:null,figmaImageUrl:L})}}let E=$n.get(k),f=E&&E.storybookImageUrl&&E.figmaImageUrl,T=E&&E.storybookImageUrl&&!E.figmaImageUrl,S=E&&!E.storybookImageUrl&&E.figmaImageUrl;if(f){b.debug("[useReviewScreenshots] Using fully cached screenshots for story:",k),C(E.storybookImageUrl),D(E.figmaImageUrl),u.current=k;return}let y=T&&I?.figmaNodeId;y&&(b.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",k),C(E.storybookImageUrl));let F=S;if(F&&(b.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",k),D(E.figmaImageUrl)),u.current===k&&I?.figmaNodeId){b.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),y?r(!0):(F||(t(!0),r(!0)),i(!0)),u.current=k,P)return;let L=F?E.figmaImageUrl:null,M;if(F)b.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(w){b.debug("[useReviewScreenshots] Found Figma node ID from mapping:",w);let h=null;try{b.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let j=await jR(m,w,p);h=j.imageUrl||null;let V=j.cached?"(cached)":"(fresh)";b.debug(`[useReviewScreenshots] Figma image fetched ${V}:`,h?"success":"not found")}catch(j){b.warn("[useReviewScreenshots] Failed to fetch Figma image:",j)}if(h)try{b.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let j=`${Yw}/api/proxy/image?url=${encodeURIComponent(h)}`,V=await ee(j);if(V.ok){let B=await V.blob(),G=new FileReader,te=await new Promise((xe,ie)=>{G.onloadend=()=>xe(G.result),G.onerror=ie,G.readAsDataURL(B)});L=te,D(te),b.debug("[useReviewScreenshots] Figma image loaded via proxy");let le=new Image;await new Promise(xe=>{le.onload=()=>{M={width:le.naturalWidth,height:le.naturalHeight},b.debug("[useReviewScreenshots] Figma dimensions:",M),xe()},le.onerror=()=>xe(),le.src=te})}else L=h,D(h),b.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(j){b.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",j),L=h,D(h)}else b.warn("[useReviewScreenshots] No thumbnail found for node:",w),D(null);L&&w&&HR(k,w,L),r(!1)}else b.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let z=E?.storybookImageUrl||null;if(z)b.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{b.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",k);let h=await Wl({storyId:k,sessionToken:p||void 0,...M&&{figmaWidth:M.width,figmaHeight:M.height}});h&&!P?(z=h,C(h),b.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",M||"natural")):b.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}$n.set(k,{storybookImageUrl:z,figmaImageUrl:L}),b.debug("[useReviewScreenshots] Screenshots cached for story:",k)}catch(L){b.error("[useReviewScreenshots] Error loading screenshots:",L),a(L instanceof Error?L.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{P=!0}},[p,m,k,I?.figmaNodeId,c]),ei(()=>{let P=Wf.getChannel(),N=null,x=v=>{qw=v.args,b.debug("[useReviewScreenshots] Args updated for story:",v.storyId,"args:",v.args),N&&clearTimeout(N),N=setTimeout(()=>{b.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return P.on(Ww,x),()=>{P.off(Ww,x),N&&clearTimeout(N)}},[d]),ei(()=>{let P=Wf.getChannel(),N=!1,x=null,v=()=>{b.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),N=!0,i(!0)},w=()=>{N&&(b.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),x&&clearTimeout(x),x=setTimeout(()=>{N=!1,b.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return P.on(Gw,v),P.on(Vw,w),()=>{P.off(Gw,v),P.off(Vw,w),x&&clearTimeout(x)}},[g]),ei(()=>{let P=Wf.getChannel(),N=async x=>{if(!x?.snapshot?.html){b.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}b.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let v=mt.getState().currentStoryId,w=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x.snapshot,storyId:v})});if(w.ok){let E=await w.json();if(E.screenshot){C(E.screenshot);let f=mt.getState().currentStoryId;if(f){let T=$n.get(f);T?T.storybookImageUrl=E.screenshot:$n.set(f,{storybookImageUrl:E.screenshot,figmaImageUrl:null})}}}else b.error("[useReviewScreenshots] Snapshot screenshot failed:",await w.text())}catch(v){b.error("[useReviewScreenshots] Snapshot screenshot error:",v)}finally{i(!1)}};return P.on("UICOPILOT/STORY_DOM_MUTATED",N),()=>{P.off("UICOPILOT/STORY_DOM_MUTATED",N)}},[]);let _=Hf((P,N,x)=>{b.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Xw(P,N,x),D(x),r(!1),u.current=P},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:g,setFigmaImageDirect:_}}});function qR(){return!q().startsWith("http://localhost")}function YR(e,t,n){let r=t.createElement("div");r.style.color=e,t.body.appendChild(r);let o=n.getComputedStyle(r).color;return r.remove(),o}function Qw(e,t,n){let r=new Map;return e.replace(/(?:color|oklch|oklab|lab|lch)\([^)]+\)/g,o=>{if(r.has(o))return r.get(o);let i=YR(o,t,n);return r.set(o,i),i})}async function KR(){let e=(await import("html2canvas")).default,t=document.getElementById("storybook-preview-iframe");if(!t?.contentDocument||!t.contentWindow)throw new Error("Storybook iframe not accessible");let n=t.contentDocument.querySelector("#storybook-root > *")||t.contentDocument.querySelector("#root > *");if(!n)throw new Error("Story element not found in iframe");let r=t.contentWindow,o=t.contentDocument;return(await e(n,{useCORS:!0,logging:!1,backgroundColor:null,onclone:s=>{s.querySelectorAll("style").forEach(u=>{let c=u.textContent||"";/(?:color|oklch|oklab|lab|lch)\(/.test(c)&&(u.textContent=Qw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(d=>d.href===c);if(l)try{let d="";for(let g of Array.from(l.cssRules))d+=g.cssText+`
13
- `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let g=s.createElement("style");g.textContent=Qw(d,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function XR(e){let t=[];for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let o;typeof r=="boolean"?o=`!${r}`:typeof r=="number"?o=String(r):typeof r=="string"?o=encodeURIComponent(r).replace(/%20/g,"+"):o=encodeURIComponent(JSON.stringify(r)),t.push(`${n}:${o}`)}return t.join(";")}async function QR(e,t){b.debug("[Screenshot] Using server-side Chrome capture for:",e);let n={"Content-Type":"application/json"};t?.sessionToken&&(n.Authorization=`Bearer ${t.sessionToken}`);let r=await ee(`${GR}/api/screenshot`,{method:"POST",headers:n,body:JSON.stringify({url:e,selector:t?.selector,width:t?.width,height:t?.height,scale:t?.scale||1,figmaWidth:t?.figmaWidth,figmaHeight:t?.figmaHeight})});if(!r.ok){let i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Screenshot failed: ${r.status}`)}return(await r.json()).screenshot}function JR(e){let t={};if(!e)return t;let n=e.split(";");for(let r of n){let o=r.indexOf(":");if(o===-1)continue;let i=r.slice(0,o),s=r.slice(o+1);typeof s=="string"&&(s==="!true"?s=!0:s==="!false"?s=!1:!isNaN(Number(s))&&s!==""?s=Number(s):s=decodeURIComponent(s.replace(/\+/g," "))),t[i]=s}return t}function ZR(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),b.debug("[Screenshot] Warning: Using story ID from URL (fallback):",n)),!n)throw new Error("Could not determine current story ID. Please select a story first.");let r=window.location.origin,o=Date.now(),i=`${r}/iframe.html?viewMode=story&id=${n}&globals=&_cb=${o}`,s=Ni();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=JR(a),b.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=XR(s);i+=`&args=${a}`,b.debug("[Screenshot] Using URL with current args:",i)}else b.debug("[Screenshot] No current args, using default URL:",i);return i}async function ez(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return b.info("[Screenshot] Local Puppeteer not available, falling back"),null;if(!t.ok){let r=await t.json().catch(()=>({error:"Unknown"}));throw new Error(r.error||`Screenshot failed: ${t.status}`)}let n=await t.json();return b.info("[Screenshot] Captured via local Puppeteer (pixel-perfect)"),n.screenshot}catch(t){if(t instanceof TypeError&&t.message.includes("fetch"))return null;throw t}}async function Wl(e){let t=e?.storyId||tz();if(t){let n=Yf.get(t);if(n)return b.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Jw(t,e).finally(()=>{Yf.delete(t)});return Yf.set(t,r),r}return Jw(void 0,e)}async function Jw(e,t){try{if(e){let n=await ez(e);if(n)return n}if(!qR()){let n=ZR(t?.storyId);return await QR(n,{...t,selector:"#storybook-root > *"})}return b.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await KR()}catch(n){throw b.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function tz(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var GR,Yf,qf=$(()=>{"use strict";He();Oi();_e();ct();GR=q();Yf=new Map});function An(e){if(e==="transparent"||e==="rgba(0, 0, 0, 0)")return"transparent";let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(!t)return e;let[,n,r,o,i]=t,s=i?parseFloat(i):1;return s<1?`rgba(${n}, ${r}, ${o}, ${s})`:`#${[n,r,o].map(u=>parseInt(u).toString(16).padStart(2,"0")).join("")}`}function Un(e,t){let r={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"],gap:["normal","0px"],flexDirection:["row"],justifyContent:["normal","flex-start"],alignItems:["normal","stretch"],textAlign:["start","left"],letterSpacing:["normal","0px"],margin:["0px","0px 0px 0px 0px"],padding:["0px","0px 0px 0px 0px"]}[e];return r?r.includes(t):!1}function qs(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Zw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let I=r.fontSize||"16px",A=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let C=t.fonts.check(`${A} ${I} Roboto`);if(b.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:C,fontWeight:A,fontSize:I,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),C)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(I=>I.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,m="unknown",k=new Map;for(let I of g){s.font=`${c} ${u} ${a} "${I}", monospace`;let A=s.measureText(o).width;if(k.set(I,A),A!==p){s.font=`${c} ${u} ${a} "${I}"`;let C=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(C-D)<.1){m=I;break}}}return b.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:m,declaredFonts:l,fontWidths:Array.from(k.entries()),isIframe:t!==document}),m}var Ys=$(()=>{"use strict";_e()});function _i(e,t){if(!t)return e;let n=t.split(" ").filter(i=>i.trim()),r=n.find(i=>!i.includes("--")),o=n.filter(i=>i.includes("--"));return r&&o.length>0?`${e}.${r}.${o[0]}`:r?`${e}.${r}`:n[0]?`${e}.${n[0]}`:e}function Kf(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return b.debug("[computedStyles] Extracting styles:",{fontFamily:n.fontFamily,fontWeight:n.fontWeight,borderRadius:n.borderRadius,backgroundColor:n.backgroundColor,padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},isIframeContext:e.ownerDocument!==document}),{color:An(n.color),backgroundColor:An(n.backgroundColor),borderColor:An(n.borderColor),padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},margin:{top:n.marginTop,right:n.marginRight,bottom:n.marginBottom,left:n.marginLeft},gap:n.gap,fontFamily:n.fontFamily,renderedFont:Zw(e),fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.textAlign,textTransform:n.textTransform,width:n.width,height:n.height,minWidth:n.minWidth,minHeight:n.minHeight,maxWidth:n.maxWidth,maxHeight:n.maxHeight,borderWidth:n.borderWidth,borderStyle:n.borderStyle,borderRadius:n.borderRadius,boxShadow:n.boxShadow,textShadow:n.textShadow,display:n.display,flexDirection:n.display==="flex"?n.flexDirection:void 0,justifyContent:n.display==="flex"?n.justifyContent:void 0,alignItems:n.display==="flex"?n.alignItems:void 0,position:n.position,opacity:n.opacity,cursor:n.cursor}}function Xf(e,t){let n={width:null,height:null,minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,display:null,flexGrow:null,flexShrink:null,flexBasis:null};try{let r=Array.from(t.styleSheets);for(let i of r)try{let s=i.cssRules||i.rules;if(!s)continue;for(let a of Array.from(s))if(a.type===1){let u=a;try{if(e.matches(u.selectorText)){let c=u.style;c.width&&(n.width=c.width),c.height&&(n.height=c.height),c.minWidth&&(n.minWidth=c.minWidth),c.minHeight&&(n.minHeight=c.minHeight),c.maxWidth&&(n.maxWidth=c.maxWidth),c.maxHeight&&(n.maxHeight=c.maxHeight),c.display&&(n.display=c.display),c.flexGrow&&(n.flexGrow=c.flexGrow),c.flexShrink&&(n.flexShrink=c.flexShrink),c.flexBasis&&(n.flexBasis=c.flexBasis)}}catch{continue}}}catch{continue}let o=e.style;o.width&&(n.width=o.width),o.height&&(n.height=o.height),o.minWidth&&(n.minWidth=o.minWidth),o.minHeight&&(n.minHeight=o.minHeight),o.maxWidth&&(n.maxWidth=o.maxWidth),o.maxHeight&&(n.maxHeight=o.maxHeight),o.display&&(n.display=o.display),o.flexGrow&&(n.flexGrow=o.flexGrow),o.flexShrink&&(n.flexShrink=o.flexShrink),o.flexBasis&&(n.flexBasis=o.flexBasis)}catch(r){b.error("Error extracting declared styles:",r)}return n}var Vl=$(()=>{"use strict";_e();Ys()});function nz(e){let t=[],n=new Set,r=ev.join(", "),o=e.querySelectorAll(r);for(let i of Array.from(o)){let s=`${i.tagName.toLowerCase()}.${i.className}`;n.has(s)||(n.add(s),t.push(i))}if(ev.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function rz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"";return{selector:_i(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:qs(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:An(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function oz(e,t=2){let n=[e],r=new Set,o=s=>{let a=s.className;return typeof a=="string"?a:a?.baseVal||""};r.add(`${e.tagName}.${o(e)}`);function i(s,a){if(a>=t)return;let u=Array.from(s.children);for(let c of u){let l=c.tagName.toLowerCase();if(["script","style","link","meta","br","hr"].includes(l))continue;let d=`${c.tagName}.${o(c)}`;r.has(d)||(r.add(d),n.push(c),i(c,a+1))}}return i(e,0),n}function iz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",s=n.borderWidth!=="0px",a=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",c=n.gap!=="normal"&&n.gap!=="0px";if(!s&&!a&&!u&&!c)return null;let l=n.borderWidth,d=n.borderStyle,g=An(n.borderColor),p=s?`${l} ${d} ${g}`:"none";return{selector:_i(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:An(n.backgroundColor),gap:n.gap}}function Ks(){b.debug("[computedStyles] extractStoryStyles called - FULL CONTEXT VERSION");try{let e=document.getElementById("storybook-preview-iframe");if(!e||!e.contentDocument)throw new Error("Storybook preview iframe not found");let t=e.contentDocument,n=t.getElementById("storybook-root");if(!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(!r)throw new Error("Component element not found in story root");let o=oz(r,2),i=o.map(iz).filter(a=>a!==null);b.debug("[computedStyles] Extracted visual styles from nested elements:",{total:o.length,withVisuals:i.length,elements:i.map(a=>({selector:a.selector,border:a.border,background:a.backgroundColor,borderRadius:a.borderRadius}))});let s=[];try{let a=nz(r);s=a.map(rz),b.debug("[computedStyles] Text elements found:",{count:a.length,elements:s.map(u=>({selector:u.selector,fontSize:u.styles.fontSize,fontWeight:u.styles.fontWeight}))})}catch(a){b.error("[computedStyles] Error extracting text elements:",a)}return{computed:Kf(r),declared:Xf(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return b.error("Error extracting computed styles:",e),null}}var ev,tv=$(()=>{"use strict";_e();Ys();Vl();ev=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Qf(e,t,n,r){return e===t&&t===n&&n===r?e:e===n&&t===r?`${e} ${t}`:t===r?`${e} ${t} ${n}`:`${e} ${t} ${n} ${r}`}function az(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function lz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=An(n.backgroundColor);Un("backgroundColor",o)||(r.backgroundColor=o);let i=az(n.borderWidth,n.borderStyle,An(n.borderColor));i&&(r.border=i),Un("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Un("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Un("opacity",n.opacity)||(r.opacity=n.opacity);let s=e.tagName.toLowerCase(),a=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||a.includes(s)){for(let I=0;I<e.attributes.length;I++){let A=e.attributes[I];if(["class","style","id","xmlns","xmlns:xlink"].includes(A.name))continue;let C=A.name.replace(/-([a-z])/g,(R,_)=>_.toUpperCase()),D=A.value.startsWith("rgb")?An(A.value):A.value;C==="d"&&D.length>100?r[C]=D.substring(0,100)+"...":r[C]=D}let p=n.getPropertyValue("fill"),m=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?An(p):p),m&&m!=="none"&&(r.stroke=m.startsWith("rgb")?An(m):m),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let I=e.getBoundingClientRect();I.width>0&&(r.width=`${Math.round(I.width*100)/100}px`),I.height>0&&(r.height=`${Math.round(I.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=sz.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=qs(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=An(n.color),Un("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Un("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Qf(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Un("padding",d)||(r.padding=d);let g=Qf(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Un("margin",g)||(r.margin=g),Un("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Un("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Un("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Un("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function nv(e){let t=1;for(let n of e.children)t+=nv(n);return t}function rv(e,t=4){function n(o,i){let s=o.tagName.toLowerCase(),a=o.className,u=typeof a=="string"?a:a?.baseVal||"",c=o.id||void 0,l=o.getAttribute("role")||void 0,d;for(let k of Array.from(o.childNodes))if(k.nodeType===Node.TEXT_NODE){let I=k.textContent?.trim();if(I){d=I.length>50?I.substring(0,50)+"...":I;break}}let g=s;c?g=`${s}#${c}`:u&&(g=_i(s,u));let p=lz(o),m=[];if(i<t){let k=Array.from(o.children);for(let I of k){let A=I.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(A))continue;let D=(I.ownerDocument.defaultView||window).getComputedStyle(I);D.display==="none"||D.visibility==="hidden"||m.push(n(I,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:m}}b.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return b.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:nv(r)}),r}function Jf(e=4){b.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(b.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(b.debug("[extractStoryDOMTree] iframe.contentDocument:",!!t.contentDocument),!t.contentDocument)throw new Error("iframe.contentDocument is not accessible (possible cross-origin issue)");let n=t.contentDocument.getElementById("storybook-root");if(b.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(b.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=rv(r,e);return b.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return b.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var sz,ov=$(()=>{"use strict";_e();Ys();Vl();sz=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Zf=$(()=>{"use strict";Ys();Vl();tv();ov()});var Pv=ar((MQ,Av)=>{"use strict";Av.exports={compareTwoStrings:Ev,findBestMatch:Bz};function Ev(e,t){if(e=e.replace(/\s+/g,""),t=t.replace(/\s+/g,""),e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let o=0;o<e.length-1;o++){let i=e.substring(o,o+2),s=n.has(i)?n.get(i)+1:1;n.set(i,s)}let r=0;for(let o=0;o<t.length-1;o++){let i=t.substring(o,o+2),s=n.has(i)?n.get(i):0;s>0&&(n.set(i,s-1),r++)}return 2*r/(e.length+t.length-2)}function Bz(e,t){if(!Dz(e,t))throw new Error("Bad arguments: First argument should be a string, second should be an array of strings");let n=[],r=0;for(let i=0;i<t.length;i++){let s=t[i],a=Ev(e,s);n.push({target:s,rating:a}),a>n[r].rating&&(r=i)}let o=n[r];return{ratings:n,bestMatch:o,bestMatchIndex:r}}function Dz(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var I1=ar((Gse,T1)=>{"use strict";var w1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,$3=/\n/g,U3=/^\s*/,j3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,H3=/^:\s*/,W3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,V3=/^[;\s]*/,G3=/^\s+|\s+$/g,q3=`
14
- `,v1="/",k1="*",li="",Y3="comment",K3="declaration";function X3(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(m){var k=m.match($3);k&&(n+=k.length);var I=m.lastIndexOf(q3);r=~I?m.length-I:r+m.length}function i(){var m={line:n,column:r};return function(k){return k.position=new s(m),c(),k}}function s(m){this.start=m,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(m){var k=new Error(t.source+":"+n+":"+r+": "+m);if(k.reason=m,k.filename=t.source,k.line=n,k.column=r,k.source=e,!t.silent)throw k}function u(m){var k=m.exec(e);if(k){var I=k[0];return o(I),e=e.slice(I.length),k}}function c(){u(U3)}function l(m){var k;for(m=m||[];k=d();)k!==!1&&m.push(k);return m}function d(){var m=i();if(!(v1!=e.charAt(0)||k1!=e.charAt(1))){for(var k=2;li!=e.charAt(k)&&(k1!=e.charAt(k)||v1!=e.charAt(k+1));)++k;if(k+=2,li===e.charAt(k-1))return a("End of comment missing");var I=e.slice(2,k-2);return r+=2,o(I),e=e.slice(k),r+=2,m({type:Y3,comment:I})}}function g(){var m=i(),k=u(j3);if(k){if(d(),!u(H3))return a("property missing ':'");var I=u(W3),A=m({type:K3,property:C1(k[0].replace(w1,li)),value:I?C1(I[0].replace(w1,li)):li});return u(V3),A}}function p(){var m=[];l(m);for(var k;k=g();)k!==!1&&(m.push(k),l(m));return m}return c(),p()}function C1(e){return e?e.replace(G3,li):li}T1.exports=X3});var F1=ar(ma=>{"use strict";var Q3=ma&&ma.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ma,"__esModule",{value:!0});ma.default=Z3;var J3=Q3(I1());function Z3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,J3.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;let{property:s,value:a}=i;o?t(s,a,i):a&&(n=n||{},n[s]=a)}),n}});var A1=ar(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.camelCase=void 0;var e5=/^--[a-zA-Z0-9_-]+$/,t5=/-([a-z])/g,n5=/^[^-]+$/,r5=/^-(webkit|moz|ms|o|khtml)-/,o5=/^-(ms)-/,i5=function(e){return!e||n5.test(e)||e5.test(e)},s5=function(e,t){return t.toUpperCase()},E1=function(e,t){return"".concat(t,"-")},a5=function(e,t){return t===void 0&&(t={}),i5(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(o5,E1):e=e.replace(r5,E1),e.replace(t5,s5))};Fc.camelCase=a5});var L1=ar((Bh,P1)=>{"use strict";var l5=Bh&&Bh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},c5=l5(F1()),u5=A1();function Mh(e,t){var n={};return!e||typeof e!="string"||(0,c5.default)(e,function(r,o){r&&o&&(n[(0,u5.camelCase)(r,t)]=o)}),n}Mh.default=Mh;P1.exports=Mh});var oI=ar((wde,rI)=>{"use strict";var Xc=Object.prototype.hasOwnProperty,nI=Object.prototype.toString,XT=Object.defineProperty,QT=Object.getOwnPropertyDescriptor,JT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):nI.call(t)==="[object Array]"},ZT=function(t){if(!t||nI.call(t)!=="[object Object]")return!1;var n=Xc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Xc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Xc.call(t,o)},eI=function(t,n){XT&&n.name==="__proto__"?XT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},tI=function(t,n){if(n==="__proto__")if(Xc.call(t,n)){if(QT)return QT(t,n).value}else return;return t[n]};rI.exports=function e(){var t,n,r,o,i,s,a=arguments[0],u=1,c=arguments.length,l=!1;for(typeof a=="boolean"&&(l=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<c;++u)if(t=arguments[u],t!=null)for(n in t)r=tI(a,n),o=tI(t,n),a!==o&&(l&&o&&(ZT(o)||(i=JT(o)))?(i?(i=!1,s=r&&JT(r)?r:[]):s=r&&ZT(r)?r:{},eI(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&eI(a,{name:n,newValue:o}));return a}});import ja from"react";import{addons as pu,types as ry,experimental_getStatusStore as oy}from"storybook/manager-api";import{AddonPanel as UV}from"storybook/internal/components";import zt,{useState as sV,useEffect as aV}from"react";import{styled as Sr}from"storybook/theming";import gy from"react";import{styled as Dt}from"storybook/theming";var se="#ea580c",fu="#c2410c",Ga="#ff6b35";var ay=Dt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ly=Dt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),xo=Dt.div({marginBottom:"20px"}),yo=Dt.label(({theme:e})=>({display:"block",marginBottom:`${e.layoutMargin*.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),gs=Dt.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,"&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`}})),bn=Dt.select(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px 32px ${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px",transition:"border-color 0.15s, box-shadow 0.15s","&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`},"&:hover":{borderColor:e.color.mediumdark},"&:disabled":{opacity:.6,cursor:"not-allowed"}})),cy=Dt(bn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),qa=e=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:disabled":{opacity:.5,cursor:"not-allowed"}}),Fn=Dt.button(({theme:e})=>({...qa(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),on=Dt.button(({theme:e})=>({...qa(e),backgroundColor:se,color:e.color.inverseText,boxShadow:`0 2px 4px ${se}4d`,"&:hover:not(:disabled)":{backgroundColor:fu,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${se}66`}})),Nr=Dt.button(({theme:e})=>({...qa(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),uy=Dt.button(({theme:e})=>({...qa(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),En=Dt.button(({theme:e})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:`${e.layoutMargin*.4}px`,fontSize:e.typography.size.s2,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),mu=Dt.button(({theme:e})=>({padding:0,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.secondary,backgroundColor:"transparent",border:"none",cursor:"pointer",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),bo=Dt.button(({theme:e,active:t})=>({padding:`${e.layoutMargin*.6}px ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:t?e.typography.weight.bold:400,color:t?e.color.secondary:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderBottom:t?`2px solid ${e.color.secondary}`:"2px solid transparent",cursor:"pointer",transition:"all 0.15s","&:hover":{color:t?e.color.secondary:e.color.defaultText}})),So=Dt(gs)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),KV=Dt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),py=Dt.h2(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s3,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),XV=Dt.h3(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),fs=Dt.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),QV=Dt.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.background.hoverable,borderRadius:e.appBorderRadius,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"100%",background:`linear-gradient(90deg, transparent, ${e.color.mediumlight}33, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{transform:"translateX(-100%)"},"100%":{transform:"translateX(100%)"}}})),dy=Dt.span(({theme:e,variant:t="default"})=>{let n={default:{bg:e.background.hoverable,color:e.color.defaultText},success:{bg:`${e.color.positive}40`,color:e.color.positive},warning:{bg:`${e.color.warning}40`,color:e.color.warning},error:{bg:`${e.color.negative}40`,color:e.color.negative}};return{display:"inline-block",padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,borderRadius:"3px",backgroundColor:n[t].bg,color:n[t].color}}),JV=Dt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),ZV=Dt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),e9=Dt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var hu=({header:e,children:t,footer:n})=>gy.createElement(ay,null,e,gy.createElement(ly,null,t),n);import eE from"react";import{styled as tE}from"storybook/theming";var nE=tE.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),xu=({toolbar:e})=>eE.createElement(nE,null,e);import u9 from"react";import{styled as Ya}from"storybook/theming";var g9=Ya.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),f9=Ya.div({display:"flex",flex:1}),m9=Ya(bo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),h9=Ya.div({display:"flex",gap:"8px",alignItems:"center"});import en,{useState as Uf,useCallback as _w,useEffect as $w}from"react";import{styled as ro}from"storybook/theming";import Ce,{useEffect as Ew}from"react";import{styled as lt}from"storybook/theming";Te();He();_e();ct();var Aw=lt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),Pw=lt.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"12px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),UD=lt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),jD=lt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:se,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),HD=lt.div({display:"flex",flexDirection:"column",gap:"4px"}),WD=lt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),VD=lt.span({display:"inline-block",alignSelf:"flex-start",padding:"2px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:"#7c3aed",backgroundColor:"rgba(124, 58, 237, 0.1)",letterSpacing:"0.3px"}),GD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),qD=lt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),YD=lt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),KD=lt.div(({theme:e})=>({height:"8px",borderRadius:"4px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",margin:"0 16px 8px",overflow:"hidden"})),XD=lt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${se} 100%)`,transition:"width 0.3s ease"})),QD=lt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),JD=lt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),ZD=lt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:se,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Lw=lt.button(({theme:e})=>({position:"absolute",top:"12px",right:"12px",width:"24px",height:"24px",borderRadius:"4px",border:"none",background:"transparent",color:e.textMutedColor,cursor:"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:e.background.hoverable}})),eR=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),tR=lt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),nR=lt.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:se,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),rR=lt.div({display:"flex",gap:"8px"}),Mw=lt(En)({fontSize:"18px"}),oR=lt.div({padding:"20px 16px"}),iR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),sR=lt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),aR=lt.div({fontSize:"28px",fontWeight:700}),lR=lt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),cR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),uR=lt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),pR=lt.div({display:"flex",alignItems:"center",gap:"8px"}),dR=lt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),gR=lt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:se,color:e.color.inverseText})),fR=lt.button(({theme:e})=>({background:"none",border:"none",color:se,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),mR=lt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),hR=lt.button(({theme:e,variant:t="primary"})=>({width:"100%",padding:"12px",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:"pointer",border:"none",marginBottom:"12px",backgroundColor:t==="primary"?se:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),xR=30*1e3,Bw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=ke(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(m=!1)=>{if(!t)return;let k=o&&Date.now()-o<xR;if(!(!m&&k&&r))try{let I=q(),A=await ee(`${I}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(A.ok){let C=await A.json();i(C)}}catch(I){b.error("Failed to fetch usage:",I)}};Ew(()=>{l()},[t]),Ew(()=>{let m=()=>{document.visibilityState==="visible"&&(b.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[t]);let d=()=>{if(t){let m=q();fetch(`${m}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}).catch(()=>{})}n(),e()},g=()=>{let m=q();window.open(`${m}/pricing`,"_blank")},p=()=>{let m=q();window.open(`${m}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let m=Math.floor(u?.creditBalance??0),I=Math.max(m,10),A=Math.max(0,I-m),C=I>0?m/I*100:0;return Ce.createElement(Ce.Fragment,null,Ce.createElement(Aw,{onClick:e}),Ce.createElement(Pw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},Ce.createElement(UD,null,Ce.createElement(jD,null,u?.email?u.email[0].toUpperCase():"U"),Ce.createElement(HD,null,Ce.createElement(WD,null,"UI Review"),Ce.createElement(VD,null,(u?.plan||"BETA").toUpperCase())),Ce.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},Ce.createElement(Lw,{onClick:d,title:"Sign out",style:{position:"static"}},Ce.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Ce.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Ce.createElement("polyline",{points:"16 17 21 12 16 7"}),Ce.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Ce.createElement(Lw,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),Ce.createElement(GD,null,Ce.createElement(qD,null,"Credits"),Ce.createElement(YD,null,m," left")),Ce.createElement(KD,null,Ce.createElement(XD,{percent:C})),Ce.createElement(QD,null,A," used \xB7 ",m," remaining"),Ce.createElement(JD,null),Ce.createElement(ZD,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return Ce.createElement(Ce.Fragment,null,Ce.createElement(Aw,{onClick:e}),Ce.createElement(Pw,{onClick:m=>m.stopPropagation()},Ce.createElement(eR,null,Ce.createElement(tR,null,Ce.createElement(nR,null,u?.email?u.email[0].toUpperCase():"U"),Ce.createElement("span",null,u?.email||"Loading...")),Ce.createElement(rR,null,Ce.createElement(Mw,{onClick:d,title:"Sign out"},Ce.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Ce.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Ce.createElement("polyline",{points:"16 17 21 12 16 7"}),Ce.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Ce.createElement(Mw,{onClick:e,title:"Close"},"\xD7"))),Ce.createElement(oR,null,c?Ce.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Ce.createElement(Ce.Fragment,null,Ce.createElement(iR,null,Ce.createElement(sR,null,"Credit Balance"),Ce.createElement(aR,null,"$",(u?.creditBalance??0).toFixed(2)),Ce.createElement(lR,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Ce.createElement(cR,null,Ce.createElement(uR,null,Ce.createElement(pR,null,Ce.createElement(dR,null,"Current Plan"),Ce.createElement(gR,null,u?.plan||"Free")),Ce.createElement(fR,{onClick:g},"View detail >")),Ce.createElement(mR,null,"~$0.02-0.05 per review depending on complexity"),Ce.createElement(hR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):Ce.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Te();import Di from"react";import{styled as Dw}from"storybook/theming";He();Te();ct();_e();var yR=Dw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),bR=Dw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),SR={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},Rw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=ke();return e!=="admin"?null:Di.createElement(yR,null,Di.createElement(bR,null,"View as:"),Di.createElement(cy,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ee(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>b.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=SR[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Di.createElement("option",{value:"admin"},"Admin"),Di.createElement("option",{value:"beta"},"Beta Tester")),t&&Di.createElement(dy,{variant:"warning"},"Previewing as ",t))};He();Te();ct();import bt,{useState as Hs,useCallback as $f}from"react";import{styled as Fr}from"storybook/theming";var wR="0.5.7",vR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],kR=Fr.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),CR=Fr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),TR=Fr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),IR=Fr.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),FR=Fr.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),ER=Fr.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),AR=Fr.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:se}})),zw=Fr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),Nw=Fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),PR=Fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),LR=Fr.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function Ow({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=ke(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=Hs("other"),[u,c]=Hs(""),[l,d]=Hs(!1),[g,p]=Hs(!1),[m,k]=Hs(null),I=$f(()=>{c(""),a("other"),p(!1),k(null),d(!1)},[]),A=$f(()=>{I(),t()},[I,t]),C=$f(async D=>{if(D.preventDefault(),!u.trim()){k("Please write a message.");return}if(!r||!n){k("Sign in to send feedback.");return}d(!0),k(null);try{let R=await ee(`${q()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:wR})});if(!R.ok){let _=await R.json().catch(()=>({}));throw new Error(_.error||`Request failed (${R.status})`)}p(!0)}catch(R){k(R instanceof Error?R.message:"Something went wrong")}finally{d(!1)}},[u,s,n,r,o,i]);return e?bt.createElement(kR,{onClick:A},bt.createElement(CR,{onClick:D=>D.stopPropagation()},bt.createElement(TR,null,bt.createElement(IR,null,bt.createElement("span",null,"\u{1F4AC}"),"Send feedback"),bt.createElement(FR,{onClick:A,"aria-label":"Close"},"\xD7")),g?bt.createElement(bt.Fragment,null,bt.createElement(LR,null,bt.createElement("h4",null,"Thanks \u2014 got it."),bt.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),bt.createElement(zw,null,bt.createElement("span",null),bt.createElement(Fn,{onClick:A},"Close"))):bt.createElement("form",{onSubmit:C},bt.createElement(ER,null,bt.createElement(xo,null,bt.createElement(yo,{htmlFor:"feedback-severity"},"Type"),bt.createElement(bn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},vR.map(D=>bt.createElement("option",{key:D.value,value:D.value},D.label)))),bt.createElement(xo,null,bt.createElement(yo,{htmlFor:"feedback-message"},"What happened?"),bt.createElement(AR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),bt.createElement(Nw,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),m&&bt.createElement(PR,null,m)),bt.createElement(zw,null,bt.createElement(Nw,null,i?`Context: ${i}`:"No story selected"),bt.createElement("div",{style:{display:"flex",gap:"8px"}},bt.createElement(Fn,{type:"button",onClick:A,disabled:l},"Cancel"),bt.createElement(on,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}Te();He();ct();var MR=ro.div({display:"flex",alignItems:"center"}),Ri=ro.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),BR=ro.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),DR=ro.div({position:"relative"}),RR=ro.button(({theme:e})=>({width:"26px",height:"26px",padding:0,background:`linear-gradient(135deg, ${e.color.secondary} 0%, ${e.color.secondary}cc 100%)`,border:"none",borderRadius:"50%",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s","&:hover":{transform:"scale(1.05)",boxShadow:`0 2px 8px ${e.color.secondary}66`}})),Uw=ro.button(({isLow:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:e?"#FEF3C7":"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",border:"none",borderRadius:"12px",color:e?"#92400E":"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,transition:"all 0.2s",minWidth:"60px",justifyContent:"center","&:hover":{transform:"scale(1.02)",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})),zR=ro.span({display:"inline-block",width:"12px",height:"12px",border:"2px solid rgba(255,255,255,0.3)",borderTopColor:"#fff",borderRadius:"50%",animation:"credit-spin 0.8s linear infinite","@keyframes credit-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),NR=ro.button(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",padding:"4px 10px",height:"28px",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.mediumdark,fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.mediumdark}})),OR=ro.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:se,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${se}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${se}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),_R=30*1e3,jf=({onOpenSettings:e})=>{let[t,n]=Uf(!1),[r,o]=Uf(!1),[i,s]=Uf(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=ke(),{userRole:d,roleOverride:g,featureFlags:p}=ce(),m=g??d;$w(()=>{(async()=>{if(!(!l||u&&Date.now()-u<_R&&a)){s(!0);try{let _=q(),P=await ee(`${_}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let N=await P.json();c(N)}}catch(_){console.error("Failed to fetch balance:",_)}finally{s(!1)}}})()},[l,u,a,c]),$w(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},R=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",R),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",R)}},[t]);let k=_w(()=>{n(!0)},[]),I=_w(()=>{n(!1)},[]),A=a?.creditBalance??0,C=A<2&&!i;return en.createElement(MR,null,e&&en.createElement(Ri,null,en.createElement(NR,{onClick:e,title:"Settings"},en.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&m==="admin"&&en.createElement(Ri,null,en.createElement(Rw,null)),en.createElement(Ri,null,en.createElement(BR,null,"v","0.5.26")),l&&p.showCosts&&en.createElement(Ri,null,en.createElement(Uw,{onClick:k,isLow:C,title:i?"Loading...":a?C?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?en.createElement(zR,null):a?`$${A.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&en.createElement(Ri,null,en.createElement(Uw,{onClick:k,isLow:Math.floor(A)<=3,title:`${Math.floor(A)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(A))),en.createElement(Ri,null,en.createElement(DR,null,en.createElement(RR,{title:"Account & Usage",onClick:k},a?.email?a.email[0].toUpperCase():"?"),t&&en.createElement(Bw,{onClose:I}))),l&&en.createElement(OR,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),en.createElement(Ow,{isOpen:r,onClose:()=>o(!1)}))};import Bt,{useEffect as B4,useRef as D4}from"react";import{styled as hr}from"storybook/theming";import rt from"react";Te();_e();He();ct();_n();import{useState as $R,useCallback as zi,useRef as jw,useEffect as UR}from"react";var oo=q();b.debug("[useAuth] Module loaded, APP_URL:",oo);var Ws=()=>{let e=jw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:g,setUserCode:p,setVerificationUri:m,setPollingInterval:k,setAuthError:I,resetAuth:A}=ke(),C=jw(null),[D,R]=$R(!1),_=zi(async()=>{try{b.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let E;try{E=await ee(`${oo}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(F){let M=F instanceof Error&&F.message.includes("timed out")?`Cannot reach ${Pt.NAME} server at ${oo}. Is the dashboard running?`:`Connection failed: ${oo} is not responding.`;I(M),b.error("[useAuth]",M);return}if(!E.ok){let F=`Cannot reach ${Pt.NAME} server. Is the dashboard running?`;I(F),b.error("[useAuth]",F);return}let{poll_code:f}=await E.json();b.debug("[useAuth] Got poll_code:",f.substring(0,15)+"...");let T=localStorage.getItem("uicopilot_force_sign_in")==="true";T&&localStorage.removeItem("uicopilot_force_sign_in");let S=`${oo}/addon/auth?poll_code=${f}${T?"&force_sign_in=true":""}`;R(!0),window.open(S,"uiparity-auth","width=520,height=620,left=300,top=150"),b.debug("[useAuth] Starting OAuth poll for token..."),C.current&&clearInterval(C.current);let y=async()=>{try{let L=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:f})})).json();L.status==="authorized"&&L.session_token?(b.debug("[useAuth] \u2705 OAuth poll successful! Got token."),C.current&&(clearInterval(C.current),C.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token),R(!1)):L.status==="expired"&&(b.debug("[useAuth] OAuth poll_code expired"),C.current&&(clearInterval(C.current),C.current=null),R(!1))}catch(F){b.error("[useAuth] OAuth poll error:",F)}};C.current=setInterval(y,2e3),setTimeout(y,1e3)}catch(E){b.error("[useAuth] OAuth flow error:",E),I(`Connection failed. Is the dashboard running at ${oo}?`),R(!1)}},[c,I]),P=zi(async()=>{try{let E=await fetch(`${oo}/api/addon/auth/device`,{method:"POST"});if(!E.ok)throw new Error("Failed to start device code flow");let f=await E.json();g(f.device_code),p(f.user_code),m(f.verification_uri),window.open(f.verification_uri,"_blank"),N(f.device_code,f.interval*1e3)}catch(E){throw b.error("[useAuth] Device code flow error:",E),E}},[g,p,m]),N=zi((E,f)=>{b.debug("[useAuth] Starting polling. Device code:",E,"Interval:",f),e.current&&clearInterval(e.current);let T=async()=>{try{let y=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:E})})).json();y.status==="authorized"?(b.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null),localStorage.setItem("uicopilot_session_token",y.session_token),c(y.session_token),setOauthUrl(null)):(y.status==="expired"||y.status==="denied")&&(b.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null))}catch(S){b.error("[useAuth] Polling error:",S)}};e.current=setInterval(T,f),k(f)},[g,p,m,c,k]),x=zi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null),k(null)},[g,p,m,k]),v=zi(E=>{l(E),c(E),localStorage.setItem("uicopilot_api_key",E)},[l,c]),w=zi(()=>{A(),setOauthUrl(null),e.current&&(clearInterval(e.current),e.current=null),C.current&&(clearInterval(C.current),C.current=null)},[A]);return UR(()=>()=>{e.current&&clearInterval(e.current),C.current&&clearInterval(C.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:D,setAuthMethod:d,startOAuth:_,startDeviceCode:P,cancelDeviceCode:x,saveApiKey:v,logout:w}};Te();_e();He();ct();import{useCallback as Ul}from"react";var Vs=q(),io=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=ke(),u=Ul(async()=>{if(!a){b.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),b.debug("[useProjects] Fetching from:",`${Vs}/api/projects`);let g=await ee(`${Vs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();b.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else b.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){b.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=Ul(async g=>{if(!a)throw new Error("Not authenticated");let p=await ee(`${Vs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!p.ok)throw new Error("Failed to create project");let m=await p.json();return await u(),m.project},[a,u]),l=Ul(async(g,p)=>{if(!a)throw new Error("Not authenticated");let m={};if(p.name!==void 0&&(m.name=p.name),p.description!==void 0&&(m.description=p.description),p.figmaFileUrl!==void 0&&(m.figmaFileId=p.figmaFileUrl||void 0),!(await ee(`${Vs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(m)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=Ul(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ee(`${Vs}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:d}};Te();var Gs=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d}=nt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};Te();qf();Zf();import{useCallback as ea,useRef as Jl}from"react";_e();function Gl(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){b.warn("[iframeReload] No preview iframe found"),e();return}let n=t.contentWindow.location.href,r=new URL(n);r.searchParams.set("_cb",Date.now().toString());let o=r.toString();b.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{b.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),b.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{b.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var ql=BigInt(4294967295),iv=BigInt(32);function cz(e,t=!1){return t?{h:Number(e&ql),l:Number(e>>iv&ql)}:{h:Number(e>>iv&ql)|0,l:Number(e&ql)|0}}function sv(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=cz(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var av=(e,t,n)=>e<<n|t>>>32-n,lv=(e,t,n)=>t<<n|e>>>32-n,cv=(e,t,n)=>t<<n-32|e>>>64-n,uv=(e,t,n)=>e<<n-32|t>>>64-n;function uz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function em(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Yl(e,t,n=""){let r=uz(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let s=n&&`"${n}" `,a=i?` of length ${t}`:"",u=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+u)}return e}function tm(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function pv(e,t){Yl(e,void 0,"digestInto() output");let n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function dv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nm(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var pz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function dz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function gz(e){for(let t=0;t<e.length;t++)e[t]=dz(e[t]);return e}var rm=pz?e=>e:gz;function gv(e,t={}){let n=(o,i)=>e(i).update(o).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=o=>e(o),Object.assign(n,t),Object.freeze(n)}var fv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var fz=BigInt(0),Xs=BigInt(1),mz=BigInt(2),hz=BigInt(7),xz=BigInt(256),yz=BigInt(113),xv=[],yv=[],bv=[];for(let e=0,t=Xs,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],xv.push(2*(5*r+n)),yv.push((e+1)*(e+2)/2%64);let o=fz;for(let i=0;i<7;i++)t=(t<<Xs^(t>>hz)*yz)%xz,t&mz&&(o^=Xs<<(Xs<<BigInt(i))-Xs);bv.push(o)}var Sv=sv(bv,!0),bz=Sv[0],Sz=Sv[1],mv=(e,t,n)=>n>32?cv(e,t,n):av(e,t,n),hv=(e,t,n)=>n>32?uv(e,t,n):lv(e,t,n);function wz(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],d=mv(c,l,1)^n[a],g=hv(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=yv[s],u=mv(o,i,a),c=hv(o,i,a),l=xv[s];o=e[l],i=e[l+1],e[l]=u,e[l+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=bz[r],e[1]^=Sz[r]}nm(n)}var om=class e{constructor(t,n,r,o=!1,i=24){lr(this,"state");lr(this,"pos",0);lr(this,"posOut",0);lr(this,"finished",!1);lr(this,"state32");lr(this,"destroyed",!1);lr(this,"blockLen");lr(this,"suffix");lr(this,"outputLen");lr(this,"enableXOF",!1);lr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,em(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=dv(this.state)}clone(){return this._cloneInto()}keccak(){rm(this.state32),wz(this.state32,this.rounds),rm(this.state32),this.posOut=0,this.pos=0}update(t){tm(this),Yl(t);let{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){tm(this,!1),Yl(t),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return em(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pv(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,nm(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new e(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}},vz=(e,t,n,r={})=>gv(()=>new om(t,e,n),r);var wv=vz(6,72,64,fv(10));var kz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,im=Math.ceil,fr=Math.floor,jn="[BigNumber Error] ",vv=jn+"Number primitive has more than 15 significant digits: ",Er=1e14,Ve=14,sm=9007199254740991,am=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Fo=1e7,ln=1e9;function kv(e){var t,n,r,o=C.prototype={constructor:C,toString:null,valueOf:null},i=new C(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,m=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},I="0123456789abcdefghijklmnopqrstuvwxyz",A=!0;function C(x,v){var w,E,f,T,S,y,F,L,M=this;if(!(M instanceof C))return new C(x,v);if(v==null){if(x&&x._isBigNumber===!0){M.s=x.s,!x.c||x.e>d?M.c=M.e=null:x.e<l?M.c=[M.e=0]:(M.e=x.e,M.c=x.c.slice());return}if((y=typeof x=="number")&&x*0==0){if(M.s=1/x<0?(x=-x,-1):1,x===~~x){for(T=0,S=x;S>=10;S/=10,T++);T>d?M.c=M.e=null:(M.e=T,M.c=[x]);return}L=String(x)}else{if(!kz.test(L=String(x)))return r(M,L,y);M.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(T=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(T<0&&(T=S),T+=+L.slice(S+1),L=L.substring(0,S)):T<0&&(T=L.length)}else{if(Ot(v,2,I.length,"Base"),v==10&&A)return M=new C(x),P(M,s+M.e+1,a);if(L=String(x),y=typeof x=="number"){if(x*0!=0)return r(M,L,y,v);if(M.s=1/x<0?(L=L.slice(1),-1):1,C.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(vv+x)}else M.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(w=I.slice(0,v),T=S=0,F=L.length;S<F;S++)if(w.indexOf(E=L.charAt(S))<0){if(E=="."){if(S>T){T=F;continue}}else if(!f&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){f=!0,S=-1,T=0;continue}return r(M,String(x),y,v)}y=!1,L=n(L,v,10,M.s),(T=L.indexOf("."))>-1?L=L.replace(".",""):T=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(F=L.length;L.charCodeAt(--F)===48;);if(L=L.slice(S,++F)){if(F-=S,y&&C.DEBUG&&F>15&&(x>sm||x!==fr(x)))throw Error(vv+M.s*x);if((T=T-S-1)>d)M.c=M.e=null;else if(T<l)M.c=[M.e=0];else{if(M.e=T,M.c=[],S=(T+1)%Ve,T<0&&(S+=Ve),S<F){for(S&&M.c.push(+L.slice(0,S)),F-=Ve;S<F;)M.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=F;for(;S--;L+="0");M.c.push(+L)}}else M.c=[M.e=0]}C.clone=kv,C.ROUND_UP=0,C.ROUND_DOWN=1,C.ROUND_CEIL=2,C.ROUND_FLOOR=3,C.ROUND_HALF_UP=4,C.ROUND_HALF_DOWN=5,C.ROUND_HALF_EVEN=6,C.ROUND_HALF_CEIL=7,C.ROUND_HALF_FLOOR=8,C.EUCLID=9,C.config=C.set=function(x){var v,w;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(v="DECIMAL_PLACES")&&(w=x[v],Ot(w,0,ln,v),s=w),x.hasOwnProperty(v="ROUNDING_MODE")&&(w=x[v],Ot(w,0,8,v),a=w),x.hasOwnProperty(v="EXPONENTIAL_AT")&&(w=x[v],w&&w.pop?(Ot(w[0],-ln,0,v),Ot(w[1],0,ln,v),u=w[0],c=w[1]):(Ot(w,-ln,ln,v),u=-(c=w<0?-w:w))),x.hasOwnProperty(v="RANGE"))if(w=x[v],w&&w.pop)Ot(w[0],-ln,-1,v),Ot(w[1],1,ln,v),l=w[0],d=w[1];else if(Ot(w,-ln,ln,v),w)l=-(d=w<0?-w:w);else throw Error(jn+v+" cannot be zero: "+w);if(x.hasOwnProperty(v="CRYPTO"))if(w=x[v],w===!!w)if(w)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=w;else throw g=!w,Error(jn+"crypto unavailable");else g=w;else throw Error(jn+v+" not true or false: "+w);if(x.hasOwnProperty(v="MODULO_MODE")&&(w=x[v],Ot(w,0,9,v),p=w),x.hasOwnProperty(v="POW_PRECISION")&&(w=x[v],Ot(w,0,ln,v),m=w),x.hasOwnProperty(v="FORMAT"))if(w=x[v],typeof w=="object")k=w;else throw Error(jn+v+" not an object: "+w);if(x.hasOwnProperty(v="ALPHABET"))if(w=x[v],typeof w=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(w))A=w.slice(0,10)=="0123456789",I=w;else throw Error(jn+v+" invalid: "+w)}else throw Error(jn+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:m,FORMAT:k,ALPHABET:I}},C.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!C.DEBUG)return!0;var v,w,E=x.c,f=x.e,T=x.s;e:if({}.toString.call(E)=="[object Array]"){if((T===1||T===-1)&&f>=-ln&&f<=ln&&f===fr(f)){if(E[0]===0){if(f===0&&E.length===1)return!0;break e}if(v=(f+1)%Ve,v<1&&(v+=Ve),String(E[0]).length==v){for(v=0;v<E.length;v++)if(w=E[v],w<0||w>=Er||w!==fr(w))break e;if(w!==0)return!0}}}else if(E===null&&f===null&&(T===null||T===1||T===-1))return!0;throw Error(jn+"Invalid BigNumber: "+x)},C.maximum=C.max=function(){return R(arguments,-1)},C.minimum=C.min=function(){return R(arguments,1)},C.random=(function(){var x=9007199254740992,v=Math.random()*x&2097151?function(){return fr(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(w){var E,f,T,S,y,F=0,L=[],M=new C(i);if(w==null?w=s:Ot(w,0,ln),S=im(w/Ve),g)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(S*=2));F<S;)y=E[F]*131072+(E[F+1]>>>11),y>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),E[F]=f[0],E[F+1]=f[1]):(L.push(y%1e14),F+=2);F=S/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(S*=7);F<S;)y=(E[F]&31)*281474976710656+E[F+1]*1099511627776+E[F+2]*4294967296+E[F+3]*16777216+(E[F+4]<<16)+(E[F+5]<<8)+E[F+6],y>=9e15?crypto.randomBytes(7).copy(E,F):(L.push(y%1e14),F+=7);F=S/7}else throw g=!1,Error(jn+"crypto unavailable");if(!g)for(;F<S;)y=v(),y<9e15&&(L[F++]=y%1e14);for(S=L[--F],w%=Ve,S&&w&&(y=am[Ve-w],L[F]=fr(S/y)*y);L[F]===0;L.pop(),F--);if(F<0)L=[T=0];else{for(T=-1;L[0]===0;L.splice(0,1),T-=Ve);for(F=1,y=L[0];y>=10;y/=10,F++);F<Ve&&(T-=Ve-F)}return M.e=T,M.c=L,M}})(),C.sum=function(){for(var x=1,v=arguments,w=new C(v[0]);x<v.length;)w=w.plus(v[x++]);return w},n=(function(){var x="0123456789";function v(w,E,f,T){for(var S,y=[0],F,L=0,M=w.length;L<M;){for(F=y.length;F--;y[F]*=E);for(y[0]+=T.indexOf(w.charAt(L++)),S=0;S<y.length;S++)y[S]>f-1&&(y[S+1]==null&&(y[S+1]=0),y[S+1]+=y[S]/f|0,y[S]%=f)}return y.reverse()}return function(w,E,f,T,S){var y,F,L,M,z,h,j,V,B=w.indexOf("."),G=s,te=a;for(B>=0&&(M=m,m=0,w=w.replace(".",""),V=new C(E),h=V.pow(w.length-B),m=M,V.c=v(so(gr(h.c),h.e,"0"),10,f,x),V.e=V.c.length),j=v(w,E,f,S?(y=I,x):(y=x,I)),L=M=j.length;j[--M]==0;j.pop());if(!j[0])return y.charAt(0);if(B<0?--L:(h.c=j,h.e=L,h.s=T,h=t(h,V,G,te,f),j=h.c,z=h.r,L=h.e),F=L+G+1,B=j[F],M=f/2,z=z||F<0||j[F+1]!=null,z=te<4?(B!=null||z)&&(te==0||te==(h.s<0?3:2)):B>M||B==M&&(te==4||z||te==6&&j[F-1]&1||te==(h.s<0?8:7)),F<1||!j[0])w=z?so(y.charAt(1),-G,y.charAt(0)):y.charAt(0);else{if(j.length=F,z)for(--f;++j[--F]>f;)j[F]=0,F||(++L,j=[1].concat(j));for(M=j.length;!j[--M];);for(B=0,w="";B<=M;w+=y.charAt(j[B++]));w=so(w,L,y.charAt(0))}return w}})(),t=(function(){function x(E,f,T){var S,y,F,L,M=0,z=E.length,h=f%Fo,j=f/Fo|0;for(E=E.slice();z--;)F=E[z]%Fo,L=E[z]/Fo|0,S=j*F+L*h,y=h*F+S%Fo*Fo+M,M=(y/T|0)+(S/Fo|0)+j*L,E[z]=y%T;return M&&(E=[M].concat(E)),E}function v(E,f,T,S){var y,F;if(T!=S)F=T>S?1:-1;else for(y=F=0;y<T;y++)if(E[y]!=f[y]){F=E[y]>f[y]?1:-1;break}return F}function w(E,f,T,S){for(var y=0;T--;)E[T]-=y,y=E[T]<f[T]?1:0,E[T]=y*S+E[T]-f[T];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,f,T,S,y){var F,L,M,z,h,j,V,B,G,te,le,xe,ie,Ke,be,Ie,ve,ue=E.s==f.s?1:-1,$e=E.c,pe=f.c;if(!$e||!$e[0]||!pe||!pe[0])return new C(!E.s||!f.s||($e?pe&&$e[0]==pe[0]:!pe)?NaN:$e&&$e[0]==0||!pe?ue*0:ue/0);for(B=new C(ue),G=B.c=[],L=E.e-f.e,ue=T+L+1,y||(y=Er,L=mr(E.e/Ve)-mr(f.e/Ve),ue=ue/Ve|0),M=0;pe[M]==($e[M]||0);M++);if(pe[M]>($e[M]||0)&&L--,ue<0)G.push(1),z=!0;else{for(Ke=$e.length,Ie=pe.length,M=0,ue+=2,h=fr(y/(pe[0]+1)),h>1&&(pe=x(pe,h,y),$e=x($e,h,y),Ie=pe.length,Ke=$e.length),ie=Ie,te=$e.slice(0,Ie),le=te.length;le<Ie;te[le++]=0);ve=pe.slice(),ve=[0].concat(ve),be=pe[0],pe[1]>=y/2&&be++;do{if(h=0,F=v(pe,te,Ie,le),F<0){if(xe=te[0],Ie!=le&&(xe=xe*y+(te[1]||0)),h=fr(xe/be),h>1)for(h>=y&&(h=y-1),j=x(pe,h,y),V=j.length,le=te.length;v(j,te,V,le)==1;)h--,w(j,Ie<V?ve:pe,V,y),V=j.length,F=1;else h==0&&(F=h=1),j=pe.slice(),V=j.length;if(V<le&&(j=[0].concat(j)),w(te,j,le,y),le=te.length,F==-1)for(;v(pe,te,Ie,le)<1;)h++,w(te,Ie<le?ve:pe,le,y),le=te.length}else F===0&&(h++,te=[0]);G[M++]=h,te[0]?te[le++]=$e[ie]||0:(te=[$e[ie]],le=1)}while((ie++<Ke||te[0]!=null)&&ue--);z=te[0]!=null,G[0]||G.splice(0,1)}if(y==Er){for(M=1,ue=G[0];ue>=10;ue/=10,M++);P(B,T+(B.e=M+L*Ve-1)+1,S,z)}else B.e=L,B.r=+z;return B}})();function D(x,v,w,E){var f,T,S,y,F;if(w==null?w=a:Ot(w,0,8),!x.c)return x.toString();if(f=x.c[0],S=x.e,v==null)F=gr(x.c),F=E==1||E==2&&(S<=u||S>=c)?Xl(F,S):so(F,S,"0");else if(x=P(new C(x),v,w),T=x.e,F=gr(x.c),y=F.length,E==1||E==2&&(v<=T||T<=u)){for(;y<v;F+="0",y++);F=Xl(F,T)}else if(v-=S+(E===2&&T>S),F=so(F,T,"0"),T+1>y){if(--v>0)for(F+=".";v--;F+="0");}else if(v+=T-y,v>0)for(T+1==y&&(F+=".");v--;F+="0");return x.s<0&&f?"-"+F:F}function R(x,v){for(var w,E,f=1,T=new C(x[0]);f<x.length;f++)E=new C(x[f]),(!E.s||(w=ni(T,E))===v||w===0&&T.s===v)&&(T=E);return T}function _(x,v,w){for(var E=1,f=v.length;!v[--f];v.pop());for(f=v[0];f>=10;f/=10,E++);return(w=E+w*Ve-1)>d?x.c=x.e=null:w<l?x.c=[x.e=0]:(x.e=w,x.c=v),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,v=/^([^.]+)\.$/,w=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,S,y,F){var L,M=y?S:S.replace(f,"");if(E.test(M))T.s=isNaN(M)?null:M<0?-1:1;else{if(!y&&(M=M.replace(x,function(z,h,j){return L=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!F||F==L?h:z}),F&&(L=F,M=M.replace(v,"$1").replace(w,"0.$1")),S!=M))return new C(M,L);if(C.DEBUG)throw Error(jn+"Not a"+(F?" base "+F:"")+" number: "+S);T.s=null}T.c=T.e=null}})();function P(x,v,w,E){var f,T,S,y,F,L,M,z=x.c,h=am;if(z){e:{for(f=1,y=z[0];y>=10;y/=10,f++);if(T=v-f,T<0)T+=Ve,S=v,F=z[L=0],M=fr(F/h[f-S-1]%10);else if(L=im((T+1)/Ve),L>=z.length)if(E){for(;z.length<=L;z.push(0));F=M=0,f=1,T%=Ve,S=T-Ve+1}else break e;else{for(F=y=z[L],f=1;y>=10;y/=10,f++);T%=Ve,S=T-Ve+f,M=S<0?0:fr(F/h[f-S-1]%10)}if(E=E||v<0||z[L+1]!=null||(S<0?F:F%h[f-S-1]),E=w<4?(M||E)&&(w==0||w==(x.s<0?3:2)):M>5||M==5&&(w==4||E||w==6&&(T>0?S>0?F/h[f-S]:0:z[L-1])%10&1||w==(x.s<0?8:7)),v<1||!z[0])return z.length=0,E?(v-=x.e+1,z[0]=h[(Ve-v%Ve)%Ve],x.e=-v||0):z[0]=x.e=0,x;if(T==0?(z.length=L,y=1,L--):(z.length=L+1,y=h[Ve-T],z[L]=S>0?fr(F/h[f-S]%h[S])*y:0),E)for(;;)if(L==0){for(T=1,S=z[0];S>=10;S/=10,T++);for(S=z[0]+=y,y=1;S>=10;S/=10,y++);T!=y&&(x.e++,z[0]==Er&&(z[0]=1));break}else{if(z[L]+=y,z[L]!=Er)break;z[L--]=0,y=1}for(T=z.length;z[--T]===0;z.pop());}x.e>d?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function N(x){var v,w=x.e;return w===null?x.toString():(v=gr(x.c),v=w<=u||w>=c?Xl(v,w):so(v,w,"0"),x.s<0?"-"+v:v)}return o.absoluteValue=o.abs=function(){var x=new C(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,v){return ni(this,new C(x,v))},o.decimalPlaces=o.dp=function(x,v){var w,E,f,T=this;if(x!=null)return Ot(x,0,ln),v==null?v=a:Ot(v,0,8),P(new C(T),x+T.e+1,v);if(!(w=T.c))return null;if(E=((f=w.length-1)-mr(this.e/Ve))*Ve,f=w[f])for(;f%10==0;f/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(x,v){return t(this,new C(x,v),s,a)},o.dividedToIntegerBy=o.idiv=function(x,v){return t(this,new C(x,v),0,1)},o.exponentiatedBy=o.pow=function(x,v){var w,E,f,T,S,y,F,L,M,z=this;if(x=new C(x),x.c&&!x.isInteger())throw Error(jn+"Exponent not an integer: "+N(x));if(v!=null&&(v=new C(v)),y=x.e>14,!z.c||!z.c[0]||z.c[0]==1&&!z.e&&z.c.length==1||!x.c||!x.c[0])return M=new C(Math.pow(+N(z),y?x.s*(2-Kl(x)):+N(x))),v?M.mod(v):M;if(F=x.s<0,v){if(v.c?!v.c[0]:!v.s)return new C(NaN);E=!F&&z.isInteger()&&v.isInteger(),E&&(z=z.mod(v))}else{if(x.e>9&&(z.e>0||z.e<-1||(z.e==0?z.c[0]>1||y&&z.c[1]>=24e7:z.c[0]<8e13||y&&z.c[0]<=9999975e7)))return T=z.s<0&&Kl(x)?-0:0,z.e>-1&&(T=1/T),new C(F?1/T:T);m&&(T=im(m/Ve+2))}for(y?(w=new C(.5),F&&(x.s=1),L=Kl(x)):(f=Math.abs(+N(x)),L=f%2),M=new C(i);;){if(L){if(M=M.times(z),!M.c)break;T?M.c.length>T&&(M.c.length=T):E&&(M=M.mod(v))}if(f){if(f=fr(f/2),f===0)break;L=f%2}else if(x=x.times(w),P(x,x.e+1,1),x.e>14)L=Kl(x);else{if(f=+N(x),f===0)break;L=f%2}z=z.times(z),T?z.c&&z.c.length>T&&(z.c.length=T):E&&(z=z.mod(v))}return E?M:(F&&(M=i.div(M)),v?M.mod(v):T?P(M,m,a,S):M)},o.integerValue=function(x){var v=new C(this);return x==null?x=a:Ot(x,0,8),P(v,v.e+1,x)},o.isEqualTo=o.eq=function(x,v){return ni(this,new C(x,v))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,v){return ni(this,new C(x,v))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,v){return(v=ni(this,new C(x,v)))===1||v===0},o.isInteger=function(){return!!this.c&&mr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,v){return ni(this,new C(x,v))<0},o.isLessThanOrEqualTo=o.lte=function(x,v){return(v=ni(this,new C(x,v)))===-1||v===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(x,v){var w,E,f,T,S=this,y=S.s;if(x=new C(x,v),v=x.s,!y||!v)return new C(NaN);if(y!=v)return x.s=-v,S.plus(x);var F=S.e/Ve,L=x.e/Ve,M=S.c,z=x.c;if(!F||!L){if(!M||!z)return M?(x.s=-v,x):new C(z?S:NaN);if(!M[0]||!z[0])return z[0]?(x.s=-v,x):new C(M[0]?S:a==3?-0:0)}if(F=mr(F),L=mr(L),M=M.slice(),y=F-L){for((T=y<0)?(y=-y,f=M):(L=F,f=z),f.reverse(),v=y;v--;f.push(0));f.reverse()}else for(E=(T=(y=M.length)<(v=z.length))?y:v,y=v=0;v<E;v++)if(M[v]!=z[v]){T=M[v]<z[v];break}if(T&&(f=M,M=z,z=f,x.s=-x.s),v=(E=z.length)-(w=M.length),v>0)for(;v--;M[w++]=0);for(v=Er-1;E>y;){if(M[--E]<z[E]){for(w=E;w&&!M[--w];M[w]=v);--M[w],M[E]+=Er}M[E]-=z[E]}for(;M[0]==0;M.splice(0,1),--L);return M[0]?_(x,M,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,v){var w,E,f=this;return x=new C(x,v),!f.c||!x.s||x.c&&!x.c[0]?new C(NaN):!x.c||f.c&&!f.c[0]?new C(f):(p==9?(E=x.s,x.s=1,w=t(f,x,0,3),x.s=E,w.s*=E):w=t(f,x,0,p),x=f.minus(w.times(x)),!x.c[0]&&p==1&&(x.s=f.s),x)},o.multipliedBy=o.times=function(x,v){var w,E,f,T,S,y,F,L,M,z,h,j,V,B,G,te=this,le=te.c,xe=(x=new C(x,v)).c;if(!le||!xe||!le[0]||!xe[0])return!te.s||!x.s||le&&!le[0]&&!xe||xe&&!xe[0]&&!le?x.c=x.e=x.s=null:(x.s*=te.s,!le||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(E=mr(te.e/Ve)+mr(x.e/Ve),x.s*=te.s,F=le.length,z=xe.length,F<z&&(V=le,le=xe,xe=V,f=F,F=z,z=f),f=F+z,V=[];f--;V.push(0));for(B=Er,G=Fo,f=z;--f>=0;){for(w=0,h=xe[f]%G,j=xe[f]/G|0,S=F,T=f+S;T>f;)L=le[--S]%G,M=le[S]/G|0,y=j*L+M*h,L=h*L+y%G*G+V[T]+w,w=(L/B|0)+(y/G|0)+j*M,V[T--]=L%B;V[T]=w}return w?++E:V.splice(0,1),_(x,V,E)},o.negated=function(){var x=new C(this);return x.s=-x.s||null,x},o.plus=function(x,v){var w,E=this,f=E.s;if(x=new C(x,v),v=x.s,!f||!v)return new C(NaN);if(f!=v)return x.s=-v,E.minus(x);var T=E.e/Ve,S=x.e/Ve,y=E.c,F=x.c;if(!T||!S){if(!y||!F)return new C(f/0);if(!y[0]||!F[0])return F[0]?x:new C(y[0]?E:f*0)}if(T=mr(T),S=mr(S),y=y.slice(),f=T-S){for(f>0?(S=T,w=F):(f=-f,w=y),w.reverse();f--;w.push(0));w.reverse()}for(f=y.length,v=F.length,f-v<0&&(w=F,F=y,y=w,v=f),f=0;v;)f=(y[--v]=y[v]+F[v]+f)/Er|0,y[v]=Er===y[v]?0:y[v]%Er;return f&&(y=[f].concat(y),++S),_(x,y,S)},o.precision=o.sd=function(x,v){var w,E,f,T=this;if(x!=null&&x!==!!x)return Ot(x,1,ln),v==null?v=a:Ot(v,0,8),P(new C(T),x,v);if(!(w=T.c))return null;if(f=w.length-1,E=f*Ve+1,f=w[f]){for(;f%10==0;f/=10,E--);for(f=w[0];f>=10;f/=10,E++);}return x&&T.e+1>E&&(E=T.e+1),E},o.shiftedBy=function(x){return Ot(x,-sm,sm),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,v,w,E,f,T=this,S=T.c,y=T.s,F=T.e,L=s+4,M=new C("0.5");if(y!==1||!S||!S[0])return new C(!y||y<0&&(!S||S[0])?NaN:S?T:1/0);if(y=Math.sqrt(+N(T)),y==0||y==1/0?(v=gr(S),(v.length+F)%2==0&&(v+="0"),y=Math.sqrt(+v),F=mr((F+1)/2)-(F<0||F%2),y==1/0?v="5e"+F:(v=y.toExponential(),v=v.slice(0,v.indexOf("e")+1)+F),w=new C(v)):w=new C(y+""),w.c[0]){for(F=w.e,y=F+L,y<3&&(y=0);;)if(f=w,w=M.times(f.plus(t(T,f,L,1))),gr(f.c).slice(0,y)===(v=gr(w.c)).slice(0,y))if(w.e<F&&--y,v=v.slice(y-3,y+1),v=="9999"||!E&&v=="4999"){if(!E&&(P(f,f.e+s+2,0),f.times(f).eq(T))){w=f;break}L+=4,y+=4,E=1}else{(!+v||!+v.slice(1)&&v.charAt(0)=="5")&&(P(w,w.e+s+2,1),x=!w.times(w).eq(T));break}}return P(w,w.e+s+1,a,x)},o.toExponential=function(x,v){return x!=null&&(Ot(x,0,ln),x++),D(this,x,v,1)},o.toFixed=function(x,v){return x!=null&&(Ot(x,0,ln),x=x+this.e+1),D(this,x,v)},o.toFormat=function(x,v,w){var E,f=this;if(w==null)x!=null&&v&&typeof v=="object"?(w=v,v=null):x&&typeof x=="object"?(w=x,x=v=null):w=k;else if(typeof w!="object")throw Error(jn+"Argument not an object: "+w);if(E=f.toFixed(x,v),f.c){var T,S=E.split("."),y=+w.groupSize,F=+w.secondaryGroupSize,L=w.groupSeparator||"",M=S[0],z=S[1],h=f.s<0,j=h?M.slice(1):M,V=j.length;if(F&&(T=y,y=F,F=T,V-=T),y>0&&V>0){for(T=V%y||y,M=j.substr(0,T);T<V;T+=y)M+=L+j.substr(T,y);F>0&&(M+=L+j.slice(T)),h&&(M="-"+M)}E=z?M+(w.decimalSeparator||"")+((F=+w.fractionGroupSize)?z.replace(new RegExp("\\d{"+F+"}\\B","g"),"$&"+(w.fractionGroupSeparator||"")):z):M}return(w.prefix||"")+E+(w.suffix||"")},o.toFraction=function(x){var v,w,E,f,T,S,y,F,L,M,z,h,j=this,V=j.c;if(x!=null&&(y=new C(x),!y.isInteger()&&(y.c||y.s!==1)||y.lt(i)))throw Error(jn+"Argument "+(y.isInteger()?"out of range: ":"not an integer: ")+N(y));if(!V)return new C(j);for(v=new C(i),L=w=new C(i),E=F=new C(i),h=gr(V),T=v.e=h.length-j.e-1,v.c[0]=am[(S=T%Ve)<0?Ve+S:S],x=!x||y.comparedTo(v)>0?T>0?v:L:y,S=d,d=1/0,y=new C(h),F.c[0]=0;M=t(y,v,0,1),f=w.plus(M.times(E)),f.comparedTo(x)!=1;)w=E,E=f,L=F.plus(M.times(f=L)),F=f,v=y.minus(M.times(f=v)),y=f;return f=t(x.minus(w),E,0,1),F=F.plus(f.times(L)),w=w.plus(f.times(E)),F.s=L.s=j.s,T=T*2,z=t(L,E,T,a).minus(j).abs().comparedTo(t(F,w,T,a).minus(j).abs())<1?[L,E]:[F,w],d=S,z},o.toNumber=function(){return+N(this)},o.toPrecision=function(x,v){return x!=null&&Ot(x,1,ln),D(this,x,v,2)},o.toString=function(x){var v,w=this,E=w.s,f=w.e;return f===null?E?(v="Infinity",E<0&&(v="-"+v)):v="NaN":(x==null?v=f<=u||f>=c?Xl(gr(w.c),f):so(gr(w.c),f,"0"):x===10&&A?(w=P(new C(w),s+f+1,a),v=so(gr(w.c),w.e,"0")):(Ot(x,2,I.length,"Base"),v=n(so(gr(w.c),f,"0"),10,x,E,!0)),E<0&&w.c[0]&&(v="-"+v)),v},o.valueOf=o.toJSON=function(){return N(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&C.set(e),C}function mr(e){var t=e|0;return e>0||e===t?t:t-1}function gr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=Ve-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function ni(e,t){var n,r,o=e.c,i=t.c,s=e.s,a=t.s,u=e.e,c=t.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=u==c,!o||!i)return r?0:!o^n?1:-1;if(!r)return u>c^n?1:-1;for(a=(u=o.length)<(c=i.length)?u:c,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return u==c?0:u>c^n?1:-1}function Ot(e,t,n,r){if(e<t||e>n||e!==fr(e))throw Error(jn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Kl(e){var t=e.c.length-1;return mr(e.e/Ve)==t&&e.c[t]%2!=0}function Xl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function so(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(r=e.length,++t>r){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var Cz=kv(),Cv=Cz;var Tz=24,Qs=32,Iz=()=>typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"?()=>{let e=new Uint32Array(1);return globalThis.crypto.getRandomValues(e),e[0]/4294967296}:Math.random,cm=Iz(),lm=(e=4,t=cm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function Fz(e){let t=new Cv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Iv=(e="")=>{let t=new TextEncoder;return Fz(wv(t.encode(e))).toString(36).slice(1)},Tv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),Ez=e=>Tv[Math.floor(e()*Tv.length)],Az=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=cm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+lm(Qs,t):lm(Qs,t);return Iv(r).substring(0,Qs)},Pz=e=>()=>e++,Lz=476782367,Fv=({random:e=cm,counter:t=Pz(Math.floor(e()*Lz)),length:n=Tz,fingerprint:r=Az({random:e})}={})=>{if(n>Qs)throw new Error(`Length must be between 2 and ${Qs}. Received: ${n}`);return function(){let i=Ez(e),s=Date.now().toString(36),a=t().toString(36),u=lm(n,e),c=`${s+u+a+r}`;return`${i+Iv(c).substring(1,n)}`}},Eo=Mz(Fv);function Mz(e){let t;return()=>(t||(t=e()),t())}var Rz=Va(Pv());_n();_e();var Ql=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function zz(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function um(e,t){let n=[],r=e.split(`
15
- `);for(let s=0;s<r.length;s++){let a=zz(r[s]),u=Ql.exec(a);if(u){let[,c,l,,d]=u,g=Nz(l),p=Oz(r,s+1),m={id:Eo(),reviewId:t,type:c.trim(),severity:g,title:d.trim(),description:p.description,file:p.file,lineNumber:p.lineNumber,property:p.property,currentValue:p.currentValue,suggestedValue:p.suggestedValue,suggestedCode:p.suggestedCode,suggestedFix:p.suggestedFix,fixTarget:p.fixTarget,fixRequired:p.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(m)}Ql.lastIndex=0}return n.map(s=>{let a=Us(s);return a.dismissed?(b.debug(`[parseIssues] Auto-dismissed: ${s.title} - ${a.dismissReason}`),{...s,dismissed:!0,dismissReason:a.dismissReason,dismissedBy:a.dismissedBy,dismissedAt:new Date}):s})}function Nz(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function Oz(e,t){let n={description:"",file:void 0,lineNumber:void 0,property:void 0,currentValue:void 0,suggestedValue:void 0,suggestedCode:void 0,suggestedFix:void 0,fixTarget:void 0,fixRequired:void 0},r=[];for(let o=t;o<e.length;o++){let i=e[o].trim();if(!i||Ql.test(i)){Ql.lastIndex=0;break}if(i.startsWith("Expected:"))n.suggestedValue=i.replace("Expected:","").trim();else if(i.startsWith("Actual:")||i.startsWith("Current:"))n.currentValue=i.replace(/^(Actual|Current):/,"").trim();else if(i.startsWith("File:")){let s=i.replace("File:","").trim(),a=s.match(/^(.+?):(\d+)$/);a?(n.file=a[1],n.lineNumber=parseInt(a[2],10)):n.file=s}else if(i.startsWith("Property:"))n.property=i.replace("Property:","").trim();else if(i.startsWith("FixTarget:")){let s=i.replace("FixTarget:","").trim().toLowerCase();(s==="css"||s==="component")&&(n.fixTarget=s)}else if(i.startsWith("FixRequired:")){let s=i.replace("FixRequired:","").trim().toLowerCase();n.fixRequired=s==="true"}else if(i.startsWith("Fix:"))n.suggestedFix=i.replace("Fix:","").trim();else if(i.startsWith("```")){let s=[];for(o++;o<e.length&&!e[o].trim().startsWith("```");)s.push(e[o]),o++;n.suggestedCode=s.join(`
16
- `)}else r.push(i)}return n.description=r.join(" ").trim(),n}_e();var Js=null,Lv=0,_z=3e4;async function $z(){let e=Date.now();if(Js&&e-Lv<_z)return Js;try{let t=await fetch("/index.json");if(!t.ok)throw new Error(`Failed to fetch index.json: ${t.status}`);let n=await t.json();return Js=n.entries||n.stories||{},Lv=e,b.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Js).length),Js}catch(t){throw b.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Zs(e){try{let n=(await $z())[e];if(!n?.importPath)return b.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;b.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),b.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,b.debug("[storyFilePaths] Derived componentFile:",i));let s=i.replace(/\.tsx$/,".css").replace(/\.ts$/,".css").replace(/\.jsx$/,".css").replace(/\.js$/,".css"),a=i.substring(0,i.lastIndexOf("/")),u={storyFile:o,componentFile:i,cssFile:s,baseDir:a};return b.debug("[storyFilePaths] Final paths:",u),u}catch(t){return b.error("[storyFilePaths] Error getting file paths:",t),null}}function pm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function Uz(e,t){let n=e.toLowerCase().trim();return["color","spacing","typography","dimension","border","shadow","layout","background","font","size","margin","padding"].some(i=>n.includes(i))?t.cssFile:t.componentFile}function dm(e,t){let n=e.property?.toLowerCase()||"",r=e.domElement?.toLowerCase()||"",o=r.startsWith("svg"),i=r.startsWith("img"),s=n==="width"||n==="height",a=/\[(?:width|height)=/.test(r);return(o||i)&&s||a?(b.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):Uz(e.type,t)}_e();function jz(e){let t=(e.description||"").toLowerCase(),n=(e.title||"").toLowerCase(),r=`${t} ${n}`;return r.includes("inner icon")||r.includes("inner vector")?"inner-icon":r.includes("second icon")?"icon-2":r.includes("first icon")?"icon-1":r.includes("icon")||r.includes("vector")||r.includes("svg")?"icon":r.includes("button")?"button":r.includes("text")||r.includes("label")?"text":r.includes("container")||r.includes("wrapper")?"container":"other"}function Hz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("width")||t.includes("height")||t.includes("size")||t.includes("dimensions")?"dimensions":t.includes("padding")||t.includes("margin")||t.includes("gap")?"spacing":t.includes("color")||t.includes("background")||t.includes("fill")?"colors":t.includes("font")||t.includes("text")||t.includes("line-height")?"typography":t.includes("border")||t.includes("radius")?"border":n.includes("overall")||n.includes("visual fidelity")||n.includes("pixel similarity")||t.includes("overall")?"summary":"other"}function Wz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("overall")||t.includes("visual fidelity")||n.includes("pixel similarity score")||n.includes("primarily explained by")||n.includes("visual discrepancy")}function Vz(e,t,n){let r={critical:3,major:2,minor:1},i=[...e].sort((c,l)=>(r[l.severity]||0)-(r[c.severity]||0))[0],s=e.length,a,u;if(t.includes("icon")&&n==="dimensions"){let c=e.map(d=>d.currentValue).filter(Boolean),l=e.map(d=>d.suggestedValue).filter(Boolean);a=`Icon sizing is incorrect (${s} related issues)`,u=`Icons are rendered at wrong dimensions. Current: ${c[0]||"10px"}, Expected: ${l[0]||"20px"}. This single CSS fix will resolve all ${s} icon dimension issues.`}else a=`${t} ${n} issues (${s} related)`,u=`${s} related ${n} issues for ${t}. ${i.description}`;return{...i,id:`merged-${t}-${n}-${i.id}`,title:a,description:u,currentValue:i.currentValue,suggestedValue:i.suggestedValue,mergedCount:s,mergedIssueIds:e.map(c=>c.id)}}function gm(e){if(!e||e.length===0)return[];let t=e.filter(i=>!Wz(i)),n=[],r=[];for(let i of t){let s=jz(i),a=Hz(i);s.includes("icon")&&a==="dimensions"?n.push(i):r.push(i)}let o=[];return n.length>0&&(n.length===1?o.push(n[0]):o.push(Vz(n,"icon","dimensions"))),o.push(...r),b.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),b.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),b.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}_e();_n();var Gz=[/Failed to fetch/i,/NetworkError/i,/network request failed/i,/load failed/i,/ERR_(NETWORK|INTERNET|CONNECTION|NAME_NOT_RESOLVED)/i,/timed out/i,/aborted/i],qz=[/credits?/i,/Rate limit/i,/Figma connection expired/i,/Map.*to Figma|Figma mapping required/i,/No project selected/i,/Not authenticated/i,/No story/i,/Monthly review limit/i,/Upgrade your plan/i];function Mv(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return qz.some(n=>n.test(t))?t:Gz.some(n=>n.test(t))?`Can't reach ${Pt.NAME}. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.`:/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?`${Pt.NAME}'s servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.`:/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t}. Try again, or send feedback if this keeps happening.`}He();import{addons as ji}from"storybook/manager-api";var fm="uireview/badge",$i={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function Yz(e){return e.score<70?"status-value:error":e.score<90?"status-value:warning":"status-value:success"}function Kz(e){let t=[`Score: ${e.score}`];return e.criticalCount>0&&t.push(`${e.criticalCount} critical`),e.majorCount>0&&t.push(`${e.majorCount} major`),e.minorCount>0&&t.push(`${e.minorCount} minor`),t.join(" \xB7 ")}function Xz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Ui(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Rv(e){if(Ui())try{ji.getChannel().emit($i.REVIEW_START,{storyId:e})}catch{}}function Ur(e,t){if(Ui())try{ji.getChannel().emit($i.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function zv(e){if(Ui())try{ji.getChannel().emit($i.REVIEW_ERROR,{storyId:e})}catch{}}function Bv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Dv=null;function Nv(e){if(Dv!==null)return;let t=ji.getChannel(),n=o=>i=>{Ui()&&o(i)};t.on($i.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:fm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on($i.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:Yz(i),typeId:fm,storyId:o,title:Xz(i),description:Kz(i)}])})),t.on($i.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:fm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Ui();r||Bv(e),Dv=setInterval(()=>{let o=Ui();o!==r&&(r=o,o||Bv(e))},1500)}var Qz="uireview/mapped",Ov="uireview/mappings-updated";function _v(e){try{ji.getChannel().emit(Ov,{storyIds:e})}catch{}}function $v(e){ji.getChannel().on(Ov,({storyIds:n})=>{n.length&&e.set(n.map(r=>({value:"status-value:success",typeId:Qz,storyId:r,title:"\u2713 Linked to Figma",description:"Story has a Figma mapping"})))})}var mm=q(),hm=180;function Ao(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="object"){let t=e;if("value"in t&&typeof t.value=="string")return t.value;if("top"in t||"left"in t){let n=[t.top,t.right,t.bottom,t.left].filter(Boolean);if(n.length>0)return n.join(" ")}return JSON.stringify(e)}return String(e)}var xm=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:d,setReviewError:g,setReviewResults:p,setShowReviewMenu:m,setSeverityFilter:k,setShowStreamingPanel:I,setStreamingPanelCollapsed:A,addStreamingMessage:C,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:_,setStreamingStatus:P,setFullPrompt:N,setFullResponse:x,setFigmaImageUrl:v,storybookImageUrl:w,setStorybookImageUrl:E,setFigmaDimensions:f,setMultiModelResults:T,updateMultiModelStreamingMessages:S,setModelCompleted:y,setActiveModelId:F,resetReview:L,addReview:M,setReviewDetailTab:z,includeTextComparison:h,usePromptCache:j,setApplyFixesResult:V,featureFlags:B}=ce(),{sessionToken:G,usageData:te,setUsageData:le}=ke(),{selectedProjectId:xe}=Je(),{currentStoryId:ie,currentStoryName:Ke}=nt(),be=Jl(te);be.current=te;let Ie=Jl(null),ve=Jl(null),ue=Jl({}),$e=ea((fe,tt)=>{C({role:fe,content:tt})},[C]),pe=ea((fe,tt)=>{_(fe),P(tt)},[_,P]),yt=ea(async fe=>{let{isIteration:tt=!1,parentReviewId:he=null}=fe||{};if(!G)throw new Error("Not authenticated");if(!xe)throw new Error("No project selected");if(!ie||!Ke)throw new Error("No story is currently selected in Storybook");if(e){b.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let re=Date.now();try{d(!0),g(null),p(null),z("issues"),V(null),ie&&B.enableReviewBadges&&Rv(ie),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{b.debug(`[useAIReview] Auto-stopping review after ${hm}s timeout`),Ie.current&&Ie.current.abort(),C({role:"system",content:`Review auto-stopped after ${hm} seconds timeout.`})},hm*1e3),N(""),x(""),I(!0),A(!1),R(),pe(0,"Starting review..."),pe(5,"Refreshing component preview..."),b.debug("[Review] Forcing iframe reload for fresh styles..."),await Gl(),b.debug("[Review] Iframe reloaded, styles should be fresh"),pe(20,"Capturing screenshot & extracting styles..."),b.debug("[Review] Starting parallel data collection...");let[K,me,oe]=await Promise.all([Wl({sessionToken:G||void 0}),Promise.resolve(Ks()),Promise.resolve(Jf())]);if(K&&K!==w&&(E(K),b.debug("[Review] Storybook screenshot captured and set")),!me)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:H,textElementStyles:Ae,nestedElementStyles:Be}=me;oe?b.debug("[Review] DOM tree extracted:",{selector:oe.selector,childrenCount:oe.children.length}):(b.error("[Review] DOM tree extraction FAILED - domTree is null"),b.error("[Review] This will cause AI to use comparison table instead of tree comparison")),pe(50,"Preparing metadata..."),b.debug("[Review] Current story:",{id:ie,name:Ke});let vt=mt.getState().currentMapping?.figmaNodeId??null,Xn=mt.getState().figmaImageUrl;if(vt&&(b.debug("[Review] Using Figma node ID from store:",vt),Xn&&(pe(65,"Using existing Figma design..."),b.debug("[Review] Reusing already-loaded Figma image"))),!vt)try{let Qe=await fetch(`${mm}/api/mappings?projectId=${xe}&storyId=${ie}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(Qe.ok){let Nt=await Qe.json();Nt.mapping?.figmaNodeId?(vt=Nt.mapping.figmaNodeId,b.debug("[Review] Found Figma node ID from API:",vt)):b.debug("[Review] No mapping found for story:",ie)}else b.debug("[Review] Failed to fetch mapping:",Qe.status)}catch(Qe){b.error("[Review] Error fetching mapping:",Qe)}if(vt&&!Xn){pe(65,"Fetching Figma design...");try{let Qe=await fetch(`${mm}/api/figma/frames?projectId=${xe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(Qe.ok){let jt=(await Qe.json()).thumbnails?.[vt];jt?(v(jt),b.debug("[Review] Figma thumbnail fetched and displayed:",jt)):b.warn("[Review] No thumbnail found for node:",vt)}else b.warn("[Review] Failed to fetch Figma frames:",Qe.status)}catch(Qe){b.error("[Review] Error fetching Figma frames:",Qe)}}if(!vt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');pe(80,"AI is analyzing your component..."),b.debug("[Review] Sending to streaming API...");let sr={projectId:xe,storyId:ie,storyName:Ke,storybookScreenshot:K,computedStyles:O,declaredStyles:U,textElementStyles:Ae,nestedElementStyles:Be,componentMarkup:H,domTree:oe,figmaNodeId:vt,figmaImageUrl:Xn||void 0,aiModels:l,includeTextComparison:h,usePromptCache:j,parentReviewId:tt?he:void 0,isIteration:tt};b.debug("[Review] Request payload:",{...sr,storybookScreenshot:K?`${K.substring(0,50)}...`:null,domTree:oe?{selector:oe.selector,childrenCount:oe.children.length}:null}),Ie.current=new AbortController;let Mn=await fetch(`${mm}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`},body:JSON.stringify(sr),signal:Ie.current.signal});if(b.debug("[Review] Response status:",Mn.status,Mn.statusText),!Mn.ok){let Qe=await Mn.json();if(b.error("[Review] API error response:",Qe),Mn.status===429){let Nt=Qe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Nt} seconds before trying again.`)}if(Mn.status===402){if(Qe.code==="INSUFFICIENT_CREDITS"){let Nt=Qe.details?.required??1,jt=Qe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Nt} credit(s) but you have ${jt}. Visit Settings to add more.`)}throw Qe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Qe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Qe.message||"Payment required")}throw Mn.status===401&&Qe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Qe.error||Qe.message||"Review request failed")}let ho=Mn.body?.getReader(),Tn=new TextDecoder,Rr="",rn="",Ue=null,gu=null,iy=l.length>1,Go={},ps={},WV={};if(!ho)throw new Error("Response body is not readable");let sy=mt.getState().streamingMessages.length;for($e("assistant","");;){let{done:Qe,value:Nt}=await ho.read();if(Qe)break;Rr+=Tn.decode(Nt,{stream:!0});let jt=Rr.split(`
12
+ --`+new Array((n||t.length)+1).join("-")+"^"})}var jb=$(()=>{"use strict";pl()});var eP,tP,nP,rP,oP,Hb,Fl,Wb=$(()=>{"use strict";jb();eP=9,tP=10,nP=12,rP=13,oP=32,Hb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),Fl=class{constructor(t){this.str=t,this.pos=0}charCodeAt(t){return t<this.str.length?this.str.charCodeAt(t):0}charCode(){return this.charCodeAt(this.pos)}isNameCharCode(t=this.charCode()){return t<128&&Hb[t]===1}nextCharCode(){return this.charCodeAt(this.pos+1)}nextNonWsCode(t){return this.charCodeAt(this.findWsEnd(t))}skipWs(){this.pos=this.findWsEnd(this.pos)}findWsEnd(t){for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n!==rP&&n!==tP&&n!==nP&&n!==oP&&n!==eP)break}return t}substringToPos(t){return this.str.substring(this.pos,this.pos=t)}eat(t){this.charCode()!==t&&this.error("Expect `"+String.fromCharCode(t)+"`"),this.pos++}peek(){return this.pos<this.str.length?this.str.charAt(this.pos++):""}error(t){throw new Ub(t,this.str,this.pos)}scanSpaces(){return this.substringToPos(this.findWsEnd(this.pos))}scanWord(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n>=128||Hb[n]===0)break}return this.pos===t&&this.error("Expect a keyword"),this.substringToPos(t)}scanNumber(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n<48||n>57)break}return this.pos===t&&this.error("Expect a number"),this.substringToPos(t)}scanString(){let t=this.str.indexOf("'",this.pos+1);return t===-1&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(t+1)}}});function Xb(e){let t=null,n=null;return e.eat(Pl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===pp?(e.pos++,e.skipWs(),e.charCode()!==lp&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(lp),{min:Number(t),max:n?Number(n):0}}function pP(e){let t=null,n=!1;switch(e.charCode()){case e0:e.pos++,t={min:0,max:0};break;case up:e.pos++,t={min:1,max:0};break;case Al:e.pos++,t={min:0,max:1};break;case cp:e.pos++,n=!0,e.charCode()===Pl?t=Xb(e):e.charCode()===Al?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Pl:t=Xb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function no(e,t){let n=pP(e);return n!==null?(n.term=t,e.charCode()===cp&&e.charCodeAt(e.pos-1)===up||e.charCode()===Al&&e.charCodeAt(e.pos-1)===lp?no(e,n):n):t}function sp(e){let t=e.peek();return t===""?null:no(e,{type:"Token",value:t})}function dP(e){let t;return e.eat(dp),e.eat(El),t=e.scanWord(),e.eat(El),e.eat(ap),no(e,{type:"Property",name:t})}function gP(e){let t=null,n=null,r=1;return e.eat(Ps),e.charCode()===Gb&&(e.peek(),r=-1),r==-1&&e.charCode()===Yb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(pp),e.skipWs(),e.charCode()===Yb?e.peek():(r=1,e.charCode()===Gb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Pi),{type:"Range",min:t,max:n}}function fP(e){let t,n=null;if(e.eat(dp),t=e.scanWord(),t==="boolean-expr"){e.eat(Ps);let r=Ll(e,Pi);return e.eat(Pi),e.eat(ap),no(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Jb&&e.nextCharCode()===Zb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Ps&&(e.skipWs(),n=gP(e)),e.eat(ap),no(e,{type:"Type",name:t,opts:n})}function mP(e){let t=e.scanWord();return e.charCode()===Jb?(e.pos++,{type:"Function",name:t}):no(e,{type:"Keyword",name:t})}function hP(e,t){function n(o,i){return{type:"Group",terms:o,combinator:i,disallowEmpty:!1,explicit:!1}}let r;for(t=Object.keys(t).sort((o,i)=>Kb[o]-Kb[i]);t.length>0;){r=t.shift();let o=0,i=0;for(;o<e.length;o++){let s=e[o];s.type==="Combinator"&&(s.value===r?(i===-1&&(i=o-1),e.splice(o,1),o--):(i!==-1&&o-i>1&&(e.splice(i,o-i,n(e.slice(i,o),r)),o=i+1),i=-1))}i!==-1&&t.length&&e.splice(i,o-i,n(e.slice(i,o),r))}return r}function Ll(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?Ll(e,Zb):yP(e);if(!a)break;if(a.type!=="Spaces"){if(s){if(a.terms.length===0){s=!1;continue}if(a.combinator===" "){for(;a.terms.length>1;)n[" "]=!0,r.push({type:"Combinator",value:" "},a.terms.shift());a=a.terms[0]}}a.type==="Combinator"?((o===null||o.type==="Combinator")&&(e.pos=i,e.error("Unexpected combinator")),n[a.value]=!0):o!==null&&o.type!=="Combinator"&&(n[" "]=!0,r.push({type:"Combinator",value:" "})),r.push(a),o=a,i=e.pos,s=a.type==="Function"}}return o!==null&&o.type==="Combinator"&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:r,combinator:hP(r,n)||" ",disallowEmpty:!1,explicit:!1}}function xP(e){let t;return e.eat(Ps),t=Ll(e,Pi),e.eat(Pi),t.explicit=!0,e.charCode()===Qb&&(e.pos++,t.disallowEmpty=!0),t}function yP(e){let t=e.charCode();switch(t){case Pi:break;case Ps:return no(e,xP(e));case dp:return e.nextCharCode()===El?dP(e):fP(e);case qb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===qb?2:1))};case Vb:return e.pos++,e.eat(Vb),{type:"Combinator",value:"&&"};case pp:return e.pos++,{type:"Comma"};case El:return no(e,{type:"String",value:e.scanString()});case cP:case iP:case sP:case lP:case aP:return{type:"Spaces",value:e.scanSpaces()};case uP:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):sp(e);case e0:case up:case Al:case cp:case Qb:break;case Pl:if(t=e.nextCharCode(),t<48||t>57)return sp(e);break;default:return e.isNameCharCode(t)?mP(e):sp(e)}}function Ls(e){let t=new Fl(e),n=Ll(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var iP,sP,aP,lP,cP,Qb,cp,Vb,El,Jb,Zb,e0,up,pp,Gb,dp,ap,Al,uP,Ps,Pi,Pl,qb,lp,Yb,Kb,gp=$(()=>{"use strict";Wb();iP=9,sP=10,aP=12,lP=13,cP=32,Qb=33,cp=35,Vb=38,El=39,Jb=40,Zb=41,e0=42,up=43,pp=44,Gb=45,dp=60,ap=62,Al=63,uP=64,Ps=91,Pi=93,Pl=123,qb=124,lp=125,Yb=8734,Kb={" ":1,"&&":2,"||":3,"|":4}});function t0(e){return typeof e=="function"?e:Ms}function fp(e,t,n){function r(s){switch(o.call(n,s),s.type){case"Group":s.terms.forEach(r);break;case"Multiplier":case"Boolean":r(s.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+s.type)}i.call(n,s)}let o=Ms,i=Ms;if(typeof t=="function"?o=t:t&&(o=t0(t.enter),i=t0(t.leave)),o===Ms&&i===Ms)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ms,n0=$(()=>{"use strict";Ms=function(){}});var mp=$(()=>{"use strict";Gu();gp();n0()});function wP(e){let t=[];return vo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function r0(e,t){return typeof e=="string"?wP(e):t.generate(e,SP)}var SP,o0=$(()=>{"use strict";ur();SP={decorator(e){let t=[],n=null;return{...e,node(r){let o=n;n=r,e.node.call(this,r),n=o},emit(r,o,i){t.push({type:o,value:r,node:i?null:n})},result(){return t}}}}});function vn(e,t,n){return t===gt&&n===kt||e===gt&&t===gt&&n===gt?e:(e.type==="If"&&e.else===kt&&t===gt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function s0(e){return e.length>2&&e.charCodeAt(e.length-2)===vP&&e.charCodeAt(e.length-1)===kP}function i0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&s0(e.name)}function Co(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Bs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Bs(e.match,t,n),e.then=Bs(e.then,t,n),e.else=Bs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function hp(e,t,n){switch(e){case" ":{let r=gt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=vn(i,r,kt)}return r}case"|":{let r=kt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(i0(s)&&(o===null&&i>0&&i0(t[i-1])&&(o=Object.create(null),r=vn({type:"Enum",map:o},gt,r)),o!==null)){let a=(s0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=vn(s,gt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=hp(e,t.filter(function(a){return a!==i}),!1):s=gt,r=vn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?gt:kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=hp(e,t.filter(function(a){return a!==i}),!0):s=gt,r=vn(i,s,r)}return r}}}function CP(e){let t=gt,n=Li(e.term);if(e.max===0)n=vn(n,Ml,kt),t=vn(n,null,kt),t.then=vn(gt,gt,t),e.comma&&(t.then.else=vn({type:"Comma",syntax:e},t,kt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==gt&&(t=vn({type:"Comma",syntax:e},t,kt)),t=vn(n,vn(gt,gt,t),kt);if(e.min===0)t=vn(gt,gt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==gt&&(t=vn({type:"Comma",syntax:e},t,kt)),t=vn(n,t,kt);return t}function Li(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=hp(e.combinator,e.terms.map(Li),!1);return e.disallowEmpty&&(t=vn(t,Ml,kt)),t}case"Multiplier":return CP(e);case"Boolean":{let t=Li(e.term),n=Li(Co([Co([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Co([{type:"Type",name:"!boolean-group"},Co([{type:"Multiplier",comma:!1,min:0,max:0,term:Co([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Co([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=Li(Co([{type:"Type",name:"!term"},Co([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Bs(r,{"!term":t,"!self":n}),Bs(n,{"!boolean-group":r}),n}case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return e.value.length===3?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}function Ds(e,t){return typeof e=="string"&&(e=Ls(e)),{type:"MatchGraph",match:Li(e),syntax:t||null,source:e}}var gt,kt,Ml,vP,kP,xp=$(()=>{"use strict";gp();gt={type:"Match"},kt={type:"Mismatch"},Ml={type:"DisallowEmpty"},vP=40,kP=41});function PP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function yp(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=t.charCodeAt(n),o=e.charCodeAt(n);if(o>=65&&o<=90&&(o=o|32),o!==r)return!1}return!0}function LP(e){return e.type!==9?!1:e.value!=="?"}function u0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||LP(e)}function p0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function MP(e,t,n){function r(){do C++,A=C<e.length?e[C]:null;while(A!==null&&(A.type===13||A.type===25))}function o(_){let P=C+_;return P<e.length?e[P]:null}function i(_,P){return{nextState:_,matchStack:R,syntaxStack:d,thenStack:g,tokenIndex:C,prev:P}}function s(_){g={nextState:_,matchStack:R,syntaxStack:d,prev:g}}function a(_){p=i(_,p)}function u(){R={type:IP,syntax:t.syntax,token:A,prev:R},r(),m=null,C>D&&(D=C)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},R={type:bp,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===bp?R=R.prev:R={type:d0,syntax:d.syntax,token:R.token,prev:R},d=d.prev}let d=null,g=null,p=null,m=null,v=0,I=null,A=null,C=-1,D=0,R={type:TP,syntax:null,token:null,prev:null};for(r();I===null&&++v<c0;)switch(t.type){case"Match":if(g===null){if(A!==null&&(C!==e.length-1||A.value!=="\\0"&&A.value!=="\\9")){t=kt;break}I=l0;break}if(t=g.nextState,t===Ml)if(g.matchStack===R){t=kt;break}else t=gt;for(;g.syntaxStack!==d;)l();g=g.prev;break;case"Mismatch":if(m!==null&&m!==!1)(p===null||C>p.tokenIndex)&&(p=m,m=!1);else if(p===null){I=FP;break}t=p.nextState,g=p.thenStack,d=p.syntaxStack,R=p.matchStack,C=p.tokenIndex,A=C<e.length?e[C]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==kt&&a(t.else),t.then!==gt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let N=t.syntax.terms;if(t.index===N.length){if(t.mask===0||t.syntax.all){t=kt;break}t=gt;break}if(t.mask===(1<<N.length)-1){t=gt;break}for(;t.index<N.length;t.index++){let x=1<<t.index;if((t.mask&x)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|x}),t=N[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(A!==null){let N=A.value.toLowerCase();if(N.indexOf("\\")!==-1&&(N=N.replace(/\\[09].*$/,"")),a0.call(t.map,N)){t=t.map[N];break}}t=kt;break;case"Generic":{let N=d!==null?d.opts:null,x=C+Math.floor(t.fn(A,o,N));if(!isNaN(x)&&x>C){for(;C<x;)u();t=gt}else t=kt;break}case"Type":case"Property":{let N=t.type==="Type"?"types":"properties",x=a0.call(n,N)?n[N][t.name]:null;if(!x||!x.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(m!==!1&&A!==null&&t.type==="Type"&&(t.name==="custom-ident"&&A.type===1||t.name==="length"&&A.value==="0")){m===null&&(m=i(t,p)),t=kt;break}c(),t=x.matchRef||x.match;break}case"Keyword":{let N=t.name;if(A!==null){let x=A.value;if(x.indexOf("\\")!==-1&&(x=x.replace(/\\[09].*$/,"")),yp(x,N)){u(),t=gt;break}}t=kt;break}case"AtKeyword":case"Function":if(A!==null&&yp(A.value,t.name)){u(),t=gt;break}t=kt;break;case"Token":if(A!==null&&A.value===t.value){u(),t=gt;break}t=kt;break;case"Comma":A!==null&&A.type===18?u0(R.token)?t=kt:(u(),t=p0(A)?kt:gt):t=u0(R.token)||p0(A)?gt:kt;break;case"String":let _="",P=C;for(;P<e.length&&_.length<t.value.length;P++)_+=e[P].value;if(yp(_,t.value)){for(;C<P;)u();t=gt}else t=kt;break;default:throw new Error("Unknown node type: "+t.type)}switch(AP+=v,I){case null:console.warn("[csstree-match] BREAK after "+c0+" iterations"),I=EP,R=null;break;case l0:for(;d!==null;)l();break;default:R=null}return{tokens:e,reason:I,iterations:v,match:R,longestMatch:D}}function Sp(e,t,n){let r=MP(e,t,n||{});if(r.match===null)return r;let o=r.match,i=r.match={syntax:t.syntax||null,match:[]},s=[i];for(o=PP(o).prev;o!==null;){switch(o.type){case bp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case d0:s.pop(),i=s[s.length-1];break;default:i.match.push({syntax:o.syntax||null,token:o.token.value,node:o.token.node})}o=o.prev}return r}var a0,TP,IP,bp,d0,l0,FP,EP,c0,AP,g0=$(()=>{"use strict";xp();({hasOwnProperty:a0}=Object.prototype),TP=0,IP=1,bp=2,d0=3,l0="Match",FP="Mismatch",EP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",c0=15e3,AP=0});var vp={};Se(vp,{getTrace:()=>f0,isKeyword:()=>RP,isProperty:()=>DP,isType:()=>BP});function f0(e){function t(o){return o===null?!1:o.type==="Type"||o.type==="Property"||o.type==="Keyword"}function n(o){if(Array.isArray(o.match)){for(let i=0;i<o.match.length;i++)if(n(o.match[i]))return t(o.syntax)&&r.unshift(o.syntax),!0}else if(o.node===e)return r=t(o.syntax)?[o.syntax]:[],!0;return!1}let r=null;return this.matched!==null&&n(this.matched),r}function BP(e,t){return wp(this,e,n=>n.type==="Type"&&n.name===t)}function DP(e,t){return wp(this,e,n=>n.type==="Property"&&n.name===t)}function RP(e){return wp(this,e,t=>t.type==="Keyword")}function wp(e,t,n){let r=f0.call(e,t);return r===null?!1:r.some(n)}var m0=$(()=>{"use strict"});function h0(e){return"node"in e?e.node:h0(e.match[0])}function x0(e){return"node"in e?e.node:x0(e.match[e.match.length-1])}function kp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=h0(a),c=x0(a);e.syntax.walk(t,function(l,d,g){if(l===u){let p=new er;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:g,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var y0=$(()=>{"use strict";vs()});function Cp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function b0(e){return!!e&&Cp(e.offset)&&Cp(e.line)&&Cp(e.column)}function zP(e,t){return function(r,o){if(!r||r.constructor!==Object)return o(r,"Type of node should be an Object");for(let i in r){let s=!0;if(Rs.call(r,i)!==!1){if(i==="type")r.type!==e&&o(r,"Wrong node type `"+r.type+"`, expected `"+e+"`");else if(i==="loc"){if(r.loc===null)continue;if(r.loc&&r.loc.constructor===Object)if(typeof r.loc.source!="string")i+=".source";else if(!b0(r.loc.start))i+=".start";else if(!b0(r.loc.end))i+=".end";else continue;s=!1}else if(t.hasOwnProperty(i)){s=!1;for(let a=0;!s&&a<t[i].length;a++){let u=t[i][a];switch(u){case String:s=typeof r[i]=="string";break;case Boolean:s=typeof r[i]=="boolean";break;case null:s=r[i]===null;break;default:typeof u=="string"?s=r[i]&&r[i].type===u:Array.isArray(u)&&(s=r[i]instanceof er)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Rs.call(t,i)&&Rs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function S0(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o===String||o===Boolean)n.push(o.name.toLowerCase());else if(o===null)n.push("null");else if(typeof o=="string")n.push(o);else if(Array.isArray(o))n.push("List<"+(S0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function NP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Rs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=S0(s,e+"."+i)}return{docs:o,check:zP(e,r)}}function w0(e){let t={};if(e.node){for(let n in e.node)if(Rs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=NP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Rs,v0=$(()=>{"use strict";vs();({hasOwnProperty:Rs}=Object.prototype)});function Tp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:Ti(e[o].syntax,{compact:t}));return r}function OP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:Ti(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Tp(i.descriptors,t,n)};return r}function _P(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function $P(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function Ir(e,t,n){return{matched:e,iterations:n,error:t,...vp}}function Mi(e,t,n,r){let o=r0(n,e.syntax),i;return _P(o)?Ir(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=Sp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=Sp(o,t.match,e),!i.match)?Ir(null,new Tb(i.reason,t.syntax,n,i),i.iterations):Ir(i.match,null,i.iterations))}var zs,k0=$(()=>{"use strict";Ib();vl();kl();_b();$b();mp();o0();xp();g0();m0();y0();v0();zs=class{constructor(t,n,r){if(this.cssWideKeywords=Ei,this.syntax=n,this.generic=!1,this.units={...Il},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||w0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(Il))Array.isArray(t.units[o])&&(this.units[o]=t.units[o]);if(t.types)for(let[o,i]of Object.entries(t.types))this.addType_(o,i);if(t.generic){this.generic=!0;for(let[o,i]of Object.entries(Ob(this.units)))this.addType_(o,i)}if(t.atrules)for(let[o,i]of Object.entries(t.atrules))this.addAtrule_(o,i);if(t.properties)for(let[o,i]of Object.entries(t.properties))this.addProperty_(o,i)}this.cssWideKeywordsSyntax=Ds(this.cssWideKeywords.join(" | "))}checkStructure(t){function n(i,s){o.push({node:i,message:s})}let r=this.structure,o=[];return this.syntax.walk(t,function(i){r.hasOwnProperty(i.type)?r[i.type].check(i,n):n(i,"Unknown node type `"+i.type+"`")}),o.length?o:!1}createDescriptor(t,n,r,o=null){let i={type:n,name:r},s={type:n,name:r,parent:o,serializable:typeof t=="string"||t&&typeof t.type=="string",syntax:null,match:null,matchRef:null};return typeof t=="function"?s.match=Ds(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ls(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Ds(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=$P(a)?Ds({...a,terms:[a.terms[0].term]},i):null;return Object.defineProperty(s,"matchRef",{value:u}),u}})),s}addAtrule_(t,n){n&&(this.atrules[t]={type:"Atrule",name:t,prelude:n.prelude?this.createDescriptor(n.prelude,"AtrulePrelude",t):null,descriptors:n.descriptors?Object.keys(n.descriptors).reduce((r,o)=>(r[o]=this.createDescriptor(n.descriptors[o],"AtruleDescriptor",o,t),r),Object.create(null)):null})}addProperty_(t,n){n&&(this.properties[t]=this.createDescriptor(n,"Property",t))}addType_(t,n){n&&(this.types[t]=this.createDescriptor(n,"Type",t))}checkAtruleName(t){if(!this.getAtrule(t))return new Ii("Unknown at-rule","@"+t)}checkAtrulePrelude(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t);if(!o.prelude&&n)return new SyntaxError("At-rule `@"+t+"` should not contain a prelude");if(o.prelude&&!n&&!Mi(this,o.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+t+"` should contain a prelude")}checkAtruleDescriptorName(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t),i=Sl(n);if(!o.descriptors)return new SyntaxError("At-rule `@"+t+"` has no known descriptors");if(!o.descriptors[i.name]&&!o.descriptors[i.basename])return new Ii("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new Ii("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Ir(null,r);let o=this.getAtrule(t);return o.prelude?Mi(this,o.prelude,n||"",!1):Ir(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Ir(null,o);let i=this.getAtrule(t),s=Sl(n);return Mi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Ir(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(qu(t).custom)return Ir(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Ir(null,r):Mi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Mi(this,r,n,!1):Ir(null,new Ii("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Ir(null,new Ii("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Mi(this,t,n,!1))}findValueFragments(t,n,r,o){return kp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return kp(this,t.value,this.matchDeclaration(t),n,r)}findAllFragments(t,n,r){let o=[];return this.syntax.walk(t,{visit:"Declaration",enter:i=>{o.push.apply(o,this.findDeclarationValueFragments(i,n,r))}}),o}getAtrule(t,n=!0){let r=Sl(t);return(r.vendor&&n?this.atrules[r.name]||this.atrules[r.basename]:this.atrules[r.name])||null}getAtrulePrelude(t,n=!0){let r=this.getAtrule(t,n);return r&&r.prelude||null}getAtruleDescriptor(t,n){return this.atrules.hasOwnProperty(t)&&this.atrules.declarators&&this.atrules[t].declarators[n]||null}getProperty(t,n=!0){let r=qu(t);return(r.vendor&&n?this.properties[r.name]||this.properties[r.basename]:this.properties[r.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(u,c){return c?`<${u}>`:`<'${u}'>`}function n(u,c,l,d){if(l.has(c))return l.get(c);l.set(c,!1),d.syntax!==null&&fp(d.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let p=g.type==="Type"?u.types:u.properties,m=g.type==="Type"?o:i;hasOwnProperty.call(p,g.name)?n(u,g.name,m,p[g.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:Tp(this.types,!n,t),properties:Tp(this.properties,!n,t),atrules:OP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function Ip(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function UP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function Fp(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?UP(i,n):i};return r}function Ns(e,t){let n={...e};for(let[r,o]of Object.entries(t))switch(r){case"generic":n[r]=!!o;break;case"cssWideKeywords":n[r]=e[r]?[...e[r],...o]:o||[];break;case"units":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=Array.isArray(s)?s:[];break;case"atrules":n[r]={...e[r]};for(let[i,s]of Object.entries(o)){let a=n[r][i]||{},u=n[r][i]={prelude:a.prelude||null,descriptors:{...a.descriptors}};if(s){u.prelude=s.prelude?Ip(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?Ip(u.descriptors[c],l):null;Object.keys(u.descriptors).length||(u.descriptors=null)}}break;case"types":case"properties":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=Ip(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Fp(e[r],o);break;case"atrule":case"pseudo":n[r]=Fp(e[r],o,["parse"]);break;case"node":n[r]=Fp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var C0=$(()=>{"use strict"});function T0(e){let t=$y(e),n=vb(e),r=fb(e),{fromPlainObject:o,toPlainObject:i}=hb(n),s={lexer:null,createLexer:a=>new zs(a,s,s.lexer.structure),tokenize:vo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Ns({},e);return T0(typeof a=="function"?a(u):Ns(u,a))}};return s.lexer=new zs({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var I0,F0=$(()=>{"use strict";ur();Uy();mb();xb();kb();k0();C0();I0=e=>T0(Ns({},e))});var E0,A0=$(()=>{"use strict";E0={generic:!0,cssWideKeywords:["initial","inherit","unset","revert","revert-layer"],units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","an+b":"odd|even|<integer>|<n-dimension>|'+'? \u2020 n|-n|<ndashdigit-dimension>|'+'? \u2020 <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? \u2020 n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? \u2020 n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? \u2020 n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>","anchor()":"anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )","anchor-name":"<dashed-ident>","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [<anchor-name>||<anchor-size>]? , <length-percentage>? )","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>|<zero>","angular-color-stop":"<color> <color-stop-angle>?","angular-color-stop-list":"<angular-color-stop> , [<angular-color-hint>? , <angular-color-stop>]#?","animateable-feature":"scroll-position|contents|<custom-ident>","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <attr-type>? , <declaration-value>? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( <syntax> )|raw-string|number|<attr-unit>","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>","basic-shape-rect":"<inset()>|<rect()>|<xywh()>","bg-clip":"<visual-box>|border-area|text","bg-image":"<image>|none","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage [0,\u221E]>|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( <length>? )","brightness()":"brightness( [<number>|<percentage>]? )","calc()":"calc( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-size()":"calc-size( <calc-size-basis> , <calc-sum> )","calc-size-basis":"<intrinsic-size-keyword>|<calc-size()>|any|<calc-sum>","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( <radial-size>? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>","color()":"color( <colorspace-params> [/ [<alpha-value>|none]]? )","color-base":"<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent","color-function":"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>","color-interpolation-method":"in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]","color-mix()":"color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"[<angle-percentage>|<zero>]{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"<linear-color-stop> , [<linear-color-hint>? , <linear-color-stop>]#?","colorspace-params":"[<predefined-rgb-params>|<xyz-params>]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":"<complex-selector-unit> [<combinator>? <complex-selector-unit>]*","complex-selector-list":"<complex-selector>#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>*]!","compound-selector-list":"<compound-selector>#","conic-gradient()":"conic-gradient( [<conic-gradient-syntax>] )","conic-gradient-syntax":"[[[from [<angle>|<zero>]]? [at <position>]?]||<color-interpolation-method>]? , <angular-color-stop-list>","container-condition":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","container-name":"<custom-ident>","container-query":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [<number>|<percentage>]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|<superellipse()>","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier()":"cubic-bezier( [<number [0,1]> , <number>]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"<dashed-ident>","custom-params":"<dashed-ident> [<number>|<percentage>|none]+",dasharray:"[[<length-percentage>|<number>]+]#","dashndashdigit-ident":"<ident-token>","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [<color>?&&<length>{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&<percentage [0,100]>]#{2,} )","easing-function":"<linear-easing-function>|<cubic-bezier-easing-function>|<step-easing-function>","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( <radial-size>? [at <position>]? )","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-value-list":"[<filter-function>|<url>]+","final-bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>||<'background-color'>","fit-content()":"fit-content( <length-percentage [0,\u221E]> )","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|<number [1,1000]>","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"<frequency>|<percentage>","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[<function-token> <any-value>? )]|[( <any-value>? )]","generic-family":"<generic-script-specific>|<generic-complete>|<generic-incomplete>|<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( [<number>|<percentage>]? )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hsla()":"hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",hue:"<number>|<angle>","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [<angle>|<zero>]? )","hwb()":"hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( [<number>|<percentage>]? )","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-selector":"from|to|<percentage [0,100]>|<timeline-range-name> <percentage>","keyframes-name":"<custom-ident>|<string>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","light-dark()":"light-dark( <color> , <color> )","line-name-list":"[<line-names>|<name-repeat>]+","line-names":"'[' <custom-ident>* ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear()":"linear( [<number>&&<percentage>{0,2}]# )","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-easing-function":"linear|<linear()>","linear-gradient()":"linear-gradient( [<linear-gradient-syntax>] )","linear-gradient-syntax":"[[<angle>|<zero>|to <side-or-corner>]||<color-interpolation-method>]? , <color-stop-list>","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","n-dimension":"<dimension-token>","name-repeat":"repeat( [<integer [1,\u221E]>|auto-fill] , <line-names>+ )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"<ident>","ndash-dimension":"<dimension-token>","ndashdigit-dimension":"<dimension-token>","ndashdigit-ident":"<ident-token>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"<ray()>|<url>|<basic-shape>","oklab()":"oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","oklch()":"oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","opacity()":"opacity( [<number>|<percentage>]? )","opacity-value":"<number>|<percentage>","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"<length>|<percentage>","overflow-position":"unsafe|safe","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-selector-list":"[<page-selector>#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke","paint()":"paint( <ident> , <declaration-value>? )","paint-box":"<visual-box>|fill-box|stroke-box","palette-identifier":"<dashed-ident>","palette-mix()":"palette-mix( <color-interpolation-method> , [[normal|light|dark|<palette-identifier>|<palette-mix()>]&&<percentage [0,100]>?]#{2} )","path()":"path( <'fill-rule'>? , <string> )","perspective()":"perspective( [<length [0,\u221E]>|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( <calc-sum> , <calc-sum> )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":"<predefined-rgb> [<number>|<percentage>|none]{3}","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>|<legacy-pseudo-element-selector>","pseudo-page":": [left|right|first|blank]","query-in-parens":"( <container-condition> )|( <size-feature> )|style( <style-query> )|<general-enclosed>",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [<radial-gradient-syntax>] )","radial-gradient-syntax":"[[[<radial-shape>||<radial-size>]? [at <position>]?]||<color-interpolation-method>]? , <color-stop-list>","radial-shape":"circle|ellipse","radial-size":"<radial-extent>|<length [0,\u221E]>|<length-percentage [0,\u221E]>{2}",ratio:"<number [0,\u221E]> [/ <number [0,\u221E]>]?","ray()":"ray( <angle>&&<ray-size>?&&contain?&&[at <position>]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [<length-percentage>|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [<conic-gradient-syntax>] )","repeating-linear-gradient()":"repeating-linear-gradient( [<linear-gradient-syntax>] )","repeating-radial-gradient()":"repeating-radial-gradient( [<radial-gradient-syntax>] )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rgba()":"rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [<number>|<percentage>]? )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )","scope-end":"<forgiving-selector-list>","scope-start":"<forgiving-selector-list>","scroll()":"scroll( [<scroller>||<axis>]? )",scroller:"root|nearest|self","scroll-state-feature":"<media-query-list>","scroll-state-in-parens":"( <scroll-state-query> )|( <scroll-state-feature> )|<general-enclosed>","scroll-state-query":"not <scroll-state-in-parens>|<scroll-state-in-parens> [[and <scroll-state-in-parens>]*|[or <scroll-state-in-parens>]*]|<scroll-state-feature>","selector-list":"<complex-selector-list>","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [<number>|<percentage>]? )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<visual-box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( <calc-sum> )","signed-integer":"<number-token>","signless-integer":"<number-token>","sin()":"sin( <calc-sum> )","single-animation":"<'animation-duration'>||<easing-function>||<'animation-delay'>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]||<single-animation-timeline>","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<dashed-ident>|<scroll()>|<view()>","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>||<transition-behavior-value>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","size-feature":"<mf-plain>|<mf-boolean>|<mf-range>","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-easing-function":"step-start|step-end|<steps()>","steps()":"steps( <integer> , <step-position>? )","style-feature":"<declaration>","style-in-parens":"( <style-condition> )|( <style-feature> )|<general-enclosed>","style-query":"<style-condition>|<style-feature>","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","superellipse()":"superellipse( [<number>|infinity|-infinity] )","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-decl":"( <declaration> )","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","symbols()":"symbols( <symbols-type>? [<string>|<image>]+ )","symbols-type":"cyclic|numeric|alphabetic|symbolic|fixed","system-color":"AccentColor|AccentColorText|ActiveText|ButtonBorder|ButtonFace|ButtonText|Canvas|CanvasText|Field|FieldText|GrayText|Highlight|HighlightText|LinkText|Mark|MarkText|SelectedItem|SelectedItemText|VisitedText","system-family-name":"caption|icon|menu|message-box|small-caption|status-bar","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","text-edge":"[text|cap|ex|ideographic|ideographic-ink] [text|alphabetic|ideographic|ideographic-ink]?","time-percentage":"<time>|<percentage>","timeline-range-name":"cover|contain|entry|exit|entry-crossing|exit-crossing","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","transition-behavior-value":"normal|allow-discrete","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","try-size":"most-width|most-height|most-block-size|most-inline-size","try-tactic":"flip-block||flip-inline||flip-start","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","view()":"view( [<axis>||<'view-timeline-inset'>]? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","xywh()":"xywh( <length-percentage>{2} <length-percentage [0,\u221E]>{2} [round <'border-radius'>]? )",xyz:"xyz|xyz-d50|xyz-d65","xyz-params":"<xyz-space> [<number>|<percentage>|none]{3}","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"overlay|-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-size":"intrinsic|min-intrinsic|-webkit-fill-available|-webkit-fit-content|-webkit-min-content|-webkit-max-content|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>",autospace:"no-autospace|[ideograph-alpha||ideograph-numeric||punctuation]||[insert|replace]",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral","generic-script-specific":"generic( kai )|generic( fangsong )|generic( nastaliq )","-non-standard-generic-family":"-apple-system|BlinkMacSystemFont","intrinsic-size-keyword":"min-content|max-content|fit-content",left:"<length>|auto","device-cmyk()":"<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>","legacy-device-cmyk-syntax":"device-cmyk( <number>#{4} )","modern-device-cmyk-syntax":"device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )","cmyk-component":"<number>|<percentage>|none","color-space":"<rectangular-color-space>|<polar-color-space>|<custom-color-space>",right:"<length>|auto","forgiving-selector-list":"<complex-real-selector-list>","forgiving-relative-selector-list":"<relative-real-selector-list>","complex-real-selector-list":"<complex-real-selector>#","simple-selector-list":"<simple-selector>#","relative-real-selector-list":"<relative-real-selector>#","complex-selector-unit":"[<compound-selector>? <pseudo-compound-selector>*]!","complex-real-selector":"<compound-selector> [<combinator>? <compound-selector>]*","relative-real-selector":"<combinator>? <complex-real-selector>","pseudo-compound-selector":"<pseudo-element-selector> <pseudo-class-selector>*","simple-selector":"<type-selector>|<subclass-selector>","legacy-pseudo-element-selector":"':' [before|after|first-line|first-letter]","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,\u221E]>","xyz-space":"xyz|xyz-d50|xyz-d65","style-condition":"not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box","inset-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]",syntax:"'*'|<syntax-component> [<syntax-combinator> <syntax-component>]*|<syntax-string>","syntax-component":"<syntax-single-component> <syntax-multiplier>?|'<' transform-list '>'","syntax-single-component":"'<' <syntax-type-name> '>'|<ident>","syntax-type-name":"angle|color|custom-ident|image|integer|length|length-percentage|number|percentage|resolution|string|time|url|transform-function","syntax-combinator":"'|'","syntax-multiplier":"'#'|'+'","syntax-string":"<string>"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-content-zooming":"none|zoom","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<visual-box>|border|padding|content|text]||[<visual-box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<coord-box>|no-clip|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<coord-box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","-webkit-user-select":"auto|none|text|all","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]|anchor-center","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>|anchor-center","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",all:"initial|inherit|unset|revert|revert-layer","anchor-name":"none|<dashed-ident>#","anchor-scope":"none|all|<dashed-ident>#",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"[auto|<time [0s,\u221E]>]#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-range":"[<'animation-range-start'> <'animation-range-end'>?]#","animation-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-timeline":"<single-animation-timeline>#","animation-timing-function":"<easing-function>#","animation-trigger":"[none|[<dashed-ident> <animation-action>+]+]#",appearance:"none|auto|<compat-auto>|<compat-special>","aspect-ratio":"auto||<ratio>","backdrop-filter":"none|<filter-value-list>","backface-visibility":"visible|hidden",background:"<bg-layer>#? , <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<visual-box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline|sub|super|<svg-length>","baseline-source":"auto|first|last","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-block-start'>","border-block-color":"<'border-top-color'>{1,2}","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-block-style":"<'border-top-style'>{1,2}","border-block-width":"<'border-top-width'>{1,2}","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"separate|collapse","border-color":"<color>{1,4}","border-end-end-radius":"<'border-top-left-radius'>","border-end-start-radius":"<'border-top-left-radius'>","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length [0,\u221E]>|<number [0,\u221E]>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"[<number [0,\u221E]>|<percentage [0,\u221E]>]{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage [0,\u221E]>|<number [0,\u221E]>|auto]{1,4}","border-inline":"<'border-block-start'>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-inline-style":"<'border-top-style'>{1,2}","border-inline-width":"<'border-top-width'>{1,2}","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage [0,\u221E]>{1,4} [/ <length-percentage [0,\u221E]>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length>{1,2}","border-start-end-radius":"<'border-top-left-radius'>","border-start-start-radius":"<'border-top-left-radius'>","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"auto|<length-percentage>|<anchor()>|<anchor-size()>","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom",caret:"<'caret-color'>||<'caret-animation'>||<'caret-shape'>","caret-animation":"auto|manual","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none","clip-rule":"nonzero|evenodd",color:"<color>","color-interpolation-filters":"auto|sRGB|linearRGB","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance","column-gap":"normal|<length-percentage>","column-height":"auto|<length [0,\u221E]>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"auto|<length [0,\u221E]>","column-wrap":"auto|nowrap|wrap",columns:"[<'column-width'>||<'column-count'>] [/ <'column-height'>]?",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-block-size":"auto? [none|<length>]","contain-intrinsic-height":"auto? [none|<length>]","contain-intrinsic-inline-size":"auto? [none|<length>]","contain-intrinsic-size":"[auto? [none|<length>]]{1,2}","contain-intrinsic-width":"auto? [none|<length>]",container:"<'container-name'> [/ <'container-type'>]?","container-name":"none|<custom-ident>+","container-type":"normal||[size|inline-size]",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>|<attr()>]+]?","content-visibility":"visible|auto|hidden","corner-block-end-shape":"<corner-shape-value>{1,2}","corner-block-start-shape":"<corner-shape-value>{1,2}","corner-bottom-shape":"<corner-shape-value>{1,2}","corner-bottom-left-shape":"<corner-shape-value>","corner-bottom-right-shape":"<corner-shape-value>","corner-end-end-shape":"<corner-shape-value>","corner-end-start-shape":"<corner-shape-value>","corner-inline-end-shape":"<corner-shape-value>{1,2}","corner-inline-start-shape":"<corner-shape-value>{1,2}","corner-left-shape":"<corner-shape-value>{1,2}","corner-right-shape":"<corner-shape-value>{1,2}","corner-shape":"<corner-shape-value>{1,4}","corner-start-start-shape":"<corner-shape-value>","corner-start-end-shape":"<corner-shape-value>","corner-top-shape":"<corner-shape-value>{1,2}","corner-top-left-shape":"<corner-shape-value>","corner-top-right-shape":"<corner-shape-value>","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",cx:"<length>|<percentage>",cy:"<length>|<percentage>",d:"none|path( <string> )",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge","dynamic-range-limit":"standard|no-limit|constrained|<dynamic-range-limit-mix()>","empty-cells":"show|hide","field-sizing":"content|fixed",fill:"<paint>","fill-opacity":"<number-zero-one>|<percentage>","fill-rule":"nonzero|evenodd",filter:"none|<filter-value-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end","flood-color":"<color>","flood-opacity":"<'opacity'>",font:"[[<'font-style'>||<font-variant-css2>||<'font-weight'>||<font-width-css3>]? <'font-size'> [/ <'line-height'>]? <'font-family'>#]|<system-family-name>|<-non-standard-font>","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-palette":"normal|light|dark|<palette-identifier>|<palette-mix()>","font-size":"<absolute-size>|<relative-size>|<length-percentage [0,\u221E]>|math","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps||position]","font-synthesis-position":"auto|none","font-synthesis-small-caps":"auto|none","font-synthesis-style":"auto|none","font-synthesis-weight":"auto|none","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-emoji":"normal|text|emoji|unicode","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>|bolder|lighter","font-width":"normal|<percentage [0,\u221E]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","forced-color-adjust":"auto|none|preserve-parent-color",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","hyphenate-character":"auto|<string>","hyphenate-limit-chars":"[auto|<integer>]{1,3}",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|smooth|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>","interpolate-size":"numeric-only|allow-keywords",isolation:"auto|isolate",interactivity:"auto|inert","interest-delay":"<'interest-delay-start'>{1,2}","interest-delay-end":"normal|<time>","interest-delay-start":"normal|<time>","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]|anchor-center","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|anchor-center","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"auto|<length-percentage>|<anchor()>|<anchor-size()>","letter-spacing":"normal|<length-percentage>","lighting-color":"<color>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"<'margin-top'>{1,4}","margin-block":"<'margin-top'>{1,2}","margin-block-end":"<'margin-top'>","margin-block-start":"<'margin-top'>","margin-bottom":"<length-percentage>|auto|<anchor-size()>","margin-inline":"<'margin-top'>{1,2}","margin-inline-end":"<'margin-top'>","margin-inline-start":"<'margin-top'>","margin-left":"<length-percentage>|auto|<anchor-size()>","margin-right":"<length-percentage>|auto|<anchor-size()>","margin-top":"<length-percentage>|auto|<anchor-size()>","margin-trim":"none|in-flow|all",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<coord-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<coord-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-block-size":"<'min-width'>","min-height":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-inline-size":"<'min-width'>","min-width":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","mix-blend-mode":"<blend-mode>|plus-darker|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>","object-view-box":"none|<basic-shape-rect>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|<offset-path>||<coord-box>","offset-position":"normal|auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<opacity-value>",order:"<integer>",orphans:"<integer>",outline:"<'outline-width'>||<'outline-style'>||<'outline-color'>","outline-color":"auto|<color>","outline-offset":"<length>","outline-style":"auto|<outline-line-style>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,\u221E]>","overflow-inline":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-y":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>",overlay:"none|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"<'padding-top'>{1,4}","padding-block":"<'padding-top'>{1,2}","padding-block-end":"<'padding-top'>","padding-block-start":"<'padding-top'>","padding-bottom":"<length-percentage [0,\u221E]>","padding-inline":"<'padding-top'>{1,2}","padding-inline-end":"<'padding-top'>","padding-inline-start":"<'padding-top'>","padding-left":"<length-percentage [0,\u221E]>","padding-right":"<length-percentage [0,\u221E]>","padding-top":"<length-percentage [0,\u221E]>",page:"auto|<custom-ident>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky","position-anchor":"auto|none|<anchor-name>","position-area":"none|<position-area>","position-try":"<'position-try-order'>? <'position-try-fallbacks'>","position-try-fallbacks":"none|[[<dashed-ident>||<try-tactic>]|<'position-area'>]#","position-try-order":"normal|<try-size>","position-visibility":"always|[anchors-valid||anchors-visible||no-overflow]","print-color-adjust":"economy|exact",quotes:"none|auto|[<string> <string>]+",r:"<length>|<percentage>","reading-flow":"normal|source-order|flex-visual|flex-flow|grid-rows|grid-columns|grid-order","reading-order":"<integer>",resize:"none|both|horizontal|vertical|block|inline",right:"auto|<length-percentage>|<anchor()>|<anchor-size()>",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-overhang":"auto|none","ruby-position":"[alternate||[over|under]]|inter-character",rx:"<length>|<percentage>",ry:"<length>|<percentage>",scale:"none|[<number>|<percentage>]{1,3}","scroll-behavior":"auto|smooth","scroll-initial-target":"none|nearest","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-end":"<length>","scroll-margin-block-start":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-end":"<length>","scroll-margin-inline-start":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-marker-group":"none|before|after","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-target-group":"none|auto","scroll-timeline":"[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#","scroll-timeline-axis":"[block|inline|x|y]#","scroll-timeline-name":"[none|<dashed-ident>]#","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","shape-image-threshold":"<opacity-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]","stop-color":"<'color'>","stop-opacity":"<'opacity'>",stroke:"<paint>","stroke-color":"<color>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<'opacity'>","stroke-width":"<svg-length>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-anchor":"start|middle|end","text-autospace":"normal|<autospace>|auto","text-box":"normal|<'text-box-trim'>||<'text-box-edge'>","text-box-edge":"auto|<text-edge>","text-box-trim":"none|trim-start|trim-end|trim-both","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-inset":"<length>{1,2}|auto","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"auto|[over|under]&&[right|left]?","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-spacing-trim":"space-all|normal|space-first|trim-start","text-transform":"none|[capitalize|uppercase|lowercase]||full-width||full-size-kana|math-auto","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]","text-wrap":"<'text-wrap-mode'>||<'text-wrap-style'>","text-wrap-mode":"wrap|nowrap","text-wrap-style":"auto|balance|stable|pretty","timeline-scope":"none|<dashed-ident>#","timeline-trigger":"none|[<'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-range'> ['/' <'timeline-trigger-exit-range'>]?]#","timeline-trigger-name":"none|<dashed-ident>#","timeline-trigger-exit-range":"[<'timeline-trigger-exit-range-start'> <'timeline-trigger-exit-range-end'>?]#","timeline-trigger-exit-range-end":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-exit-range-start":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range":"[<'timeline-trigger-range-start'> <'timeline-trigger-range-end'>?]#","timeline-trigger-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-source":"<single-animation-timeline>#",top:"auto|<length-percentage>|<anchor()>|<anchor-size()>","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-behavior":"<transition-behavior-value>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","trigger-scope":"none|all|<dashed-ident>#","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|all","vector-effect":"none|non-scaling-stroke|non-scaling-size|non-rotation|fixed-position","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>","view-timeline":"[<'view-timeline-name'> [<'view-timeline-axis'>||<'view-timeline-inset'>]?]#","view-timeline-axis":"[block|inline|x|y]#","view-timeline-inset":"[[auto|<length-percentage>]{1,2}]#","view-timeline-name":"[none|<dashed-ident>]#","view-transition-class":"none|<custom-ident>+","view-transition-name":"none|<custom-ident>|match-element",visibility:"visible|hidden|collapse","white-space":"normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>","white-space-collapse":"collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",widows:"<integer>",width:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word|auto-phrase","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",x:"<length>|<percentage>",y:"<length>|<percentage>","z-index":"auto|<integer>",zoom:"normal|reset|<number [0,\u221E]>||<percentage [0,\u221E]>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<visual-box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto",behavior:"<url>+",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong","position-try-options":"<'position-try-fallbacks'>",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong",speak:"auto|never|always","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]","white-space-trim":"none|discard-before||discard-after||discard-inner"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer [0,\u221E]>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer [0,\u221E]>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},container:{prelude:"[<container-name>]? <container-condition>",descriptors:null},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"auto|block|swap|fallback|optional","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>{1,2}","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},"font-palette-values":{prelude:"<dashed-ident>",descriptors:{"base-palette":"light|dark|<integer [0,\u221E]>","font-family":"<family-name>#","override-colors":"[<integer [0,\u221E]> <color>]#"}},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]","page-orientation":"upright|rotate-left|rotate-right",size:"<length [0,\u221E]>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},"position-try":{prelude:"<dashed-ident>",descriptors:{top:"<'top'>",left:"<'left'>",bottom:"<'bottom'>",right:"<'right'>","inset-block-start":"<'inset-block-start'>","inset-block-end":"<'inset-block-end'>","inset-inline-start":"<'inset-inline-start'>","inset-inline-end":"<'inset-inline-end'>","inset-block":"<'inset-block'>","inset-inline":"<'inset-inline'>",inset:"<'inset'>","margin-top":"<'margin-top'>","margin-left":"<'margin-left'>","margin-bottom":"<'margin-bottom'>","margin-right":"<'margin-right'>","margin-block-start":"<'margin-block-start'>","margin-block-end":"<'margin-block-end'>","margin-inline-start":"<'margin-inline-start'>","margin-inline-end":"<'margin-inline-end'>",margin:"<'margin'>","margin-block":"<'margin-block'>","margin-inline":"<'margin-inline'>",width:"<'width'>",height:"<'height'>","min-width":"<'min-width'>","min-height":"<'min-height'>","max-width":"<'max-width'>","max-height":"<'max-height'>","block-size":"<'block-size'>","inline-size":"<'inline-size'>","min-block-size":"<'min-block-size'>","min-inline-size":"<'min-inline-size'>","max-block-size":"<'max-block-size'>","max-inline-size":"<'max-inline-size'>","align-self":"<'align-self'>|anchor-center","justify-self":"<'justify-self'>|anchor-center"}},property:{prelude:"<custom-property-name>",descriptors:{inherits:"true|false","initial-value":"<declaration-value>?",syntax:"<string>"}},scope:{prelude:"[( <scope-start> )]? [to ( <scope-end> )]?",descriptors:null},"starting-style":{prelude:null,descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},"view-transition":{prelude:null,descriptors:{navigation:"auto|none",types:"none|<custom-ident>+"}},"font-features-values":{prelude:"[<string>|<custom-ident>]+",descriptors:{"font-display":"auto|block|swap|fallback|optional"}}}}});var Pp={};Se(Pp,{generate:()=>VP,name:()=>HP,parse:()=>Ap,structure:()=>WP});function Dl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===$r||r===tr)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Ht(this.charCodeAt(n))||this.error("Integer is expected",n)}function Bi(e){return Dl.call(this,0,e)}function To(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Bl:n="N is expected";break;case tr:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Ep(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim($r,e)||this.isDelim(tr,e)){t=this.isDelim($r,e)?$r:tr;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Bi.call(this,Qo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==$r&&n!==tr&&this.error("Number sign is expected")),Bi.call(this,t!==0),t===tr?"-"+this.consume(10):this.consume(10)}function Ap(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Bi.call(this,jP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,tr))switch(t="-1",To.call(this,1,Bl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Ep.call(this);break;case 3:To.call(this,2,tr),this.next(),this.skipSC(),Bi.call(this,Qo),n="-"+this.consume(10);break;default:To.call(this,2,tr),Dl.call(this,3,Qo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim($r)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim($r)&&(r=1,this.next()),To.call(this,0,Bl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Ep.call(this);break;case 2:To.call(this,1,tr),this.next(),this.skipSC(),Bi.call(this,Qo),n="-"+this.consume(10);break;default:To.call(this,1,tr),Dl.call(this,2,Qo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===$r||r===tr,i=this.tokenStart+o;for(;i<this.tokenEnd&&Ht(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),To.call(this,i-this.tokenStart,Bl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Ep.call(this)):(To.call(this,i-this.tokenStart+1,tr),i+2===this.tokenEnd?(this.next(),this.skipSC(),Bi.call(this,Qo),n="-"+this.consume(10)):(Dl.call(this,i-this.tokenStart+2,Qo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===$r&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===$r&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function VP(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let n=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+n)}else this.tokenize(t)}else this.tokenize(e.b)}var $r,tr,Bl,Qo,jP,HP,WP,Lp=$(()=>{"use strict";ur();$r=43,tr=45,Bl=110,Qo=!0,jP=!1;HP="AnPlusB",WP={a:[String,null],b:[String,null]}});var Bp={};Se(Bp,{generate:()=>XP,name:()=>qP,parse:()=>Mp,structure:()=>KP,walkContext:()=>YP});function P0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function GP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function Mp(e=!1){let t=this.tokenStart,n,r,o=null,i=null;switch(this.eat(3),n=this.substrToCursor(t+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,n,e),P0):o=P0.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?i=this.atrule[r].block.call(this,e):i=this.Block(GP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function XP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var qP,YP,KP,Dp=$(()=>{"use strict";qP="Atrule",YP="atrule",KP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var zp={};Se(zp,{generate:()=>e2,name:()=>QP,parse:()=>Rp,structure:()=>ZP,walkContext:()=>JP});function Rp(e){let t=null;return e!==null&&(e=e.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,e)&&typeof this.atrule[e].prelude=="function"?t=this.atrule[e].prelude.call(this):t=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==23&&this.tokenType!==17&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function e2(e){this.children(e)}var QP,JP,ZP,Np=$(()=>{"use strict";QP="AtrulePrelude",JP="atrulePrelude",ZP={children:[[]]}});var $p={};Se($p,{generate:()=>l2,name:()=>s2,parse:()=>_p,structure:()=>a2});function o2(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(L0)?(t=!0,this.next()):this.isDelim(Op)||this.eat(1),this.isDelim(Op)?this.charCodeAt(this.tokenStart+1)!==Rl?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function i2(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Rl&&t!==r2&&t!==n2&&t!==t2&&t!==L0&&t!==Op&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Rl&&(this.isDelim(Rl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function _p(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=o2.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=i2.call(this),this.skipSC(),r=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:n,value:r,flags:o}}function l2(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}var t2,L0,Rl,n2,Op,r2,s2,a2,Up=$(()=>{"use strict";t2=36,L0=42,Rl=61,n2=94,Op=124,r2=126;s2="AttributeSelector",a2={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Hp={};Se(Hp,{generate:()=>f2,name:()=>p2,parse:()=>jp,structure:()=>g2,walkContext:()=>d2});function D0(){return this.Raw(null,!0)}function M0(){return this.parseWithFallback(this.Rule,D0)}function B0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function u2(){if(this.tokenType===17)return B0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,B0);return this.tokenType===17&&this.next(),e}function jp(e){let t=e?u2:M0,n=this.tokenStart,r=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:r.push(this.parseWithFallback(this.Atrule.bind(this,e),D0));break;default:e&&this.isDelim(c2)?r.push(M0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function f2(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var c2,p2,d2,g2,Wp=$(()=>{"use strict";c2=38;p2="Block",d2="block",g2={children:[["Atrule","Rule","Declaration"]]}});var Gp={};Se(Gp,{generate:()=>x2,name:()=>m2,parse:()=>Vp,structure:()=>h2});function Vp(e,t){let n=this.tokenStart,r=null;return this.eat(19),r=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function x2(e){this.token(9,"["),this.children(e),this.token(9,"]")}var m2,h2,qp=$(()=>{"use strict";m2="Brackets",h2={children:[[]]}});var Kp={};Se(Kp,{generate:()=>S2,name:()=>y2,parse:()=>Yp,structure:()=>b2});function Yp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function S2(){this.token(15,"-->")}var y2,b2,Xp=$(()=>{"use strict";y2="CDC",b2=[]});var Jp={};Se(Jp,{generate:()=>k2,name:()=>w2,parse:()=>Qp,structure:()=>v2});function Qp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function k2(){this.token(14,"<!--")}var w2,v2,Zp=$(()=>{"use strict";w2="CDO",v2=[]});var td={};Se(td,{generate:()=>F2,name:()=>T2,parse:()=>ed,structure:()=>I2});function ed(){return this.eatDelim(C2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function F2(e){this.token(9,"."),this.token(1,e.name)}var C2,T2,I2,nd=$(()=>{"use strict";C2=46,T2="ClassSelector",I2={name:String}});var od={};Se(od,{generate:()=>B2,name:()=>L2,parse:()=>rd,structure:()=>M2});function rd(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case A2:case E2:case P2:this.next();break;case R0:this.next(),this.eatIdent("deep"),this.eatDelim(R0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function B2(e){this.tokenize(e.name)}var E2,R0,A2,P2,L2,M2,id=$(()=>{"use strict";E2=43,R0=47,A2=62,P2=126,L2="Combinator",M2={name:String}});var ad={};Se(ad,{generate:()=>O2,name:()=>z2,parse:()=>sd,structure:()=>N2});function sd(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===D2&&this.charCodeAt(t-1)===R2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function O2(e){this.token(25,"/*"+e.value+"*/")}var D2,R2,z2,N2,ld=$(()=>{"use strict";D2=42,R2=47,z2="Comment",N2={value:String}});var ud={};Se(ud,{generate:()=>H2,name:()=>$2,parse:()=>cd,structure:()=>U2});function z0(e){return this.lookupTypeNonSC(1)===1&&_2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function cd(e="media"){let t=this.createList();e:for(;!this.eof;)switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t.push(this.Identifier());break;case 21:{let n=this.parseWithFallback(()=>j2[e].call(this,e),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(21);let r=this.Condition(e);return this.eat(22),r},()=>this.GeneralEnclosed(e))),t.push(n);break}case 2:{let n=this.parseWithFallback(()=>this.FeatureFunction(e),()=>null);n||(n=this.GeneralEnclosed(e)),t.push(n);break}default:break e}return t.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(t),kind:e,children:t}}function H2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var _2,$2,U2,j2,pd=$(()=>{"use strict";_2=new Set([16,22,0]),$2="Condition",U2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};j2={media:z0,container:z0,supports(){return this.SupportsDeclaration()}}});var gd={};Se(gd,{generate:()=>tL,name:()=>J2,parse:()=>dd,structure:()=>eL,walkContext:()=>Z2});function K2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function X2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function Q2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(O0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function dd(){let e=this.tokenStart,t=this.tokenIndex,n=nL.call(this),r=wl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?X2:K2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(Q2,i):a=i.call(this,this.tokenIndex),r&&a.type==="Value"&&a.children.isEmpty){for(let c=u-this.tokenIndex;c<=0;c++)if(this.lookupType(c)===13){a.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(O0)&&(s=rL.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==17&&this.isBalanceEdge(t)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:s,property:n,value:a}}function tL(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function nL(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case q2:case V2:case Y2:case W2:case G2:this.next();break;case N0:this.next(),this.isDelim(N0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function rL(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var O0,W2,V2,G2,q2,Y2,N0,J2,Z2,eL,fd=$(()=>{"use strict";vl();O0=33,W2=35,V2=36,G2=38,q2=42,Y2=43,N0=47;J2="Declaration",Z2="declaration",eL={important:[Boolean,String],property:String,value:["Value","Raw"]}});var xd={};Se(xd,{generate:()=>aL,name:()=>iL,parse:()=>hd,structure:()=>sL});function md(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function hd(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;case 3:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),md));break;default:this.isDelim(oL)?e.push(this.parseWithFallback(this.Rule,md)):e.push(this.parseWithFallback(this.Declaration,md))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function aL(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var oL,iL,sL,yd=$(()=>{"use strict";oL=38;iL="DeclarationList",sL={children:[["Declaration","Atrule","Rule"]]}});var Sd={};Se(Sd,{generate:()=>uL,name:()=>lL,parse:()=>bd,structure:()=>cL});function bd(){let e=this.tokenStart,t=this.consumeNumber(12);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function uL(e){this.token(12,e.value+e.unit)}var lL,cL,wd=$(()=>{"use strict";lL="Dimension",cL={value:String,unit:String}});var kd={};Se(kd,{generate:()=>fL,name:()=>dL,parse:()=>vd,structure:()=>gL});function vd(e){let t=this.tokenStart,n,r=null;if(this.eat(21),this.skipSC(),n=this.consume(1),this.skipSC(),this.tokenType!==22){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:this.lookupNonWSType(1)===9?r=this.Ratio():r=this.Number();break;case 12:r=this.Dimension();break;case 1:r=this.Identifier();break;case 2:r=this.parseWithFallback(()=>{let o=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(pL)&&this.error(),o},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(22),{type:"Feature",loc:this.getLocation(t,this.tokenStart),kind:e,name:n,value:r}}function fL(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var pL,dL,gL,Cd=$(()=>{"use strict";pL=47,dL="Feature",gL={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var Id={};Se(Id,{generate:()=>yL,name:()=>mL,parse:()=>Td,structure:()=>hL});function xL(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function Td(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=xL.call(this,e,n.toLowerCase());this.skipSC();let o=this.parseWithFallback(()=>{let i=this.tokenIndex,s=r.call(this);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),s},()=>this.Raw(null,!1));return this.eof||this.eat(22),{type:"FeatureFunction",loc:this.getLocation(t,this.tokenStart),kind:e,feature:n,value:o}}function yL(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var mL,hL,Fd=$(()=>{"use strict";mL="FeatureFunction",hL={kind:String,feature:String,value:["Declaration","Selector"]}});var Pd={};Se(Pd,{generate:()=>kL,name:()=>wL,parse:()=>Ad,structure:()=>vL});function Ed(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(_0,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case 12:return this.Dimension();case 1:return this.Identifier();case 2:return this.parseWithFallback(()=>{let e=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(_0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function U0(e){if(this.skipSC(),this.isDelim(bL)||this.isDelim(SL)){let t=this.source[this.tokenStart];return this.next(),this.isDelim($0)?(this.next(),t+"="):t}if(this.isDelim($0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Ad(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Ed.call(this),r=U0.call(this,n.type==="Identifier"),o=Ed.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=U0.call(this),s=Ed.call(this)),this.skipSC(),this.eat(22),{type:"FeatureRange",loc:this.getLocation(t,this.tokenStart),kind:e,left:n,leftComparison:r,middle:o,rightComparison:i,right:s}}function kL(e){this.token(21,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(22,")")}var _0,bL,$0,SL,wL,vL,Ld=$(()=>{"use strict";_0=47,bL=60,$0=61,SL=62,wL="FeatureRange",vL={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]}});var Bd={};Se(Bd,{generate:()=>FL,name:()=>CL,parse:()=>Md,structure:()=>IL,walkContext:()=>TL});function Md(e,t){let n=this.tokenStart,r=this.consumeFunctionName(),o=r.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:i}}function FL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var CL,TL,IL,Dd=$(()=>{"use strict";CL="Function",TL="function",IL={name:String,children:[[]]}});var zd={};Se(zd,{generate:()=>PL,name:()=>EL,parse:()=>Rd,structure:()=>AL});function Rd(e){let t=this.tokenStart,n=null;this.tokenType===2?n=this.consumeFunctionName():this.eat(21);let r=this.parseWithFallback(()=>{let o=this.tokenIndex,i=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),i},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(22),{type:"GeneralEnclosed",loc:this.getLocation(t,this.tokenStart),kind:e,function:n,children:r}}function PL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var EL,AL,Nd=$(()=>{"use strict";EL="GeneralEnclosed",AL={kind:String,function:[String,null],children:[[]]}});var _d={};Se(_d,{generate:()=>DL,name:()=>ML,parse:()=>Od,structure:()=>BL,xxx:()=>LL});function Od(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function DL(e){this.token(4,"#"+e.value)}var LL,ML,BL,$d=$(()=>{"use strict";LL="XXX",ML="Hash",BL={value:String}});var jd={};Se(jd,{generate:()=>NL,name:()=>RL,parse:()=>Ud,structure:()=>zL});function Ud(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function NL(e){this.token(1,e.name)}var RL,zL,Hd=$(()=>{"use strict";RL="Identifier",zL={name:String}});var Vd={};Se(Vd,{generate:()=>$L,name:()=>OL,parse:()=>Wd,structure:()=>_L});function Wd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function $L(e){this.token(9,"#"+e.name)}var OL,_L,Gd=$(()=>{"use strict";OL="IdSelector",_L={name:String}});var Yd={};Se(Yd,{generate:()=>WL,name:()=>jL,parse:()=>qd,structure:()=>HL});function qd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(UL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function WL(e){this.tokenize(e.name)}var UL,jL,HL,Kd=$(()=>{"use strict";UL=46,jL="Layer",HL={name:String}});var Qd={};Se(Qd,{generate:()=>qL,name:()=>VL,parse:()=>Xd,structure:()=>GL});function Xd(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.Layer()),this.lookupTypeNonSC(0)===18);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(e),children:e}}function qL(e){this.children(e,()=>this.token(18,","))}var VL,GL,Jd=$(()=>{"use strict";VL="LayerList",GL={children:[["Layer"]]}});var eg={};Se(eg,{generate:()=>XL,name:()=>YL,parse:()=>Zd,structure:()=>KL});function Zd(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function XL(e){e.mediaType?(e.modifier&&this.token(1,e.modifier),this.token(1,e.mediaType),e.condition&&(this.token(1,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}var YL,KL,tg=$(()=>{"use strict";YL="MediaQuery",KL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var rg={};Se(rg,{generate:()=>ZL,name:()=>QL,parse:()=>ng,structure:()=>JL});function ng(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===18);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function ZL(e){this.children(e,()=>this.token(18,","))}var QL,JL,og=$(()=>{"use strict";QL="MediaQueryList",JL={children:[["MediaQuery"]]}});var sg={};Se(sg,{generate:()=>rM,name:()=>tM,parse:()=>ig,structure:()=>nM});function ig(){let e=this.tokenStart;return this.eatDelim(eM),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function rM(){this.token(9,"&")}var eM,tM,nM,ag=$(()=>{"use strict";eM=38,tM="NestingSelector",nM={}});var cg={};Se(cg,{generate:()=>sM,name:()=>oM,parse:()=>lg,structure:()=>iM});function lg(){this.skipSC();let e=this.tokenStart,t=e,n=null,r;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?r=this.Identifier():r=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:r,selector:n}}function sM(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var oM,iM,ug=$(()=>{"use strict";oM="Nth",iM={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var dg={};Se(dg,{generate:()=>cM,name:()=>aM,parse:()=>pg,structure:()=>lM});function pg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function cM(e){this.token(10,e.value)}var aM,lM,gg=$(()=>{"use strict";aM="Number",lM={value:String}});var mg={};Se(mg,{generate:()=>dM,name:()=>uM,parse:()=>fg,structure:()=>pM});function fg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function dM(e){this.tokenize(e.value)}var uM,pM,hg=$(()=>{"use strict";uM="Operator",pM={value:String}});var yg={};Se(yg,{generate:()=>mM,name:()=>gM,parse:()=>xg,structure:()=>fM});function xg(e,t){let n=this.tokenStart,r=null;return this.eat(21),r=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function mM(e){this.token(21,"("),this.children(e),this.token(22,")")}var gM,fM,bg=$(()=>{"use strict";gM="Parentheses",fM={children:[[]]}});var wg={};Se(wg,{generate:()=>yM,name:()=>hM,parse:()=>Sg,structure:()=>xM});function Sg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function yM(e){this.token(11,e.value+"%")}var hM,xM,vg=$(()=>{"use strict";hM="Percentage",xM={value:String}});var Cg={};Se(Cg,{generate:()=>vM,name:()=>bM,parse:()=>kg,structure:()=>wM,walkContext:()=>SM});function kg(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function vM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var bM,SM,wM,Tg=$(()=>{"use strict";bM="PseudoClassSelector",SM="function",wM={name:String,children:[["Raw"],null]}});var Fg={};Se(Fg,{generate:()=>IM,name:()=>kM,parse:()=>Ig,structure:()=>TM,walkContext:()=>CM});function Ig(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function IM(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var kM,CM,TM,Eg=$(()=>{"use strict";kM="PseudoElementSelector",CM="function",TM={name:String,children:[["Raw"],null]}});var Pg={};Se(Pg,{generate:()=>AM,name:()=>FM,parse:()=>Ag,structure:()=>EM});function H0(){switch(this.skipSC(),this.tokenType){case 10:return this.Number();case 2:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}function Ag(){let e=this.tokenStart,t=H0.call(this),n=null;return this.skipSC(),this.isDelim(j0)&&(this.eatDelim(j0),n=H0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function AM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var j0,FM,EM,Lg=$(()=>{"use strict";j0=47;FM="Ratio",EM={left:["Number","Function"],right:["Number","Function",null]}});var Bg={};Se(Bg,{generate:()=>BM,name:()=>LM,parse:()=>Mg,structure:()=>MM});function PM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Mg(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=PM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function BM(e){this.tokenize(e.value)}var LM,MM,Dg=$(()=>{"use strict";LM="Raw",MM={value:String}});var zg={};Se(zg,{generate:()=>OM,name:()=>RM,parse:()=>Rg,structure:()=>NM,walkContext:()=>zM});function W0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function DM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Rg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(DM,W0):n=W0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function OM(e){this.node(e.prelude),this.node(e.block)}var RM,zM,NM,Ng=$(()=>{"use strict";RM="Rule",zM="rule",NM={prelude:["SelectorList","Raw"],block:["Block"]}});var _g={};Se(_g,{generate:()=>UM,name:()=>_M,parse:()=>Og,structure:()=>$M});function Og(){let e=null,t=null;this.skipSC();let n=this.tokenStart;return this.tokenType===21&&(this.next(),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),this.lookupNonWSType(0)===1&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(21),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:e,limit:t}}function UM(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}var _M,$M,$g=$(()=>{"use strict";_M="Scope",$M={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var jg={};Se(jg,{generate:()=>WM,name:()=>jM,parse:()=>Ug,structure:()=>HM});function Ug(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function WM(e){this.children(e)}var jM,HM,Hg=$(()=>{"use strict";jM="Selector",HM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Vg={};Se(Vg,{generate:()=>YM,name:()=>VM,parse:()=>Wg,structure:()=>qM,walkContext:()=>GM});function Wg(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function YM(e){this.children(e,()=>this.token(18,","))}var VM,GM,qM,Gg=$(()=>{"use strict";VM="SelectorList",GM="selector",qM={children:[["Selector","Raw"]]}});function zl(e){let t=e.length,n=e.charCodeAt(0),r=n===V0||n===G0?1:0,o=r===1&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,i="";for(let s=r;s<=o;s++){let a=e.charCodeAt(s);if(a===qg){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Dn(qg,a)){let u=s-1,c=Qr(e,u);s=c-1,i+=il(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function q0(e,t){let n=t?"'":'"',r=t?G0:V0,o="",i=!1;for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);if(a===0){o+="\uFFFD";continue}if(a<=31||a===127){o+="\\"+a.toString(16),i=!0;continue}a===r||a===qg?(o+="\\"+e.charAt(s),i=!1):(i&&(Rn(a)||Or(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var qg,V0,G0,Nl=$(()=>{"use strict";ur();qg=92,V0=34,G0=39});var Kg={};Se(Kg,{generate:()=>QM,name:()=>KM,parse:()=>Yg,structure:()=>XM});function Yg(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:zl(this.consume(5))}}function QM(e){this.token(5,q0(e.value))}var KM,XM,Xg=$(()=>{"use strict";Nl();KM="String",XM={value:String}});var Jg={};Se(Jg,{generate:()=>nB,name:()=>ZM,parse:()=>Qg,structure:()=>tB,walkContext:()=>eB});function K0(){return this.Raw(null,!1)}function Qg(){let e=this.tokenStart,t=this.createList(),n;for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==JM){this.next();continue}n=this.Comment();break;case 14:n=this.CDO();break;case 15:n=this.CDC();break;case 3:n=this.parseWithFallback(this.Atrule,K0);break;default:n=this.parseWithFallback(this.Rule,K0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function nB(e){this.children(e)}var JM,ZM,eB,tB,Zg=$(()=>{"use strict";JM=33;ZM="StyleSheet",eB="stylesheet",tB={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var tf={};Se(tf,{generate:()=>iB,name:()=>rB,parse:()=>ef,structure:()=>oB});function ef(){let e=this.tokenStart;this.eat(21),this.skipSC();let t=this.Declaration();return this.eof||this.eat(22),{type:"SupportsDeclaration",loc:this.getLocation(e,this.tokenStart),declaration:t}}function iB(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var rB,oB,nf=$(()=>{"use strict";rB="SupportsDeclaration",oB={declaration:"Declaration"}});var sf={};Se(sf,{generate:()=>cB,name:()=>aB,parse:()=>of,structure:()=>lB});function rf(){this.tokenType!==1&&this.isDelim(sB)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function of(){let e=this.tokenStart;return this.isDelim(X0)?(this.next(),rf.call(this)):(rf.call(this),this.isDelim(X0)&&(this.next(),rf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function cB(e){this.tokenize(e.name)}var sB,X0,aB,lB,af=$(()=>{"use strict";sB=42,X0=124;aB="TypeSelector",lB={name:String}});var uf={};Se(uf,{generate:()=>fB,name:()=>dB,parse:()=>cf,structure:()=>gB});function Os(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===J0&&t&&n!==0)return Os.call(this,e+n+1,!1),-1;Rn(o)||this.error(t&&n!==0?"Hyphen minus"+(n<6?" or hex digit":"")+" is expected":n<6?"Hex digit is expected":"Unexpected input",r),++n>6&&this.error("Too many hex digits",r)}return this.next(),n}function Ol(e){let t=0;for(;this.isDelim(lf);)++t>e&&this.error("Too many question marks"),this.next()}function uB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===Q0?"Plus sign":"Hyphen minus")+" is expected")}function pB(){let e=0;switch(this.tokenType){case 10:if(e=Os.call(this,1,!0),this.isDelim(lf)){Ol.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){uB.call(this,J0),Os.call(this,1,!1);break}break;case 12:e=Os.call(this,1,!0),e>0&&Ol.call(this,6-e);break;default:if(this.eatDelim(Q0),this.tokenType===1){e=Os.call(this,0,!0),e>0&&Ol.call(this,6-e);break}if(this.isDelim(lf)){this.next(),Ol.call(this,5);break}this.error("Hex digit or question mark is expected")}}function cf(){let e=this.tokenStart;return this.eatIdent("u"),pB.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function fB(e){this.tokenize(e.value)}var Q0,J0,lf,dB,gB,pf=$(()=>{"use strict";ur();Q0=43,J0=45,lf=63;dB="UnicodeRange",gB={value:String}});function eS(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===Z0?t-2:t-1,o="";for(;n<r&&Or(e.charCodeAt(n));)n++;for(;n<r&&Or(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===df){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Dn(df,s)){let a=i-1,u=Qr(e,a);i=u-1,o+=il(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function tS(e){let t="",n=!1;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===0){t+="\uFFFD";continue}if(o<=31||o===127){t+="\\"+o.toString(16),n=!0;continue}o===mB||o===df||o===hB||o===xB||o===yB||o===Z0?(t+="\\"+e.charAt(r),n=!1):(n&&Rn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var mB,df,hB,xB,yB,Z0,gf=$(()=>{"use strict";ur();mB=32,df=92,hB=34,xB=39,yB=40,Z0=41});var mf={};Se(mf,{generate:()=>wB,name:()=>bB,parse:()=>ff,structure:()=>SB});function ff(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=eS(this.consume(7));break;case 2:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(2),this.skipSC(),t=zl(this.consume(5)),this.skipSC(),this.eof||this.eat(22);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(e,this.tokenStart),value:t}}function wB(e){this.token(7,tS(e.value))}var bB,SB,hf=$(()=>{"use strict";gf();Nl();bB="Url",SB={value:String}});var yf={};Se(yf,{generate:()=>CB,name:()=>vB,parse:()=>xf,structure:()=>kB});function xf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function CB(e){this.children(e)}var vB,kB,bf=$(()=>{"use strict";vB="Value",kB={children:[[]]}});var wf={};Se(wf,{generate:()=>EB,name:()=>IB,parse:()=>Sf,structure:()=>FB});function Sf(){return this.eat(13),TB}function EB(e){this.token(13,e.value)}var TB,IB,FB,vf=$(()=>{"use strict";TB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),IB="WhiteSpace",FB={value:String}});var _s={};Se(_s,{AnPlusB:()=>Pp,Atrule:()=>Bp,AtrulePrelude:()=>zp,AttributeSelector:()=>$p,Block:()=>Hp,Brackets:()=>Gp,CDC:()=>Kp,CDO:()=>Jp,ClassSelector:()=>td,Combinator:()=>od,Comment:()=>ad,Condition:()=>ud,Declaration:()=>gd,DeclarationList:()=>xd,Dimension:()=>Sd,Feature:()=>kd,FeatureFunction:()=>Id,FeatureRange:()=>Pd,Function:()=>Bd,GeneralEnclosed:()=>zd,Hash:()=>_d,IdSelector:()=>Vd,Identifier:()=>jd,Layer:()=>Yd,LayerList:()=>Qd,MediaQuery:()=>eg,MediaQueryList:()=>rg,NestingSelector:()=>sg,Nth:()=>cg,Number:()=>dg,Operator:()=>mg,Parentheses:()=>yg,Percentage:()=>wg,PseudoClassSelector:()=>Cg,PseudoElementSelector:()=>Fg,Ratio:()=>Pg,Raw:()=>Bg,Rule:()=>zg,Scope:()=>_g,Selector:()=>jg,SelectorList:()=>Vg,String:()=>Kg,StyleSheet:()=>Jg,SupportsDeclaration:()=>tf,TypeSelector:()=>sf,UnicodeRange:()=>uf,Url:()=>mf,Value:()=>yf,WhiteSpace:()=>wf});var kf=$(()=>{"use strict";Lp();Dp();Np();Up();Wp();qp();Xp();Zp();nd();id();ld();pd();fd();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tg();og();ag();ug();gg();hg();bg();vg();Tg();Eg();Lg();Dg();Ng();$g();Hg();Gg();Xg();Zg();nf();af();pf();hf();bf();vf()});var rS,oS=$(()=>{"use strict";kl();A0();kf();rS={generic:!0,cssWideKeywords:Ei,...E0,node:_s}});function $s(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,BB)&&this.cmpChar(this.tokenStart+1,iS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===MB||t===PB||t===iS||t===LB)return this.Operator();t===AB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var AB,PB,iS,LB,MB,BB,Cf=$(()=>{"use strict";AB=35,PB=42,iS=43,LB=45,MB=47,BB=117});var sS,aS=$(()=>{"use strict";Cf();sS={getNode:$s}});function jB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function HB(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===lS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case NB:case _B:case UB:case OB:return this.Combinator();case lS:return this.ClassSelector();case zB:case $B:return this.TypeSelector();case DB:return this.IdSelector();case RB:return this.NestingSelector()}break}}}var DB,RB,zB,NB,OB,lS,_B,$B,UB,cS,uS=$(()=>{"use strict";DB=35,RB=38,zB=42,NB=43,OB=47,lS=46,_B=62,$B=124,UB=126;cS={onWhiteSpace:jB,getNode:HB}});function pS(){return this.createSingleNodeList(this.Raw(null,!1))}var dS=$(()=>{"use strict"});function gS(){let e=this.createList();if(this.skipSC(),e.push(this.Identifier()),this.skipSC(),this.tokenType===18){e.push(this.Operator());let t=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let r=t-this.tokenIndex;r<=0;r++)if(this.lookupType(r)===13){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}e.push(n)}return e}var fS=$(()=>{"use strict"});function mS(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var hS,xS=$(()=>{"use strict";Cf();dS();fS();hS={getNode:$s,onWhiteSpace(e,t){mS(e)&&(e.value=" "+e.value),mS(t.last)&&(t.last.value+=" ")},expression:pS,var:gS}});var Tf={};Se(Tf,{AtrulePrelude:()=>sS,Selector:()=>cS,Value:()=>hS});var yS=$(()=>{"use strict";aS();uS();xS()});var WB,bS,SS=$(()=>{"use strict";WB=new Set(["none","and","not","or"]),bS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);WB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var wS,vS=$(()=>{"use strict";wS={parse:{prelude:null,block(){return this.Block(!0)}}}});function If(e,t){return this.parseWithFallback(()=>{try{return e.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==22&&this.error()}},t||(()=>this.Raw(null,!0)))}var kS,CS,TS=$(()=>{"use strict";kS={layer(){this.skipSC();let e=this.createList(),t=If.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=If.call(this,this.Declaration,()=>If.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},CS={parse:{prelude(){let e=this.createList();switch(this.tokenType){case 5:e.push(this.String());break;case 7:case 2:e.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===1&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?e.push(this.Identifier()):this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&e.push(this.Function(null,kS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,kS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var IS,FS=$(()=>{"use strict";IS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var ES,AS=$(()=>{"use strict";ES={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var PS,LS=$(()=>{"use strict";PS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var MS,BS=$(()=>{"use strict";MS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var DS,RS=$(()=>{"use strict";DS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var zS,NS=$(()=>{"use strict";zS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var OS,_S=$(()=>{"use strict";OS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var $S,US=$(()=>{"use strict";SS();vS();TS();FS();AS();LS();BS();RS();NS();_S();$S={container:bS,"font-face":wS,import:CS,layer:IS,media:ES,nest:PS,page:MS,scope:DS,"starting-style":zS,supports:OS}});function jS(){let e=this.createList();this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 1:e.push(this.Identifier());break;case 5:e.push(this.String());break;case 18:e.push(this.Operator());break;case 22:break e;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return e}var HS=$(()=>{"use strict"});var Jo,Ff,VB,GB,_l,WS,VS=$(()=>{"use strict";HS();Jo={parse(){return this.createSingleNodeList(this.SelectorList())}},Ff={parse(){return this.createSingleNodeList(this.Selector())}},VB={parse(){return this.createSingleNodeList(this.Identifier())}},GB={parse:jS},_l={parse(){return this.createSingleNodeList(this.Nth())}},WS={dir:VB,has:Jo,lang:GB,matches:Jo,is:Jo,"-moz-any":Jo,"-webkit-any":Jo,where:Jo,not:Jo,"nth-child":_l,"nth-last-child":_l,"nth-last-of-type":_l,"nth-of-type":_l,slotted:Ff,host:Ff,"host-context":Ff}});var Ef={};Se(Ef,{AnPlusB:()=>Ap,Atrule:()=>Mp,AtrulePrelude:()=>Rp,AttributeSelector:()=>_p,Block:()=>jp,Brackets:()=>Vp,CDC:()=>Yp,CDO:()=>Qp,ClassSelector:()=>ed,Combinator:()=>rd,Comment:()=>sd,Condition:()=>cd,Declaration:()=>dd,DeclarationList:()=>hd,Dimension:()=>bd,Feature:()=>vd,FeatureFunction:()=>Td,FeatureRange:()=>Ad,Function:()=>Md,GeneralEnclosed:()=>Rd,Hash:()=>Od,IdSelector:()=>Wd,Identifier:()=>Ud,Layer:()=>qd,LayerList:()=>Xd,MediaQuery:()=>Zd,MediaQueryList:()=>ng,NestingSelector:()=>ig,Nth:()=>lg,Number:()=>pg,Operator:()=>fg,Parentheses:()=>xg,Percentage:()=>Sg,PseudoClassSelector:()=>kg,PseudoElementSelector:()=>Ig,Ratio:()=>Ag,Raw:()=>Mg,Rule:()=>Rg,Scope:()=>Og,Selector:()=>Ug,SelectorList:()=>Wg,String:()=>Yg,StyleSheet:()=>Qg,SupportsDeclaration:()=>ef,TypeSelector:()=>of,UnicodeRange:()=>cf,Url:()=>ff,Value:()=>xf,WhiteSpace:()=>Sf});var GS=$(()=>{"use strict";Lp();Dp();Np();Up();Wp();qp();Xp();Zp();nd();id();ld();pd();fd();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tg();og();ag();ug();gg();hg();bg();vg();Tg();Eg();Lg();Dg();Ng();$g();Hg();Gg();Xg();Zg();nf();af();pf();hf();bf();vf()});var qS,YS=$(()=>{"use strict";yS();US();VS();GS();qS={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(e){return this.AtrulePrelude(e.atrule?String(e.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(e){return this.Condition(e.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:Tf,atrule:$S,pseudo:WS,node:Ef}});var KS,XS=$(()=>{"use strict";kf();KS={node:_s}});var QS,JS=$(()=>{"use strict";F0();oS();YS();XS();QS=I0({...rS,...qS,...KS})});var ZS=$(()=>{"use strict"});var ew=$(()=>{"use strict"});var bY,tw,SY,wY,vY,nw,kY,CY,TY,IY,FY,EY,rw=$(()=>{"use strict";JS();ZS();mp();vl();ew();Nl();gf();({tokenize:bY,parse:tw,generate:SY,lexer:wY,createLexer:vY,walk:nw,find:kY,findLast:CY,findAll:TY,toPlainObject:IY,fromPlainObject:FY,fork:EY}=QS)});function XB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function iw(e){try{let t=tw(e.trim(),{context:"value"}),n=[];return nw(t,{enter(r){if(r.type==="Dimension"){let o=parseFloat(r.value);n.push(`${o}${r.unit}`)}else if(r.type==="Number"){let o=parseFloat(r.value);n.push(`${o}`)}else r.type==="Percentage"?n.push(`${parseFloat(r.value)}%`):r.type==="Identifier"?n.push(r.name.toLowerCase()):r.type==="Hash"?n.push(`#${r.value.toLowerCase()}`):r.type}}),n}catch{return[e.trim().toLowerCase()]}}function QB(e,t){let n=XB(e);if(!KB.has(n))return t;let r=iw(t);if(r.length<1||r.length>4)return t;let o=r.map(i=>i==="0"?"0px":i);return o.length===1?`${o[0]} ${o[0]} ${o[0]} ${o[0]}`:o.length===2?`${o[0]} ${o[1]} ${o[0]} ${o[1]}`:o.length===3?`${o[0]} ${o[1]} ${o[2]} ${o[1]}`:o.join(" ")}function ow(e,t){let n=t.trim();if(!n)return"";let r=QB(e,n);return iw(r).map(i=>i==="0"?"0px":i).join(" ")}function sw(e,t,n){let r=ow(e,t),o=ow(e,n);return r!==""&&o!==""&&r===o}var KB,aw=$(()=>{"use strict";rw();KB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function JB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function ZB(e){let t=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(!t)return null;let n=parseInt(t[1],10).toString(16).padStart(2,"0"),r=parseInt(t[2],10).toString(16).padStart(2,"0"),o=parseInt(t[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`}function lw(e){let t=typeof e=="string"?e:String(e??"");if(!t||t==="[object Object]")return"";let n=t.match(/rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)/);if(n){let i=ZB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return JB(r[0]);let o=t.match(/(-?\d+\.?\d*)(px|em|rem|%|pt|vw|vh)?/g);return o&&o.length>1?o.join(" ").toLowerCase():o&&o.length===1?o[0].toLowerCase():t.toLowerCase().trim().replace(/\s+/g," ")}function Zo(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),s=o.toLowerCase(),a=i.includes("none"),u=s.includes("none");if(a!==u)return!1;let c=/\b(fill|stroke)\s*:/i,l=c.test(r),d=c.test(o);if(l!==d)return!1;let g=lw(r),p=lw(o);return!!(g===p||n&&sw(n,r,o))}var Af=$(()=>{"use strict";aw()});function oD(e){let t=String(e.property||"").toLowerCase(),n=String(e.description||"").toLowerCase(),r=String(e.expected||e.suggestedValue||"").toLowerCase(),o=String(e.actual||e.currentValue||"").toLowerCase();if(t.includes("color")||t.includes("fill")||t.includes("background")||n.includes("color")||n.includes("fill"))return!0;let i=s=>/^#[0-9a-f]{3,8}$/i.test(s)||s.includes("rgb")||["white","black","red","blue","green","orange","yellow","transparent"].includes(s);return!!(i(r)||i(o)||e.relatedProperties?.some(s=>{let a=s.property?.toLowerCase()||"";return a.includes("color")||a.includes("fill")||a.includes("background")}))}function cw(e){if(e.includes("\xD7")||/\d+px\s*x\s*\d+px/i.test(e))return!1;let t=e.match(/\d+px/g);return t?t.length>1:!1}function iD(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase(),r=String(e.property||"").toLowerCase(),o=String(e.description||"").toLowerCase(),i=n.includes("margin")||t.includes("margin")||r==="margin",s=t.includes("gap")||o.includes("gap");return i&&s}function sD(e,t,n){if(!e||!t)return!1;let r=typeof e=="string"?e:String(e??""),o=typeof t=="string"?t:String(t??"");if(!r||!o||r==="[object Object]"||o==="[object Object]"||n&&oD(n)||cw(r)||cw(o)||n&&iD(n))return!1;let i=parseFloat(r),s=parseFloat(o);if(isNaN(i)||isNaN(s))return!1;let a=Math.abs(i-s);if(r.includes("px")||o.includes("px")){let u=n?.property?.toLowerCase()||"";return u==="width"||u==="height"||u.includes("width")||u.includes("height")?a<pw:a<uw}return r.includes("%")||o.includes("%")?a<1:!1}function aD(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(rD.some(s=>t.includes(s))||!tD.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Zo(o,i,e.property))}function lD(e){let t=(e.expected!==void 0?"fill":"").toLowerCase(),n=e.actual!==void 0||e.currentValue!==void 0?"fill":"";if(!(t==="fill"||n==="fill"||e.description?.toLowerCase().includes("fill")||e.title?.toLowerCase().includes("fill")))return!1;let o=String(e.expected||e.suggestedValue||"").toLowerCase();if(!(o==="none"||o==="transparent"||o.includes("no fills")||o.includes("transparent")))return!1;let s=`${e.description||""} ${e.title||""}`.toLowerCase();return s.includes("container")||s.includes("svg ")||s.includes("<svg")||s.includes("wrapper")}function cD(e){let t=`${e.description||""} ${e.title||""}`.toLowerCase(),n=e.property?.toLowerCase()||"";if(!(t.includes("text ")||t.includes("text layer")||t.includes("text span")||t.includes("span ")||t.includes("label "))||!(n==="width"||n==="height"||n.includes("width")||n.includes("height")||t.includes("width")||t.includes("height")))return!1;let i=e.expected||e.suggestedValue||"",s=e.actual||e.currentValue||"",a=parseFloat(i),u=parseFloat(s);return isNaN(a)||isNaN(u)?!1:Math.abs(a-u)<dw}function uD(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase(),n=String(e.expected||e.suggestedValue||"").toLowerCase(),r=String(e.actual||e.currentValue||"").toLowerCase();if(!nD.some(d=>t.includes(d)||n.includes(d)))return!1;let i=`${t} ${n} ${r}`;if(i.includes("min-width")||i.includes("max-width")||i.includes("min-height")||i.includes("max-height")||i.includes("explicit")||i.includes("constraint")||i.includes("forced"))return!1;let a=n.includes("hug")||n.includes("auto"),u=/\d+\.?\d*px/.test(r);if(!a||!u)return!1;let c=n.match(/(\d+\.?\d*)px/),l=r.match(/(\d+\.?\d*)px/);return!(c&&l&&Math.abs(parseFloat(c[1])-parseFloat(l[1]))>eD)}function pD(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase();return(!n||!t||n.includes("see ")||t.includes("see ")||n.includes("image")||t.includes("image"))&&e.type==="visual"}function Us(e){if(e.programmaticallyVerified)return{dismissed:!1};let t=e.expected||e.suggestedValue,n=e.actual||e.currentValue;if(e.fixRequired===!1)return{dismissed:!0,dismissReason:"Auto-dismissed: FixRequired is false (no code change needed)",dismissedBy:"post-ai-validation"};if(Zo(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: expected equals actual (identical values)",dismissedBy:"post-ai-validation"};if(e.fixRequired===!0)return{dismissed:!1};if(cD(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${dw}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(sD(t,n,e)){let r=e.property?.toLowerCase()||"";return{dismissed:!0,dismissReason:`Auto-dismissed: negligible difference (<${r==="width"||r==="height"||r.includes("width")||r.includes("height")?pw:uw}px)`,dismissedBy:"post-ai-validation"}}return pD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:aD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:uD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:lD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var uw,pw,dw,eD,tD,nD,rD,gw=$(()=>{"use strict";Af();uw=.5,pw=2,dw=2,eD=5,tD=["values match","values already match","already correct","correctly implemented","implementation is correct","css matches","matches figma","identical","same value","no difference","none - ","no changes needed","no fix needed"],nD=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],rD=["duplicate","extra","missing","additional","removed","should not exist","does not exist","not in figma","not in storybook","renders 2","renders two","has 1","has one"]});function Io(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var fw=$(()=>{"use strict"});var mw=$(()=>{"use strict"});var hw=$(()=>{"use strict"});var Pf=$(()=>{"use strict";Af();gw();fw();mw();hw()});var SD,wD,VY,Lf=$(()=>{"use strict";SD=["flex","inline-flex"],wD=["grid","inline-grid"],VY=[...SD,...wD]});var yw=$(()=>{"use strict";Pf();Lf()});var bw=$(()=>{"use strict"});var _n=$(()=>{"use strict";Cu();ky();Cy();Pf();Lf();yw();bw()});function kD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function nr(e){try{let t=e.map(kD),n=JSON.stringify(t,CD);sessionStorage.setItem(Mf,n)}catch(t){b.error("[SessionStorage] Failed to save review history:",t)}}function Bf(){try{let e=sessionStorage.getItem(Mf);if(!e)return[];let t=JSON.parse(e,TD);return Array.isArray(t)?t:[]}catch(e){return b.error("[SessionStorage] Failed to load review history:",e),[]}}function Sw(){try{let e=Bf();if(e.length===0)return;let t=!1,n=e.map(r=>{if(r.aiPrompt!==void 0||r.aiResponse!==void 0){t=!0;let{aiPrompt:o,aiResponse:i,...s}=r;return s}return r});t&&(nr(n),b.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){b.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function ww(){try{sessionStorage.removeItem(Mf),b.debug("[SessionStorage] Review history cleared")}catch(e){b.error("[SessionStorage] Failed to clear review history:",e)}}function CD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function TD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Mf,Df=$(()=>{"use strict";_e();Mf="uicopilot_review_history"});import ID,{createContext as FD,useContext as ED,useReducer as AD,useMemo as vw,useRef as PD,useEffect as LD}from"react";function $l(e){let t=e.length>kw?e.slice(e.length-kw):e,n=Math.max(0,t.length-MD);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),s=r.figmaImageData?.startsWith("data:");return!i&&!s?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:s?void 0:r.figmaImageData}})}function BD(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"ADD_STREAMING_MESSAGE":return{...e,streamingMessages:[...e.streamingMessages,t.payload]};case"UPDATE_STREAMING_MESSAGE":return{...e,streamingMessages:e.streamingMessages.map((n,r)=>r===t.payload.index?{...n,content:t.payload.content}:n)};case"CLEAR_STREAMING_MESSAGES":return{...e,streamingMessages:[]};case"TOGGLE_MODEL":{let n=e.selectedModels.includes(t.payload);return n&&e.selectedModels.length===1?e:{...e,selectedModels:n?e.selectedModels.filter(r=>r!==t.payload):[...e.selectedModels,t.payload]}}case"SET_REVIEW_RESULTS":{if(!t.payload)return{...e,reviewResults:null,currentReviewId:null};let n=e.userRole==="admin",r={id:t.payload.id,componentId:t.payload.componentId,storyId:t.payload.storyId,modelId:t.payload.modelId,complianceScore:t.payload.complianceScore,issuesCount:t.payload.issuesCount,issues:t.payload.issues,createdAt:t.payload.createdAt,visualSimilarity:t.payload.visualSimilarity,storybookImageData:e.storybookImageUrl||void 0,figmaImageData:e.figmaImageUrl||void 0,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},o=e.reviewHistory.findIndex(s=>s.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((s,a)=>a===o?r:s):i=[...e.reviewHistory,r],i=$l(i),nr(i),{...e,reviewResults:t.payload,reviewHistory:i,currentReviewId:t.payload.id}}case"UPDATE_MULTI_MODEL_STREAMING":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload.modelId]:{...e.multiModelResults.byModel[t.payload.modelId],streamingMessages:t.payload.messages}}}}:{...e,multiModelResults:{byModel:{[t.payload.modelId]:{streamingMessages:t.payload.messages}},activeModelId:t.payload.modelId}};case"SET_MODEL_COMPLETED":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload]:{...e.multiModelResults.byModel[t.payload],completed:!0}}}}:e;case"BULK_ADD_REVIEWS":{let n=new Set(e.reviewHistory.map(i=>i.id)),r=t.payload.filter(i=>!n.has(i.id));if(r.length===0)return e;let o=$l([...e.reviewHistory,...r]);return nr(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=$l([...e.reviewHistory,t.payload]);return nr(n),{...e,reviewHistory:n,currentReviewId:t.payload.id}}case"TOGGLE_ISSUE_SELECTION":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,selectedForFix:!o.selectedForFix}:o)});return nr(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_STATUS":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,status:t.payload.status,error:t.payload.error}:o)});return nr(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_GENERATED_FIX":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,generatedFix:o.generatedFix?{...o.generatedFix,...t.payload.generatedFix}:t.payload.generatedFix,selectedForFix:t.payload.generatedFix?.status==="failed"?!1:o.selectedForFix}:o)});return nr(n),{...e,reviewHistory:n}}case"BATCH_UPDATE_ISSUE_GENERATED_FIXES":{if(!e.currentReviewId)return e;let n=new Map(t.payload.map(o=>[o.issueId,o.generatedFix])),r=e.reviewHistory.map(o=>o.id!==e.currentReviewId?o:{...o,issues:o.issues.map(i=>{let s=n.get(i.id);return s?{...i,generatedFix:i.generatedFix?{...i.generatedFix,...s}:s,selectedForFix:s?.status==="failed"?!1:i.selectedForFix}:i})});return nr(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload.issueId?{...c,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:Io(s,a,u),issuesCount:i.length}});return nr(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload?{...c,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:Io(s,a,u),issuesCount:i.length}});return nr(n),{...e,reviewHistory:n}}case"RECALCULATE_SCORE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.filter(c=>!c.dismissed),i=o.filter(c=>c.severity==="critical").length,s=o.filter(c=>c.severity==="major").length,a=o.filter(c=>c.severity==="minor").length,u=Io(i,s,a);return b.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return nr(n),{...e,reviewHistory:n}}case"UPDATE_REVIEW_SCORE":{let n=e.reviewHistory.map(r=>r.id!==t.payload.reviewId?r:{...r,complianceScore:t.payload.newScore});return nr(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return ww(),{...e,reviewHistory:[],currentReviewId:null};case"CLEAR_STALE_REVIEWS":return{...e,currentReviewId:null,reviewResults:null};case"RESET_REVIEW":{let n=e.isReviewing;return{...e,isReviewing:!1,reviewError:null,reviewResults:n?null:e.reviewResults,multiModelResults:null,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:n?"chat":e.reviewDetailTab,fullPrompt:"",fullResponse:"",figmaImageUrl:n?null:e.figmaImageUrl,storybookImageUrl:n?null:e.storybookImageUrl,currentReviewId:n?null:e.currentReviewId}}case"RESET_PROMPT":return{...e,isGenerating:!1,generatedPrompt:null,promptError:null};case"TRIGGER_SCREENSHOT_REFRESH":return{...e,screenshotRefreshKey:e.screenshotRefreshKey+1};default:return e}}function zf({children:e}){let[t,n]=AD(BD,OD),r=PD(t);LD(()=>{r.current=t},[t]);let o=vw(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewError:s=>n({type:"SET_STATE",payload:{reviewError:s}}),bulkAddReviews:s=>n({type:"BULK_ADD_REVIEWS",payload:s}),setReviewResults:s=>n({type:"SET_REVIEW_RESULTS",payload:s}),setMultiModelResults:s=>n({type:"SET_STATE",payload:{multiModelResults:s}}),updateMultiModelStreamingMessages:(s,a)=>n({type:"UPDATE_MULTI_MODEL_STREAMING",payload:{modelId:s,messages:a}}),setModelCompleted:s=>n({type:"SET_MODEL_COMPLETED",payload:s}),setActiveModelId:s=>{let a=r.current;a.multiModelResults&&n({type:"SET_STATE",payload:{multiModelResults:{...a.multiModelResults,activeModelId:s}}})},setShowReviewMenu:s=>n({type:"SET_STATE",payload:{showReviewMenu:s}}),setSeverityFilter:s=>n({type:"SET_STATE",payload:{severityFilter:s}}),setShowStreamingPanel:s=>n({type:"SET_STATE",payload:{showStreamingPanel:s}}),setStreamingPanelCollapsed:s=>n({type:"SET_STATE",payload:{streamingPanelCollapsed:s}}),addStreamingMessage:s=>n({type:"ADD_STREAMING_MESSAGE",payload:s}),updateStreamingMessage:(s,a)=>n({type:"UPDATE_STREAMING_MESSAGE",payload:{index:s,content:a}}),clearStreamingMessages:()=>n({type:"CLEAR_STREAMING_MESSAGES"}),setStreamingProgress:s=>n({type:"SET_STATE",payload:{streamingProgress:s}}),setStreamingStatus:s=>n({type:"SET_STATE",payload:{streamingStatus:s}}),setReviewDetailTab:s=>n({type:"SET_STATE",payload:{reviewDetailTab:s}}),setFullPrompt:s=>n({type:"SET_STATE",payload:{fullPrompt:s}}),setFullResponse:s=>n({type:"SET_STATE",payload:{fullResponse:s}}),setFigmaImageUrl:s=>n({type:"SET_STATE",payload:{figmaImageUrl:s}}),setStorybookImageUrl:s=>n({type:"SET_STATE",payload:{storybookImageUrl:s}}),setFigmaDimensions:s=>n({type:"SET_STATE",payload:{figmaDimensions:s}}),setSelectedModels:s=>n({type:"SET_STATE",payload:{selectedModels:s}}),toggleModel:s=>n({type:"TOGGLE_MODEL",payload:s}),setModelComparisonView:s=>n({type:"SET_STATE",payload:{modelComparisonView:s}}),resetReview:()=>n({type:"RESET_REVIEW"}),addReview:s=>n({type:"ADD_REVIEW",payload:s}),getCurrentReview:()=>{let s=r.current;return s.currentReviewId&&s.reviewHistory.find(a=>a.id===s.currentReviewId)||null},getReviewById:s=>r.current.reviewHistory.find(a=>a.id===s)||null,getParentReview:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return a?.parentReviewId&&s.reviewHistory.find(u=>u.id===a.parentReviewId)||null},hasAppliedFixes:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return!a||!Array.isArray(a.issues)||a.issues.length===0?!1:a.issues.some(u=>u.status==="applied"||u.generatedFix?.status==="applied")},toggleIssueSelection:s=>n({type:"TOGGLE_ISSUE_SELECTION",payload:s}),updateIssueStatus:(s,a,u)=>n({type:"UPDATE_ISSUE_STATUS",payload:{issueId:s,status:a,error:u}}),updateIssueGeneratedFix:(s,a)=>n({type:"UPDATE_ISSUE_GENERATED_FIX",payload:{issueId:s,generatedFix:a}}),batchUpdateIssueGeneratedFixes:s=>n({type:"BATCH_UPDATE_ISSUE_GENERATED_FIXES",payload:s}),dismissIssue:(s,a,u)=>n({type:"DISMISS_ISSUE",payload:{issueId:s,reason:a,dismissedBy:u}}),undismissIssue:s=>n({type:"UNDISMISS_ISSUE",payload:s}),recalculateScore:()=>n({type:"RECALCULATE_SCORE"}),updateReviewScore:(s,a)=>n({type:"UPDATE_REVIEW_SCORE",payload:{reviewId:s,newScore:a}}),clearAllReviews:()=>n({type:"CLEAR_ALL_REVIEWS"}),clearStaleReviewsForStory:s=>n({type:"CLEAR_STALE_REVIEWS",payload:s}),setIsApplying:s=>n({type:"SET_STATE",payload:{isApplying:s}}),setApplyFixesResult:s=>n({type:"SET_STATE",payload:{applyFixesResult:s}}),setIncludeComponentIssues:s=>n({type:"SET_STATE",payload:{includeComponentIssues:s}}),setIncludeTextComparison:s=>n({type:"SET_STATE",payload:{includeTextComparison:s}}),setUsePromptCache:s=>n({type:"SET_STATE",payload:{usePromptCache:s}}),setIsValidating:s=>n({type:"SET_STATE",payload:{isValidating:s}}),setValidationUsage:s=>n({type:"SET_STATE",payload:{validationUsage:s}}),setWorkspacePath:s=>n({type:"SET_STATE",payload:{workspacePath:s}}),triggerScreenshotRefresh:()=>n({type:"TRIGGER_SCREENSHOT_REFRESH"}),setHoveredIssueId:s=>n({type:"SET_STATE",payload:{hoveredIssueId:s}}),setFeatureFlags:s=>n({type:"SET_STATE",payload:{featureFlags:s}}),setUserRole:s=>n({type:"SET_STATE",payload:{userRole:s}}),setRoleOverride:s=>{try{s?localStorage.setItem("uicopilot_role_override",s):localStorage.removeItem("uicopilot_role_override")}catch{}n({type:"SET_STATE",payload:{roleOverride:s}})},setReviewAllConcurrency:s=>{let a=Math.max(1,Math.min(5,s));try{localStorage.setItem("uicopilot_review_all_concurrency",String(a))}catch{}n({type:"SET_STATE",payload:{reviewAllConcurrency:a}})},setIsGenerating:s=>n({type:"SET_STATE",payload:{isGenerating:s}}),setGeneratedPrompt:s=>n({type:"SET_STATE",payload:{generatedPrompt:s}}),setPromptError:s=>n({type:"SET_STATE",payload:{promptError:s}}),resetPrompt:()=>n({type:"RESET_PROMPT"})}),[]),i=vw(()=>({...t,...o}),[t,o]);return ID.createElement(Cw.Provider,{value:i},e)}function ce(){let e=ED(Cw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var kw,MD,DD,RD,Rf,zD,ND,OD,Cw,Nf=$(()=>{"use strict";_n();Df();_e();kw=20,MD=5;DD=()=>{if(typeof localStorage>"u")return 3;try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3},RD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Rf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},zD=()=>{if(typeof localStorage>"u")return Rf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Rf;let t=JSON.parse(e);return{enableFixGeneration:!!t.enableFixGeneration,enableFixApply:!!t.enableFixApply,enableAutoMap:!!t.enableAutoMap,enableReviewBadges:!!t.enableReviewBadges,showCosts:!!t.showCosts,enableParallelReview:!!t.enableParallelReview,enableModelSelection:!!t.enableModelSelection}}catch{}return Rf},ND=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},OD={isReviewing:!1,reviewError:null,reviewResults:null,multiModelResults:null,showReviewMenu:!1,severityFilter:"all",showStreamingPanel:!1,streamingPanelCollapsed:!1,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:"chat",fullPrompt:"",fullResponse:"",figmaImageUrl:null,storybookImageUrl:null,figmaDimensions:null,selectedModels:["claude-sonnet-4-5-20250929"],modelComparisonView:"side-by-side",reviewHistory:$l(Bf()),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:ND(),roleOverride:RD(),featureFlags:zD(),reviewAllConcurrency:DD(),hoveredIssueId:null},Cw=FD(null)});import js,{useMemo as _D}from"react";function _f({children:e}){return js.createElement(yu,null,js.createElement(Su,null,js.createElement(vu,null,js.createElement(zf,null,js.createElement($D,null),e))))}function Tw(e){let t=ke(),n=Je(),r=nt(),o=ce(),i=_D(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function $D(){return Of=Tw(),null}var Of,mt,Iw=$(()=>{"use strict";bu();wu();ku();Nf();Of=null,mt=Object.assign(Tw,{getState:()=>{if(!Of)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Of}})});var Te=$(()=>{"use strict";Iw();bu();wu();ku();Nf()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||UD).replace(/\/$/,"")}var UD,Fw,He=$(()=>{"use strict";UD="https://app.uiparity.com";Fw=3.6});async function ee(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var ct=$(()=>{"use strict"});import{useEffect as ei,useState as jl,useRef as Hw,useCallback as Hf}from"react";import{addons as Wf}from"storybook/manager-api";async function HR(e,t,n){let r=`${e}:${t}`,o=Vf.get(r);if(o)return b.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ee(`${Yw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Vf.delete(r)});return Vf.set(r,i),i}function WR(e,t,n){try{sessionStorage.setItem(`${Hl}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function VR(e,t){try{let n=sessionStorage.getItem(`${Hl}${e}`);if(!n)return null;let r=JSON.parse(n);if(r.figmaNodeId===t&&Date.now()-r.timestamp<1800*1e3)return r.imageUrl;sessionStorage.removeItem(`${Hl}${e}`)}catch{}return null}function GR(e){try{let t=sessionStorage.getItem(`${Hl}${e}`);if(!t)return null;let n=JSON.parse(t);if(n.imageUrl&&Date.now()-n.timestamp<300*1e3)return n.imageUrl}catch{}return null}var Ww,Vw,Gw,qw,Ni,Yw,$n,Gf,Vf,Hl,Kw,Xw,ti,Oi=$(()=>{"use strict";Te();qf();_e();He();ct();Ww="storyArgsUpdated",Vw="storyRendered",Gw="forceRemount",qw=null,Ni=()=>qw,Yw=q(),$n=new Map,Gf=null,Vf=new Map;Hl="uicopilot-figma-image-";Kw=(e,t,n)=>{let r=$n.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):$n.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),b.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},Xw=(e,t,n)=>{Gf=t;let r=$n.get(e);r?r.figmaImageUrl=n:$n.set(e,{storybookImageUrl:null,figmaImageUrl:n}),b.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},ti=()=>{let[e,t]=jl(!1),[n,r]=jl(!1),[o,i]=jl(!1),[s,a]=jl(null),u=Hw(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ce(),d=Hf(()=>{let P=mt.getState().currentStoryId;P&&(b.debug("[useReviewScreenshots] Refreshing screenshots for story:",P),$n.delete(P),u.current=null,i(!0),l())},[l]),g=Hf(()=>{let P=mt.getState().currentStoryId;if(P){b.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",P);let N=$n.get(P);N&&(N.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=ke(),{selectedProjectId:m}=Je(),{currentStoryId:v,currentMapping:I,loadingMapping:A}=nt(),{setStorybookImageUrl:C,setFigmaImageUrl:D}=ce(),R=Hw(null);ei(()=>{v&&R.current&&R.current!==v&&(b.debug("[useReviewScreenshots] Story switched, clearing images"),C(""),D("")),R.current=v},[v,C,D]),ei(()=>{!v||A||I||D("")},[v,I,A,D]),ei(()=>{if(!v)return;let P=GR(v);P&&(b.debug("[useReviewScreenshots] Quick-restored Figma image for:",v),D(P))},[v,D]),ei(()=>{let P=!1;return(async()=>{if(!p||!m||!v){b.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==v&&(b.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),C(""),D(""));let x=mt.getState();if(u.current===v&&x.storybookImageUrl&&x.figmaImageUrl){b.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let k=I?.figmaNodeId??null;if(k!==Gf){b.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",v);let L=$n.get(v);L&&(L.figmaImageUrl=null),Gf=k,u.current=null}let w=I?.figmaNodeId;if(w&&!$n.get(v)?.figmaImageUrl){let L=VR(v,w);if(L){b.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",v),D(L);let M=$n.get(v);M?M.figmaImageUrl=L:$n.set(v,{storybookImageUrl:null,figmaImageUrl:L})}}let E=$n.get(v),f=E&&E.storybookImageUrl&&E.figmaImageUrl,T=E&&E.storybookImageUrl&&!E.figmaImageUrl,S=E&&!E.storybookImageUrl&&E.figmaImageUrl;if(f){b.debug("[useReviewScreenshots] Using fully cached screenshots for story:",v),C(E.storybookImageUrl),D(E.figmaImageUrl),u.current=v;return}let y=T&&I?.figmaNodeId;y&&(b.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",v),C(E.storybookImageUrl));let F=S;if(F&&(b.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",v),D(E.figmaImageUrl)),u.current===v&&I?.figmaNodeId){b.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),y?r(!0):(F||(t(!0),r(!0)),i(!0)),u.current=v,P)return;let L=F?E.figmaImageUrl:null,M;if(F)b.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(w){b.debug("[useReviewScreenshots] Found Figma node ID from mapping:",w);let h=null;try{b.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let j=await HR(m,w,p);h=j.imageUrl||null;let V=j.cached?"(cached)":"(fresh)";b.debug(`[useReviewScreenshots] Figma image fetched ${V}:`,h?"success":"not found")}catch(j){b.warn("[useReviewScreenshots] Failed to fetch Figma image:",j)}if(h)try{b.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let j=`${Yw}/api/proxy/image?url=${encodeURIComponent(h)}`,V=await ee(j);if(V.ok){let B=await V.blob(),G=new FileReader,te=await new Promise((xe,ie)=>{G.onloadend=()=>xe(G.result),G.onerror=ie,G.readAsDataURL(B)});L=te,D(te),b.debug("[useReviewScreenshots] Figma image loaded via proxy");let le=new Image;await new Promise(xe=>{le.onload=()=>{M={width:le.naturalWidth,height:le.naturalHeight},b.debug("[useReviewScreenshots] Figma dimensions:",M),xe()},le.onerror=()=>xe(),le.src=te})}else L=h,D(h),b.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(j){b.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",j),L=h,D(h)}else b.warn("[useReviewScreenshots] No thumbnail found for node:",w),D(null);L&&w&&WR(v,w,L),r(!1)}else b.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let z=E?.storybookImageUrl||null;if(z)b.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{b.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",v);let h=await Wl({storyId:v,sessionToken:p||void 0,...M&&{figmaWidth:M.width,figmaHeight:M.height}});h&&!P?(z=h,C(h),b.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",M||"natural")):b.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}$n.set(v,{storybookImageUrl:z,figmaImageUrl:L}),b.debug("[useReviewScreenshots] Screenshots cached for story:",v)}catch(L){b.error("[useReviewScreenshots] Error loading screenshots:",L),a(L instanceof Error?L.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{P=!0}},[p,m,v,I?.figmaNodeId,c]),ei(()=>{let P=Wf.getChannel(),N=null,x=k=>{qw=k.args,b.debug("[useReviewScreenshots] Args updated for story:",k.storyId,"args:",k.args),N&&clearTimeout(N),N=setTimeout(()=>{b.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return P.on(Ww,x),()=>{P.off(Ww,x),N&&clearTimeout(N)}},[d]),ei(()=>{let P=Wf.getChannel(),N=!1,x=null,k=()=>{b.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),N=!0,i(!0)},w=()=>{N&&(b.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),x&&clearTimeout(x),x=setTimeout(()=>{N=!1,b.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return P.on(Gw,k),P.on(Vw,w),()=>{P.off(Gw,k),P.off(Vw,w),x&&clearTimeout(x)}},[g]),ei(()=>{let P=Wf.getChannel(),N=async x=>{if(!x?.snapshot?.html){b.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}b.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let k=mt.getState().currentStoryId,w=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x.snapshot,storyId:k})});if(w.ok){let E=await w.json();if(E.screenshot){C(E.screenshot);let f=mt.getState().currentStoryId;if(f){let T=$n.get(f);T?T.storybookImageUrl=E.screenshot:$n.set(f,{storybookImageUrl:E.screenshot,figmaImageUrl:null})}}}else b.error("[useReviewScreenshots] Snapshot screenshot failed:",await w.text())}catch(k){b.error("[useReviewScreenshots] Snapshot screenshot error:",k)}finally{i(!1)}};return P.on("UICOPILOT/STORY_DOM_MUTATED",N),()=>{P.off("UICOPILOT/STORY_DOM_MUTATED",N)}},[]);let _=Hf((P,N,x)=>{b.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Xw(P,N,x),D(x),r(!1),u.current=P},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:g,setFigmaImageDirect:_}}});function YR(){return!q().startsWith("http://localhost")}function KR(e,t,n){let r=t.createElement("div");r.style.color=e,t.body.appendChild(r);let o=n.getComputedStyle(r).color;return r.remove(),o}function Qw(e,t,n){let r=new Map;return e.replace(/(?:color|oklch|oklab|lab|lch)\([^)]+\)/g,o=>{if(r.has(o))return r.get(o);let i=KR(o,t,n);return r.set(o,i),i})}async function XR(){let e=(await import("html2canvas")).default,t=document.getElementById("storybook-preview-iframe");if(!t?.contentDocument||!t.contentWindow)throw new Error("Storybook iframe not accessible");let n=t.contentDocument.querySelector("#storybook-root > *")||t.contentDocument.querySelector("#root > *");if(!n)throw new Error("Story element not found in iframe");let r=t.contentWindow,o=t.contentDocument;return(await e(n,{useCORS:!0,logging:!1,backgroundColor:null,onclone:s=>{s.querySelectorAll("style").forEach(u=>{let c=u.textContent||"";/(?:color|oklch|oklab|lab|lch)\(/.test(c)&&(u.textContent=Qw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(d=>d.href===c);if(l)try{let d="";for(let g of Array.from(l.cssRules))d+=g.cssText+`
13
+ `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let g=s.createElement("style");g.textContent=Qw(d,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function QR(e){let t=[];for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let o;typeof r=="boolean"?o=`!${r}`:typeof r=="number"?o=String(r):typeof r=="string"?o=encodeURIComponent(r).replace(/%20/g,"+"):o=encodeURIComponent(JSON.stringify(r)),t.push(`${n}:${o}`)}return t.join(";")}async function JR(e,t){b.debug("[Screenshot] Using server-side Chrome capture for:",e);let n={"Content-Type":"application/json"};t?.sessionToken&&(n.Authorization=`Bearer ${t.sessionToken}`);let r=await ee(`${qR}/api/screenshot`,{method:"POST",headers:n,body:JSON.stringify({url:e,selector:t?.selector,width:t?.width,height:t?.height,scale:t?.scale||1,figmaWidth:t?.figmaWidth,figmaHeight:t?.figmaHeight})});if(!r.ok){let i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Screenshot failed: ${r.status}`)}return(await r.json()).screenshot}function ZR(e){let t={};if(!e)return t;let n=e.split(";");for(let r of n){let o=r.indexOf(":");if(o===-1)continue;let i=r.slice(0,o),s=r.slice(o+1);typeof s=="string"&&(s==="!true"?s=!0:s==="!false"?s=!1:!isNaN(Number(s))&&s!==""?s=Number(s):s=decodeURIComponent(s.replace(/\+/g," "))),t[i]=s}return t}function ez(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),b.debug("[Screenshot] Warning: Using story ID from URL (fallback):",n)),!n)throw new Error("Could not determine current story ID. Please select a story first.");let r=window.location.origin,o=Date.now(),i=`${r}/iframe.html?viewMode=story&id=${n}&globals=&_cb=${o}`,s=Ni();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=ZR(a),b.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=QR(s);i+=`&args=${a}`,b.debug("[Screenshot] Using URL with current args:",i)}else b.debug("[Screenshot] No current args, using default URL:",i);return i}async function tz(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return b.info("[Screenshot] Local Puppeteer not available, falling back"),null;if(!t.ok){let r=await t.json().catch(()=>({error:"Unknown"}));throw new Error(r.error||`Screenshot failed: ${t.status}`)}let n=await t.json();return b.info("[Screenshot] Captured via local Puppeteer (pixel-perfect)"),n.screenshot}catch(t){if(t instanceof TypeError&&t.message.includes("fetch"))return null;throw t}}async function Wl(e){let t=e?.storyId||nz();if(t){let n=Yf.get(t);if(n)return b.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Jw(t,e).finally(()=>{Yf.delete(t)});return Yf.set(t,r),r}return Jw(void 0,e)}async function Jw(e,t){try{if(e){let n=await tz(e);if(n)return n}if(!YR()){let n=ez(t?.storyId);return await JR(n,{...t,selector:"#storybook-root > *"})}return b.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await XR()}catch(n){throw b.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function nz(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var qR,Yf,qf=$(()=>{"use strict";He();Oi();_e();ct();qR=q();Yf=new Map});function An(e){if(e==="transparent"||e==="rgba(0, 0, 0, 0)")return"transparent";let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(!t)return e;let[,n,r,o,i]=t,s=i?parseFloat(i):1;return s<1?`rgba(${n}, ${r}, ${o}, ${s})`:`#${[n,r,o].map(u=>parseInt(u).toString(16).padStart(2,"0")).join("")}`}function Un(e,t){let r={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"],gap:["normal","0px"],flexDirection:["row"],justifyContent:["normal","flex-start"],alignItems:["normal","stretch"],textAlign:["start","left"],letterSpacing:["normal","0px"],margin:["0px","0px 0px 0px 0px"],padding:["0px","0px 0px 0px 0px"]}[e];return r?r.includes(t):!1}function qs(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Zw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let I=r.fontSize||"16px",A=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let C=t.fonts.check(`${A} ${I} Roboto`);if(b.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:C,fontWeight:A,fontSize:I,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),C)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(I=>I.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,m="unknown",v=new Map;for(let I of g){s.font=`${c} ${u} ${a} "${I}", monospace`;let A=s.measureText(o).width;if(v.set(I,A),A!==p){s.font=`${c} ${u} ${a} "${I}"`;let C=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(C-D)<.1){m=I;break}}}return b.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:m,declaredFonts:l,fontWidths:Array.from(v.entries()),isIframe:t!==document}),m}var Ys=$(()=>{"use strict";_e()});function _i(e,t){if(!t)return e;let n=t.split(" ").filter(i=>i.trim()),r=n.find(i=>!i.includes("--")),o=n.filter(i=>i.includes("--"));return r&&o.length>0?`${e}.${r}.${o[0]}`:r?`${e}.${r}`:n[0]?`${e}.${n[0]}`:e}function Kf(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return b.debug("[computedStyles] Extracting styles:",{fontFamily:n.fontFamily,fontWeight:n.fontWeight,borderRadius:n.borderRadius,backgroundColor:n.backgroundColor,padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},isIframeContext:e.ownerDocument!==document}),{color:An(n.color),backgroundColor:An(n.backgroundColor),borderColor:An(n.borderColor),padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},margin:{top:n.marginTop,right:n.marginRight,bottom:n.marginBottom,left:n.marginLeft},gap:n.gap,fontFamily:n.fontFamily,renderedFont:Zw(e),fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.textAlign,textTransform:n.textTransform,width:n.width,height:n.height,minWidth:n.minWidth,minHeight:n.minHeight,maxWidth:n.maxWidth,maxHeight:n.maxHeight,borderWidth:n.borderWidth,borderStyle:n.borderStyle,borderRadius:n.borderRadius,boxShadow:n.boxShadow,textShadow:n.textShadow,display:n.display,flexDirection:n.display==="flex"?n.flexDirection:void 0,justifyContent:n.display==="flex"?n.justifyContent:void 0,alignItems:n.display==="flex"?n.alignItems:void 0,position:n.position,opacity:n.opacity,cursor:n.cursor}}function Xf(e,t){let n={width:null,height:null,minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,display:null,flexGrow:null,flexShrink:null,flexBasis:null};try{let r=Array.from(t.styleSheets);for(let i of r)try{let s=i.cssRules||i.rules;if(!s)continue;for(let a of Array.from(s))if(a.type===1){let u=a;try{if(e.matches(u.selectorText)){let c=u.style;c.width&&(n.width=c.width),c.height&&(n.height=c.height),c.minWidth&&(n.minWidth=c.minWidth),c.minHeight&&(n.minHeight=c.minHeight),c.maxWidth&&(n.maxWidth=c.maxWidth),c.maxHeight&&(n.maxHeight=c.maxHeight),c.display&&(n.display=c.display),c.flexGrow&&(n.flexGrow=c.flexGrow),c.flexShrink&&(n.flexShrink=c.flexShrink),c.flexBasis&&(n.flexBasis=c.flexBasis)}}catch{continue}}}catch{continue}let o=e.style;o.width&&(n.width=o.width),o.height&&(n.height=o.height),o.minWidth&&(n.minWidth=o.minWidth),o.minHeight&&(n.minHeight=o.minHeight),o.maxWidth&&(n.maxWidth=o.maxWidth),o.maxHeight&&(n.maxHeight=o.maxHeight),o.display&&(n.display=o.display),o.flexGrow&&(n.flexGrow=o.flexGrow),o.flexShrink&&(n.flexShrink=o.flexShrink),o.flexBasis&&(n.flexBasis=o.flexBasis)}catch(r){b.error("Error extracting declared styles:",r)}return n}var Vl=$(()=>{"use strict";_e();Ys()});function rz(e){let t=[],n=new Set,r=ev.join(", "),o=e.querySelectorAll(r);for(let i of Array.from(o)){let s=`${i.tagName.toLowerCase()}.${i.className}`;n.has(s)||(n.add(s),t.push(i))}if(ev.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function oz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"";return{selector:_i(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:qs(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:An(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function iz(e,t=2){let n=[e],r=new Set,o=s=>{let a=s.className;return typeof a=="string"?a:a?.baseVal||""};r.add(`${e.tagName}.${o(e)}`);function i(s,a){if(a>=t)return;let u=Array.from(s.children);for(let c of u){let l=c.tagName.toLowerCase();if(["script","style","link","meta","br","hr"].includes(l))continue;let d=`${c.tagName}.${o(c)}`;r.has(d)||(r.add(d),n.push(c),i(c,a+1))}}return i(e,0),n}function sz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",s=n.borderWidth!=="0px",a=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",c=n.gap!=="normal"&&n.gap!=="0px";if(!s&&!a&&!u&&!c)return null;let l=n.borderWidth,d=n.borderStyle,g=An(n.borderColor),p=s?`${l} ${d} ${g}`:"none";return{selector:_i(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:An(n.backgroundColor),gap:n.gap}}function Ks(){b.debug("[computedStyles] extractStoryStyles called - FULL CONTEXT VERSION");try{let e=document.getElementById("storybook-preview-iframe");if(!e||!e.contentDocument)throw new Error("Storybook preview iframe not found");let t=e.contentDocument,n=t.getElementById("storybook-root");if(!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(!r)throw new Error("Component element not found in story root");let o=iz(r,2),i=o.map(sz).filter(a=>a!==null);b.debug("[computedStyles] Extracted visual styles from nested elements:",{total:o.length,withVisuals:i.length,elements:i.map(a=>({selector:a.selector,border:a.border,background:a.backgroundColor,borderRadius:a.borderRadius}))});let s=[];try{let a=rz(r);s=a.map(oz),b.debug("[computedStyles] Text elements found:",{count:a.length,elements:s.map(u=>({selector:u.selector,fontSize:u.styles.fontSize,fontWeight:u.styles.fontWeight}))})}catch(a){b.error("[computedStyles] Error extracting text elements:",a)}return{computed:Kf(r),declared:Xf(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return b.error("Error extracting computed styles:",e),null}}var ev,tv=$(()=>{"use strict";_e();Ys();Vl();ev=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Qf(e,t,n,r){return e===t&&t===n&&n===r?e:e===n&&t===r?`${e} ${t}`:t===r?`${e} ${t} ${n}`:`${e} ${t} ${n} ${r}`}function lz(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function cz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=An(n.backgroundColor);Un("backgroundColor",o)||(r.backgroundColor=o);let i=lz(n.borderWidth,n.borderStyle,An(n.borderColor));i&&(r.border=i),Un("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Un("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Un("opacity",n.opacity)||(r.opacity=n.opacity);let s=e.tagName.toLowerCase(),a=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||a.includes(s)){for(let I=0;I<e.attributes.length;I++){let A=e.attributes[I];if(["class","style","id","xmlns","xmlns:xlink"].includes(A.name))continue;let C=A.name.replace(/-([a-z])/g,(R,_)=>_.toUpperCase()),D=A.value.startsWith("rgb")?An(A.value):A.value;C==="d"&&D.length>100?r[C]=D.substring(0,100)+"...":r[C]=D}let p=n.getPropertyValue("fill"),m=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?An(p):p),m&&m!=="none"&&(r.stroke=m.startsWith("rgb")?An(m):m),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let I=e.getBoundingClientRect();I.width>0&&(r.width=`${Math.round(I.width*100)/100}px`),I.height>0&&(r.height=`${Math.round(I.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=az.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=qs(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=An(n.color),Un("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Un("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Qf(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Un("padding",d)||(r.padding=d);let g=Qf(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Un("margin",g)||(r.margin=g),Un("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Un("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Un("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Un("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function nv(e){let t=1;for(let n of e.children)t+=nv(n);return t}function rv(e,t=4){function n(o,i){let s=o.tagName.toLowerCase(),a=o.className,u=typeof a=="string"?a:a?.baseVal||"",c=o.id||void 0,l=o.getAttribute("role")||void 0,d;for(let v of Array.from(o.childNodes))if(v.nodeType===Node.TEXT_NODE){let I=v.textContent?.trim();if(I){d=I.length>50?I.substring(0,50)+"...":I;break}}let g=s;c?g=`${s}#${c}`:u&&(g=_i(s,u));let p=cz(o),m=[];if(i<t){let v=Array.from(o.children);for(let I of v){let A=I.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(A))continue;let D=(I.ownerDocument.defaultView||window).getComputedStyle(I);D.display==="none"||D.visibility==="hidden"||m.push(n(I,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:m}}b.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return b.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:nv(r)}),r}function Jf(e=4){b.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(b.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(b.debug("[extractStoryDOMTree] iframe.contentDocument:",!!t.contentDocument),!t.contentDocument)throw new Error("iframe.contentDocument is not accessible (possible cross-origin issue)");let n=t.contentDocument.getElementById("storybook-root");if(b.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(b.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=rv(r,e);return b.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return b.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var az,ov=$(()=>{"use strict";_e();Ys();Vl();az=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Zf=$(()=>{"use strict";Ys();Vl();tv();ov()});var Pv=ar((MQ,Av)=>{"use strict";Av.exports={compareTwoStrings:Ev,findBestMatch:Dz};function Ev(e,t){if(e=e.replace(/\s+/g,""),t=t.replace(/\s+/g,""),e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let o=0;o<e.length-1;o++){let i=e.substring(o,o+2),s=n.has(i)?n.get(i)+1:1;n.set(i,s)}let r=0;for(let o=0;o<t.length-1;o++){let i=t.substring(o,o+2),s=n.has(i)?n.get(i):0;s>0&&(n.set(i,s-1),r++)}return 2*r/(e.length+t.length-2)}function Dz(e,t){if(!Rz(e,t))throw new Error("Bad arguments: First argument should be a string, second should be an array of strings");let n=[],r=0;for(let i=0;i<t.length;i++){let s=t[i],a=Ev(e,s);n.push({target:s,rating:a}),a>n[r].rating&&(r=i)}let o=n[r];return{ratings:n,bestMatch:o,bestMatchIndex:r}}function Rz(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var F1=ar((Gse,I1)=>{"use strict";var v1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,$3=/\n/g,U3=/^\s*/,j3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,H3=/^:\s*/,W3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,V3=/^[;\s]*/,G3=/^\s+|\s+$/g,q3=`
14
+ `,k1="/",C1="*",li="",Y3="comment",K3="declaration";function X3(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(m){var v=m.match($3);v&&(n+=v.length);var I=m.lastIndexOf(q3);r=~I?m.length-I:r+m.length}function i(){var m={line:n,column:r};return function(v){return v.position=new s(m),c(),v}}function s(m){this.start=m,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function u(m){var v=m.exec(e);if(v){var I=v[0];return o(I),e=e.slice(I.length),v}}function c(){u(U3)}function l(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=i();if(!(k1!=e.charAt(0)||C1!=e.charAt(1))){for(var v=2;li!=e.charAt(v)&&(C1!=e.charAt(v)||k1!=e.charAt(v+1));)++v;if(v+=2,li===e.charAt(v-1))return a("End of comment missing");var I=e.slice(2,v-2);return r+=2,o(I),e=e.slice(v),r+=2,m({type:Y3,comment:I})}}function g(){var m=i(),v=u(j3);if(v){if(d(),!u(H3))return a("property missing ':'");var I=u(W3),A=m({type:K3,property:T1(v[0].replace(v1,li)),value:I?T1(I[0].replace(v1,li)):li});return u(V3),A}}function p(){var m=[];l(m);for(var v;v=g();)v!==!1&&(m.push(v),l(m));return m}return c(),p()}function T1(e){return e?e.replace(G3,li):li}I1.exports=X3});var E1=ar(ma=>{"use strict";var Q3=ma&&ma.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ma,"__esModule",{value:!0});ma.default=Z3;var J3=Q3(F1());function Z3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,J3.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;let{property:s,value:a}=i;o?t(s,a,i):a&&(n=n||{},n[s]=a)}),n}});var P1=ar(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.camelCase=void 0;var eU=/^--[a-zA-Z0-9_-]+$/,tU=/-([a-z])/g,nU=/^[^-]+$/,rU=/^-(webkit|moz|ms|o|khtml)-/,oU=/^-(ms)-/,iU=function(e){return!e||nU.test(e)||eU.test(e)},sU=function(e,t){return t.toUpperCase()},A1=function(e,t){return"".concat(t,"-")},aU=function(e,t){return t===void 0&&(t={}),iU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(oU,A1):e=e.replace(rU,A1),e.replace(tU,sU))};Fc.camelCase=aU});var M1=ar((Bh,L1)=>{"use strict";var lU=Bh&&Bh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},cU=lU(E1()),uU=P1();function Mh(e,t){var n={};return!e||typeof e!="string"||(0,cU.default)(e,function(r,o){r&&o&&(n[(0,uU.camelCase)(r,t)]=o)}),n}Mh.default=Mh;L1.exports=Mh});var iI=ar((wde,oI)=>{"use strict";var Xc=Object.prototype.hasOwnProperty,rI=Object.prototype.toString,QT=Object.defineProperty,JT=Object.getOwnPropertyDescriptor,ZT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):rI.call(t)==="[object Array]"},eI=function(t){if(!t||rI.call(t)!=="[object Object]")return!1;var n=Xc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Xc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Xc.call(t,o)},tI=function(t,n){QT&&n.name==="__proto__"?QT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},nI=function(t,n){if(n==="__proto__")if(Xc.call(t,n)){if(JT)return JT(t,n).value}else return;return t[n]};oI.exports=function e(){var t,n,r,o,i,s,a=arguments[0],u=1,c=arguments.length,l=!1;for(typeof a=="boolean"&&(l=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<c;++u)if(t=arguments[u],t!=null)for(n in t)r=nI(a,n),o=nI(t,n),a!==o&&(l&&o&&(eI(o)||(i=ZT(o)))?(i?(i=!1,s=r&&ZT(r)?r:[]):s=r&&eI(r)?r:{},tI(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&tI(a,{name:n,newValue:o}));return a}});import ja from"react";import{addons as pu,types as ry,experimental_getStatusStore as oy}from"storybook/manager-api";import{AddonPanel as UV}from"storybook/internal/components";import zt,{useState as sV,useEffect as aV}from"react";import{styled as Sr}from"storybook/theming";import gy from"react";import{styled as Dt}from"storybook/theming";var se="#ea580c",fu="#c2410c",Ga="#ff6b35";var ay=Dt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ly=Dt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),xo=Dt.div({marginBottom:"20px"}),yo=Dt.label(({theme:e})=>({display:"block",marginBottom:`${e.layoutMargin*.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),gs=Dt.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,"&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`}})),bn=Dt.select(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px 32px ${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px",transition:"border-color 0.15s, box-shadow 0.15s","&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`},"&:hover":{borderColor:e.color.mediumdark},"&:disabled":{opacity:.6,cursor:"not-allowed"}})),cy=Dt(bn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),qa=e=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:disabled":{opacity:.5,cursor:"not-allowed"}}),Fn=Dt.button(({theme:e})=>({...qa(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),on=Dt.button(({theme:e})=>({...qa(e),backgroundColor:se,color:e.color.inverseText,boxShadow:`0 2px 4px ${se}4d`,"&:hover:not(:disabled)":{backgroundColor:fu,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${se}66`}})),Nr=Dt.button(({theme:e})=>({...qa(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),uy=Dt.button(({theme:e})=>({...qa(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),En=Dt.button(({theme:e})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:`${e.layoutMargin*.4}px`,fontSize:e.typography.size.s2,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),mu=Dt.button(({theme:e})=>({padding:0,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.secondary,backgroundColor:"transparent",border:"none",cursor:"pointer",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),bo=Dt.button(({theme:e,active:t})=>({padding:`${e.layoutMargin*.6}px ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:t?e.typography.weight.bold:400,color:t?e.color.secondary:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderBottom:t?`2px solid ${e.color.secondary}`:"2px solid transparent",cursor:"pointer",transition:"all 0.15s","&:hover":{color:t?e.color.secondary:e.color.defaultText}})),So=Dt(gs)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),KV=Dt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),py=Dt.h2(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s3,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),XV=Dt.h3(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),fs=Dt.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),QV=Dt.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.background.hoverable,borderRadius:e.appBorderRadius,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"100%",background:`linear-gradient(90deg, transparent, ${e.color.mediumlight}33, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{transform:"translateX(-100%)"},"100%":{transform:"translateX(100%)"}}})),dy=Dt.span(({theme:e,variant:t="default"})=>{let n={default:{bg:e.background.hoverable,color:e.color.defaultText},success:{bg:`${e.color.positive}40`,color:e.color.positive},warning:{bg:`${e.color.warning}40`,color:e.color.warning},error:{bg:`${e.color.negative}40`,color:e.color.negative}};return{display:"inline-block",padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,borderRadius:"3px",backgroundColor:n[t].bg,color:n[t].color}}),JV=Dt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),ZV=Dt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),e9=Dt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var hu=({header:e,children:t,footer:n})=>gy.createElement(ay,null,e,gy.createElement(ly,null,t),n);import tE from"react";import{styled as nE}from"storybook/theming";var rE=nE.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),xu=({toolbar:e})=>tE.createElement(rE,null,e);import u9 from"react";import{styled as Ya}from"storybook/theming";var g9=Ya.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),f9=Ya.div({display:"flex",flex:1}),m9=Ya(bo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),h9=Ya.div({display:"flex",gap:"8px",alignItems:"center"});import en,{useState as Uf,useCallback as _w,useEffect as $w}from"react";import{styled as ro}from"storybook/theming";import Ce,{useEffect as Ew}from"react";import{styled as lt}from"storybook/theming";Te();He();_e();ct();var Aw=lt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),Pw=lt.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"12px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),jD=lt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),HD=lt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:se,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),WD=lt.div({display:"flex",flexDirection:"column",gap:"4px"}),VD=lt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),GD=lt.span({display:"inline-block",alignSelf:"flex-start",padding:"2px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:"#7c3aed",backgroundColor:"rgba(124, 58, 237, 0.1)",letterSpacing:"0.3px"}),qD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),YD=lt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),KD=lt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),XD=lt.div(({theme:e})=>({height:"8px",borderRadius:"4px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",margin:"0 16px 8px",overflow:"hidden"})),QD=lt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${se} 100%)`,transition:"width 0.3s ease"})),JD=lt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),ZD=lt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),eR=lt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:se,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Lw=lt.button(({theme:e})=>({position:"absolute",top:"12px",right:"12px",width:"24px",height:"24px",borderRadius:"4px",border:"none",background:"transparent",color:e.textMutedColor,cursor:"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:e.background.hoverable}})),tR=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),nR=lt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),rR=lt.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:se,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),oR=lt.div({display:"flex",gap:"8px"}),Mw=lt(En)({fontSize:"18px"}),iR=lt.div({padding:"20px 16px"}),sR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),aR=lt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),lR=lt.div({fontSize:"28px",fontWeight:700}),cR=lt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),uR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),pR=lt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),dR=lt.div({display:"flex",alignItems:"center",gap:"8px"}),gR=lt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),fR=lt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:se,color:e.color.inverseText})),mR=lt.button(({theme:e})=>({background:"none",border:"none",color:se,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),hR=lt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),xR=lt.button(({theme:e,variant:t="primary"})=>({width:"100%",padding:"12px",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:"pointer",border:"none",marginBottom:"12px",backgroundColor:t==="primary"?se:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),yR=30*1e3,Bw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=ke(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(m=!1)=>{if(!t)return;let v=o&&Date.now()-o<yR;if(!(!m&&v&&r))try{let I=q(),A=await ee(`${I}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(A.ok){let C=await A.json();i(C)}}catch(I){b.error("Failed to fetch usage:",I)}};Ew(()=>{l()},[t]),Ew(()=>{let m=()=>{document.visibilityState==="visible"&&(b.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[t]);let d=()=>{if(t){let m=q();fetch(`${m}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}).catch(()=>{})}n(),e()},g=()=>{let m=q();window.open(`${m}/pricing`,"_blank")},p=()=>{let m=q();window.open(`${m}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let m=Math.floor(u?.creditBalance??0),I=Math.max(m,10),A=Math.max(0,I-m),C=I>0?m/I*100:0;return Ce.createElement(Ce.Fragment,null,Ce.createElement(Aw,{onClick:e}),Ce.createElement(Pw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},Ce.createElement(jD,null,Ce.createElement(HD,null,u?.email?u.email[0].toUpperCase():"U"),Ce.createElement(WD,null,Ce.createElement(VD,null,"UI Review"),Ce.createElement(GD,null,(u?.plan||"BETA").toUpperCase())),Ce.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},Ce.createElement(Lw,{onClick:d,title:"Sign out",style:{position:"static"}},Ce.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Ce.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Ce.createElement("polyline",{points:"16 17 21 12 16 7"}),Ce.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Ce.createElement(Lw,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),Ce.createElement(qD,null,Ce.createElement(YD,null,"Credits"),Ce.createElement(KD,null,m," left")),Ce.createElement(XD,null,Ce.createElement(QD,{percent:C})),Ce.createElement(JD,null,A," used \xB7 ",m," remaining"),Ce.createElement(ZD,null),Ce.createElement(eR,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return Ce.createElement(Ce.Fragment,null,Ce.createElement(Aw,{onClick:e}),Ce.createElement(Pw,{onClick:m=>m.stopPropagation()},Ce.createElement(tR,null,Ce.createElement(nR,null,Ce.createElement(rR,null,u?.email?u.email[0].toUpperCase():"U"),Ce.createElement("span",null,u?.email||"Loading...")),Ce.createElement(oR,null,Ce.createElement(Mw,{onClick:d,title:"Sign out"},Ce.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Ce.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Ce.createElement("polyline",{points:"16 17 21 12 16 7"}),Ce.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Ce.createElement(Mw,{onClick:e,title:"Close"},"\xD7"))),Ce.createElement(iR,null,c?Ce.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Ce.createElement(Ce.Fragment,null,Ce.createElement(sR,null,Ce.createElement(aR,null,"Credit Balance"),Ce.createElement(lR,null,"$",(u?.creditBalance??0).toFixed(2)),Ce.createElement(cR,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Ce.createElement(uR,null,Ce.createElement(pR,null,Ce.createElement(dR,null,Ce.createElement(gR,null,"Current Plan"),Ce.createElement(fR,null,u?.plan||"Free")),Ce.createElement(mR,{onClick:g},"View detail >")),Ce.createElement(hR,null,"~$0.02-0.05 per review depending on complexity"),Ce.createElement(xR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):Ce.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Te();import Di from"react";import{styled as Dw}from"storybook/theming";He();Te();ct();_e();var bR=Dw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),SR=Dw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),wR={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},Rw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=ke();return e!=="admin"?null:Di.createElement(bR,null,Di.createElement(SR,null,"View as:"),Di.createElement(cy,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ee(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>b.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=wR[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Di.createElement("option",{value:"admin"},"Admin"),Di.createElement("option",{value:"beta"},"Beta Tester")),t&&Di.createElement(dy,{variant:"warning"},"Previewing as ",t))};He();Te();ct();import bt,{useState as Hs,useCallback as $f}from"react";import{styled as Fr}from"storybook/theming";var vR="0.5.7",kR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],CR=Fr.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),TR=Fr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),IR=Fr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),FR=Fr.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),ER=Fr.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),AR=Fr.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),PR=Fr.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:se}})),zw=Fr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),Nw=Fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),LR=Fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),MR=Fr.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function Ow({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=ke(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=Hs("other"),[u,c]=Hs(""),[l,d]=Hs(!1),[g,p]=Hs(!1),[m,v]=Hs(null),I=$f(()=>{c(""),a("other"),p(!1),v(null),d(!1)},[]),A=$f(()=>{I(),t()},[I,t]),C=$f(async D=>{if(D.preventDefault(),!u.trim()){v("Please write a message.");return}if(!r||!n){v("Sign in to send feedback.");return}d(!0),v(null);try{let R=await ee(`${q()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:vR})});if(!R.ok){let _=await R.json().catch(()=>({}));throw new Error(_.error||`Request failed (${R.status})`)}p(!0)}catch(R){v(R instanceof Error?R.message:"Something went wrong")}finally{d(!1)}},[u,s,n,r,o,i]);return e?bt.createElement(CR,{onClick:A},bt.createElement(TR,{onClick:D=>D.stopPropagation()},bt.createElement(IR,null,bt.createElement(FR,null,bt.createElement("span",null,"\u{1F4AC}"),"Send feedback"),bt.createElement(ER,{onClick:A,"aria-label":"Close"},"\xD7")),g?bt.createElement(bt.Fragment,null,bt.createElement(MR,null,bt.createElement("h4",null,"Thanks \u2014 got it."),bt.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),bt.createElement(zw,null,bt.createElement("span",null),bt.createElement(Fn,{onClick:A},"Close"))):bt.createElement("form",{onSubmit:C},bt.createElement(AR,null,bt.createElement(xo,null,bt.createElement(yo,{htmlFor:"feedback-severity"},"Type"),bt.createElement(bn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},kR.map(D=>bt.createElement("option",{key:D.value,value:D.value},D.label)))),bt.createElement(xo,null,bt.createElement(yo,{htmlFor:"feedback-message"},"What happened?"),bt.createElement(PR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),bt.createElement(Nw,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),m&&bt.createElement(LR,null,m)),bt.createElement(zw,null,bt.createElement(Nw,null,i?`Context: ${i}`:"No story selected"),bt.createElement("div",{style:{display:"flex",gap:"8px"}},bt.createElement(Fn,{type:"button",onClick:A,disabled:l},"Cancel"),bt.createElement(on,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}Te();He();ct();var BR=ro.div({display:"flex",alignItems:"center"}),Ri=ro.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),DR=ro.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),RR=ro.div({position:"relative"}),zR=ro.button(({theme:e})=>({width:"26px",height:"26px",padding:0,background:`linear-gradient(135deg, ${e.color.secondary} 0%, ${e.color.secondary}cc 100%)`,border:"none",borderRadius:"50%",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s","&:hover":{transform:"scale(1.05)",boxShadow:`0 2px 8px ${e.color.secondary}66`}})),Uw=ro.button(({isLow:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:e?"#FEF3C7":"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",border:"none",borderRadius:"12px",color:e?"#92400E":"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,transition:"all 0.2s",minWidth:"60px",justifyContent:"center","&:hover":{transform:"scale(1.02)",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})),NR=ro.span({display:"inline-block",width:"12px",height:"12px",border:"2px solid rgba(255,255,255,0.3)",borderTopColor:"#fff",borderRadius:"50%",animation:"credit-spin 0.8s linear infinite","@keyframes credit-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),OR=ro.button(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",padding:"4px 10px",height:"28px",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.mediumdark,fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.mediumdark}})),_R=ro.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:se,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${se}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${se}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),$R=30*1e3,jf=({onOpenSettings:e})=>{let[t,n]=Uf(!1),[r,o]=Uf(!1),[i,s]=Uf(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=ke(),{userRole:d,roleOverride:g,featureFlags:p}=ce(),m=g??d;$w(()=>{(async()=>{if(!(!l||u&&Date.now()-u<$R&&a)){s(!0);try{let _=q(),P=await ee(`${_}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let N=await P.json();c(N)}}catch(_){console.error("Failed to fetch balance:",_)}finally{s(!1)}}})()},[l,u,a,c]),$w(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},R=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",R),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",R)}},[t]);let v=_w(()=>{n(!0)},[]),I=_w(()=>{n(!1)},[]),A=a?.creditBalance??0,C=A<2&&!i;return en.createElement(BR,null,e&&en.createElement(Ri,null,en.createElement(OR,{onClick:e,title:"Settings"},en.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&m==="admin"&&en.createElement(Ri,null,en.createElement(Rw,null)),en.createElement(Ri,null,en.createElement(DR,null,"v","0.5.27")),l&&p.showCosts&&en.createElement(Ri,null,en.createElement(Uw,{onClick:v,isLow:C,title:i?"Loading...":a?C?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?en.createElement(NR,null):a?`$${A.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&en.createElement(Ri,null,en.createElement(Uw,{onClick:v,isLow:Math.floor(A)<=3,title:`${Math.floor(A)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(A))),en.createElement(Ri,null,en.createElement(RR,null,en.createElement(zR,{title:"Account & Usage",onClick:v},a?.email?a.email[0].toUpperCase():"?"),t&&en.createElement(Bw,{onClose:I}))),l&&en.createElement(_R,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),en.createElement(Ow,{isOpen:r,onClose:()=>o(!1)}))};import Bt,{useEffect as B4,useRef as D4}from"react";import{styled as hr}from"storybook/theming";import rt from"react";Te();_e();He();ct();_n();import{useState as UR,useCallback as zi,useRef as jw,useEffect as jR}from"react";var oo=q();b.debug("[useAuth] Module loaded, APP_URL:",oo);var Ws=()=>{let e=jw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:g,setUserCode:p,setVerificationUri:m,setPollingInterval:v,setAuthError:I,resetAuth:A}=ke(),C=jw(null),[D,R]=UR(!1),_=zi(async()=>{try{b.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let E;try{E=await ee(`${oo}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(F){let M=F instanceof Error&&F.message.includes("timed out")?`Cannot reach ${Pt.NAME} server at ${oo}. Is the dashboard running?`:`Connection failed: ${oo} is not responding.`;I(M),b.error("[useAuth]",M);return}if(!E.ok){let F=`Cannot reach ${Pt.NAME} server. Is the dashboard running?`;I(F),b.error("[useAuth]",F);return}let{poll_code:f}=await E.json();b.debug("[useAuth] Got poll_code:",f.substring(0,15)+"...");let T=localStorage.getItem("uicopilot_force_sign_in")==="true";T&&localStorage.removeItem("uicopilot_force_sign_in");let S=`${oo}/addon/auth?poll_code=${f}${T?"&force_sign_in=true":""}`;R(!0),window.open(S,"uiparity-auth","width=520,height=620,left=300,top=150"),b.debug("[useAuth] Starting OAuth poll for token..."),C.current&&clearInterval(C.current);let y=async()=>{try{let L=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:f})})).json();L.status==="authorized"&&L.session_token?(b.debug("[useAuth] \u2705 OAuth poll successful! Got token."),C.current&&(clearInterval(C.current),C.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token),R(!1)):L.status==="expired"&&(b.debug("[useAuth] OAuth poll_code expired"),C.current&&(clearInterval(C.current),C.current=null),R(!1))}catch(F){b.error("[useAuth] OAuth poll error:",F)}};C.current=setInterval(y,2e3),setTimeout(y,1e3)}catch(E){b.error("[useAuth] OAuth flow error:",E),I(`Connection failed. Is the dashboard running at ${oo}?`),R(!1)}},[c,I]),P=zi(async()=>{try{let E=await fetch(`${oo}/api/addon/auth/device`,{method:"POST"});if(!E.ok)throw new Error("Failed to start device code flow");let f=await E.json();g(f.device_code),p(f.user_code),m(f.verification_uri),window.open(f.verification_uri,"_blank"),N(f.device_code,f.interval*1e3)}catch(E){throw b.error("[useAuth] Device code flow error:",E),E}},[g,p,m]),N=zi((E,f)=>{b.debug("[useAuth] Starting polling. Device code:",E,"Interval:",f),e.current&&clearInterval(e.current);let T=async()=>{try{let y=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:E})})).json();y.status==="authorized"?(b.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null),localStorage.setItem("uicopilot_session_token",y.session_token),c(y.session_token),setOauthUrl(null)):(y.status==="expired"||y.status==="denied")&&(b.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null))}catch(S){b.error("[useAuth] Polling error:",S)}};e.current=setInterval(T,f),v(f)},[g,p,m,c,v]),x=zi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null),v(null)},[g,p,m,v]),k=zi(E=>{l(E),c(E),localStorage.setItem("uicopilot_api_key",E)},[l,c]),w=zi(()=>{A(),setOauthUrl(null),e.current&&(clearInterval(e.current),e.current=null),C.current&&(clearInterval(C.current),C.current=null)},[A]);return jR(()=>()=>{e.current&&clearInterval(e.current),C.current&&clearInterval(C.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:D,setAuthMethod:d,startOAuth:_,startDeviceCode:P,cancelDeviceCode:x,saveApiKey:k,logout:w}};Te();_e();He();ct();import{useCallback as Ul}from"react";var Vs=q(),io=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=ke(),u=Ul(async()=>{if(!a){b.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),b.debug("[useProjects] Fetching from:",`${Vs}/api/projects`);let g=await ee(`${Vs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();b.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else b.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){b.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=Ul(async g=>{if(!a)throw new Error("Not authenticated");let p=await ee(`${Vs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!p.ok)throw new Error("Failed to create project");let m=await p.json();return await u(),m.project},[a,u]),l=Ul(async(g,p)=>{if(!a)throw new Error("Not authenticated");let m={};if(p.name!==void 0&&(m.name=p.name),p.description!==void 0&&(m.description=p.description),p.figmaFileUrl!==void 0&&(m.figmaFileId=p.figmaFileUrl||void 0),!(await ee(`${Vs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(m)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=Ul(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ee(`${Vs}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:d}};Te();var Gs=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d}=nt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};Te();qf();Zf();import{useCallback as ea,useRef as Jl}from"react";_e();function Gl(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){b.warn("[iframeReload] No preview iframe found"),e();return}let n=t.contentWindow.location.href,r=new URL(n);r.searchParams.set("_cb",Date.now().toString());let o=r.toString();b.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{b.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),b.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{b.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var ql=BigInt(4294967295),iv=BigInt(32);function uz(e,t=!1){return t?{h:Number(e&ql),l:Number(e>>iv&ql)}:{h:Number(e>>iv&ql)|0,l:Number(e&ql)|0}}function sv(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=uz(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var av=(e,t,n)=>e<<n|t>>>32-n,lv=(e,t,n)=>t<<n|e>>>32-n,cv=(e,t,n)=>t<<n-32|e>>>64-n,uv=(e,t,n)=>e<<n-32|t>>>64-n;function pz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function em(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Yl(e,t,n=""){let r=pz(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let s=n&&`"${n}" `,a=i?` of length ${t}`:"",u=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+u)}return e}function tm(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function pv(e,t){Yl(e,void 0,"digestInto() output");let n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function dv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nm(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var dz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function fz(e){for(let t=0;t<e.length;t++)e[t]=gz(e[t]);return e}var rm=dz?e=>e:fz;function gv(e,t={}){let n=(o,i)=>e(i).update(o).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=o=>e(o),Object.assign(n,t),Object.freeze(n)}var fv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var mz=BigInt(0),Xs=BigInt(1),hz=BigInt(2),xz=BigInt(7),yz=BigInt(256),bz=BigInt(113),xv=[],yv=[],bv=[];for(let e=0,t=Xs,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],xv.push(2*(5*r+n)),yv.push((e+1)*(e+2)/2%64);let o=mz;for(let i=0;i<7;i++)t=(t<<Xs^(t>>xz)*bz)%yz,t&hz&&(o^=Xs<<(Xs<<BigInt(i))-Xs);bv.push(o)}var Sv=sv(bv,!0),Sz=Sv[0],wz=Sv[1],mv=(e,t,n)=>n>32?cv(e,t,n):av(e,t,n),hv=(e,t,n)=>n>32?uv(e,t,n):lv(e,t,n);function vz(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],d=mv(c,l,1)^n[a],g=hv(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=yv[s],u=mv(o,i,a),c=hv(o,i,a),l=xv[s];o=e[l],i=e[l+1],e[l]=u,e[l+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Sz[r],e[1]^=wz[r]}nm(n)}var om=class e{constructor(t,n,r,o=!1,i=24){lr(this,"state");lr(this,"pos",0);lr(this,"posOut",0);lr(this,"finished",!1);lr(this,"state32");lr(this,"destroyed",!1);lr(this,"blockLen");lr(this,"suffix");lr(this,"outputLen");lr(this,"enableXOF",!1);lr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,em(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=dv(this.state)}clone(){return this._cloneInto()}keccak(){rm(this.state32),vz(this.state32,this.rounds),rm(this.state32),this.posOut=0,this.pos=0}update(t){tm(this),Yl(t);let{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){tm(this,!1),Yl(t),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return em(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pv(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,nm(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new e(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}},kz=(e,t,n,r={})=>gv(()=>new om(t,e,n),r);var wv=kz(6,72,64,fv(10));var Cz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,im=Math.ceil,fr=Math.floor,jn="[BigNumber Error] ",vv=jn+"Number primitive has more than 15 significant digits: ",Er=1e14,Ve=14,sm=9007199254740991,am=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Fo=1e7,ln=1e9;function kv(e){var t,n,r,o=C.prototype={constructor:C,toString:null,valueOf:null},i=new C(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,m=0,v={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},I="0123456789abcdefghijklmnopqrstuvwxyz",A=!0;function C(x,k){var w,E,f,T,S,y,F,L,M=this;if(!(M instanceof C))return new C(x,k);if(k==null){if(x&&x._isBigNumber===!0){M.s=x.s,!x.c||x.e>d?M.c=M.e=null:x.e<l?M.c=[M.e=0]:(M.e=x.e,M.c=x.c.slice());return}if((y=typeof x=="number")&&x*0==0){if(M.s=1/x<0?(x=-x,-1):1,x===~~x){for(T=0,S=x;S>=10;S/=10,T++);T>d?M.c=M.e=null:(M.e=T,M.c=[x]);return}L=String(x)}else{if(!Cz.test(L=String(x)))return r(M,L,y);M.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(T=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(T<0&&(T=S),T+=+L.slice(S+1),L=L.substring(0,S)):T<0&&(T=L.length)}else{if(Ot(k,2,I.length,"Base"),k==10&&A)return M=new C(x),P(M,s+M.e+1,a);if(L=String(x),y=typeof x=="number"){if(x*0!=0)return r(M,L,y,k);if(M.s=1/x<0?(L=L.slice(1),-1):1,C.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(vv+x)}else M.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(w=I.slice(0,k),T=S=0,F=L.length;S<F;S++)if(w.indexOf(E=L.charAt(S))<0){if(E=="."){if(S>T){T=F;continue}}else if(!f&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){f=!0,S=-1,T=0;continue}return r(M,String(x),y,k)}y=!1,L=n(L,k,10,M.s),(T=L.indexOf("."))>-1?L=L.replace(".",""):T=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(F=L.length;L.charCodeAt(--F)===48;);if(L=L.slice(S,++F)){if(F-=S,y&&C.DEBUG&&F>15&&(x>sm||x!==fr(x)))throw Error(vv+M.s*x);if((T=T-S-1)>d)M.c=M.e=null;else if(T<l)M.c=[M.e=0];else{if(M.e=T,M.c=[],S=(T+1)%Ve,T<0&&(S+=Ve),S<F){for(S&&M.c.push(+L.slice(0,S)),F-=Ve;S<F;)M.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=F;for(;S--;L+="0");M.c.push(+L)}}else M.c=[M.e=0]}C.clone=kv,C.ROUND_UP=0,C.ROUND_DOWN=1,C.ROUND_CEIL=2,C.ROUND_FLOOR=3,C.ROUND_HALF_UP=4,C.ROUND_HALF_DOWN=5,C.ROUND_HALF_EVEN=6,C.ROUND_HALF_CEIL=7,C.ROUND_HALF_FLOOR=8,C.EUCLID=9,C.config=C.set=function(x){var k,w;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(k="DECIMAL_PLACES")&&(w=x[k],Ot(w,0,ln,k),s=w),x.hasOwnProperty(k="ROUNDING_MODE")&&(w=x[k],Ot(w,0,8,k),a=w),x.hasOwnProperty(k="EXPONENTIAL_AT")&&(w=x[k],w&&w.pop?(Ot(w[0],-ln,0,k),Ot(w[1],0,ln,k),u=w[0],c=w[1]):(Ot(w,-ln,ln,k),u=-(c=w<0?-w:w))),x.hasOwnProperty(k="RANGE"))if(w=x[k],w&&w.pop)Ot(w[0],-ln,-1,k),Ot(w[1],1,ln,k),l=w[0],d=w[1];else if(Ot(w,-ln,ln,k),w)l=-(d=w<0?-w:w);else throw Error(jn+k+" cannot be zero: "+w);if(x.hasOwnProperty(k="CRYPTO"))if(w=x[k],w===!!w)if(w)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=w;else throw g=!w,Error(jn+"crypto unavailable");else g=w;else throw Error(jn+k+" not true or false: "+w);if(x.hasOwnProperty(k="MODULO_MODE")&&(w=x[k],Ot(w,0,9,k),p=w),x.hasOwnProperty(k="POW_PRECISION")&&(w=x[k],Ot(w,0,ln,k),m=w),x.hasOwnProperty(k="FORMAT"))if(w=x[k],typeof w=="object")v=w;else throw Error(jn+k+" not an object: "+w);if(x.hasOwnProperty(k="ALPHABET"))if(w=x[k],typeof w=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(w))A=w.slice(0,10)=="0123456789",I=w;else throw Error(jn+k+" invalid: "+w)}else throw Error(jn+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:m,FORMAT:v,ALPHABET:I}},C.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!C.DEBUG)return!0;var k,w,E=x.c,f=x.e,T=x.s;e:if({}.toString.call(E)=="[object Array]"){if((T===1||T===-1)&&f>=-ln&&f<=ln&&f===fr(f)){if(E[0]===0){if(f===0&&E.length===1)return!0;break e}if(k=(f+1)%Ve,k<1&&(k+=Ve),String(E[0]).length==k){for(k=0;k<E.length;k++)if(w=E[k],w<0||w>=Er||w!==fr(w))break e;if(w!==0)return!0}}}else if(E===null&&f===null&&(T===null||T===1||T===-1))return!0;throw Error(jn+"Invalid BigNumber: "+x)},C.maximum=C.max=function(){return R(arguments,-1)},C.minimum=C.min=function(){return R(arguments,1)},C.random=(function(){var x=9007199254740992,k=Math.random()*x&2097151?function(){return fr(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(w){var E,f,T,S,y,F=0,L=[],M=new C(i);if(w==null?w=s:Ot(w,0,ln),S=im(w/Ve),g)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(S*=2));F<S;)y=E[F]*131072+(E[F+1]>>>11),y>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),E[F]=f[0],E[F+1]=f[1]):(L.push(y%1e14),F+=2);F=S/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(S*=7);F<S;)y=(E[F]&31)*281474976710656+E[F+1]*1099511627776+E[F+2]*4294967296+E[F+3]*16777216+(E[F+4]<<16)+(E[F+5]<<8)+E[F+6],y>=9e15?crypto.randomBytes(7).copy(E,F):(L.push(y%1e14),F+=7);F=S/7}else throw g=!1,Error(jn+"crypto unavailable");if(!g)for(;F<S;)y=k(),y<9e15&&(L[F++]=y%1e14);for(S=L[--F],w%=Ve,S&&w&&(y=am[Ve-w],L[F]=fr(S/y)*y);L[F]===0;L.pop(),F--);if(F<0)L=[T=0];else{for(T=-1;L[0]===0;L.splice(0,1),T-=Ve);for(F=1,y=L[0];y>=10;y/=10,F++);F<Ve&&(T-=Ve-F)}return M.e=T,M.c=L,M}})(),C.sum=function(){for(var x=1,k=arguments,w=new C(k[0]);x<k.length;)w=w.plus(k[x++]);return w},n=(function(){var x="0123456789";function k(w,E,f,T){for(var S,y=[0],F,L=0,M=w.length;L<M;){for(F=y.length;F--;y[F]*=E);for(y[0]+=T.indexOf(w.charAt(L++)),S=0;S<y.length;S++)y[S]>f-1&&(y[S+1]==null&&(y[S+1]=0),y[S+1]+=y[S]/f|0,y[S]%=f)}return y.reverse()}return function(w,E,f,T,S){var y,F,L,M,z,h,j,V,B=w.indexOf("."),G=s,te=a;for(B>=0&&(M=m,m=0,w=w.replace(".",""),V=new C(E),h=V.pow(w.length-B),m=M,V.c=k(so(gr(h.c),h.e,"0"),10,f,x),V.e=V.c.length),j=k(w,E,f,S?(y=I,x):(y=x,I)),L=M=j.length;j[--M]==0;j.pop());if(!j[0])return y.charAt(0);if(B<0?--L:(h.c=j,h.e=L,h.s=T,h=t(h,V,G,te,f),j=h.c,z=h.r,L=h.e),F=L+G+1,B=j[F],M=f/2,z=z||F<0||j[F+1]!=null,z=te<4?(B!=null||z)&&(te==0||te==(h.s<0?3:2)):B>M||B==M&&(te==4||z||te==6&&j[F-1]&1||te==(h.s<0?8:7)),F<1||!j[0])w=z?so(y.charAt(1),-G,y.charAt(0)):y.charAt(0);else{if(j.length=F,z)for(--f;++j[--F]>f;)j[F]=0,F||(++L,j=[1].concat(j));for(M=j.length;!j[--M];);for(B=0,w="";B<=M;w+=y.charAt(j[B++]));w=so(w,L,y.charAt(0))}return w}})(),t=(function(){function x(E,f,T){var S,y,F,L,M=0,z=E.length,h=f%Fo,j=f/Fo|0;for(E=E.slice();z--;)F=E[z]%Fo,L=E[z]/Fo|0,S=j*F+L*h,y=h*F+S%Fo*Fo+M,M=(y/T|0)+(S/Fo|0)+j*L,E[z]=y%T;return M&&(E=[M].concat(E)),E}function k(E,f,T,S){var y,F;if(T!=S)F=T>S?1:-1;else for(y=F=0;y<T;y++)if(E[y]!=f[y]){F=E[y]>f[y]?1:-1;break}return F}function w(E,f,T,S){for(var y=0;T--;)E[T]-=y,y=E[T]<f[T]?1:0,E[T]=y*S+E[T]-f[T];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,f,T,S,y){var F,L,M,z,h,j,V,B,G,te,le,xe,ie,Ke,be,Ie,ve,ue=E.s==f.s?1:-1,$e=E.c,pe=f.c;if(!$e||!$e[0]||!pe||!pe[0])return new C(!E.s||!f.s||($e?pe&&$e[0]==pe[0]:!pe)?NaN:$e&&$e[0]==0||!pe?ue*0:ue/0);for(B=new C(ue),G=B.c=[],L=E.e-f.e,ue=T+L+1,y||(y=Er,L=mr(E.e/Ve)-mr(f.e/Ve),ue=ue/Ve|0),M=0;pe[M]==($e[M]||0);M++);if(pe[M]>($e[M]||0)&&L--,ue<0)G.push(1),z=!0;else{for(Ke=$e.length,Ie=pe.length,M=0,ue+=2,h=fr(y/(pe[0]+1)),h>1&&(pe=x(pe,h,y),$e=x($e,h,y),Ie=pe.length,Ke=$e.length),ie=Ie,te=$e.slice(0,Ie),le=te.length;le<Ie;te[le++]=0);ve=pe.slice(),ve=[0].concat(ve),be=pe[0],pe[1]>=y/2&&be++;do{if(h=0,F=k(pe,te,Ie,le),F<0){if(xe=te[0],Ie!=le&&(xe=xe*y+(te[1]||0)),h=fr(xe/be),h>1)for(h>=y&&(h=y-1),j=x(pe,h,y),V=j.length,le=te.length;k(j,te,V,le)==1;)h--,w(j,Ie<V?ve:pe,V,y),V=j.length,F=1;else h==0&&(F=h=1),j=pe.slice(),V=j.length;if(V<le&&(j=[0].concat(j)),w(te,j,le,y),le=te.length,F==-1)for(;k(pe,te,Ie,le)<1;)h++,w(te,Ie<le?ve:pe,le,y),le=te.length}else F===0&&(h++,te=[0]);G[M++]=h,te[0]?te[le++]=$e[ie]||0:(te=[$e[ie]],le=1)}while((ie++<Ke||te[0]!=null)&&ue--);z=te[0]!=null,G[0]||G.splice(0,1)}if(y==Er){for(M=1,ue=G[0];ue>=10;ue/=10,M++);P(B,T+(B.e=M+L*Ve-1)+1,S,z)}else B.e=L,B.r=+z;return B}})();function D(x,k,w,E){var f,T,S,y,F;if(w==null?w=a:Ot(w,0,8),!x.c)return x.toString();if(f=x.c[0],S=x.e,k==null)F=gr(x.c),F=E==1||E==2&&(S<=u||S>=c)?Xl(F,S):so(F,S,"0");else if(x=P(new C(x),k,w),T=x.e,F=gr(x.c),y=F.length,E==1||E==2&&(k<=T||T<=u)){for(;y<k;F+="0",y++);F=Xl(F,T)}else if(k-=S+(E===2&&T>S),F=so(F,T,"0"),T+1>y){if(--k>0)for(F+=".";k--;F+="0");}else if(k+=T-y,k>0)for(T+1==y&&(F+=".");k--;F+="0");return x.s<0&&f?"-"+F:F}function R(x,k){for(var w,E,f=1,T=new C(x[0]);f<x.length;f++)E=new C(x[f]),(!E.s||(w=ni(T,E))===k||w===0&&T.s===k)&&(T=E);return T}function _(x,k,w){for(var E=1,f=k.length;!k[--f];k.pop());for(f=k[0];f>=10;f/=10,E++);return(w=E+w*Ve-1)>d?x.c=x.e=null:w<l?x.c=[x.e=0]:(x.e=w,x.c=k),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,w=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,S,y,F){var L,M=y?S:S.replace(f,"");if(E.test(M))T.s=isNaN(M)?null:M<0?-1:1;else{if(!y&&(M=M.replace(x,function(z,h,j){return L=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!F||F==L?h:z}),F&&(L=F,M=M.replace(k,"$1").replace(w,"0.$1")),S!=M))return new C(M,L);if(C.DEBUG)throw Error(jn+"Not a"+(F?" base "+F:"")+" number: "+S);T.s=null}T.c=T.e=null}})();function P(x,k,w,E){var f,T,S,y,F,L,M,z=x.c,h=am;if(z){e:{for(f=1,y=z[0];y>=10;y/=10,f++);if(T=k-f,T<0)T+=Ve,S=k,F=z[L=0],M=fr(F/h[f-S-1]%10);else if(L=im((T+1)/Ve),L>=z.length)if(E){for(;z.length<=L;z.push(0));F=M=0,f=1,T%=Ve,S=T-Ve+1}else break e;else{for(F=y=z[L],f=1;y>=10;y/=10,f++);T%=Ve,S=T-Ve+f,M=S<0?0:fr(F/h[f-S-1]%10)}if(E=E||k<0||z[L+1]!=null||(S<0?F:F%h[f-S-1]),E=w<4?(M||E)&&(w==0||w==(x.s<0?3:2)):M>5||M==5&&(w==4||E||w==6&&(T>0?S>0?F/h[f-S]:0:z[L-1])%10&1||w==(x.s<0?8:7)),k<1||!z[0])return z.length=0,E?(k-=x.e+1,z[0]=h[(Ve-k%Ve)%Ve],x.e=-k||0):z[0]=x.e=0,x;if(T==0?(z.length=L,y=1,L--):(z.length=L+1,y=h[Ve-T],z[L]=S>0?fr(F/h[f-S]%h[S])*y:0),E)for(;;)if(L==0){for(T=1,S=z[0];S>=10;S/=10,T++);for(S=z[0]+=y,y=1;S>=10;S/=10,y++);T!=y&&(x.e++,z[0]==Er&&(z[0]=1));break}else{if(z[L]+=y,z[L]!=Er)break;z[L--]=0,y=1}for(T=z.length;z[--T]===0;z.pop());}x.e>d?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function N(x){var k,w=x.e;return w===null?x.toString():(k=gr(x.c),k=w<=u||w>=c?Xl(k,w):so(k,w,"0"),x.s<0?"-"+k:k)}return o.absoluteValue=o.abs=function(){var x=new C(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,k){return ni(this,new C(x,k))},o.decimalPlaces=o.dp=function(x,k){var w,E,f,T=this;if(x!=null)return Ot(x,0,ln),k==null?k=a:Ot(k,0,8),P(new C(T),x+T.e+1,k);if(!(w=T.c))return null;if(E=((f=w.length-1)-mr(this.e/Ve))*Ve,f=w[f])for(;f%10==0;f/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(x,k){return t(this,new C(x,k),s,a)},o.dividedToIntegerBy=o.idiv=function(x,k){return t(this,new C(x,k),0,1)},o.exponentiatedBy=o.pow=function(x,k){var w,E,f,T,S,y,F,L,M,z=this;if(x=new C(x),x.c&&!x.isInteger())throw Error(jn+"Exponent not an integer: "+N(x));if(k!=null&&(k=new C(k)),y=x.e>14,!z.c||!z.c[0]||z.c[0]==1&&!z.e&&z.c.length==1||!x.c||!x.c[0])return M=new C(Math.pow(+N(z),y?x.s*(2-Kl(x)):+N(x))),k?M.mod(k):M;if(F=x.s<0,k){if(k.c?!k.c[0]:!k.s)return new C(NaN);E=!F&&z.isInteger()&&k.isInteger(),E&&(z=z.mod(k))}else{if(x.e>9&&(z.e>0||z.e<-1||(z.e==0?z.c[0]>1||y&&z.c[1]>=24e7:z.c[0]<8e13||y&&z.c[0]<=9999975e7)))return T=z.s<0&&Kl(x)?-0:0,z.e>-1&&(T=1/T),new C(F?1/T:T);m&&(T=im(m/Ve+2))}for(y?(w=new C(.5),F&&(x.s=1),L=Kl(x)):(f=Math.abs(+N(x)),L=f%2),M=new C(i);;){if(L){if(M=M.times(z),!M.c)break;T?M.c.length>T&&(M.c.length=T):E&&(M=M.mod(k))}if(f){if(f=fr(f/2),f===0)break;L=f%2}else if(x=x.times(w),P(x,x.e+1,1),x.e>14)L=Kl(x);else{if(f=+N(x),f===0)break;L=f%2}z=z.times(z),T?z.c&&z.c.length>T&&(z.c.length=T):E&&(z=z.mod(k))}return E?M:(F&&(M=i.div(M)),k?M.mod(k):T?P(M,m,a,S):M)},o.integerValue=function(x){var k=new C(this);return x==null?x=a:Ot(x,0,8),P(k,k.e+1,x)},o.isEqualTo=o.eq=function(x,k){return ni(this,new C(x,k))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,k){return ni(this,new C(x,k))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,k){return(k=ni(this,new C(x,k)))===1||k===0},o.isInteger=function(){return!!this.c&&mr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,k){return ni(this,new C(x,k))<0},o.isLessThanOrEqualTo=o.lte=function(x,k){return(k=ni(this,new C(x,k)))===-1||k===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(x,k){var w,E,f,T,S=this,y=S.s;if(x=new C(x,k),k=x.s,!y||!k)return new C(NaN);if(y!=k)return x.s=-k,S.plus(x);var F=S.e/Ve,L=x.e/Ve,M=S.c,z=x.c;if(!F||!L){if(!M||!z)return M?(x.s=-k,x):new C(z?S:NaN);if(!M[0]||!z[0])return z[0]?(x.s=-k,x):new C(M[0]?S:a==3?-0:0)}if(F=mr(F),L=mr(L),M=M.slice(),y=F-L){for((T=y<0)?(y=-y,f=M):(L=F,f=z),f.reverse(),k=y;k--;f.push(0));f.reverse()}else for(E=(T=(y=M.length)<(k=z.length))?y:k,y=k=0;k<E;k++)if(M[k]!=z[k]){T=M[k]<z[k];break}if(T&&(f=M,M=z,z=f,x.s=-x.s),k=(E=z.length)-(w=M.length),k>0)for(;k--;M[w++]=0);for(k=Er-1;E>y;){if(M[--E]<z[E]){for(w=E;w&&!M[--w];M[w]=k);--M[w],M[E]+=Er}M[E]-=z[E]}for(;M[0]==0;M.splice(0,1),--L);return M[0]?_(x,M,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,k){var w,E,f=this;return x=new C(x,k),!f.c||!x.s||x.c&&!x.c[0]?new C(NaN):!x.c||f.c&&!f.c[0]?new C(f):(p==9?(E=x.s,x.s=1,w=t(f,x,0,3),x.s=E,w.s*=E):w=t(f,x,0,p),x=f.minus(w.times(x)),!x.c[0]&&p==1&&(x.s=f.s),x)},o.multipliedBy=o.times=function(x,k){var w,E,f,T,S,y,F,L,M,z,h,j,V,B,G,te=this,le=te.c,xe=(x=new C(x,k)).c;if(!le||!xe||!le[0]||!xe[0])return!te.s||!x.s||le&&!le[0]&&!xe||xe&&!xe[0]&&!le?x.c=x.e=x.s=null:(x.s*=te.s,!le||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(E=mr(te.e/Ve)+mr(x.e/Ve),x.s*=te.s,F=le.length,z=xe.length,F<z&&(V=le,le=xe,xe=V,f=F,F=z,z=f),f=F+z,V=[];f--;V.push(0));for(B=Er,G=Fo,f=z;--f>=0;){for(w=0,h=xe[f]%G,j=xe[f]/G|0,S=F,T=f+S;T>f;)L=le[--S]%G,M=le[S]/G|0,y=j*L+M*h,L=h*L+y%G*G+V[T]+w,w=(L/B|0)+(y/G|0)+j*M,V[T--]=L%B;V[T]=w}return w?++E:V.splice(0,1),_(x,V,E)},o.negated=function(){var x=new C(this);return x.s=-x.s||null,x},o.plus=function(x,k){var w,E=this,f=E.s;if(x=new C(x,k),k=x.s,!f||!k)return new C(NaN);if(f!=k)return x.s=-k,E.minus(x);var T=E.e/Ve,S=x.e/Ve,y=E.c,F=x.c;if(!T||!S){if(!y||!F)return new C(f/0);if(!y[0]||!F[0])return F[0]?x:new C(y[0]?E:f*0)}if(T=mr(T),S=mr(S),y=y.slice(),f=T-S){for(f>0?(S=T,w=F):(f=-f,w=y),w.reverse();f--;w.push(0));w.reverse()}for(f=y.length,k=F.length,f-k<0&&(w=F,F=y,y=w,k=f),f=0;k;)f=(y[--k]=y[k]+F[k]+f)/Er|0,y[k]=Er===y[k]?0:y[k]%Er;return f&&(y=[f].concat(y),++S),_(x,y,S)},o.precision=o.sd=function(x,k){var w,E,f,T=this;if(x!=null&&x!==!!x)return Ot(x,1,ln),k==null?k=a:Ot(k,0,8),P(new C(T),x,k);if(!(w=T.c))return null;if(f=w.length-1,E=f*Ve+1,f=w[f]){for(;f%10==0;f/=10,E--);for(f=w[0];f>=10;f/=10,E++);}return x&&T.e+1>E&&(E=T.e+1),E},o.shiftedBy=function(x){return Ot(x,-sm,sm),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,k,w,E,f,T=this,S=T.c,y=T.s,F=T.e,L=s+4,M=new C("0.5");if(y!==1||!S||!S[0])return new C(!y||y<0&&(!S||S[0])?NaN:S?T:1/0);if(y=Math.sqrt(+N(T)),y==0||y==1/0?(k=gr(S),(k.length+F)%2==0&&(k+="0"),y=Math.sqrt(+k),F=mr((F+1)/2)-(F<0||F%2),y==1/0?k="5e"+F:(k=y.toExponential(),k=k.slice(0,k.indexOf("e")+1)+F),w=new C(k)):w=new C(y+""),w.c[0]){for(F=w.e,y=F+L,y<3&&(y=0);;)if(f=w,w=M.times(f.plus(t(T,f,L,1))),gr(f.c).slice(0,y)===(k=gr(w.c)).slice(0,y))if(w.e<F&&--y,k=k.slice(y-3,y+1),k=="9999"||!E&&k=="4999"){if(!E&&(P(f,f.e+s+2,0),f.times(f).eq(T))){w=f;break}L+=4,y+=4,E=1}else{(!+k||!+k.slice(1)&&k.charAt(0)=="5")&&(P(w,w.e+s+2,1),x=!w.times(w).eq(T));break}}return P(w,w.e+s+1,a,x)},o.toExponential=function(x,k){return x!=null&&(Ot(x,0,ln),x++),D(this,x,k,1)},o.toFixed=function(x,k){return x!=null&&(Ot(x,0,ln),x=x+this.e+1),D(this,x,k)},o.toFormat=function(x,k,w){var E,f=this;if(w==null)x!=null&&k&&typeof k=="object"?(w=k,k=null):x&&typeof x=="object"?(w=x,x=k=null):w=v;else if(typeof w!="object")throw Error(jn+"Argument not an object: "+w);if(E=f.toFixed(x,k),f.c){var T,S=E.split("."),y=+w.groupSize,F=+w.secondaryGroupSize,L=w.groupSeparator||"",M=S[0],z=S[1],h=f.s<0,j=h?M.slice(1):M,V=j.length;if(F&&(T=y,y=F,F=T,V-=T),y>0&&V>0){for(T=V%y||y,M=j.substr(0,T);T<V;T+=y)M+=L+j.substr(T,y);F>0&&(M+=L+j.slice(T)),h&&(M="-"+M)}E=z?M+(w.decimalSeparator||"")+((F=+w.fractionGroupSize)?z.replace(new RegExp("\\d{"+F+"}\\B","g"),"$&"+(w.fractionGroupSeparator||"")):z):M}return(w.prefix||"")+E+(w.suffix||"")},o.toFraction=function(x){var k,w,E,f,T,S,y,F,L,M,z,h,j=this,V=j.c;if(x!=null&&(y=new C(x),!y.isInteger()&&(y.c||y.s!==1)||y.lt(i)))throw Error(jn+"Argument "+(y.isInteger()?"out of range: ":"not an integer: ")+N(y));if(!V)return new C(j);for(k=new C(i),L=w=new C(i),E=F=new C(i),h=gr(V),T=k.e=h.length-j.e-1,k.c[0]=am[(S=T%Ve)<0?Ve+S:S],x=!x||y.comparedTo(k)>0?T>0?k:L:y,S=d,d=1/0,y=new C(h),F.c[0]=0;M=t(y,k,0,1),f=w.plus(M.times(E)),f.comparedTo(x)!=1;)w=E,E=f,L=F.plus(M.times(f=L)),F=f,k=y.minus(M.times(f=k)),y=f;return f=t(x.minus(w),E,0,1),F=F.plus(f.times(L)),w=w.plus(f.times(E)),F.s=L.s=j.s,T=T*2,z=t(L,E,T,a).minus(j).abs().comparedTo(t(F,w,T,a).minus(j).abs())<1?[L,E]:[F,w],d=S,z},o.toNumber=function(){return+N(this)},o.toPrecision=function(x,k){return x!=null&&Ot(x,1,ln),D(this,x,k,2)},o.toString=function(x){var k,w=this,E=w.s,f=w.e;return f===null?E?(k="Infinity",E<0&&(k="-"+k)):k="NaN":(x==null?k=f<=u||f>=c?Xl(gr(w.c),f):so(gr(w.c),f,"0"):x===10&&A?(w=P(new C(w),s+f+1,a),k=so(gr(w.c),w.e,"0")):(Ot(x,2,I.length,"Base"),k=n(so(gr(w.c),f,"0"),10,x,E,!0)),E<0&&w.c[0]&&(k="-"+k)),k},o.valueOf=o.toJSON=function(){return N(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&C.set(e),C}function mr(e){var t=e|0;return e>0||e===t?t:t-1}function gr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=Ve-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function ni(e,t){var n,r,o=e.c,i=t.c,s=e.s,a=t.s,u=e.e,c=t.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=u==c,!o||!i)return r?0:!o^n?1:-1;if(!r)return u>c^n?1:-1;for(a=(u=o.length)<(c=i.length)?u:c,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return u==c?0:u>c^n?1:-1}function Ot(e,t,n,r){if(e<t||e>n||e!==fr(e))throw Error(jn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Kl(e){var t=e.c.length-1;return mr(e.e/Ve)==t&&e.c[t]%2!=0}function Xl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function so(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(r=e.length,++t>r){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var Tz=kv(),Cv=Tz;var Iz=24,Qs=32,Fz=()=>typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"?()=>{let e=new Uint32Array(1);return globalThis.crypto.getRandomValues(e),e[0]/4294967296}:Math.random,cm=Fz(),lm=(e=4,t=cm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function Ez(e){let t=new Cv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Iv=(e="")=>{let t=new TextEncoder;return Ez(wv(t.encode(e))).toString(36).slice(1)},Tv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),Az=e=>Tv[Math.floor(e()*Tv.length)],Pz=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=cm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+lm(Qs,t):lm(Qs,t);return Iv(r).substring(0,Qs)},Lz=e=>()=>e++,Mz=476782367,Fv=({random:e=cm,counter:t=Lz(Math.floor(e()*Mz)),length:n=Iz,fingerprint:r=Pz({random:e})}={})=>{if(n>Qs)throw new Error(`Length must be between 2 and ${Qs}. Received: ${n}`);return function(){let i=Az(e),s=Date.now().toString(36),a=t().toString(36),u=lm(n,e),c=`${s+u+a+r}`;return`${i+Iv(c).substring(1,n)}`}},Eo=Bz(Fv);function Bz(e){let t;return()=>(t||(t=e()),t())}var zz=Va(Pv());_n();_e();var Ql=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function Nz(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function um(e,t){let n=[],r=e.split(`
15
+ `);for(let s=0;s<r.length;s++){let a=Nz(r[s]),u=Ql.exec(a);if(u){let[,c,l,,d]=u,g=Oz(l),p=_z(r,s+1),m={id:Eo(),reviewId:t,type:c.trim(),severity:g,title:d.trim(),description:p.description,file:p.file,lineNumber:p.lineNumber,property:p.property,currentValue:p.currentValue,suggestedValue:p.suggestedValue,suggestedCode:p.suggestedCode,suggestedFix:p.suggestedFix,fixTarget:p.fixTarget,fixRequired:p.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(m)}Ql.lastIndex=0}return n.map(s=>{let a=Us(s);return a.dismissed?(b.debug(`[parseIssues] Auto-dismissed: ${s.title} - ${a.dismissReason}`),{...s,dismissed:!0,dismissReason:a.dismissReason,dismissedBy:a.dismissedBy,dismissedAt:new Date}):s})}function Oz(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function _z(e,t){let n={description:"",file:void 0,lineNumber:void 0,property:void 0,currentValue:void 0,suggestedValue:void 0,suggestedCode:void 0,suggestedFix:void 0,fixTarget:void 0,fixRequired:void 0},r=[];for(let o=t;o<e.length;o++){let i=e[o].trim();if(!i||Ql.test(i)){Ql.lastIndex=0;break}if(i.startsWith("Expected:"))n.suggestedValue=i.replace("Expected:","").trim();else if(i.startsWith("Actual:")||i.startsWith("Current:"))n.currentValue=i.replace(/^(Actual|Current):/,"").trim();else if(i.startsWith("File:")){let s=i.replace("File:","").trim(),a=s.match(/^(.+?):(\d+)$/);a?(n.file=a[1],n.lineNumber=parseInt(a[2],10)):n.file=s}else if(i.startsWith("Property:"))n.property=i.replace("Property:","").trim();else if(i.startsWith("FixTarget:")){let s=i.replace("FixTarget:","").trim().toLowerCase();(s==="css"||s==="component")&&(n.fixTarget=s)}else if(i.startsWith("FixRequired:")){let s=i.replace("FixRequired:","").trim().toLowerCase();n.fixRequired=s==="true"}else if(i.startsWith("Fix:"))n.suggestedFix=i.replace("Fix:","").trim();else if(i.startsWith("```")){let s=[];for(o++;o<e.length&&!e[o].trim().startsWith("```");)s.push(e[o]),o++;n.suggestedCode=s.join(`
16
+ `)}else r.push(i)}return n.description=r.join(" ").trim(),n}_e();var Js=null,Lv=0,$z=3e4;async function Uz(){let e=Date.now();if(Js&&e-Lv<$z)return Js;try{let t=await fetch("/index.json");if(!t.ok)throw new Error(`Failed to fetch index.json: ${t.status}`);let n=await t.json();return Js=n.entries||n.stories||{},Lv=e,b.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Js).length),Js}catch(t){throw b.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Zs(e){try{let n=(await Uz())[e];if(!n?.importPath)return b.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;b.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),b.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,b.debug("[storyFilePaths] Derived componentFile:",i));let s=i.replace(/\.tsx$/,".css").replace(/\.ts$/,".css").replace(/\.jsx$/,".css").replace(/\.js$/,".css"),a=i.substring(0,i.lastIndexOf("/")),u={storyFile:o,componentFile:i,cssFile:s,baseDir:a};return b.debug("[storyFilePaths] Final paths:",u),u}catch(t){return b.error("[storyFilePaths] Error getting file paths:",t),null}}function pm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function jz(e,t){let n=e.toLowerCase().trim();return["color","spacing","typography","dimension","border","shadow","layout","background","font","size","margin","padding"].some(i=>n.includes(i))?t.cssFile:t.componentFile}function dm(e,t){let n=e.property?.toLowerCase()||"",r=e.domElement?.toLowerCase()||"",o=r.startsWith("svg"),i=r.startsWith("img"),s=n==="width"||n==="height",a=/\[(?:width|height)=/.test(r);return(o||i)&&s||a?(b.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):jz(e.type,t)}_e();function Hz(e){let t=(e.description||"").toLowerCase(),n=(e.title||"").toLowerCase(),r=`${t} ${n}`;return r.includes("inner icon")||r.includes("inner vector")?"inner-icon":r.includes("second icon")?"icon-2":r.includes("first icon")?"icon-1":r.includes("icon")||r.includes("vector")||r.includes("svg")?"icon":r.includes("button")?"button":r.includes("text")||r.includes("label")?"text":r.includes("container")||r.includes("wrapper")?"container":"other"}function Wz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("width")||t.includes("height")||t.includes("size")||t.includes("dimensions")?"dimensions":t.includes("padding")||t.includes("margin")||t.includes("gap")?"spacing":t.includes("color")||t.includes("background")||t.includes("fill")?"colors":t.includes("font")||t.includes("text")||t.includes("line-height")?"typography":t.includes("border")||t.includes("radius")?"border":n.includes("overall")||n.includes("visual fidelity")||n.includes("pixel similarity")||t.includes("overall")?"summary":"other"}function Vz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("overall")||t.includes("visual fidelity")||n.includes("pixel similarity score")||n.includes("primarily explained by")||n.includes("visual discrepancy")}function Gz(e,t,n){let r={critical:3,major:2,minor:1},i=[...e].sort((c,l)=>(r[l.severity]||0)-(r[c.severity]||0))[0],s=e.length,a,u;if(t.includes("icon")&&n==="dimensions"){let c=e.map(d=>d.currentValue).filter(Boolean),l=e.map(d=>d.suggestedValue).filter(Boolean);a=`Icon sizing is incorrect (${s} related issues)`,u=`Icons are rendered at wrong dimensions. Current: ${c[0]||"10px"}, Expected: ${l[0]||"20px"}. This single CSS fix will resolve all ${s} icon dimension issues.`}else a=`${t} ${n} issues (${s} related)`,u=`${s} related ${n} issues for ${t}. ${i.description}`;return{...i,id:`merged-${t}-${n}-${i.id}`,title:a,description:u,currentValue:i.currentValue,suggestedValue:i.suggestedValue,mergedCount:s,mergedIssueIds:e.map(c=>c.id)}}function gm(e){if(!e||e.length===0)return[];let t=e.filter(i=>!Vz(i)),n=[],r=[];for(let i of t){let s=Hz(i),a=Wz(i);s.includes("icon")&&a==="dimensions"?n.push(i):r.push(i)}let o=[];return n.length>0&&(n.length===1?o.push(n[0]):o.push(Gz(n,"icon","dimensions"))),o.push(...r),b.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),b.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),b.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}_e();_n();var qz=[/Failed to fetch/i,/NetworkError/i,/network request failed/i,/load failed/i,/ERR_(NETWORK|INTERNET|CONNECTION|NAME_NOT_RESOLVED)/i,/timed out/i,/aborted/i],Yz=[/credits?/i,/Rate limit/i,/Figma connection expired/i,/Map.*to Figma|Figma mapping required/i,/No project selected/i,/Not authenticated/i,/No story/i,/Monthly review limit/i,/Upgrade your plan/i];function Mv(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return Yz.some(n=>n.test(t))?t:qz.some(n=>n.test(t))?`Can't reach ${Pt.NAME}. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.`:/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?`${Pt.NAME}'s servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.`:/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t}. Try again, or send feedback if this keeps happening.`}He();import{addons as ji}from"storybook/manager-api";var fm="uireview/badge",$i={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function Kz(e){return e.score<70?"status-value:error":e.score<90?"status-value:warning":"status-value:success"}function Xz(e){let t=[`Score: ${e.score}`];return e.criticalCount>0&&t.push(`${e.criticalCount} critical`),e.majorCount>0&&t.push(`${e.majorCount} major`),e.minorCount>0&&t.push(`${e.minorCount} minor`),t.join(" \xB7 ")}function Qz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Ui(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Rv(e){if(Ui())try{ji.getChannel().emit($i.REVIEW_START,{storyId:e})}catch{}}function Ur(e,t){if(Ui())try{ji.getChannel().emit($i.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function zv(e){if(Ui())try{ji.getChannel().emit($i.REVIEW_ERROR,{storyId:e})}catch{}}function Bv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Dv=null;function Nv(e){if(Dv!==null)return;let t=ji.getChannel(),n=o=>i=>{Ui()&&o(i)};t.on($i.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:fm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on($i.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:Kz(i),typeId:fm,storyId:o,title:Qz(i),description:Xz(i)}])})),t.on($i.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:fm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Ui();r||Bv(e),Dv=setInterval(()=>{let o=Ui();o!==r&&(r=o,o||Bv(e))},1500)}var Jz="uireview/mapped",Ov="uireview/mappings-updated";function _v(e){try{ji.getChannel().emit(Ov,{storyIds:e})}catch{}}function $v(e){ji.getChannel().on(Ov,({storyIds:n})=>{n.length&&e.set(n.map(r=>({value:"status-value:success",typeId:Jz,storyId:r,title:"\u2713 Linked to Figma",description:"Story has a Figma mapping"})))})}var mm=q(),hm=180;function Ao(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="object"){let t=e;if("value"in t&&typeof t.value=="string")return t.value;if("top"in t||"left"in t){let n=[t.top,t.right,t.bottom,t.left].filter(Boolean);if(n.length>0)return n.join(" ")}return JSON.stringify(e)}return String(e)}var xm=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:d,setReviewError:g,setReviewResults:p,setShowReviewMenu:m,setSeverityFilter:v,setShowStreamingPanel:I,setStreamingPanelCollapsed:A,addStreamingMessage:C,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:_,setStreamingStatus:P,setFullPrompt:N,setFullResponse:x,setFigmaImageUrl:k,storybookImageUrl:w,setStorybookImageUrl:E,setFigmaDimensions:f,setMultiModelResults:T,updateMultiModelStreamingMessages:S,setModelCompleted:y,setActiveModelId:F,resetReview:L,addReview:M,setReviewDetailTab:z,includeTextComparison:h,usePromptCache:j,setApplyFixesResult:V,featureFlags:B}=ce(),{sessionToken:G,usageData:te,setUsageData:le}=ke(),{selectedProjectId:xe}=Je(),{currentStoryId:ie,currentStoryName:Ke}=nt(),be=Jl(te);be.current=te;let Ie=Jl(null),ve=Jl(null),ue=Jl({}),$e=ea((fe,tt)=>{C({role:fe,content:tt})},[C]),pe=ea((fe,tt)=>{_(fe),P(tt)},[_,P]),yt=ea(async fe=>{let{isIteration:tt=!1,parentReviewId:he=null}=fe||{};if(!G)throw new Error("Not authenticated");if(!xe)throw new Error("No project selected");if(!ie||!Ke)throw new Error("No story is currently selected in Storybook");if(e){b.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let re=Date.now();try{d(!0),g(null),p(null),z("issues"),V(null),ie&&B.enableReviewBadges&&Rv(ie),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{b.debug(`[useAIReview] Auto-stopping review after ${hm}s timeout`),Ie.current&&Ie.current.abort(),C({role:"system",content:`Review auto-stopped after ${hm} seconds timeout.`})},hm*1e3),N(""),x(""),I(!0),A(!1),R(),pe(0,"Starting review..."),pe(5,"Refreshing component preview..."),b.debug("[Review] Forcing iframe reload for fresh styles..."),await Gl(),b.debug("[Review] Iframe reloaded, styles should be fresh"),pe(20,"Capturing screenshot & extracting styles..."),b.debug("[Review] Starting parallel data collection...");let[K,me,oe]=await Promise.all([Wl({sessionToken:G||void 0}),Promise.resolve(Ks()),Promise.resolve(Jf())]);if(K&&K!==w&&(E(K),b.debug("[Review] Storybook screenshot captured and set")),!me)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:H,textElementStyles:Ae,nestedElementStyles:Be}=me;oe?b.debug("[Review] DOM tree extracted:",{selector:oe.selector,childrenCount:oe.children.length}):(b.error("[Review] DOM tree extraction FAILED - domTree is null"),b.error("[Review] This will cause AI to use comparison table instead of tree comparison")),pe(50,"Preparing metadata..."),b.debug("[Review] Current story:",{id:ie,name:Ke});let vt=mt.getState().currentMapping?.figmaNodeId??null,Xn=mt.getState().figmaImageUrl;if(vt&&(b.debug("[Review] Using Figma node ID from store:",vt),Xn&&(pe(65,"Using existing Figma design..."),b.debug("[Review] Reusing already-loaded Figma image"))),!vt)try{let Qe=await fetch(`${mm}/api/mappings?projectId=${xe}&storyId=${ie}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(Qe.ok){let Nt=await Qe.json();Nt.mapping?.figmaNodeId?(vt=Nt.mapping.figmaNodeId,b.debug("[Review] Found Figma node ID from API:",vt)):b.debug("[Review] No mapping found for story:",ie)}else b.debug("[Review] Failed to fetch mapping:",Qe.status)}catch(Qe){b.error("[Review] Error fetching mapping:",Qe)}if(vt&&!Xn){pe(65,"Fetching Figma design...");try{let Qe=await fetch(`${mm}/api/figma/frames?projectId=${xe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(Qe.ok){let jt=(await Qe.json()).thumbnails?.[vt];jt?(k(jt),b.debug("[Review] Figma thumbnail fetched and displayed:",jt)):b.warn("[Review] No thumbnail found for node:",vt)}else b.warn("[Review] Failed to fetch Figma frames:",Qe.status)}catch(Qe){b.error("[Review] Error fetching Figma frames:",Qe)}}if(!vt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');pe(80,"AI is analyzing your component..."),b.debug("[Review] Sending to streaming API...");let sr={projectId:xe,storyId:ie,storyName:Ke,storybookScreenshot:K,computedStyles:O,declaredStyles:U,textElementStyles:Ae,nestedElementStyles:Be,componentMarkup:H,domTree:oe,figmaNodeId:vt,figmaImageUrl:Xn||void 0,aiModels:l,includeTextComparison:h,usePromptCache:j,parentReviewId:tt?he:void 0,isIteration:tt};b.debug("[Review] Request payload:",{...sr,storybookScreenshot:K?`${K.substring(0,50)}...`:null,domTree:oe?{selector:oe.selector,childrenCount:oe.children.length}:null}),Ie.current=new AbortController;let Mn=await fetch(`${mm}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`},body:JSON.stringify(sr),signal:Ie.current.signal});if(b.debug("[Review] Response status:",Mn.status,Mn.statusText),!Mn.ok){let Qe=await Mn.json();if(b.error("[Review] API error response:",Qe),Mn.status===429){let Nt=Qe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Nt} seconds before trying again.`)}if(Mn.status===402){if(Qe.code==="INSUFFICIENT_CREDITS"){let Nt=Qe.details?.required??1,jt=Qe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Nt} credit(s) but you have ${jt}. Visit Settings to add more.`)}throw Qe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Qe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Qe.message||"Payment required")}throw Mn.status===401&&Qe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Qe.error||Qe.message||"Review request failed")}let ho=Mn.body?.getReader(),Tn=new TextDecoder,Rr="",rn="",Ue=null,gu=null,iy=l.length>1,Go={},ps={},WV={};if(!ho)throw new Error("Response body is not readable");let sy=mt.getState().streamingMessages.length;for($e("assistant","");;){let{done:Qe,value:Nt}=await ho.read();if(Qe)break;Rr+=Tn.decode(Nt,{stream:!0});let jt=Rr.split(`
17
17
  `);Rr=jt.pop()||"";for(let Qn of jt)if(Qn.startsWith("data: ")){let gn=Qn.slice(6);if(gn==="[DONE]")continue;try{let ne=JSON.parse(gn);if(ne.type!=="text"&&ne.type!=="content"&&b.debug("[Review] SSE Event received:",ne.type),ne.type==="prompt")ne.prompt&&(N(ne.prompt),b.debug("[Review] Prompt received early"));else if(ne.type==="model_started")b.debug("[Review] Model started:",ne.modelId),Go[ne.modelId]||(Go[ne.modelId]="",ps[ne.modelId]=[{role:"assistant",content:""}]);else if(ne.type==="text"||ne.type==="content")if(iy&&ne.modelId){Go[ne.modelId]||(Go[ne.modelId]="",ps[ne.modelId]=[{role:"assistant",content:""}]),Go[ne.modelId]+=ne.content,ps[ne.modelId][0].content=Go[ne.modelId],S(ne.modelId,ps[ne.modelId]);let Kt=Object.entries(Go).map(([fn,at])=>`[${fn}]
18
18
  ${at}`).join(`
19
19
 
20
20
  ---
21
21
 
22
- `);D(sy,Kt)}else rn+=ne.content,D(sy,rn);else if(ne.type==="model_completed")b.debug("[Review] Model completed:",ne.modelId,ne.complianceScore),y(ne.modelId);else if(ne.type==="figma_image")ne.url&&(v(ne.url),b.debug("[Review] Figma image URL received:",ne.url));else if(ne.type==="figma_dimensions")ne.width&&ne.height&&(f({width:ne.width,height:ne.height}),b.debug("[Review] Figma dimensions received:",ne.width,"x",ne.height));else if(ne.type==="complete"||ne.type==="result")Ue=ne,b.debug("[Review] Final result received! Type:",ne.type),b.debug("[Review] Final result issues count:",ne.issues?.length||0),b.debug("[Review] Final result score:",ne.validation?.complianceScore),ne.remainingCredits!=null&&be.current&&le({...be.current,creditBalance:ne.remainingCredits,reviewCredits:Math.floor(ne.remainingCredits)});else if(ne.type==="all_complete")Ue=ne,b.debug("[Review] Multi-model results received:",Object.keys(ne.byModel)),ne.remainingCredits!=null&&be.current&&le({...be.current,creditBalance:ne.remainingCredits,reviewCredits:Math.floor(ne.remainingCredits)});else if(ne.type==="error"||ne.type==="model_error"){let Kt=new Error(ne.message||ne.error||"Streaming error");throw Kt.isServerError=!0,Kt}}catch(ne){if(ne.isServerError)throw ne;let Kt=ne instanceof Error?{message:ne.message,name:ne.name,stack:ne.stack}:String(ne);b.error("[Review] Error parsing SSE data:",Kt),b.error("[Review] Failed to parse data:",gn.substring(0,200)+(gn.length>200?"...":"")),gu=ne instanceof Error?ne:new Error(String(ne))}}}if(pe(100,"Review complete!"),!Ue&&gu&&(b.error("[Review] No final result received. Last parse error:",gu),b.error("[Review] Streaming text available:",rn.length,"chars")),iy&&Ue?.type==="all_complete"){let Qe=Object.keys(Ue.byModel).reduce((jt,Qn)=>{let gn=Ue.byModel[Qn];return jt[Qn]={...gn,fullResponse:gn.response||gn.fullResponse||"",fullPrompt:gn.prompt||gn.fullPrompt||"",streamingMessages:ps[Qn]||[]},jt},{}),Nt=Object.keys(Ue.byModel)[0];T({byModel:Qe,activeModelId:Nt}),Qe[Nt]?.fullPrompt&&N(Qe[Nt].fullPrompt),b.debug("[Review] Multi-model results stored:",Object.keys(Ue.byModel));try{let jt=Eo(),Qn=Ue.byModel?.[Nt]?.issues,gn=Qn&&Qn.length>0,ne=gn?Qn.map(ge=>({id:Eo(),reviewId:jt,dbId:ge.dbId,type:ge.type,severity:ge.severity,title:ge.description,description:ge.description,property:ge.property,expected:Ao(ge.expected),actual:Ao(ge.actual),currentValue:Ao(ge.actual),suggestedValue:Ao(ge.expected),source:ge.source||"computed-styles",suggestedFix:ge.suggestedFix,file:ge.file,domElement:ge.domElement,figmaElement:ge.figmaElement,fixTarget:ge.fixTarget,fixRequired:ge.fixRequired,detectedBy:ge.detectedBy,dismissed:ge.dismissed??!1,dismissReason:ge.dismissReason,dismissedAt:ge.dismissed?new Date:void 0,_unreliable:ge._unreliable,_validationError:ge._validationError,figmaContext:ge.figmaContext,relatedTo:Array.isArray(ge.relatedTo)?ge.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):um(Qe[Nt]?.fullResponse||"",jt);b.debug("[Review] Multi-model issues source:",gn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Multi-model issues count:",ne.length,"issues");let Kt=ne.filter(ge=>ge.dismissed).length;Kt>0&&(b.debug("[Review] Multi-model auto-dismissed:",Kt,"false positive issues"),$e("system",`
22
+ `);D(sy,Kt)}else rn+=ne.content,D(sy,rn);else if(ne.type==="model_completed")b.debug("[Review] Model completed:",ne.modelId,ne.complianceScore),y(ne.modelId);else if(ne.type==="figma_image")ne.url&&(k(ne.url),b.debug("[Review] Figma image URL received:",ne.url));else if(ne.type==="figma_dimensions")ne.width&&ne.height&&(f({width:ne.width,height:ne.height}),b.debug("[Review] Figma dimensions received:",ne.width,"x",ne.height));else if(ne.type==="complete"||ne.type==="result")Ue=ne,b.debug("[Review] Final result received! Type:",ne.type),b.debug("[Review] Final result issues count:",ne.issues?.length||0),b.debug("[Review] Final result score:",ne.validation?.complianceScore),ne.remainingCredits!=null&&be.current&&le({...be.current,creditBalance:ne.remainingCredits,reviewCredits:Math.floor(ne.remainingCredits)});else if(ne.type==="all_complete")Ue=ne,b.debug("[Review] Multi-model results received:",Object.keys(ne.byModel)),ne.remainingCredits!=null&&be.current&&le({...be.current,creditBalance:ne.remainingCredits,reviewCredits:Math.floor(ne.remainingCredits)});else if(ne.type==="error"||ne.type==="model_error"){let Kt=new Error(ne.message||ne.error||"Streaming error");throw Kt.isServerError=!0,Kt}}catch(ne){if(ne.isServerError)throw ne;let Kt=ne instanceof Error?{message:ne.message,name:ne.name,stack:ne.stack}:String(ne);b.error("[Review] Error parsing SSE data:",Kt),b.error("[Review] Failed to parse data:",gn.substring(0,200)+(gn.length>200?"...":"")),gu=ne instanceof Error?ne:new Error(String(ne))}}}if(pe(100,"Review complete!"),!Ue&&gu&&(b.error("[Review] No final result received. Last parse error:",gu),b.error("[Review] Streaming text available:",rn.length,"chars")),iy&&Ue?.type==="all_complete"){let Qe=Object.keys(Ue.byModel).reduce((jt,Qn)=>{let gn=Ue.byModel[Qn];return jt[Qn]={...gn,fullResponse:gn.response||gn.fullResponse||"",fullPrompt:gn.prompt||gn.fullPrompt||"",streamingMessages:ps[Qn]||[]},jt},{}),Nt=Object.keys(Ue.byModel)[0];T({byModel:Qe,activeModelId:Nt}),Qe[Nt]?.fullPrompt&&N(Qe[Nt].fullPrompt),b.debug("[Review] Multi-model results stored:",Object.keys(Ue.byModel));try{let jt=Eo(),Qn=Ue.byModel?.[Nt]?.issues,gn=Qn&&Qn.length>0,ne=gn?Qn.map(ge=>({id:Eo(),reviewId:jt,dbId:ge.dbId,type:ge.type,severity:ge.severity,title:ge.description,description:ge.description,property:ge.property,expected:Ao(ge.expected),actual:Ao(ge.actual),currentValue:Ao(ge.actual),suggestedValue:Ao(ge.expected),source:ge.source||"computed-styles",suggestedFix:ge.suggestedFix,file:ge.file,domElement:ge.domElement,figmaElement:ge.figmaElement,fixTarget:ge.fixTarget,fixRequired:ge.fixRequired,detectedBy:ge.detectedBy,dismissed:ge.dismissed??!1,dismissReason:ge.dismissReason,dismissedAt:ge.dismissed?new Date:void 0,_unreliable:ge._unreliable,_validationError:ge._validationError,figmaContext:ge.figmaContext,relatedTo:Array.isArray(ge.relatedTo)?ge.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):um(Qe[Nt]?.fullResponse||"",jt);b.debug("[Review] Multi-model issues source:",gn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Multi-model issues count:",ne.length,"issues");let Kt=ne.filter(ge=>ge.dismissed).length;Kt>0&&(b.debug("[Review] Multi-model auto-dismissed:",Kt,"false positive issues"),$e("system",`
23
23
 
24
24
  ---
25
25
 
26
- \u2705 ${Kt} issue${Kt>1?"s were":" was"} auto-dismissed as false positive${Kt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let fn=ue.current[ie];fn||(fn=await Zs(ie)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},fn.storyFile&&(ue.current[ie]=fn)),b.debug("[Review] Story file paths:",fn);let at=ne.map(ge=>({...ge,file:ge.file||pm(ge.fixTarget,fn)||dm(ge,fn)}));if(at=gm(at),b.debug("[Review] After de-duplication:",at.length,"issues"),!h){let ge=at.length;at=at.filter(In=>In.property?.toLowerCase()!=="textcontent"&&!In.description?.toLowerCase().includes("text content")),ge!==at.length&&b.debug("[Review] Filtered out",ge-at.length,"textContent issues (toggle OFF)")}let zr=Ue.validation?.complianceScore??Qe[Nt]?.complianceScore;if(b.debug("[Review] Multi-model score sources:",{firstModelId:Nt,validationScore:Ue.validation?.complianceScore,modelScore:Qe[Nt]?.complianceScore,multiModelScore:zr}),zr==null){let In=(Qe[Nt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);zr=In?parseInt(In[1],10):void 0,b.debug("[Review] Parsed multi-model score from response:",zr)}let Bn;tt&&he&&(Bn=(mt.getState().reviewHistory.find(In=>In.id===he)?.iterationNumber||0)+1);let ds={id:jt,componentId:ie,storyId:ie,modelId:Nt,parentReviewId:tt&&he||void 0,iterationNumber:Bn,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Xn||void 0,complianceScore:zr,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(ge=>!ge.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-re,costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens};if(b.debug("[Review] Multi-model token data:",{costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens,reviewTokens:ds.inputTokens}),M(ds),ie&&B.enableReviewBadges){let ge=at.filter(In=>!In.dismissed);Ur(ie,{score:zr??100,issueCount:ge.length,criticalCount:ge.filter(In=>In.severity==="critical").length,majorCount:ge.filter(In=>In.severity==="major").length,minorCount:ge.filter(In=>In.severity==="minor").length})}z("issues");let Ha=at.filter(ge=>!ge.dismissed).length;b.debug("[Review] Created multi-model review with",Ha,"active issues,",at.length-Ha,"dismissed");let Fe=vt||mt.getState().currentMapping?.figmaNodeId;b.debug("[Review] Issue validation handled server-side. Active:",at.filter(ge=>!ge.dismissed).length,"Dismissed:",at.filter(ge=>ge.dismissed).length)}catch(jt){b.error("[Review] Failed to parse issues from multi-model response:",jt)}}else if(Ue){Ue.prompt&&N(Ue.prompt),(Ue.response||rn)&&x(Ue.response||rn),Ue.figmaImageUrl&&v(Ue.figmaImageUrl),b.debug("[Review] State updated with prompt, response, and screenshots");try{let Qe=Eo(),Nt=Ue.response||rn,jt=Ue.issues,Qn=jt&&jt.length>0,gn=Qn?jt.map(Fe=>({id:Eo(),reviewId:Qe,dbId:Fe.dbId,type:Fe.type,severity:Fe.severity,title:Fe.description,description:Fe.description,property:Fe.property,expected:Ao(Fe.expected),actual:Ao(Fe.actual),currentValue:Ao(Fe.actual),suggestedValue:Ao(Fe.expected),source:Fe.source||"computed-styles",suggestedFix:Fe.suggestedFix,file:Fe.file,domElement:Fe.domElement,figmaElement:Fe.figmaElement,fixTarget:Fe.fixTarget,fixRequired:Fe.fixRequired,detectedBy:Fe.detectedBy,dismissed:Fe.dismissed??!1,dismissReason:Fe.dismissReason,dismissedAt:Fe.dismissed?new Date:void 0,_unreliable:Fe._unreliable,_validationError:Fe._validationError,figmaContext:Fe.figmaContext,relatedTo:Array.isArray(Fe.relatedTo)?Fe.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):um(Nt,Qe);b.debug("[Review] Issues source:",Qn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Issues count:",gn.length,"issues");let ne=gn.filter(Fe=>Fe.dismissed).length;ne>0&&(b.debug("[Review] Auto-dismissed:",ne,"false positive issues"),$e("system",`
26
+ \u2705 ${Kt} issue${Kt>1?"s were":" was"} auto-dismissed as false positive${Kt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let fn=ue.current[ie];fn||(fn=await Zs(ie)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},fn.storyFile&&(ue.current[ie]=fn)),b.debug("[Review] Story file paths:",fn);let at=ne.map(ge=>({...ge,file:ge.file||pm(ge.fixTarget,fn)||dm(ge,fn)}));if(at=gm(at),b.debug("[Review] After de-duplication:",at.length,"issues"),!h){let ge=at.length;at=at.filter(In=>In.property?.toLowerCase()!=="textcontent"&&!In.description?.toLowerCase().includes("text content")),ge!==at.length&&b.debug("[Review] Filtered out",ge-at.length,"textContent issues (toggle OFF)")}let zr=Ue.validation?.complianceScore??Qe[Nt]?.complianceScore;if(b.debug("[Review] Multi-model score sources:",{firstModelId:Nt,validationScore:Ue.validation?.complianceScore,modelScore:Qe[Nt]?.complianceScore,multiModelScore:zr}),zr==null){let In=(Qe[Nt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);zr=In?parseInt(In[1],10):void 0,b.debug("[Review] Parsed multi-model score from response:",zr)}let Bn;tt&&he&&(Bn=(mt.getState().reviewHistory.find(In=>In.id===he)?.iterationNumber||0)+1);let ds={id:jt,componentId:ie,storyId:ie,modelId:Nt,parentReviewId:tt&&he||void 0,iterationNumber:Bn,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Xn||void 0,complianceScore:zr,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(ge=>!ge.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-re,costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens};if(b.debug("[Review] Multi-model token data:",{costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens,reviewTokens:ds.inputTokens}),M(ds),ie&&B.enableReviewBadges){let ge=at.filter(In=>!In.dismissed);Ur(ie,{score:zr??100,issueCount:ge.length,criticalCount:ge.filter(In=>In.severity==="critical").length,majorCount:ge.filter(In=>In.severity==="major").length,minorCount:ge.filter(In=>In.severity==="minor").length})}z("issues");let Ha=at.filter(ge=>!ge.dismissed).length;b.debug("[Review] Created multi-model review with",Ha,"active issues,",at.length-Ha,"dismissed");let Fe=vt||mt.getState().currentMapping?.figmaNodeId;b.debug("[Review] Issue validation handled server-side. Active:",at.filter(ge=>!ge.dismissed).length,"Dismissed:",at.filter(ge=>ge.dismissed).length)}catch(jt){b.error("[Review] Failed to parse issues from multi-model response:",jt)}}else if(Ue){Ue.prompt&&N(Ue.prompt),(Ue.response||rn)&&x(Ue.response||rn),Ue.figmaImageUrl&&k(Ue.figmaImageUrl),b.debug("[Review] State updated with prompt, response, and screenshots");try{let Qe=Eo(),Nt=Ue.response||rn,jt=Ue.issues,Qn=jt&&jt.length>0,gn=Qn?jt.map(Fe=>({id:Eo(),reviewId:Qe,dbId:Fe.dbId,type:Fe.type,severity:Fe.severity,title:Fe.description,description:Fe.description,property:Fe.property,expected:Ao(Fe.expected),actual:Ao(Fe.actual),currentValue:Ao(Fe.actual),suggestedValue:Ao(Fe.expected),source:Fe.source||"computed-styles",suggestedFix:Fe.suggestedFix,file:Fe.file,domElement:Fe.domElement,figmaElement:Fe.figmaElement,fixTarget:Fe.fixTarget,fixRequired:Fe.fixRequired,detectedBy:Fe.detectedBy,dismissed:Fe.dismissed??!1,dismissReason:Fe.dismissReason,dismissedAt:Fe.dismissed?new Date:void 0,_unreliable:Fe._unreliable,_validationError:Fe._validationError,figmaContext:Fe.figmaContext,relatedTo:Array.isArray(Fe.relatedTo)?Fe.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):um(Nt,Qe);b.debug("[Review] Issues source:",Qn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Issues count:",gn.length,"issues");let ne=gn.filter(Fe=>Fe.dismissed).length;ne>0&&(b.debug("[Review] Auto-dismissed:",ne,"false positive issues"),$e("system",`
27
27
 
28
28
  ---
29
29
 
30
- \u2705 ${ne} issue${ne>1?"s were":" was"} auto-dismissed as false positive${ne>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Kt=Ue.complianceScore??Ue.validation?.complianceScore;if(b.debug("[Review] Score sources:",{directScore:Ue.complianceScore,validationScore:Ue.validation?.complianceScore,parsedScore:Kt}),Kt==null){let Fe=Nt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Kt=Fe?parseInt(Fe[1],10):void 0,b.debug("[Review] Parsed score from response:",Kt)}let fn=ue.current[ie];fn||(fn=await Zs(ie)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},fn.storyFile&&(ue.current[ie]=fn)),b.debug("[Review] Story file paths:",fn);let at=gn.map(Fe=>({...Fe,file:Fe.file||pm(Fe.fixTarget,fn)||dm(Fe,fn)}));if(at=gm(at),b.debug("[Review] After de-duplication:",at.length,"issues"),!h){let Fe=at.length;at=at.filter(ge=>ge.property?.toLowerCase()!=="textcontent"&&!ge.description?.toLowerCase().includes("text content")),Fe!==at.length&&b.debug("[Review] Filtered out",Fe-at.length,"textContent issues (toggle OFF)")}let zr;tt&&he&&(zr=(mt.getState().reviewHistory.find(ge=>ge.id===he)?.iterationNumber||0)+1);let Bn={id:Qe,componentId:ie,storyId:ie,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:zr,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Xn||void 0,complianceScore:Kt,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(Fe=>!Fe.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-re,costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens,variantMismatch:Ue.variantMismatch,storybookVariant:Ue.storybookVariant,figmaVariant:Ue.figmaVariant};if(b.debug("[useAIReview] About to call addReview with review:",{id:Bn.id,storyId:Bn.storyId,issueCount:Bn.issues?.length,complianceScore:Bn.complianceScore,createdAt:Bn.createdAt?.toISOString(),inputTokens:Bn.inputTokens,outputTokens:Bn.outputTokens,costUsd:Bn.costUsd,cacheCreationTokens:Bn.cacheCreationTokens,cacheReadTokens:Bn.cacheReadTokens}),M(Bn),b.debug("[useAIReview] addReview called successfully"),ie&&B.enableReviewBadges){let Fe=at.filter(ge=>!ge.dismissed);Ur(ie,{score:Kt??100,issueCount:Fe.length,criticalCount:Fe.filter(ge=>ge.severity==="critical").length,majorCount:Fe.filter(ge=>ge.severity==="major").length,minorCount:Fe.filter(ge=>ge.severity==="minor").length})}z("issues");let ds=at.filter(Fe=>!Fe.dismissed).length;b.debug("[Review] Created review with",ds,"active issues,",at.length-ds,"dismissed");let Ha=vt||mt.getState().currentMapping?.figmaNodeId;b.debug("[Review] Validation check:",{figmaNodeId:vt,effectiveFigmaNodeIdSingle:Ha,hasSessionToken:!!G,selectedProjectId:xe,issueCount:at.length}),b.debug("[Review] Issue validation handled server-side. Active:",at.filter(Fe=>!Fe.dismissed).length,"Dismissed:",at.filter(Fe=>Fe.dismissed).length)}catch(Qe){b.error("[Review] Failed to parse issues:",Qe)}}else throw rn?(b.error("[Review] ERROR: No structured result received from backend!"),b.error("[Review] Streaming text length:",rn.length),b.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(K){if(K instanceof Error&&K.name==="AbortError"){b.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}b.error("[useAIReview] Review error:",K);let me=Mv(K);throw g(me),ie&&B.enableReviewBadges&&zv(ie),pe(0,`Error: ${me}`),K}finally{d(!1),Ie.current=null,ve.current&&(clearTimeout(ve.current),ve.current=null),le(null)}},[e,G,xe,ie,Ke,l,d,g,p,T,S,y,F,I,A,R,$e,pe,D,E,v,N,x,le]),$t=ea(()=>n?.issues?o==="all"?n.issues:n.issues.filter(fe=>fe.severity===o):[],[n,o]),yn=ea(()=>{Ie.current&&(b.debug("[useAIReview] Cancelling review..."),Ie.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:yt,cancelReview:yn,setShowReviewMenu:m,setSeverityFilter:k,setShowStreamingPanel:I,setStreamingPanelCollapsed:A,addStreamingMessage:C,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:_,setStreamingStatus:P,resetReview:L,getFilteredIssues:$t}};Te();_e();He();import{useCallback as lJ}from"react";var dJ=q();Te();_e();import{useEffect as Uv,useRef as jv}from"react";import{useStorybookApi as Jz,useStorybookState as Zz,addons as eN}from"storybook/manager-api";var Hv="storyArgsUpdated",ym=()=>{let e=Jz(),t=Zz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=jv(null),d=jv(0);return Uv(()=>{let g=t.storyId;if(g){l.current!==g&&(b.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,d.current=Date.now()),o(g);let p=e.getData(g),m=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(m),b.debug("[useCurrentStory] Current story:",{storyId:g,fullName:m})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),Uv(()=>{let g=eN.getChannel(),p=null,m=k=>{if(k.storyId===n){if(u||c){b.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:I,isValidating:A}=mt.getState();if(I||A){b.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){b.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}b.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(Hv,m),()=>{g.off(Hv,m),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Te();He();ct();import{useCallback as Wv}from"react";import{addons as Vv}from"storybook/manager-api";var Gv=q(),ri=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=ke(),{selectedProjectId:i}=Je(),s=Wv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ee(`${Gv}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({projectId:i,...c})});if(!l.ok)throw new Error("Failed to create mapping");let d=await l.json();r();try{Vv.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=Wv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ee(`${Gv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{Vv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Oi();Te();import{useCallback as bm,useEffect as qv,useRef as tN}from"react";import{useChannel as nN,addons as Yv}from"storybook/manager-api";_e();var rN=3e4,oN="forceRemount";function iN(e,t){let n=parseFloat(e.replace(/[^0-9.-]/g,"")),r=parseFloat(t.replace(/[^0-9.-]/g,""));if(isNaN(n)||isNaN(r))return!1;let o=Math.abs(n-r);return e.includes("px")||t.includes("px")?o<.5:e.includes("%")||t.includes("%")?o<1:o<.5}function sN(e){let t=["design system","design token","css variable","var(--","hard-coded"],n=`${e.description} ${e.suggestedFix||""} ${e.suggestedValue||""}`.toLowerCase();return t.some(r=>n.includes(r))}var aN="UICOPILOT/APPLY_FIXES",lN="UICOPILOT/FIX_STARTED",cN="UICOPILOT/FIX_COMPLETED",uN="UICOPILOT/FIX_FAILED",pN="UICOPILOT/ALL_FIXES_APPLIED",Sm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=tN(null),l=bm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);qv(()=>()=>l(),[l]),qv(()=>{let m=Yv.getChannel(),k=()=>{mt.getState().isApplying&&(b.error("[useApplyFixes] WebSocket disconnected while applying fixes"),l(),o(!1),i({succeeded:0,failed:0,total:0,error:"Connection lost. Please restart Storybook and try again."}))};return m.on("channelWSDisconnect",k),()=>m.off("channelWSDisconnect",k)},[l,o,i]);let d=nN({[lN]:({issueId:m})=>{b.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[cN]:({issueId:m,result:k})=>{b.debug(`[useApplyFixes] Fix completed for issue: ${m}`,k),s(m,"applied"),a(m,{status:"applied"})},[uN]:({issueId:m,error:k})=>{b.error(`[useApplyFixes] Fix failed for issue: ${m}`,k),s(m,"failed",k),a(m,{status:"failed",error:k})},[pN]:async({summary:m})=>{if(b.debug("[useApplyFixes] All fixes applied:",m),l(),o(!1),i({succeeded:m.succeeded,failed:m.failed,total:m.total}),m.failed>0?b.warn(`Applied ${m.succeeded}/${m.total} fixes. ${m.failed} failed.`):b.debug(`Successfully applied all ${m.total} fixes!`),m.succeeded>0){b.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{Yv.getChannel().emit(oN,{storyId:mt.getState().currentStoryId}),b.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(k){b.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",k)}b.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Gl(),b.debug("[useApplyFixes] Storybook preview reloaded")}t&&(b.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),b.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=bm(m=>{let k=[],I=[],A=[];for(let C of m){let D=C.currentValue||C.actual||"",R=C.suggestedValue||C.expected||"";if(D&&R&&iN(D,R)){k.push(C);continue}if(sN(C)){I.push(C);continue}let _=C.generatedFix?.filePath||C.file||"";if(!_){b.warn(`[useApplyFixes] Skipping issue ${C.id} - no target file path`);continue}let P=_.toLowerCase().split(".").pop()||"",N=["tsx","jsx","ts","js"].includes(P)?"component":"css";A.push({...C,targetFilePath:_,targetFileType:N})}return{actionable:A,negligible:k,designTokens:I}},[]);return{applyFixes:bm(m=>{if(r){b.warn("[useApplyFixes] Already applying fixes");return}if(m.length===0){b.warn("[useApplyFixes] No issues to fix");return}let k=g(m);if(k.negligible.length>0&&b.debug(`[useApplyFixes] Filtered ${k.negligible.length} negligible issue(s)`),k.designTokens.length>0&&b.debug(`[useApplyFixes] Skipped ${k.designTokens.length} design token suggestion(s)`),k.actionable.length===0){b.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let I=k.actionable.filter(D=>D.targetFileType==="css"),A=k.actionable.filter(D=>D.targetFileType==="component");if(b.debug("[useApplyFixes] Applying fixes:"),I.length>0){let D=[...new Set(I.map(R=>R.targetFilePath))];b.debug(` - ${I.length} CSS issue(s) in: ${D.join(", ")}`)}if(A.length>0){let D=[...new Set(A.map(R=>R.targetFilePath))];b.debug(` - ${A.length} component issue(s) in: ${D.join(", ")}`),b.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){b.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:k.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{mt.getState().isApplying&&(b.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:k.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},rN),d(aN,{issues:k.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};Te();He();import{useState as BJ}from"react";var zJ=q();Te();import{useState as oi}from"react";He();_e();ct();var dN=q();async function Zl(e,t,n,r,o){if(!e)return b.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ee(`${dN}/api/issues/dismiss`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify({issueId:e,dismissed:t,dismissReason:n,dismissedBy:r})});if(!i.ok){let a=await i.text();return b.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return b.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return b.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Kv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return b.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Zl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return b.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}_n();Zf();Oi();_e();He();var gN=["no-fix-needed","no-fix-required","no-change-needed","no-changes-needed","no-change-required","no-changes-required","no-action-needed","no-action-required","no_fix_needed","no_change_needed","no_changes_needed","already-correct","values-match","values-already-match","already-matches","css-matches","matches-figma","correctly-implemented","implementation-correct","none-needed","none-required","skipped","skip"],fN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],mN=q();function wm(){let[e,t]=oi(!1),[n,r]=oi(null),[o,i]=oi(null),[s,a]=oi(null),[u,c]=oi(null),[l,d]=oi(null),[g,p]=oi(null),{sessionToken:m}=ke(),{selectedProjectId:k}=Je(),{currentStoryId:I,currentStoryName:A}=nt(),{workspacePath:C,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:_,dismissIssue:P,recalculateScore:N,addStreamingMessage:x}=ce();return{generateBatchFixes:async w=>{if(!m){r("Not authenticated");return}if(!k){r("No project selected");return}if(!I){r("No story selected");return}if(w.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:w.length,completed:0});let E=w.map(f=>({issueId:f.id,generatedFix:{code:"",diffPreview:"",filePath:f.file||"",confidence:0,strategy:"",status:"generating"}}));R(E);try{b.debug("[useBatchGenerateFixes] Generating fixes for",w.length,"issues");let f=null;try{let h=Ks();h?.computed&&(f=h.computed,b.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){b.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let T=null;try{T=await Zs(I),T&&b.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",T)}catch(h){b.warn("[useBatchGenerateFixes] Could not resolve story file paths:",h)}let S=await fetch(`${mN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:k,storyId:I,workspacePath:C,includeComponentIssues:_,computedStyles:f,storyFilePaths:T,reviewContext:{storyName:A||void 0,variantArgs:Ni()||void 0},issues:w.map(h=>({id:h.id,dbId:h.dbId,title:h.title,description:h.description,property:h.property,currentValue:h.currentValue,suggestedValue:h.suggestedValue,file:h.file,lineNumber:h.lineNumber,severity:h.severity,type:h.type,fixTarget:h.fixTarget,domElement:h.domElement,figmaContext:h.figmaContext,suggestedFix:h.suggestedFix}))})});if(!S.ok){let h=await S.json().catch(()=>({}));throw new Error(h.error||"Batch fix generation failed")}let y=await S.json();if(!y.success)throw new Error(y.error||"Batch fix generation failed");if(b.debug("[useBatchGenerateFixes] Generated",y.result.fixes.length,"fixes"),y.result.storybookRoot&&(p(y.result.storybookRoot),b.debug("[useBatchGenerateFixes] Stored storybookRoot:",y.result.storybookRoot)),y.result.selfReview&&(d(y.result.selfReview),b.debug("[useBatchGenerateFixes] Self-review:",y.result.selfReview)),y.result.partialFailure){let{failedBatches:h,errors:j}=y.result.partialFailure;b.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),b.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${h.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:w.length,completed:y.result.fixes.length});let F=new Set(y.result.fixes.map(h=>h.issueId)),L=w.filter(h=>!F.has(h.id));L.length>0&&(b.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(h=>{D(h.id,{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),y.timing&&(i({durationSec:y.timing.durationSec,issueCount:y.timing.issueCount,avgPerIssueSec:y.timing.avgPerIssueSec}),b.debug(`[useBatchGenerateFixes] Generation took ${y.timing.durationSec}s for ${y.timing.issueCount} issues`)),y.result?.usage&&(c({inputTokens:y.result.usage.inputTokens||0,outputTokens:y.result.usage.outputTokens||0,costUsd:y.result.usage.costUsd||0,modelId:y.result.usage.modelId||"unknown",provider:y.result.usage.provider||"unknown"}),b.debug(`[useBatchGenerateFixes] Token usage: ${y.result.usage.inputTokens} in, ${y.result.usage.outputTokens} out, $${y.result.usage.costUsd?.toFixed(4)}`));let M=[],z=[];if(y.result.fixes.forEach(h=>{let j=h.noChangesNeeded===!0;if(!j){let G=(h.fixStrategy||"").toLowerCase(),te=(h.generatedCode||"").toLowerCase(),le=(h.diffPreview||"").toLowerCase(),xe=gN.some(Ke=>G.includes(Ke.toLowerCase())||G.replace(/[-_]/g,"").includes(Ke.replace(/[-_]/g,""))),ie=fN.some(Ke=>te.includes(Ke)||le.includes(Ke));j=xe||ie}let V=w.find(G=>G.id===h.issueId);if(j&&V){let G=V.suggestedValue,te=V.currentValue;G&&te&&!Zo(G,te)&&(b.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${G}", actual="${te}"), NOT auto-dismissing issue ${h.issueId}`),j=!1)}let B=V?.programmaticallyVerified===!0;if(b.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:B,detectedBy:V?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:V?.title?.substring(0,50)}),B&&j&&(b.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${V?.detectedBy})`),j=!1),j){let G=`Auto-dismissed: ${h.fixStrategy} - values already match`;b.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,G),M.push({localId:h.issueId,dbId:V?.dbId,dismissReason:G}),z.push({issueId:h.issueId,generatedFix:{code:h.generatedCode||"",diffPreview:h.diffPreview||"",filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:"ready",error:void 0,noChangesExplanation:h.noChangesExplanation}})}else{let G=h.error||h.fixStrategy==="skipped"?"failed":"ready";z.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:G,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),z.length>0&&(b.debug(`[useBatchGenerateFixes] Applying ${z.length} fix updates in batch`),R(z)),M.length>0){if(b.debug(`[useBatchGenerateFixes] Auto-dismissed ${M.length} false positive(s), recalculating score`),N(),m){let j=M.filter(V=>V.dbId).map(V=>({dbId:V.dbId,dismissed:!0,dismissReason:V.dismissReason,dismissedBy:"system"}));j.length>0&&(b.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Kv(j,m).then(V=>{V.success?b.debug(`[useBatchGenerateFixes] Server score updated to: ${V.newScore}`):b.warn("[useBatchGenerateFixes] Failed to sync dismissals:",V.error)}).catch(V=>{b.error("[useBatchGenerateFixes] Error syncing dismissals:",V)}))}let h=M.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${M.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;x({role:"system",content:h})}b.debug("[useBatchGenerateFixes] Updated",y.result.fixes.length,"issues with fixes")}catch(f){b.error("[useBatchGenerateFixes] Failed to generate batch fixes:",f),r(f?.message||"Failed to generate batch fixes");let T=w.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:f?.message||"Failed to generate fix"}}));R(T)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}Te();_e();He();ct();import{useState as vm,useCallback as km}from"react";var hN=q();function Cm(){let[e,t]=vm([]),[n,r]=vm(!1),[o,i]=vm(null),{sessionToken:s}=ke(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=km(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let m=await ee(`${hN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!m.ok){let I=await m.json().catch(()=>({}));throw new Error(I.error||"Failed to fetch reviews")}let k=await m.json();if(!k.success)throw new Error("Failed to fetch reviews");b.debug("[useReviewHistory] Fetched",k.reviews.length,"reviews for:",u),t(k.reviews)}catch(p){b.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=km(p=>{b.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let m=[];if(typeof p.models=="string")try{m=JSON.parse(p.models)}catch(C){b.error("[useReviewHistory] Failed to parse models:",C),m=["claude-sonnet-4-20250514"]}else m=p.models;let k=p.issues.map(C=>({id:C.id,reviewId:p.id,type:C.type,severity:C.severity,title:C.description,description:C.description,file:void 0,lineNumber:void 0,property:C.property,currentValue:C.actual,suggestedValue:C.expected,suggestedCode:C.suggestedFix||void 0,status:C.status,dismissed:C.dismissed||!1,dismissReason:C.dismissReason,dismissedBy:C.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(C.createdAt)})),I=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,A=p.storyId||"";if(c({id:p.id,componentId:"",storyId:A,modelId:m[0]||"claude-sonnet-4-6",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:k,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:I}),A){let C=p.issues.filter(P=>!P.dismissed),D=C.filter(P=>P.severity==="critical").length,R=C.filter(P=>P.severity==="major").length,_=C.filter(P=>P.severity==="minor").length;Ur(A,{score:p.complianceScore,issueCount:C.length,criticalCount:D,majorCount:R,minorCount:_})}},[c]),g=km(p=>{let m=e.find(k=>k.id===p);if(!m){b.error("[useReviewHistory] Review not found:",p);return}d(m)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}Te();_e();import{useEffect as xN,useState as yN,useRef as ec}from"react";import{useChannel as bN}from"storybook/manager-api";var SN="UICOPILOT/WORKSPACE_PATH",Xv="UICOPILOT/REQUEST_WORKSPACE_PATH",wN=3e3,vN=500,kN=5,Tm=()=>{let[e,t]=yN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=ec(!1),o=ec(null),i=ec(0),s=ec(null),a=bN({[SN]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),b.debug("[useAutoApplySupport] Server responded - auto-apply supported"),b.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return xN(()=>(b.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Xv,{}),s.current=setInterval(()=>{!r.current&&i.current<kN&&(i.current++,b.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Xv,{}))},vN),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){b.debug("[useAutoApplySupport] Channel detection timed out, trying HTTP fallback...");try{let u=await fetch("/__uicopilot/health");if(u.ok){let c=await u.json();if(c.ok&&c.workspacePath&&!r.current){r.current=!0,b.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),b.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,b.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},wN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},Im=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}}catch(t){return b.error("[copyToClipboard] Failed to copy:",t),!1}};Te();He();import{useEffect as CN,useRef as TN}from"react";var gZ=q(),IN=new Set;function Fm(){let{sessionToken:e}=ke(),{selectedProjectId:t}=Je(),n=TN(!1);CN(()=>{t&&IN.add(t)},[e,t])}Te();_n();import{useCallback as hZ,useState as xZ}from"react";import{useState as ii,useMemo as ak,useCallback as Vi}from"react";He();_e();ct();_n();import{useState as ao,useEffect as tc,useRef as Hi,useCallback as Em}from"react";var FN=300;function Qv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=ao([]),[u,c]=ao({}),[l,d]=ao(0),[g,p]=ao([]),[m,k]=ao(new Set),[I,A]=ao(!1),[C,D]=ao(!1),[R,_]=ao(null),P=Hi(1),N=Hi(null),x=Hi(null),[v,w]=ao(0),E=Hi(!1),f=Hi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});f.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let T=Em(async(M,z,h=!1)=>{let{projectId:j,typeFilter:V,search:B,figmaPage:G,limit:te}=f.current;if(!j||!V)return;N.current&&N.current.abort();let le=new AbortController;N.current=le,z?D(!0):A(!0),_(null);try{let xe=q(),ie=localStorage.getItem("uicopilot_session_token");if(!ie)throw new Error(`Not authenticated. Please connect to ${Pt.NAME} first.`);let Ke=new URLSearchParams({projectId:j,page:String(M),limit:String(te)});V&&Ke.append("type",V),G&&Ke.append("figmaPage",G),B.trim()&&Ke.append("search",B.trim()),h&&Ke.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ke.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ie}`},signal:le.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Ie=await be.json(),ve=Ie.frames||[],ue=Ie.thumbnails||{},$e=be.headers.get("X-Cache-Status");if(ve.length===0&&M===1&&!z&&!h&&!E.current&&$e!=="HIT"){b.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),E.current=!0,await T(1,!1,!0);return}z?(a(pe=>[...pe,...ve]),c(pe=>({...pe,...ue}))):(a(ve),c(ue)),d(Ie.total||ve.length),Ie.pages&&p(Ie.pages),Ie.cacheDiff?.added&&k(new Set(Ie.cacheDiff.added)),P.current=M}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let ie=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";_(ie),b.error("Error fetching frames:",xe)}finally{le.signal.aborted||(A(!1),D(!1))}},[]);tc(()=>{if(!i||!e||!t)return;E.current=!1,x.current&&clearTimeout(x.current);let M=n.trim()?FN:0;return x.current=setTimeout(()=>{P.current=1,T(1,!1)},M),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,v,T]);let S=Hi(new Set);tc(()=>{if(s.length===0)return;let M={};for(let z of s)z.thumbnailCdnUrl&&!u[z.id]&&(M[z.id]=z.thumbnailCdnUrl);Object.keys(M).length>0&&c(z=>({...z,...M}))},[s]),tc(()=>{if(s.length===0)return;let M=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(M.length===0)return;M.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=f.current,j=q(),V=localStorage.getItem("uicopilot_session_token");if(!V||!h)return;let B=await ee(`${j}/api/figma/frames?projectId=${h}&thumbnailIds=${M.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${V}`}});if(B.ok){let G=await B.json();G.thumbnails&&Object.keys(G.thumbnails).length>0&&c(te=>({...te,...G.thumbnails}))}}catch(h){M.forEach(j=>S.current.delete(j)),b.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),tc(()=>()=>{N.current&&N.current.abort(),x.current&&clearTimeout(x.current)},[]);let y=Em(async()=>{let M=P.current+1;await T(M,!0)},[T]),F=Em(()=>{E.current=!1,P.current=1,a([]),c({}),w(M=>M+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:m,isLoading:I,loadingMore:C,hasMore:L,loadMore:y,refresh:F,error:R}}He();_e();ct();import{useState as Wi,useCallback as nc,useRef as EN}from"react";function Jv({projectId:e}){let[t,n]=Wi({}),[r,o]=Wi({}),[i,s]=Wi(new Set),[a,u]=Wi(new Set),[c,l]=Wi({}),[d,g]=Wi(null),p=EN({}),m=nc(async C=>{if(!(!e||i.has(C))){s(D=>new Set(D).add(C));try{let D=q(),R=localStorage.getItem("uicopilot_session_token"),_=await ee(`${D}/api/figma/variants?projectId=${e}&componentSetId=${C}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(_.ok){let P=await _.json();if(P.variants){n(x=>({...x,[C]:P.variants}));let N={};for(let x of P.variants)x.thumbnailCdnUrl&&(N[x.id]=x.thumbnailCdnUrl);o(x=>({...x,[C]:{...x[C]||{},...N}})),p.current[C]||(p.current[C]=new Set),Object.keys(N).forEach(x=>p.current[C].add(x))}else o(N=>({...N,[C]:N[C]||{}}))}else o(P=>({...P,[C]:{}}))}catch(D){b.error("Failed to fetch variant metadata:",D),o(R=>({...R,[C]:{}}))}finally{s(D=>{let R=new Set(D);return R.delete(C),R})}}},[e,i]),k=nc(async(C,D)=>{if(!e||D.length===0)return;p.current[C]||(p.current[C]=new Set);let R=r[C]||{},_=D.filter(P=>!p.current[C].has(P)&&!R[P]);if(_.length!==0){_.forEach(P=>p.current[C].add(P)),u(P=>new Set(P).add(C));try{let P=q(),N=localStorage.getItem("uicopilot_session_token"),x=await ee(`${P}/api/figma/variants?projectId=${e}&componentSetId=${C}&thumbnailIds=${_.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`}});if(x.ok){let v=await x.json();v.rateLimitError?(g(v.rateLimitError),_.forEach(w=>p.current[C]?.delete(w))):(v.thumbnails&&Object.keys(v.thumbnails).length>0&&o(w=>({...w,[C]:{...w[C]||{},...v.thumbnails}})),Array.isArray(v.failed)&&v.failed.length>0&&l(w=>{let E=new Set(w[C]||[]);for(let f of v.failed)E.add(f);return{...w,[C]:E}}))}}catch(P){b.error("Failed to fetch variant thumbnails:",P),_.forEach(N=>p.current[C]?.delete(N))}finally{u(P=>{let N=new Set(P);return N.delete(C),N})}}},[e]),I=nc(C=>{o(D=>{let R={...D};return delete R[C],R}),n(D=>{let R={...D};return delete R[C],R}),l(D=>{let R={...D};return delete R[C],R}),delete p.current[C]},[]),A=nc(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,rateLimitError:d,fetchVariants:m,fetchVariantThumbnails:k,clearVariantsForSet:I,clearAllVariants:A}}He();Oi();Te();_e();ct();import{useState as Zv,useEffect as ek,useRef as tk,useCallback as Am}from"react";function nk({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Zv(null),[i,s]=Zv(!1),a=tk(null),u=tk(new Set),c=Am(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Ni();if(!g||Object.keys(g).length===0)return;let p=mt.getState().currentStoryId||"",m=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,k=>k.toUpperCase());a.current=e,s(!0),o(null);try{let k=q(),I=localStorage.getItem("uicopilot_session_token"),A=await ee(`${k}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({storyName:m,storyId:p,storyArgs:g,availableFilters:t.map(C=>({property:C.property,values:C.values}))})});if(A.ok){let C=await A.json();C.confidence>0&&Object.keys(C.suggestedFilters).length>0&&(b.debug("[useFilterSuggestion] Suggestion:",C),o(C))}}catch(k){b.error("[useFilterSuggestion] Error:",k)}finally{s(!1)}},[e,t,n]);ek(()=>{c()},[c]),ek(()=>{e||(o(null),a.current=null)},[e]);let l=Am(()=>{},[]),d=Am(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function rk(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function ok(e){let t={};for(let n of Object.values(e))for(let r of n)if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);return Object.entries(t).map(([n,r])=>({property:n,values:Array.from(r).sort()}))}function ik(e){let t={},n=r=>{if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);r.children?.forEach(n)};return e.forEach(n),Object.entries(t).map(([r,o])=>({property:r,values:Array.from(o).sort()}))}function sk(e,t,n){if(t.length===0||!t.some(o=>o.value))return!0;let r=o=>o.variantProperties?t.every(i=>i.value?o.variantProperties?.[i.property]===i.value:!0):!1;return!!(r(e)||e.children?.some(r)||n?.some(r))}function ta({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=ii(!0),[i,s]=ii(!1),[a,u]=ii(!1),[c,l]=ii(""),[d,g]=ii(""),[p,m]=ii([]),[k,I]=ii(new Set),A=Vi(ue=>{l(ue),p.length>0&&m([]),k.size>0&&I(new Set)},[p.length,k.size]),C=rk(r,i,a),{frames:D,thumbnails:R,totalFrames:_,availablePages:P,recentlyAdded:N,isLoading:x,loadingMore:v,hasMore:w,loadMore:E,refresh:f,error:T}=Qv({projectId:e,typeFilter:C,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!C}),{variantChildren:S,variantThumbnails:y,variantFailed:F,loadingVariants:L,loadingThumbnails:M,rateLimitError:z,fetchVariants:h,fetchVariantThumbnails:j,clearVariantsForSet:V,clearAllVariants:B}=Jv({projectId:e}),G=ak(()=>{let ue=ok(S),$e=ik(D),pe={};for(let yt of[...ue,...$e])pe[yt.property]||(pe[yt.property]=new Set),yt.values.forEach($t=>pe[yt.property].add($t));return Object.entries(pe).map(([yt,$t])=>({property:yt,values:Array.from($t).sort()}))},[S,D]),te=k.size===1?Array.from(k)[0]:null,le=nk({expandedSetId:te,availableFilters:G,filtersReady:G.length>0}),xe=Vi(()=>{if(!le.suggestion)return;let{suggestedFilters:ue}=le.suggestion,$e=Object.entries(ue).map(([pe,yt])=>({property:pe,value:yt}));m($e),le.dismissSuggestion()},[le.suggestion]),ie=ak(()=>p.some(ue=>ue.value)?D.filter(ue=>sk(ue,p,S[ue.id])):D,[D,p,S]),Ke=Vi((ue,$e)=>{$e.stopPropagation();let pe=!k.has(ue);I(yt=>{let $t=new Set(yt);return $t.has(ue)?$t.delete(ue):$t.add(ue),$t}),pe&&!S[ue]&&!L.has(ue)?h(ue):pe||V(ue)},[k,S,L,h,V]),be=Vi((ue,$e)=>{let pe=$e===""?null:$e;m(yt=>yt.find(yn=>yn.property===ue)?yt.map(yn=>yn.property===ue?{...yn,value:pe}:yn):[...yt,{property:ue,value:pe}])},[]),Ie=Vi(()=>{m([])},[]),ve=Vi(ue=>{let $e=D.find(pe=>pe.id===ue);if($e?.thumbnailCdnUrl)return $e.thumbnailCdnUrl;if(R[ue])return R[ue];for(let pe of Object.values(y))if(pe[ue])return pe[ue]},[R,y]);return{frames:D,filteredFrames:ie,thumbnails:R,totalFrames:_,isLoading:x,loadingMore:v,hasMore:w,error:T,loadMore:E,refresh:f,search:c,setSearch:A,figmaPage:d,setFigmaPage:g,availablePages:P,recentlyAdded:N,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:G,handleFilterChange:be,clearFilters:Ie,expandedSets:k,toggleExpanded:Ke,variantChildren:S,variantThumbnails:y,variantFailed:F,loadingVariants:L,loadingThumbnails:M,rateLimitError:z,fetchVariantThumbnails:j,resolveThumbnail:ve,filterSuggestion:le.suggestion,filterSuggestionLoading:le.isLoading,applySuggestedFilters:xe,dismissFilterSuggestion:le.dismissSuggestion}}Te();import{useEffect as Ar,useCallback as BN,useState as DN,useRef as RN}from"react";import{useChannel as zN}from"storybook/manager-api";function Po(e){return e.status===401||e.status===403}var Pn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};_n();function lk(e){try{let t=new URL(e),n=t.pathname.match(/\/(file|design)\/([a-zA-Z0-9]+)/),r=n?n[2]:null,o=t.searchParams.get("node-id"),i=t.hash.match(/node-id=([0-9-:]+)/),s=o||(i?i[1]:null);if(!r||!s)return null;let a=s.replace(/-/g,":");return{fileKey:r,nodeId:a}}catch(t){return Tu.error("Error parsing Figma URL:",t),null}}_e();He();He();ct();var AN=q();async function Pm(e){let t=await ee(`${AN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Po(t))throw new Pn(t.status);return t.ok?(await t.json()).projects||[]:[]}He();ct();var PN=q();async function Lm(e,t){let n=await ee(`${PN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new Pn(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}He();ct();var LN=q();async function Mm(e,t,n,r=10,o=!1){let i=new URLSearchParams({projectId:t,limit:String(r),storyId:n});o&&i.set("includeAI","true");let s=await ee(`${LN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(s))throw new Pn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}He();ct();var MN=q();async function Bm(e,t){let n=await ee(`${MN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new Pn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Oi();function NN(e){return e.storyId?{id:e.id,componentId:"",storyId:e.storyId,modelId:e.models?.[0]||"unknown",complianceScore:e.complianceScore,issuesCount:e.issuesCount,costUsd:e.costUsd,inputTokens:e.inputTokens,outputTokens:e.outputTokens,parentReviewId:e.parentReviewId||void 0,iterationNumber:e.iterationNumber,storybookImageData:e.storybookScreenshot||void 0,figmaImageData:e.figmaScreenshot||void 0,aiPrompt:e.aiPrompt||void 0,aiResponse:e.aiResponse||void 0,issues:e.issues.map(t=>({id:t.id,reviewId:e.id,type:t.type,severity:t.severity,title:t.description,description:t.description,property:t.property,currentValue:t.actual,suggestedValue:t.expected,suggestedCode:t.suggestedFix||void 0,status:t.status||"pending",dismissed:t.dismissed||!1,dismissReason:t.dismissReason,dismissedBy:t.dismissedBy,figmaContext:t.figmaContext,selectedForFix:!1,createdAt:new Date(t.createdAt)})),createdAt:new Date(e.createdAt)}:null}var ON=q(),_N="UICOPILOT/WORKSPACE_PATH",$N="UICOPILOT/REQUEST_WORKSPACE_PATH",Dm=!1;function Rm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=ke(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:m,setMappingsByStoryId:k,setMappingSource:I,setLoadingMapping:A}=nt(),{setReviewResults:C,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:_,setFullPrompt:P,setFullResponse:N,bulkAddReviews:x}=ce(),[v,w]=DN([]),E=RN(null);Ar(()=>{let S=y=>{y.origin.startsWith(ON)&&y.data?.type==="UICOPILOT_AUTH_SUCCESS"&&y.data.token&&(b.debug("[useDataInit] OAuth success, setting token"),t(y.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let f=zN({[_N]:S=>{b.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Ar(()=>{f($N)},[f]),Ar(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let F=await Pm(e);S||(s(F),n(null))}catch(F){F instanceof Pn&&(t(null),n(F.message)),b.error("[useDataInit] Failed to fetch projects:",F)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Ar(()=>{if(!i||r.length===0)return;let S=r.find(y=>y.storybookRoot===i);S?o!==S.id&&(b.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id)):o&&(b.debug("[useDataInit] No project matches this Storybook \u2014 clearing selection"),a(null))},[i,r,o,a]),Ar(()=>{if(!o||r.length===0)return;let S=r.find(F=>F.id===o),y=S?.figmaFileId;if(S&&typeof y=="string"&&y){let F=y,L=F.includes("figma.com")&&lk(F)?.fileKey||F;p(`https://www.figma.com/file/${L}`)}},[o,r,p]),Ar(()=>!e||!o||Dm?void 0:(Dm=!0,(async()=>{try{let y=await Bm(e,o);for(let[F,L]of Object.entries(y))Ur(F,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});b.debug("[useDataInit] Populated sidebar badges for",Object.keys(y).length,"stories")}catch(y){y instanceof Pn&&(t(null),n(y.message)),b.error("[useDataInit] Failed to fetch review statuses:",y)}})(),()=>{Dm=!1}),[e,o]),Ar(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let F=await Lm(e,o);if(S)return;let L={};for(let M of F)M.storyId&&(L[M.storyId]=M);k(L),_v(Object.keys(L))}catch(F){F instanceof Pn&&(t(null),n(F.message)),b.error("[useDataInit] Failed to fetch all mappings:",F)}})(),()=>{S=!0}},[e,o,d,k]),Ar(()=>{if(!l){m(null),I(null);return}let S=g[l]||null;S?(m(S),I("database")):(m(null),I(null)),A(!1)},[l,g,m,I,A]),Ar(()=>{w([]),E.current=null},[l]),Ar(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let F=await Mm(e,o,l,10,!0);if(!S){w(F);let L=F.map(M=>NN(M)).filter(Boolean);L.length>0&&x(L)}}catch(F){F instanceof Pn&&(t(null),n(F.message)),b.error("[useDataInit] Failed to fetch reviews:",F)}})(),()=>{S=!0}},[e,o,l]);let T=BN(S=>{b.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let y=[];if(typeof S.models=="string")try{y=JSON.parse(S.models)}catch{y=["claude-sonnet-4-20250514"]}else y=S.models;let F=S.issues.map(h=>({id:h.id,reviewId:S.id,type:h.type,severity:h.severity,title:h.description,description:h.description,file:void 0,lineNumber:void 0,property:h.property,currentValue:h.actual,suggestedValue:h.expected,suggestedCode:h.suggestedFix||void 0,status:h.status,dismissed:h.dismissed||!1,dismissReason:h.dismissReason,dismissedBy:h.dismissedBy,figmaContext:h.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(h.createdAt)})),L=S.completedAt&&S.createdAt?new Date(S.completedAt).getTime()-new Date(S.createdAt).getTime():void 0,M=S.storyId||"";C({id:S.id,componentId:"",storyId:M,modelId:y[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:F,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let z=mt.getState().currentStoryId;if(M&&M===z&&(S.storybookScreenshot&&(R(S.storybookScreenshot),Kw(M,S.storybookScreenshot,S.figmaScreenshot??void 0),b.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&(_(S.figmaScreenshot),b.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),b.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(N(S.aiResponse),b.debug("[useDataInit] Loaded persisted AI response")),M){let h=S.issues.filter(G=>!G.dismissed),j=h.filter(G=>G.severity==="critical").length,V=h.filter(G=>G.severity==="major").length,B=h.filter(G=>G.severity==="minor").length;Ur(M,{score:S.complianceScore,issueCount:h.length,criticalCount:j,majorCount:V,minorCount:B})}},[C,R,_,P,N]);Ar(()=>{if(v.length>0&&l&&E.current!==l){let S=v[0];S&&S.storyId===l&&(b.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),E.current=l,T(S),D("issues"))}},[v,l,T,D])}_n();import{styled as na}from"storybook/theming";var UN=na.div({display:"flex",gap:"10px",marginTop:"8px"}),ck=na.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),uk=na.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",marginBottom:"12px",display:"flex",alignItems:"center",justifyContent:"space-between"})),pk=na.div({display:"flex",alignItems:"center",gap:"8px"}),dk=na(Fn)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),gk=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=Ws(),[c,l]=rt.useState(""),d=()=>{let g=c.trim();g&&(u(g),e?.())};return rt.createElement(rt.Fragment,null,rt.createElement(xo,null,rt.createElement(yo,null,"Authentication Method"),rt.createElement(UN,null,rt.createElement(ck,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),rt.createElement(ck,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="apikey",onChange:()=>r("apikey")}),"API Key"))),n==="oauth"&&rt.createElement(xo,null,rt.createElement(yo,null,"Connect to ",Pt.NAME),t?rt.createElement(uk,null,rt.createElement(pk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Pt.NAME)),rt.createElement(dk,{onClick:i},"Disconnect")):s?rt.createElement("div",{style:{padding:"20px 0",textAlign:"center",fontSize:"13px"}},rt.createElement("div",{style:{fontSize:"24px",marginBottom:"8px"}},"\u{1F510}"),rt.createElement(fs,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),rt.createElement(fs,{style:{color:"inherit",opacity:.7}},"Complete sign-in in the popup, then return here.")):rt.createElement("div",null,a&&rt.createElement("div",{style:{marginBottom:"12px",padding:"10px 12px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#b91c1c"}},"\u26A0\uFE0F ",a),rt.createElement(fs,{style:{marginBottom:"12px"}},"Connect to ",Pt.NAME," to manage projects and integrations."),rt.createElement(Fn,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Pt.NAME))),n==="apikey"&&rt.createElement(xo,null,rt.createElement(yo,null,"Session Token"),t?rt.createElement(uk,null,rt.createElement(pk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Pt.NAME)),rt.createElement(dk,{onClick:i},"Disconnect")):rt.createElement(rt.Fragment,null,rt.createElement(fs,{style:{marginBottom:"12px"}},"Paste the session token from your ",Pt.NAME," setup page."),rt.createElement(gs,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),rt.createElement(Fn,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:d},"Save Token"))))};import ut,{useState as Gi}from"react";Te();import Hn,{useState as jN,useEffect as HN,useCallback as WN}from"react";import{styled as lo,keyframes as fk}from"storybook/theming";var VN=fk({from:{opacity:0},to:{opacity:1}}),GN=fk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),qN=lo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${VN} 150ms ease-out`}),YN=lo.div(({theme:e})=>({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10001,backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,padding:`${e.layoutMargin*2.4}px`,minWidth:"320px",maxWidth:"440px",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.2)",animation:`${GN} 150ms ease-out`})),KN=lo.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),XN=lo.p(({theme:e})=>({margin:`${e.layoutMargin}px 0 ${e.layoutMargin*2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),QN=lo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),JN=lo.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),ZN=lo.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),eO=lo.button(({theme:e})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,cursor:"pointer",backgroundColor:"transparent",color:e.color.defaultText,transition:"background-color 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),tO=lo.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),jr=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=jN(""),d=!!s&&c!==s,g=WN(p=>{p.key==="Escape"&&u()},[u]);return HN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?Hn.createElement(Hn.Fragment,null,Hn.createElement(qN,{onClick:u}),Hn.createElement(YN,{role:"dialog","aria-modal":"true","aria-label":t},Hn.createElement(KN,null,t),Hn.createElement(XN,null,n),s&&Hn.createElement(Hn.Fragment,null,Hn.createElement(ZN,null,"Type ",Hn.createElement("strong",null,s)," to confirm:"),Hn.createElement(JN,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),Hn.createElement(QN,null,Hn.createElement(eO,{onClick:u},o),Hn.createElement(tO,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as cn}from"storybook/theming";function nO(e,t,n){return e.filter(r=>r.id===t||!r.storybookRoot?!0:n?r.storybookRoot===n:!1)}var rO=cn.div({marginBottom:"30px"}),oO=cn.div({display:"flex",gap:"8px",alignItems:"center"}),iO=cn(bn)({flex:1}),sO=cn(on)({padding:"8px 12px",whiteSpace:"nowrap"}),aO=cn.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),lO=cn.div(({theme:e})=>({marginTop:"6px",padding:"8px 10px",fontSize:"11px",lineHeight:1.4,color:e.color.warning,backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}40`,borderRadius:"4px"})),cO=cn.div(({theme:e})=>({marginBottom:"10px",padding:"8px 10px",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",backgroundColor:e.background.content})),uO=cn.div(({theme:e})=>({fontSize:"11px",lineHeight:1.5,color:e.color.mediumdark,marginBottom:"6px"})),pO=cn.div({display:"flex",alignItems:"center",gap:"6px"}),dO=cn.a(({theme:e})=>({flex:1,fontSize:"11px",fontFamily:e.typography.fonts.mono,color:e.color.secondary,textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","&:hover":{textDecoration:"underline"}})),gO=cn.button(({theme:e})=>({fontSize:"11px",padding:"3px 8px",borderRadius:"3px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,color:e.color.defaultText,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:e.background.app}}));function fO(e){return/figma\.com\/community\/file\//.test(e)}var zm=cn.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Nm=cn.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Om=cn(gs)({fontSize:"13px",padding:"6px 8px"}),mO=cn.div({display:"flex",gap:"8px",marginTop:"12px"}),mk=cn(on)({fontSize:"12px",padding:"6px 12px"}),hO=cn(mk)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),xO=cn.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),hk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=io(),{currentStorybookPath:s}=Je(),[a,u]=Gi(!1),[c,l]=Gi(!1),[d,g]=Gi(!1),[p,m]=Gi(!1),[k,I]=Gi({name:"",storybookRoot:"",figmaFileUrl:""}),A=e.find(f=>f.id===t),C=nO(e,t,s),D=f=>{n(f||null),u(!1)},R=async()=>{if(t)try{m(!0),await i(t),g(!1)}catch(f){console.error("Failed to delete project:",f)}finally{m(!1)}},_=process.env.STORYBOOK_UICOPILOT_FIGMA_KIT||"",[P,N]=Gi(!1),x=()=>{_&&navigator.clipboard.writeText(_).then(()=>{N(!0),setTimeout(()=>N(!1),2e3)})},v=()=>{if(u(!0),s){let f=s.replace(/\/+$/,"").split("/").pop()||"";I({storybookRoot:s,name:f,figmaFileUrl:""})}},w=async()=>{if(k.name.trim())try{l(!0);let f;if(k.figmaFileUrl.trim()){let S=k.figmaFileUrl.trim(),y=S.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);f=y?y[1]:S}let T=await o({name:k.name.trim(),storybookRoot:k.storybookRoot.trim()||void 0,figmaFileId:f});n(T.id),u(!1),I({name:"",storybookRoot:"",figmaFileUrl:""})}catch(f){console.error("Failed to create project:",f)}finally{l(!1)}},E=f=>{I(T=>{let S={...T,storybookRoot:f};if(!T.name&&f){let y=f.replace(/\/+$/,"").split("/").pop()||"";S.name=y}return S})};return ut.createElement(rO,null,ut.createElement(py,null,"Project"),ut.createElement(oO,null,ut.createElement(iO,{value:t||"",onChange:f=>D(f.target.value),disabled:r||a},ut.createElement("option",{value:""},"-- Select a project --"),C.map(f=>ut.createElement("option",{key:f.id,value:f.id},f.name))),ut.createElement(sO,{onClick:v,disabled:r,type:"button"},"+ New"),ut.createElement(xO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),ut.createElement(jr,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${A?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:A?.name,variant:"danger",onConfirm:R,onCancel:()=>g(!1)}),a&&ut.createElement(aO,null,ut.createElement(zm,null,ut.createElement(Nm,null,"Storybook Path (for fix generation)"),ut.createElement(Om,{type:"text",placeholder:"/path/to/your/storybook",value:k.storybookRoot,onChange:f=>E(f.target.value)})),ut.createElement(zm,null,ut.createElement(Nm,null,"Project Name *"),ut.createElement(Om,{type:"text",placeholder:"my-storybook",value:k.name,onChange:f=>{let T=f.target.value;I(S=>({...S,name:T}))}})),_&&ut.createElement(cO,null,ut.createElement(uO,null,ut.createElement("strong",null,"1.")," Open this template's Figma kit, then click"," ",ut.createElement("strong",null,"Open in Figma")," (or ",ut.createElement("strong",null,"Get a copy"),") to duplicate it to your own Figma workspace. ",ut.createElement("strong",null,"2.")," ","Paste the URL of your copy (",ut.createElement("code",null,"figma.com/design/\u2026"),") into the field below."),ut.createElement(pO,null,ut.createElement(dO,{href:_,target:"_blank",rel:"noopener noreferrer",title:_},_),ut.createElement(gO,{type:"button",onClick:x},P?"Copied!":"Copy"))),ut.createElement(zm,null,ut.createElement(Nm,null,"Your Figma File URL (after duplicating)"),ut.createElement(Om,{type:"text",placeholder:"https://www.figma.com/design/...",value:k.figmaFileUrl,onChange:f=>{let T=f.target.value;I(S=>({...S,figmaFileUrl:T}))}}),fO(k.figmaFileUrl)&&ut.createElement(lO,null,"\u26A0 This is a community file URL \u2014 it can't be read by the API. Use the duplicated copy's URL instead (see instructions above).")),ut.createElement(mO,null,ut.createElement(mk,{onClick:w,disabled:c||!k.name.trim()},c?"Creating...":"Create"),ut.createElement(hO,{onClick:()=>{u(!1),I({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import wt,{useState as wc,useCallback as YC,useEffect as k4}from"react";import{styled as Lr}from"storybook/theming";import Hr,{useState as ra,useEffect as zO,useCallback as $m}from"react";import{styled as Lo}from"storybook/theming";Te();He();ct();Te();He();ct();import Vt,{useState as _m}from"react";import{styled as Wn,keyframes as yO}from"storybook/theming";var bO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},SO=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",wO=Wn.div({position:"relative",display:"inline-flex"}),vO=yO`
30
+ \u2705 ${ne} issue${ne>1?"s were":" was"} auto-dismissed as false positive${ne>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Kt=Ue.complianceScore??Ue.validation?.complianceScore;if(b.debug("[Review] Score sources:",{directScore:Ue.complianceScore,validationScore:Ue.validation?.complianceScore,parsedScore:Kt}),Kt==null){let Fe=Nt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Kt=Fe?parseInt(Fe[1],10):void 0,b.debug("[Review] Parsed score from response:",Kt)}let fn=ue.current[ie];fn||(fn=await Zs(ie)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},fn.storyFile&&(ue.current[ie]=fn)),b.debug("[Review] Story file paths:",fn);let at=gn.map(Fe=>({...Fe,file:Fe.file||pm(Fe.fixTarget,fn)||dm(Fe,fn)}));if(at=gm(at),b.debug("[Review] After de-duplication:",at.length,"issues"),!h){let Fe=at.length;at=at.filter(ge=>ge.property?.toLowerCase()!=="textcontent"&&!ge.description?.toLowerCase().includes("text content")),Fe!==at.length&&b.debug("[Review] Filtered out",Fe-at.length,"textContent issues (toggle OFF)")}let zr;tt&&he&&(zr=(mt.getState().reviewHistory.find(ge=>ge.id===he)?.iterationNumber||0)+1);let Bn={id:Qe,componentId:ie,storyId:ie,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:zr,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Xn||void 0,complianceScore:Kt,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(Fe=>!Fe.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-re,costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens,variantMismatch:Ue.variantMismatch,storybookVariant:Ue.storybookVariant,figmaVariant:Ue.figmaVariant};if(b.debug("[useAIReview] About to call addReview with review:",{id:Bn.id,storyId:Bn.storyId,issueCount:Bn.issues?.length,complianceScore:Bn.complianceScore,createdAt:Bn.createdAt?.toISOString(),inputTokens:Bn.inputTokens,outputTokens:Bn.outputTokens,costUsd:Bn.costUsd,cacheCreationTokens:Bn.cacheCreationTokens,cacheReadTokens:Bn.cacheReadTokens}),M(Bn),b.debug("[useAIReview] addReview called successfully"),ie&&B.enableReviewBadges){let Fe=at.filter(ge=>!ge.dismissed);Ur(ie,{score:Kt??100,issueCount:Fe.length,criticalCount:Fe.filter(ge=>ge.severity==="critical").length,majorCount:Fe.filter(ge=>ge.severity==="major").length,minorCount:Fe.filter(ge=>ge.severity==="minor").length})}z("issues");let ds=at.filter(Fe=>!Fe.dismissed).length;b.debug("[Review] Created review with",ds,"active issues,",at.length-ds,"dismissed");let Ha=vt||mt.getState().currentMapping?.figmaNodeId;b.debug("[Review] Validation check:",{figmaNodeId:vt,effectiveFigmaNodeIdSingle:Ha,hasSessionToken:!!G,selectedProjectId:xe,issueCount:at.length}),b.debug("[Review] Issue validation handled server-side. Active:",at.filter(Fe=>!Fe.dismissed).length,"Dismissed:",at.filter(Fe=>Fe.dismissed).length)}catch(Qe){b.error("[Review] Failed to parse issues:",Qe)}}else throw rn?(b.error("[Review] ERROR: No structured result received from backend!"),b.error("[Review] Streaming text length:",rn.length),b.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(K){if(K instanceof Error&&K.name==="AbortError"){b.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}b.error("[useAIReview] Review error:",K);let me=Mv(K);throw g(me),ie&&B.enableReviewBadges&&zv(ie),pe(0,`Error: ${me}`),K}finally{d(!1),Ie.current=null,ve.current&&(clearTimeout(ve.current),ve.current=null),le(null)}},[e,G,xe,ie,Ke,l,d,g,p,T,S,y,F,I,A,R,$e,pe,D,E,k,N,x,le]),$t=ea(()=>n?.issues?o==="all"?n.issues:n.issues.filter(fe=>fe.severity===o):[],[n,o]),yn=ea(()=>{Ie.current&&(b.debug("[useAIReview] Cancelling review..."),Ie.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:yt,cancelReview:yn,setShowReviewMenu:m,setSeverityFilter:v,setShowStreamingPanel:I,setStreamingPanelCollapsed:A,addStreamingMessage:C,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:_,setStreamingStatus:P,resetReview:L,getFilteredIssues:$t}};Te();_e();He();import{useCallback as lJ}from"react";var dJ=q();Te();_e();import{useEffect as Uv,useRef as jv}from"react";import{useStorybookApi as Zz,useStorybookState as eN,addons as tN}from"storybook/manager-api";var Hv="storyArgsUpdated",ym=()=>{let e=Zz(),t=eN(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=jv(null),d=jv(0);return Uv(()=>{let g=t.storyId;if(g){l.current!==g&&(b.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,d.current=Date.now()),o(g);let p=e.getData(g),m=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(m),b.debug("[useCurrentStory] Current story:",{storyId:g,fullName:m})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),Uv(()=>{let g=tN.getChannel(),p=null,m=v=>{if(v.storyId===n){if(u||c){b.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:I,isValidating:A}=mt.getState();if(I||A){b.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){b.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}b.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(Hv,m),()=>{g.off(Hv,m),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Te();He();ct();import{useCallback as Wv}from"react";import{addons as Vv}from"storybook/manager-api";var Gv=q(),ri=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=ke(),{selectedProjectId:i}=Je(),s=Wv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ee(`${Gv}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({projectId:i,...c})});if(!l.ok)throw new Error("Failed to create mapping");let d=await l.json();r();try{Vv.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=Wv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ee(`${Gv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{Vv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Oi();Te();import{useCallback as bm,useEffect as qv,useRef as nN}from"react";import{useChannel as rN,addons as Yv}from"storybook/manager-api";_e();var oN=3e4,iN="forceRemount";function sN(e,t){let n=parseFloat(e.replace(/[^0-9.-]/g,"")),r=parseFloat(t.replace(/[^0-9.-]/g,""));if(isNaN(n)||isNaN(r))return!1;let o=Math.abs(n-r);return e.includes("px")||t.includes("px")?o<.5:e.includes("%")||t.includes("%")?o<1:o<.5}function aN(e){let t=["design system","design token","css variable","var(--","hard-coded"],n=`${e.description} ${e.suggestedFix||""} ${e.suggestedValue||""}`.toLowerCase();return t.some(r=>n.includes(r))}var lN="UICOPILOT/APPLY_FIXES",cN="UICOPILOT/FIX_STARTED",uN="UICOPILOT/FIX_COMPLETED",pN="UICOPILOT/FIX_FAILED",dN="UICOPILOT/ALL_FIXES_APPLIED",Sm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=nN(null),l=bm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);qv(()=>()=>l(),[l]),qv(()=>{let m=Yv.getChannel(),v=()=>{mt.getState().isApplying&&(b.error("[useApplyFixes] WebSocket disconnected while applying fixes"),l(),o(!1),i({succeeded:0,failed:0,total:0,error:"Connection lost. Please restart Storybook and try again."}))};return m.on("channelWSDisconnect",v),()=>m.off("channelWSDisconnect",v)},[l,o,i]);let d=rN({[cN]:({issueId:m})=>{b.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[uN]:({issueId:m,result:v})=>{b.debug(`[useApplyFixes] Fix completed for issue: ${m}`,v),s(m,"applied"),a(m,{status:"applied"})},[pN]:({issueId:m,error:v})=>{b.error(`[useApplyFixes] Fix failed for issue: ${m}`,v),s(m,"failed",v),a(m,{status:"failed",error:v})},[dN]:async({summary:m})=>{if(b.debug("[useApplyFixes] All fixes applied:",m),l(),o(!1),i({succeeded:m.succeeded,failed:m.failed,total:m.total}),m.failed>0?b.warn(`Applied ${m.succeeded}/${m.total} fixes. ${m.failed} failed.`):b.debug(`Successfully applied all ${m.total} fixes!`),m.succeeded>0){b.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{Yv.getChannel().emit(iN,{storyId:mt.getState().currentStoryId}),b.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(v){b.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",v)}b.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Gl(),b.debug("[useApplyFixes] Storybook preview reloaded")}t&&(b.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),b.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=bm(m=>{let v=[],I=[],A=[];for(let C of m){let D=C.currentValue||C.actual||"",R=C.suggestedValue||C.expected||"";if(D&&R&&sN(D,R)){v.push(C);continue}if(aN(C)){I.push(C);continue}let _=C.generatedFix?.filePath||C.file||"";if(!_){b.warn(`[useApplyFixes] Skipping issue ${C.id} - no target file path`);continue}let P=_.toLowerCase().split(".").pop()||"",N=["tsx","jsx","ts","js"].includes(P)?"component":"css";A.push({...C,targetFilePath:_,targetFileType:N})}return{actionable:A,negligible:v,designTokens:I}},[]);return{applyFixes:bm(m=>{if(r){b.warn("[useApplyFixes] Already applying fixes");return}if(m.length===0){b.warn("[useApplyFixes] No issues to fix");return}let v=g(m);if(v.negligible.length>0&&b.debug(`[useApplyFixes] Filtered ${v.negligible.length} negligible issue(s)`),v.designTokens.length>0&&b.debug(`[useApplyFixes] Skipped ${v.designTokens.length} design token suggestion(s)`),v.actionable.length===0){b.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let I=v.actionable.filter(D=>D.targetFileType==="css"),A=v.actionable.filter(D=>D.targetFileType==="component");if(b.debug("[useApplyFixes] Applying fixes:"),I.length>0){let D=[...new Set(I.map(R=>R.targetFilePath))];b.debug(` - ${I.length} CSS issue(s) in: ${D.join(", ")}`)}if(A.length>0){let D=[...new Set(A.map(R=>R.targetFilePath))];b.debug(` - ${A.length} component issue(s) in: ${D.join(", ")}`),b.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){b.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:v.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{mt.getState().isApplying&&(b.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:v.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},oN),d(lN,{issues:v.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};Te();He();import{useState as BJ}from"react";var zJ=q();Te();import{useState as oi}from"react";He();_e();ct();var gN=q();async function Zl(e,t,n,r,o){if(!e)return b.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ee(`${gN}/api/issues/dismiss`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify({issueId:e,dismissed:t,dismissReason:n,dismissedBy:r})});if(!i.ok){let a=await i.text();return b.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return b.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return b.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Kv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return b.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Zl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return b.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}_n();Zf();Oi();_e();He();var fN=["no-fix-needed","no-fix-required","no-change-needed","no-changes-needed","no-change-required","no-changes-required","no-action-needed","no-action-required","no_fix_needed","no_change_needed","no_changes_needed","already-correct","values-match","values-already-match","already-matches","css-matches","matches-figma","correctly-implemented","implementation-correct","none-needed","none-required","skipped","skip"],mN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],hN=q();function wm(){let[e,t]=oi(!1),[n,r]=oi(null),[o,i]=oi(null),[s,a]=oi(null),[u,c]=oi(null),[l,d]=oi(null),[g,p]=oi(null),{sessionToken:m}=ke(),{selectedProjectId:v}=Je(),{currentStoryId:I,currentStoryName:A}=nt(),{workspacePath:C,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:_,dismissIssue:P,recalculateScore:N,addStreamingMessage:x}=ce();return{generateBatchFixes:async w=>{if(!m){r("Not authenticated");return}if(!v){r("No project selected");return}if(!I){r("No story selected");return}if(w.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:w.length,completed:0});let E=w.map(f=>({issueId:f.id,generatedFix:{code:"",diffPreview:"",filePath:f.file||"",confidence:0,strategy:"",status:"generating"}}));R(E);try{b.debug("[useBatchGenerateFixes] Generating fixes for",w.length,"issues");let f=null;try{let h=Ks();h?.computed&&(f=h.computed,b.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){b.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let T=null;try{T=await Zs(I),T&&b.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",T)}catch(h){b.warn("[useBatchGenerateFixes] Could not resolve story file paths:",h)}let S=await fetch(`${hN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:v,storyId:I,workspacePath:C,includeComponentIssues:_,computedStyles:f,storyFilePaths:T,reviewContext:{storyName:A||void 0,variantArgs:Ni()||void 0},issues:w.map(h=>({id:h.id,dbId:h.dbId,title:h.title,description:h.description,property:h.property,currentValue:h.currentValue,suggestedValue:h.suggestedValue,file:h.file,lineNumber:h.lineNumber,severity:h.severity,type:h.type,fixTarget:h.fixTarget,domElement:h.domElement,figmaContext:h.figmaContext,suggestedFix:h.suggestedFix}))})});if(!S.ok){let h=await S.json().catch(()=>({}));throw new Error(h.error||"Batch fix generation failed")}let y=await S.json();if(!y.success)throw new Error(y.error||"Batch fix generation failed");if(b.debug("[useBatchGenerateFixes] Generated",y.result.fixes.length,"fixes"),y.result.storybookRoot&&(p(y.result.storybookRoot),b.debug("[useBatchGenerateFixes] Stored storybookRoot:",y.result.storybookRoot)),y.result.selfReview&&(d(y.result.selfReview),b.debug("[useBatchGenerateFixes] Self-review:",y.result.selfReview)),y.result.partialFailure){let{failedBatches:h,errors:j}=y.result.partialFailure;b.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),b.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${h.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:w.length,completed:y.result.fixes.length});let F=new Set(y.result.fixes.map(h=>h.issueId)),L=w.filter(h=>!F.has(h.id));L.length>0&&(b.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(h=>{D(h.id,{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),y.timing&&(i({durationSec:y.timing.durationSec,issueCount:y.timing.issueCount,avgPerIssueSec:y.timing.avgPerIssueSec}),b.debug(`[useBatchGenerateFixes] Generation took ${y.timing.durationSec}s for ${y.timing.issueCount} issues`)),y.result?.usage&&(c({inputTokens:y.result.usage.inputTokens||0,outputTokens:y.result.usage.outputTokens||0,costUsd:y.result.usage.costUsd||0,modelId:y.result.usage.modelId||"unknown",provider:y.result.usage.provider||"unknown"}),b.debug(`[useBatchGenerateFixes] Token usage: ${y.result.usage.inputTokens} in, ${y.result.usage.outputTokens} out, $${y.result.usage.costUsd?.toFixed(4)}`));let M=[],z=[];if(y.result.fixes.forEach(h=>{let j=h.noChangesNeeded===!0;if(!j){let G=(h.fixStrategy||"").toLowerCase(),te=(h.generatedCode||"").toLowerCase(),le=(h.diffPreview||"").toLowerCase(),xe=fN.some(Ke=>G.includes(Ke.toLowerCase())||G.replace(/[-_]/g,"").includes(Ke.replace(/[-_]/g,""))),ie=mN.some(Ke=>te.includes(Ke)||le.includes(Ke));j=xe||ie}let V=w.find(G=>G.id===h.issueId);if(j&&V){let G=V.suggestedValue,te=V.currentValue;G&&te&&!Zo(G,te)&&(b.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${G}", actual="${te}"), NOT auto-dismissing issue ${h.issueId}`),j=!1)}let B=V?.programmaticallyVerified===!0;if(b.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:B,detectedBy:V?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:V?.title?.substring(0,50)}),B&&j&&(b.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${V?.detectedBy})`),j=!1),j){let G=`Auto-dismissed: ${h.fixStrategy} - values already match`;b.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,G),M.push({localId:h.issueId,dbId:V?.dbId,dismissReason:G}),z.push({issueId:h.issueId,generatedFix:{code:h.generatedCode||"",diffPreview:h.diffPreview||"",filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:"ready",error:void 0,noChangesExplanation:h.noChangesExplanation}})}else{let G=h.error||h.fixStrategy==="skipped"?"failed":"ready";z.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:G,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),z.length>0&&(b.debug(`[useBatchGenerateFixes] Applying ${z.length} fix updates in batch`),R(z)),M.length>0){if(b.debug(`[useBatchGenerateFixes] Auto-dismissed ${M.length} false positive(s), recalculating score`),N(),m){let j=M.filter(V=>V.dbId).map(V=>({dbId:V.dbId,dismissed:!0,dismissReason:V.dismissReason,dismissedBy:"system"}));j.length>0&&(b.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Kv(j,m).then(V=>{V.success?b.debug(`[useBatchGenerateFixes] Server score updated to: ${V.newScore}`):b.warn("[useBatchGenerateFixes] Failed to sync dismissals:",V.error)}).catch(V=>{b.error("[useBatchGenerateFixes] Error syncing dismissals:",V)}))}let h=M.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${M.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;x({role:"system",content:h})}b.debug("[useBatchGenerateFixes] Updated",y.result.fixes.length,"issues with fixes")}catch(f){b.error("[useBatchGenerateFixes] Failed to generate batch fixes:",f),r(f?.message||"Failed to generate batch fixes");let T=w.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:f?.message||"Failed to generate fix"}}));R(T)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}Te();_e();He();ct();import{useState as vm,useCallback as km}from"react";var xN=q();function Cm(){let[e,t]=vm([]),[n,r]=vm(!1),[o,i]=vm(null),{sessionToken:s}=ke(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=km(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let m=await ee(`${xN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!m.ok){let I=await m.json().catch(()=>({}));throw new Error(I.error||"Failed to fetch reviews")}let v=await m.json();if(!v.success)throw new Error("Failed to fetch reviews");b.debug("[useReviewHistory] Fetched",v.reviews.length,"reviews for:",u),t(v.reviews)}catch(p){b.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=km(p=>{b.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let m=[];if(typeof p.models=="string")try{m=JSON.parse(p.models)}catch(C){b.error("[useReviewHistory] Failed to parse models:",C),m=["claude-sonnet-4-20250514"]}else m=p.models;let v=p.issues.map(C=>({id:C.id,reviewId:p.id,type:C.type,severity:C.severity,title:C.description,description:C.description,file:void 0,lineNumber:void 0,property:C.property,currentValue:C.actual,suggestedValue:C.expected,suggestedCode:C.suggestedFix||void 0,status:C.status,dismissed:C.dismissed||!1,dismissReason:C.dismissReason,dismissedBy:C.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(C.createdAt)})),I=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,A=p.storyId||"";if(c({id:p.id,componentId:"",storyId:A,modelId:m[0]||"claude-sonnet-4-6",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:v,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:I}),A){let C=p.issues.filter(P=>!P.dismissed),D=C.filter(P=>P.severity==="critical").length,R=C.filter(P=>P.severity==="major").length,_=C.filter(P=>P.severity==="minor").length;Ur(A,{score:p.complianceScore,issueCount:C.length,criticalCount:D,majorCount:R,minorCount:_})}},[c]),g=km(p=>{let m=e.find(v=>v.id===p);if(!m){b.error("[useReviewHistory] Review not found:",p);return}d(m)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}Te();_e();import{useEffect as yN,useState as bN,useRef as ec}from"react";import{useChannel as SN}from"storybook/manager-api";var wN="UICOPILOT/WORKSPACE_PATH",Xv="UICOPILOT/REQUEST_WORKSPACE_PATH",vN=3e3,kN=500,CN=5,Tm=()=>{let[e,t]=bN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=ec(!1),o=ec(null),i=ec(0),s=ec(null),a=SN({[wN]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),b.debug("[useAutoApplySupport] Server responded - auto-apply supported"),b.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return yN(()=>(b.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Xv,{}),s.current=setInterval(()=>{!r.current&&i.current<CN&&(i.current++,b.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Xv,{}))},kN),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){b.debug("[useAutoApplySupport] Channel detection timed out, trying HTTP fallback...");try{let u=await fetch("/__uicopilot/health");if(u.ok){let c=await u.json();if(c.ok&&c.workspacePath&&!r.current){r.current=!0,b.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),b.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,b.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},vN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},Im=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}}catch(t){return b.error("[copyToClipboard] Failed to copy:",t),!1}};Te();He();import{useEffect as TN,useRef as IN}from"react";var gZ=q(),FN=new Set;function Fm(){let{sessionToken:e}=ke(),{selectedProjectId:t}=Je(),n=IN(!1);TN(()=>{t&&FN.add(t)},[e,t])}Te();_n();import{useCallback as hZ,useState as xZ}from"react";import{useState as ii,useMemo as ak,useCallback as Vi}from"react";He();_e();ct();_n();import{useState as ao,useEffect as tc,useRef as Hi,useCallback as Em}from"react";var EN=300;function Qv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=ao([]),[u,c]=ao({}),[l,d]=ao(0),[g,p]=ao([]),[m,v]=ao(new Set),[I,A]=ao(!1),[C,D]=ao(!1),[R,_]=ao(null),P=Hi(1),N=Hi(null),x=Hi(null),[k,w]=ao(0),E=Hi(!1),f=Hi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});f.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let T=Em(async(M,z,h=!1)=>{let{projectId:j,typeFilter:V,search:B,figmaPage:G,limit:te}=f.current;if(!j||!V)return;N.current&&N.current.abort();let le=new AbortController;N.current=le,z?D(!0):A(!0),_(null);try{let xe=q(),ie=localStorage.getItem("uicopilot_session_token");if(!ie)throw new Error(`Not authenticated. Please connect to ${Pt.NAME} first.`);let Ke=new URLSearchParams({projectId:j,page:String(M),limit:String(te)});V&&Ke.append("type",V),G&&Ke.append("figmaPage",G),B.trim()&&Ke.append("search",B.trim()),h&&Ke.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ke.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ie}`},signal:le.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Ie=await be.json(),ve=Ie.frames||[],ue=Ie.thumbnails||{},$e=be.headers.get("X-Cache-Status");if(ve.length===0&&M===1&&!z&&!h&&!E.current&&$e!=="HIT"){b.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),E.current=!0,await T(1,!1,!0);return}z?(a(pe=>[...pe,...ve]),c(pe=>({...pe,...ue}))):(a(ve),c(ue)),d(Ie.total||ve.length),Ie.pages&&p(Ie.pages),Ie.cacheDiff?.added&&v(new Set(Ie.cacheDiff.added)),P.current=M}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let ie=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";_(ie),b.error("Error fetching frames:",xe)}finally{le.signal.aborted||(A(!1),D(!1))}},[]);tc(()=>{if(!i||!e||!t)return;E.current=!1,x.current&&clearTimeout(x.current);let M=n.trim()?EN:0;return x.current=setTimeout(()=>{P.current=1,T(1,!1)},M),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,k,T]);let S=Hi(new Set);tc(()=>{if(s.length===0)return;let M={};for(let z of s)z.thumbnailCdnUrl&&!u[z.id]&&(M[z.id]=z.thumbnailCdnUrl);Object.keys(M).length>0&&c(z=>({...z,...M}))},[s]),tc(()=>{if(s.length===0)return;let M=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(M.length===0)return;M.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=f.current,j=q(),V=localStorage.getItem("uicopilot_session_token");if(!V||!h)return;let B=await ee(`${j}/api/figma/frames?projectId=${h}&thumbnailIds=${M.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${V}`}});if(B.ok){let G=await B.json();G.thumbnails&&Object.keys(G.thumbnails).length>0&&c(te=>({...te,...G.thumbnails}))}}catch(h){M.forEach(j=>S.current.delete(j)),b.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),tc(()=>()=>{N.current&&N.current.abort(),x.current&&clearTimeout(x.current)},[]);let y=Em(async()=>{let M=P.current+1;await T(M,!0)},[T]),F=Em(()=>{E.current=!1,P.current=1,a([]),c({}),w(M=>M+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:m,isLoading:I,loadingMore:C,hasMore:L,loadMore:y,refresh:F,error:R}}He();_e();ct();import{useState as Wi,useCallback as nc,useRef as AN}from"react";function Jv({projectId:e}){let[t,n]=Wi({}),[r,o]=Wi({}),[i,s]=Wi(new Set),[a,u]=Wi(new Set),[c,l]=Wi({}),[d,g]=Wi(null),p=AN({}),m=nc(async C=>{if(!(!e||i.has(C))){s(D=>new Set(D).add(C));try{let D=q(),R=localStorage.getItem("uicopilot_session_token"),_=await ee(`${D}/api/figma/variants?projectId=${e}&componentSetId=${C}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(_.ok){let P=await _.json();if(P.variants){n(x=>({...x,[C]:P.variants}));let N={};for(let x of P.variants)x.thumbnailCdnUrl&&(N[x.id]=x.thumbnailCdnUrl);o(x=>({...x,[C]:{...x[C]||{},...N}})),p.current[C]||(p.current[C]=new Set),Object.keys(N).forEach(x=>p.current[C].add(x))}else o(N=>({...N,[C]:N[C]||{}}))}else o(P=>({...P,[C]:{}}))}catch(D){b.error("Failed to fetch variant metadata:",D),o(R=>({...R,[C]:{}}))}finally{s(D=>{let R=new Set(D);return R.delete(C),R})}}},[e,i]),v=nc(async(C,D)=>{if(!e||D.length===0)return;p.current[C]||(p.current[C]=new Set);let R=r[C]||{},_=D.filter(P=>!p.current[C].has(P)&&!R[P]);if(_.length!==0){_.forEach(P=>p.current[C].add(P)),u(P=>new Set(P).add(C));try{let P=q(),N=localStorage.getItem("uicopilot_session_token"),x=await ee(`${P}/api/figma/variants?projectId=${e}&componentSetId=${C}&thumbnailIds=${_.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`}});if(x.ok){let k=await x.json();k.rateLimitError?(g(k.rateLimitError),_.forEach(w=>p.current[C]?.delete(w))):(k.thumbnails&&Object.keys(k.thumbnails).length>0&&o(w=>({...w,[C]:{...w[C]||{},...k.thumbnails}})),Array.isArray(k.failed)&&k.failed.length>0&&l(w=>{let E=new Set(w[C]||[]);for(let f of k.failed)E.add(f);return{...w,[C]:E}}))}}catch(P){b.error("Failed to fetch variant thumbnails:",P),_.forEach(N=>p.current[C]?.delete(N))}finally{u(P=>{let N=new Set(P);return N.delete(C),N})}}},[e]),I=nc(C=>{o(D=>{let R={...D};return delete R[C],R}),n(D=>{let R={...D};return delete R[C],R}),l(D=>{let R={...D};return delete R[C],R}),delete p.current[C]},[]),A=nc(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,rateLimitError:d,fetchVariants:m,fetchVariantThumbnails:v,clearVariantsForSet:I,clearAllVariants:A}}He();Oi();Te();_e();ct();import{useState as Zv,useEffect as ek,useRef as tk,useCallback as Am}from"react";function nk({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Zv(null),[i,s]=Zv(!1),a=tk(null),u=tk(new Set),c=Am(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Ni();if(!g||Object.keys(g).length===0)return;let p=mt.getState().currentStoryId||"",m=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase());a.current=e,s(!0),o(null);try{let v=q(),I=localStorage.getItem("uicopilot_session_token"),A=await ee(`${v}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({storyName:m,storyId:p,storyArgs:g,availableFilters:t.map(C=>({property:C.property,values:C.values}))})});if(A.ok){let C=await A.json();C.confidence>0&&Object.keys(C.suggestedFilters).length>0&&(b.debug("[useFilterSuggestion] Suggestion:",C),o(C))}}catch(v){b.error("[useFilterSuggestion] Error:",v)}finally{s(!1)}},[e,t,n]);ek(()=>{c()},[c]),ek(()=>{e||(o(null),a.current=null)},[e]);let l=Am(()=>{},[]),d=Am(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function rk(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function ok(e){let t={};for(let n of Object.values(e))for(let r of n)if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);return Object.entries(t).map(([n,r])=>({property:n,values:Array.from(r).sort()}))}function ik(e){let t={},n=r=>{if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);r.children?.forEach(n)};return e.forEach(n),Object.entries(t).map(([r,o])=>({property:r,values:Array.from(o).sort()}))}function sk(e,t,n){if(t.length===0||!t.some(o=>o.value))return!0;let r=o=>o.variantProperties?t.every(i=>i.value?o.variantProperties?.[i.property]===i.value:!0):!1;return!!(r(e)||e.children?.some(r)||n?.some(r))}function ta({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=ii(!0),[i,s]=ii(!1),[a,u]=ii(!1),[c,l]=ii(""),[d,g]=ii(""),[p,m]=ii([]),[v,I]=ii(new Set),A=Vi(ue=>{l(ue),p.length>0&&m([]),v.size>0&&I(new Set)},[p.length,v.size]),C=rk(r,i,a),{frames:D,thumbnails:R,totalFrames:_,availablePages:P,recentlyAdded:N,isLoading:x,loadingMore:k,hasMore:w,loadMore:E,refresh:f,error:T}=Qv({projectId:e,typeFilter:C,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!C}),{variantChildren:S,variantThumbnails:y,variantFailed:F,loadingVariants:L,loadingThumbnails:M,rateLimitError:z,fetchVariants:h,fetchVariantThumbnails:j,clearVariantsForSet:V,clearAllVariants:B}=Jv({projectId:e}),G=ak(()=>{let ue=ok(S),$e=ik(D),pe={};for(let yt of[...ue,...$e])pe[yt.property]||(pe[yt.property]=new Set),yt.values.forEach($t=>pe[yt.property].add($t));return Object.entries(pe).map(([yt,$t])=>({property:yt,values:Array.from($t).sort()}))},[S,D]),te=v.size===1?Array.from(v)[0]:null,le=nk({expandedSetId:te,availableFilters:G,filtersReady:G.length>0}),xe=Vi(()=>{if(!le.suggestion)return;let{suggestedFilters:ue}=le.suggestion,$e=Object.entries(ue).map(([pe,yt])=>({property:pe,value:yt}));m($e),le.dismissSuggestion()},[le.suggestion]),ie=ak(()=>p.some(ue=>ue.value)?D.filter(ue=>sk(ue,p,S[ue.id])):D,[D,p,S]),Ke=Vi((ue,$e)=>{$e.stopPropagation();let pe=!v.has(ue);I(yt=>{let $t=new Set(yt);return $t.has(ue)?$t.delete(ue):$t.add(ue),$t}),pe&&!S[ue]&&!L.has(ue)?h(ue):pe||V(ue)},[v,S,L,h,V]),be=Vi((ue,$e)=>{let pe=$e===""?null:$e;m(yt=>yt.find(yn=>yn.property===ue)?yt.map(yn=>yn.property===ue?{...yn,value:pe}:yn):[...yt,{property:ue,value:pe}])},[]),Ie=Vi(()=>{m([])},[]),ve=Vi(ue=>{let $e=D.find(pe=>pe.id===ue);if($e?.thumbnailCdnUrl)return $e.thumbnailCdnUrl;if(R[ue])return R[ue];for(let pe of Object.values(y))if(pe[ue])return pe[ue]},[R,y]);return{frames:D,filteredFrames:ie,thumbnails:R,totalFrames:_,isLoading:x,loadingMore:k,hasMore:w,error:T,loadMore:E,refresh:f,search:c,setSearch:A,figmaPage:d,setFigmaPage:g,availablePages:P,recentlyAdded:N,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:G,handleFilterChange:be,clearFilters:Ie,expandedSets:v,toggleExpanded:Ke,variantChildren:S,variantThumbnails:y,variantFailed:F,loadingVariants:L,loadingThumbnails:M,rateLimitError:z,fetchVariantThumbnails:j,resolveThumbnail:ve,filterSuggestion:le.suggestion,filterSuggestionLoading:le.isLoading,applySuggestedFilters:xe,dismissFilterSuggestion:le.dismissSuggestion}}Te();import{useEffect as Ar,useCallback as DN,useState as RN,useRef as zN}from"react";import{useChannel as NN}from"storybook/manager-api";function Po(e){return e.status===401||e.status===403}var Pn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};_n();function lk(e){try{let t=new URL(e),n=t.pathname.match(/\/(file|design)\/([a-zA-Z0-9]+)/),r=n?n[2]:null,o=t.searchParams.get("node-id"),i=t.hash.match(/node-id=([0-9-:]+)/),s=o||(i?i[1]:null);if(!r||!s)return null;let a=s.replace(/-/g,":");return{fileKey:r,nodeId:a}}catch(t){return Tu.error("Error parsing Figma URL:",t),null}}_e();He();He();ct();var PN=q();async function Pm(e){let t=await ee(`${PN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Po(t))throw new Pn(t.status);return t.ok?(await t.json()).projects||[]:[]}He();ct();var LN=q();async function Lm(e,t){let n=await ee(`${LN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new Pn(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}He();ct();var MN=q();async function Mm(e,t,n,r=10,o=!1){let i=new URLSearchParams({projectId:t,limit:String(r),storyId:n});o&&i.set("includeAI","true");let s=await ee(`${MN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(s))throw new Pn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}He();ct();var BN=q();async function Bm(e,t){let n=await ee(`${BN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new Pn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Oi();function ON(e){return e.storyId?{id:e.id,componentId:"",storyId:e.storyId,modelId:e.models?.[0]||"unknown",complianceScore:e.complianceScore,issuesCount:e.issuesCount,costUsd:e.costUsd,inputTokens:e.inputTokens,outputTokens:e.outputTokens,parentReviewId:e.parentReviewId||void 0,iterationNumber:e.iterationNumber,storybookImageData:e.storybookScreenshot||void 0,figmaImageData:e.figmaScreenshot||void 0,aiPrompt:e.aiPrompt||void 0,aiResponse:e.aiResponse||void 0,issues:e.issues.map(t=>({id:t.id,reviewId:e.id,type:t.type,severity:t.severity,title:t.description,description:t.description,property:t.property,currentValue:t.actual,suggestedValue:t.expected,suggestedCode:t.suggestedFix||void 0,status:t.status||"pending",dismissed:t.dismissed||!1,dismissReason:t.dismissReason,dismissedBy:t.dismissedBy,figmaContext:t.figmaContext,selectedForFix:!1,createdAt:new Date(t.createdAt)})),createdAt:new Date(e.createdAt)}:null}var _N=q(),$N="UICOPILOT/WORKSPACE_PATH",UN="UICOPILOT/REQUEST_WORKSPACE_PATH",Dm=!1;function Rm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=ke(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:m,setMappingsByStoryId:v,setMappingSource:I,setLoadingMapping:A}=nt(),{setReviewResults:C,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:_,setFullPrompt:P,setFullResponse:N,bulkAddReviews:x}=ce(),[k,w]=RN([]),E=zN(null);Ar(()=>{let S=y=>{y.origin.startsWith(_N)&&y.data?.type==="UICOPILOT_AUTH_SUCCESS"&&y.data.token&&(b.debug("[useDataInit] OAuth success, setting token"),t(y.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let f=NN({[$N]:S=>{b.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Ar(()=>{f(UN)},[f]),Ar(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let F=await Pm(e);S||(s(F),n(null))}catch(F){F instanceof Pn&&(t(null),n(F.message)),b.error("[useDataInit] Failed to fetch projects:",F)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Ar(()=>{if(!i||r.length===0)return;let S=r.find(y=>y.storybookRoot===i);S?o!==S.id&&(b.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id)):o&&(b.debug("[useDataInit] No project matches this Storybook \u2014 clearing selection"),a(null))},[i,r,o,a]),Ar(()=>{if(!o||r.length===0)return;let S=r.find(F=>F.id===o),y=S?.figmaFileId;if(S&&typeof y=="string"&&y){let F=y,L=F.includes("figma.com")&&lk(F)?.fileKey||F;p(`https://www.figma.com/file/${L}`)}},[o,r,p]),Ar(()=>!e||!o||Dm?void 0:(Dm=!0,(async()=>{try{let y=await Bm(e,o);for(let[F,L]of Object.entries(y))Ur(F,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});b.debug("[useDataInit] Populated sidebar badges for",Object.keys(y).length,"stories")}catch(y){y instanceof Pn&&(t(null),n(y.message)),b.error("[useDataInit] Failed to fetch review statuses:",y)}})(),()=>{Dm=!1}),[e,o]),Ar(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let F=await Lm(e,o);if(S)return;let L={};for(let M of F)M.storyId&&(L[M.storyId]=M);v(L),_v(Object.keys(L))}catch(F){F instanceof Pn&&(t(null),n(F.message)),b.error("[useDataInit] Failed to fetch all mappings:",F)}})(),()=>{S=!0}},[e,o,d,v]),Ar(()=>{if(!l){m(null),I(null);return}let S=g[l]||null;S?(m(S),I("database")):(m(null),I(null)),A(!1)},[l,g,m,I,A]),Ar(()=>{w([]),E.current=null},[l]),Ar(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let F=await Mm(e,o,l,10,!0);if(!S){w(F);let L=F.map(M=>ON(M)).filter(Boolean);L.length>0&&x(L)}}catch(F){F instanceof Pn&&(t(null),n(F.message)),b.error("[useDataInit] Failed to fetch reviews:",F)}})(),()=>{S=!0}},[e,o,l]);let T=DN(S=>{b.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let y=[];if(typeof S.models=="string")try{y=JSON.parse(S.models)}catch{y=["claude-sonnet-4-20250514"]}else y=S.models;let F=S.issues.map(h=>({id:h.id,reviewId:S.id,type:h.type,severity:h.severity,title:h.description,description:h.description,file:void 0,lineNumber:void 0,property:h.property,currentValue:h.actual,suggestedValue:h.expected,suggestedCode:h.suggestedFix||void 0,status:h.status,dismissed:h.dismissed||!1,dismissReason:h.dismissReason,dismissedBy:h.dismissedBy,figmaContext:h.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(h.createdAt)})),L=S.completedAt&&S.createdAt?new Date(S.completedAt).getTime()-new Date(S.createdAt).getTime():void 0,M=S.storyId||"";C({id:S.id,componentId:"",storyId:M,modelId:y[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:F,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let z=mt.getState().currentStoryId;if(M&&M===z&&(S.storybookScreenshot&&(R(S.storybookScreenshot),Kw(M,S.storybookScreenshot,S.figmaScreenshot??void 0),b.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&(_(S.figmaScreenshot),b.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),b.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(N(S.aiResponse),b.debug("[useDataInit] Loaded persisted AI response")),M){let h=S.issues.filter(G=>!G.dismissed),j=h.filter(G=>G.severity==="critical").length,V=h.filter(G=>G.severity==="major").length,B=h.filter(G=>G.severity==="minor").length;Ur(M,{score:S.complianceScore,issueCount:h.length,criticalCount:j,majorCount:V,minorCount:B})}},[C,R,_,P,N]);Ar(()=>{if(k.length>0&&l&&E.current!==l){let S=k[0];S&&S.storyId===l&&(b.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),E.current=l,T(S),D("issues"))}},[k,l,T,D])}_n();import{styled as na}from"storybook/theming";var jN=na.div({display:"flex",gap:"10px",marginTop:"8px"}),ck=na.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),uk=na.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",marginBottom:"12px",display:"flex",alignItems:"center",justifyContent:"space-between"})),pk=na.div({display:"flex",alignItems:"center",gap:"8px"}),dk=na(Fn)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),gk=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=Ws(),[c,l]=rt.useState(""),d=()=>{let g=c.trim();g&&(u(g),e?.())};return rt.createElement(rt.Fragment,null,rt.createElement(xo,null,rt.createElement(yo,null,"Authentication Method"),rt.createElement(jN,null,rt.createElement(ck,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),rt.createElement(ck,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="apikey",onChange:()=>r("apikey")}),"API Key"))),n==="oauth"&&rt.createElement(xo,null,rt.createElement(yo,null,"Connect to ",Pt.NAME),t?rt.createElement(uk,null,rt.createElement(pk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Pt.NAME)),rt.createElement(dk,{onClick:i},"Disconnect")):s?rt.createElement("div",{style:{padding:"20px 0",textAlign:"center",fontSize:"13px"}},rt.createElement("div",{style:{fontSize:"24px",marginBottom:"8px"}},"\u{1F510}"),rt.createElement(fs,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),rt.createElement(fs,{style:{color:"inherit",opacity:.7}},"Complete sign-in in the popup, then return here.")):rt.createElement("div",null,a&&rt.createElement("div",{style:{marginBottom:"12px",padding:"10px 12px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#b91c1c"}},"\u26A0\uFE0F ",a),rt.createElement(fs,{style:{marginBottom:"12px"}},"Connect to ",Pt.NAME," to manage projects and integrations."),rt.createElement(Fn,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Pt.NAME))),n==="apikey"&&rt.createElement(xo,null,rt.createElement(yo,null,"Session Token"),t?rt.createElement(uk,null,rt.createElement(pk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Pt.NAME)),rt.createElement(dk,{onClick:i},"Disconnect")):rt.createElement(rt.Fragment,null,rt.createElement(fs,{style:{marginBottom:"12px"}},"Paste the session token from your ",Pt.NAME," setup page."),rt.createElement(gs,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),rt.createElement(Fn,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:d},"Save Token"))))};import ut,{useState as Gi}from"react";Te();import Hn,{useState as HN,useEffect as WN,useCallback as VN}from"react";import{styled as lo,keyframes as fk}from"storybook/theming";var GN=fk({from:{opacity:0},to:{opacity:1}}),qN=fk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),YN=lo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${GN} 150ms ease-out`}),KN=lo.div(({theme:e})=>({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10001,backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,padding:`${e.layoutMargin*2.4}px`,minWidth:"320px",maxWidth:"440px",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.2)",animation:`${qN} 150ms ease-out`})),XN=lo.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),QN=lo.p(({theme:e})=>({margin:`${e.layoutMargin}px 0 ${e.layoutMargin*2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),JN=lo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),ZN=lo.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),eO=lo.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),tO=lo.button(({theme:e})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,cursor:"pointer",backgroundColor:"transparent",color:e.color.defaultText,transition:"background-color 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),nO=lo.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),jr=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=HN(""),d=!!s&&c!==s,g=VN(p=>{p.key==="Escape"&&u()},[u]);return WN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?Hn.createElement(Hn.Fragment,null,Hn.createElement(YN,{onClick:u}),Hn.createElement(KN,{role:"dialog","aria-modal":"true","aria-label":t},Hn.createElement(XN,null,t),Hn.createElement(QN,null,n),s&&Hn.createElement(Hn.Fragment,null,Hn.createElement(eO,null,"Type ",Hn.createElement("strong",null,s)," to confirm:"),Hn.createElement(ZN,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),Hn.createElement(JN,null,Hn.createElement(tO,{onClick:u},o),Hn.createElement(nO,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as cn}from"storybook/theming";function rO(e,t,n){return e.filter(r=>r.id===t||!r.storybookRoot?!0:n?r.storybookRoot===n:!1)}var oO=cn.div({marginBottom:"30px"}),iO=cn.div({display:"flex",gap:"8px",alignItems:"center"}),sO=cn(bn)({flex:1}),aO=cn(on)({padding:"8px 12px",whiteSpace:"nowrap"}),lO=cn.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),cO=cn.div(({theme:e})=>({marginTop:"6px",padding:"8px 10px",fontSize:"11px",lineHeight:1.4,color:e.color.warning,backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}40`,borderRadius:"4px"})),uO=cn.div(({theme:e})=>({marginBottom:"10px",padding:"8px 10px",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",backgroundColor:e.background.content})),pO=cn.div(({theme:e})=>({fontSize:"11px",lineHeight:1.5,color:e.color.mediumdark,marginBottom:"6px"})),dO=cn.div({display:"flex",alignItems:"center",gap:"6px"}),gO=cn.a(({theme:e})=>({flex:1,fontSize:"11px",fontFamily:e.typography.fonts.mono,color:e.color.secondary,textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","&:hover":{textDecoration:"underline"}})),fO=cn.button(({theme:e})=>({fontSize:"11px",padding:"3px 8px",borderRadius:"3px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,color:e.color.defaultText,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:e.background.app}}));function mk(e){return/figma\.com\/community\/file\//.test(e)}var zm=cn.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Nm=cn.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Om=cn(gs)({fontSize:"13px",padding:"6px 8px"}),mO=cn.div({display:"flex",gap:"8px",marginTop:"12px"}),hk=cn(on)({fontSize:"12px",padding:"6px 12px"}),hO=cn(hk)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),xO=cn.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),xk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=io(),{currentStorybookPath:s}=Je(),[a,u]=Gi(!1),[c,l]=Gi(!1),[d,g]=Gi(!1),[p,m]=Gi(!1),[v,I]=Gi({name:"",storybookRoot:"",figmaFileUrl:""}),A=e.find(f=>f.id===t),C=rO(e,t,s),D=f=>{n(f||null),u(!1)},R=async()=>{if(t)try{m(!0),await i(t),g(!1)}catch(f){console.error("Failed to delete project:",f)}finally{m(!1)}},_=process.env.STORYBOOK_UICOPILOT_FIGMA_KIT||"",[P,N]=Gi(!1),x=()=>{_&&navigator.clipboard.writeText(_).then(()=>{N(!0),setTimeout(()=>N(!1),2e3)})},k=()=>{if(u(!0),s){let f=s.replace(/\/+$/,"").split("/").pop()||"";I({storybookRoot:s,name:f,figmaFileUrl:""})}},w=async()=>{if(v.name.trim())try{l(!0);let f;if(v.figmaFileUrl.trim()){let S=v.figmaFileUrl.trim(),y=S.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);f=y?y[1]:S}let T=await o({name:v.name.trim(),storybookRoot:v.storybookRoot.trim()||void 0,figmaFileId:f});n(T.id),u(!1),I({name:"",storybookRoot:"",figmaFileUrl:""})}catch(f){console.error("Failed to create project:",f)}finally{l(!1)}},E=f=>{I(T=>{let S={...T,storybookRoot:f};if(!T.name&&f){let y=f.replace(/\/+$/,"").split("/").pop()||"";S.name=y}return S})};return ut.createElement(oO,null,ut.createElement(py,null,"Project"),ut.createElement(iO,null,ut.createElement(sO,{value:t||"",onChange:f=>D(f.target.value),disabled:r||a},ut.createElement("option",{value:""},"-- Select a project --"),C.map(f=>ut.createElement("option",{key:f.id,value:f.id},f.name))),ut.createElement(aO,{onClick:k,disabled:r,type:"button"},"+ New"),ut.createElement(xO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),ut.createElement(jr,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${A?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:A?.name,variant:"danger",onConfirm:R,onCancel:()=>g(!1)}),a&&ut.createElement(lO,null,ut.createElement(zm,null,ut.createElement(Nm,null,"Storybook Path (for fix generation)"),ut.createElement(Om,{type:"text",placeholder:"/path/to/your/storybook",value:v.storybookRoot,onChange:f=>E(f.target.value)})),ut.createElement(zm,null,ut.createElement(Nm,null,"Project Name *"),ut.createElement(Om,{type:"text",placeholder:"my-storybook",value:v.name,onChange:f=>{let T=f.target.value;I(S=>({...S,name:T}))}})),_&&ut.createElement(uO,null,ut.createElement(pO,null,ut.createElement("strong",null,"1.")," Open this template's Figma kit, then click"," ",ut.createElement("strong",null,"Open in Figma")," (or ",ut.createElement("strong",null,"Get a copy"),") to duplicate it to your own Figma workspace. ",ut.createElement("strong",null,"2.")," ","Paste the URL of your copy (",ut.createElement("code",null,"figma.com/design/\u2026"),") into the field below."),ut.createElement(dO,null,ut.createElement(gO,{href:_,target:"_blank",rel:"noopener noreferrer",title:_},_),ut.createElement(fO,{type:"button",onClick:x},P?"Copied!":"Copy"))),ut.createElement(zm,null,ut.createElement(Nm,null,"Your Figma File URL (after duplicating)"),ut.createElement(Om,{type:"text",placeholder:"https://www.figma.com/design/...",value:v.figmaFileUrl,onChange:f=>{let T=f.target.value;I(S=>({...S,figmaFileUrl:T}))}}),mk(v.figmaFileUrl)&&ut.createElement(cO,null,"\u26A0 This is a community file URL \u2014 it can't be read by the API. Use the duplicated copy's URL instead (see instructions above).")),ut.createElement(mO,null,ut.createElement(hk,{onClick:w,disabled:c||!v.name.trim()||!v.figmaFileUrl.trim()||mk(v.figmaFileUrl)},c?"Creating...":"Create"),ut.createElement(hO,{onClick:()=>{u(!1),I({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import wt,{useState as wc,useCallback as KC,useEffect as k4}from"react";import{styled as Lr}from"storybook/theming";import Hr,{useState as ra,useEffect as zO,useCallback as $m}from"react";import{styled as Lo}from"storybook/theming";Te();He();ct();Te();He();ct();import Vt,{useState as _m}from"react";import{styled as Wn,keyframes as yO}from"storybook/theming";var bO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},SO=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",wO=Wn.div({position:"relative",display:"inline-flex"}),vO=yO`
31
31
  0% { transform: rotate(0deg); }
32
32
  100% { transform: rotate(360deg); }
33
33
  `,kO=Wn.button(({score:e,isLoading:t,theme:n})=>{let r=()=>t?n.color.secondary:e?e>=80?n.color.positive:e>=50?n.color.warning:n.color.negative:n.color.mediumdark;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",fontSize:n.typography.size.s1,fontWeight:n.typography.weight.bold,fontFamily:n.typography.fonts.base,backgroundColor:r(),color:n.color.inverseText,cursor:t?"wait":"pointer",transition:"all 0.15s",border:"none",outline:"none","&:hover:not(:disabled)":{transform:"scale(1.05)",opacity:.9},"&:disabled":{cursor:"not-allowed",opacity:.7}}}),CO=Wn.span`
@@ -38,10 +38,10 @@ ${at}`).join(`
38
38
  border-top-color: #fff;
39
39
  border-radius: 50%;
40
40
  animation: ${vO} 0.8s linear infinite;
41
- `,TO=Wn.div(({theme:e})=>({position:"absolute",top:"100%",left:"0",marginTop:"6px",padding:"12px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:1e3,minWidth:"220px",fontSize:e.typography.size.s1})),IO=Wn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),FO=Wn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),EO=Wn.span(({score:e,theme:t})=>{let n=()=>e>=80?t.color.positive:e>=50?t.color.warning:t.color.negative;return{fontWeight:700,fontSize:t.typography.size.s3,color:n()}}),AO=Wn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),PO=Wn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),LO=Wn.span({display:"flex",alignItems:"center",gap:"4px"}),MO=Wn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),BO=Wn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),DO=Wn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),RO=Wn.ul(({theme:e})=>({margin:"8px 0 0 0",padding:"0 0 0 14px",fontSize:e.typography.size.s1,color:e.color.defaultText,"& li":{marginBottom:"2px"}})),xk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Je(),[n,r]=_m(!1),[o,i]=_m(!1),[s,a]=_m(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=q(),l=localStorage.getItem("uicopilot_session_token"),d=await ee(`${c}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({projectId:t,figmaFileUrl:e,figmaMetadata:{}})});if(!d.ok)throw new Error("Failed to check quality");let g=await d.json();a(g),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Vt.createElement(wO,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Vt.createElement(kO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Vt.createElement(Vt.Fragment,null,Vt.createElement(CO,null)," Checking..."):s?Vt.createElement(Vt.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Vt.createElement(Vt.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Vt.createElement(TO,null,Vt.createElement(IO,null,Vt.createElement(FO,null,"Figma Design Quality"),Vt.createElement(EO,{score:s.score},Math.round(s.score),"%")),Vt.createElement(AO,null,Object.entries(s.categories).map(([c,l])=>Vt.createElement(PO,{key:c},Vt.createElement(LO,null,Vt.createElement(MO,{status:l.status},SO(l.status)),bO[c]||c),Vt.createElement(BO,null,l.score)))),s.summary&&Vt.createElement(DO,null,s.summary),s.recommendations?.length>0&&Vt.createElement(RO,null,s.recommendations.slice(0,2).map((c,l)=>Vt.createElement("li",{key:l},c))))):null};var NO=Lo.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),OO=Lo.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),_O=Lo.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),$O=Lo.div({display:"flex",gap:"8px",alignItems:"center"}),UO=Lo.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:se,boxShadow:`0 0 0 1px ${se}`},"&::placeholder":{color:e.color.mediumlight}})),jO=Lo(on)({whiteSpace:"nowrap"}),HO=Lo.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"12px",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),WO=Lo.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),yk=()=>{let{selectedProjectId:e,projects:t}=Je(),{sessionToken:n}=ke(),{updateProject:r}=io(),o=t.find(R=>R.id===e),[i,s]=ra(""),[a,u]=ra(!1),[c,l]=ra(null),d=o?.figmaFileUrl||o?.figmaFileId||"";zO(()=>{s(d),l(null)},[o?.id,d]);let g=i!==d,p=$m(async()=>{if(!(!e||!g))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let R=q();try{await ee(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}ee(`${R}/api/figma/frames?projectId=${e}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${n}`}},6e4).catch(()=>{}),l({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>l(null),3e3)}catch(R){l({type:"error",message:R instanceof Error?R.message:"Failed to save"})}finally{u(!1)}},[e,i,g,r]),m=$m(R=>{R.key==="Enter"&&g&&!a&&p()},[g,a,p]),[k,I]=ra(!1),[A,C]=ra(!1),D=$m(async()=>{if(!(!e||!n))try{C(!0),await r(e,{figmaFileUrl:""});let R=q();await ee(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),await ee(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),s(""),I(!1),l({type:"success",message:"Figma file removed and cache cleared"}),setTimeout(()=>l(null),3e3)}catch{l({type:"error",message:"Failed to remove Figma file"})}finally{C(!1)}},[e,n,r]);return e?Hr.createElement(NO,null,Hr.createElement(OO,null,Hr.createElement(_O,null,"Figma File URL"),Hr.createElement(xk,{figmaFileUrl:d})),Hr.createElement($O,null,Hr.createElement(UO,{type:"text",value:i,onChange:R=>s(R.target.value),onKeyDown:m,placeholder:"https://www.figma.com/file/..."}),Hr.createElement(jO,{onClick:p,disabled:!g||a},a?"Saving...":"Save"),d&&Hr.createElement(HO,{onClick:()=>I(!0),title:"Remove Figma file and clear cache"},"\u{1F5D1}")),Hr.createElement(jr,{isOpen:k,title:"Remove Figma File",message:"This will remove the Figma file link and clear all cached data (thumbnails, enrichment). Component mappings will be preserved but won't have design data until a new file is linked.",confirmLabel:A?"Removing...":"Remove",variant:"danger",onConfirm:D,onCancel:()=>I(!1)}),c&&Hr.createElement(WO,{variant:c.type},c.message)):null};import It,{useState as hc,useEffect as t4}from"react";import{styled as rr}from"storybook/theming";Te();He();import et,{useState as Xi,useEffect as N$,useCallback as Ro}from"react";import{styled as tn}from"storybook/theming";He();He();_e();import Q,{useState as Yi,useEffect as iC,useMemo as Zm,useCallback as sC}from"react";import{styled as Ye}from"storybook/theming";ct();import Re,{useState as oC,useEffect as VO,memo as GO}from"react";import{styled as ye}from"storybook/theming";var bk=ye.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10001}),Sk=ye.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"6px",width:"90%",maxWidth:"900px",maxHeight:"85vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.3)",border:`1px solid ${e.appBorderColor}`})),wk=ye.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),vk=ye.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),kk=ye(En)({fontSize:"20px",padding:"4px 8px"}),Ck=ye.div({flex:1,overflow:"auto",padding:"20px"}),Tk=ye(So)({fontSize:"14px",marginBottom:"16px"}),Um=ye.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Ik=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s","&:hover":{borderColor:se,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),jm=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Fk=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Ek=ye.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),oa=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",height:"100%",minHeight:"80px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:e.color.mediumdark})),Hm=ye.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:se,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),ia=ye.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Wm=ye.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Vm=ye.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Gm=ye.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),qm=ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Ak=ye.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),rc=ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Pk=ye.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Lk=ye.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),Mk=ye.button(({theme:e})=>({position:"absolute",top:"8px",left:"8px",width:"24px",height:"24px",padding:0,background:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"14px",color:e.color.defaultText,zIndex:10,transition:"all 0.2s","&:hover":{background:e.background.hoverable,borderColor:se}})),Bk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${se}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.08)",height:"auto",minHeight:"200px","&:hover":{borderColor:se,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Dk=ye.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:se,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),Rk=ye.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),Bte=ye.div(({theme:e})=>({padding:"20px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",backgroundColor:e.background.app,border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",gridColumn:"1 / -1"})),zk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${se}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),Nk=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Ym=ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"8px 12px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"}})),Ok=ye.span(({theme:e})=>({display:"inline-block",padding:"3px 8px",background:e.background.app,borderRadius:"4px",fontSize:"11px",color:e.color.defaultText,border:`1px solid ${e.appBorderColor}`,lineHeight:1.2})),_k=ye.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),$k=ye.span(({theme:e})=>({color:e.color.defaultText})),oc=ye.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.appBorderColor,borderRadius:"4px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.hoverable}, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Uk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),jk=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Hk=ye.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),Wk=ye(bn)({flex:1,width:"auto"}),Vk=ye.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),Gk=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",marginBottom:"8px",backgroundColor:e.background.hoverable||"#f0f9ff",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s1,flexWrap:"wrap"})),qk=ye.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),Yk=ye.span(({theme:e})=>({color:e.color.defaultText})),Kk=ye.button(({theme:e})=>({padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.lightest,backgroundColor:e.color.secondary,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer","&:hover":{opacity:.9}})),Xk=ye.button(({theme:e})=>({padding:"2px 6px",fontSize:e.typography.size.s1,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer","&:hover":{color:e.color.defaultText}})),Qk=ye.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),ic=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),sa=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),qi=ye(bn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),sc=ye.button(({theme:e})=>({padding:"6px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.color.negative,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:`${e.color.negative}15`}})),Jk=ye.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),Zk=ye.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:se,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),eC=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Km=ye.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?se:e.appBorderColor}`,borderRadius:"8px",backgroundColor:t?"rgba(234, 88, 12, 0.06)":e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",position:"relative","&:hover":{borderColor:se,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Xm=ye.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?se:e.appBorderColor}`,backgroundColor:t?se:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),tC=ye.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),nC=ye.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:se,color:e.color.lightest,fontSize:"14px",fontWeight:500,cursor:t?"not-allowed":"pointer",opacity:t?.6:1,transition:"all 0.2s","&:hover":{backgroundColor:t?e.color.mediumdark:se,opacity:t?.6:.9}})),rC=ye.span(({theme:e})=>({display:"inline-block",padding:"1px 5px",marginLeft:"6px",borderRadius:"3px",fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:"rgba(16, 185, 129, 0.15)",color:e.color.positive,verticalAlign:"middle"}));_e();import{styled as qO}from"storybook/theming";var YO=qO.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover":{borderColor:e.color.secondary,color:e.color.secondary}})),Qm=GO(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=oC(!1),[a,u]=oC(!1);return VO(()=>{s(!1),u(!1)},[e]),i?Re.createElement(oa,null,Re.createElement(Wm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Re.createElement(ia,null,"Failed to load")):e?Re.createElement(Re.Fragment,null,!a&&Re.createElement(oa,{style:{position:"absolute",inset:0}},Re.createElement(Hm,null),Re.createElement(ia,null,"Loading...")),Re.createElement(Ek,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?Re.createElement(oa,null,Re.createElement(Wm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Re.createElement(ia,null,o?"Render failed":"No preview")):Re.createElement(oa,null,Re.createElement(Hm,null),Re.createElement(ia,null,"Loading..."))}),aa=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,variantFailed:i,isLoadingVariants:s=!1,isExpanded:a,isNew:u=!1,onToggleExpand:c,onSelect:l,multiSelect:d=!1,selectedFrames:g=new Set,variantFilters:p=[],variantPage:m=1,onShowMore:k})=>{let A=e.type==="COMPONENT_SET",C=A&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],R=Re.useMemo(()=>D.length===0?[]:p.some(N=>N.value)?D.filter(N=>N.variantProperties?p.every(x=>x.value?N.variantProperties?.[x.property]===x.value:!0):!1):D,[D,p]),_=N=>{if(A){c(e.id,N);return}l(e)},P=d?Km:Ik;return Re.createElement(Re.Fragment,null,Re.createElement(P,{onClick:_,title:e.name,isSelected:d?g.has(e.id):void 0,style:{cursor:"pointer"}},d&&!C&&Re.createElement(Xm,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),A?Re.createElement(Fk,null,C&&Re.createElement(Mk,{onClick:N=>c(e.id,N),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),C&&Re.createElement(Dk,null,R.length>0&&R.length!==D.length?`${R.length} / ${D.length}`:e.childCount??D.length," ","variants"),Re.createElement(Qm,{src:t,alt:e.name,isComponentSet:!0})):Re.createElement(jm,null,Re.createElement(Qm,{src:t,alt:e.name,isComponentSet:!1})),Re.createElement(Vm,null,Re.createElement(Gm,null,e.name,u&&Re.createElement(rC,null,"New")),Re.createElement(qm,null,e.type))),C&&a&&s&&Re.createElement(Re.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((N,x)=>Re.createElement(zk,{key:`skeleton-${x}`},Re.createElement(Nk,null),Re.createElement(Ym,{width:"80%"}),Re.createElement(Ym,{width:"50%"})))),C&&a&&!s&&R.slice(0,m*50).map(N=>Re.createElement(Jm,{key:N.id,variant:N,thumbnail:r?.[N.id]||n[N.id],onSelect:l,multiSelect:d,isSelected:g.has(N.id),loadingDone:!!t||r!==void 0&&N.id in(r||{})||!!i?.has(N.id),failed:i?.has(N.id)})),C&&a&&!s&&R.length>m*50&&Re.createElement(YO,{onClick:()=>k?.(e.id)},"Show more (",R.length-m*50," ","remaining)"))},Jm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>Re.createElement(r?Km:Bk,{onClick:()=>{b.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Re.createElement(Xm,{isSelected:o},o?"\u2713":""),Re.createElement(jm,null,Re.createElement(Qm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),Re.createElement(Vm,null,Re.createElement(Gm,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Re.createElement(Rk,null,Object.entries(e.variantProperties).map(([c,l])=>Re.createElement(Ok,{key:c},Re.createElement(_k,null,c,":")," ",Re.createElement($k,null,l)))),Re.createElement(qm,{style:{marginTop:"6px"}},"VARIANT")));var KO=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),XO=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),QO=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),aC=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),lC=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),ac=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),JO=Ye(bn)({flex:1,width:"auto"}),cC=Ye(So)({flex:1,fontSize:"13px"}),ZO=Ye.div({flex:1,overflow:"auto",padding:"8px"}),e_=Ye.div(({theme:e,selected:t,mapped:n})=>({padding:"12px",marginBottom:"8px",borderRadius:"8px",border:`2px solid ${t?e.color.secondary:n?e.color.positive:e.appBorderColor}`,backgroundColor:t?`${e.color.secondary}10`:e.background.content,cursor:"pointer",transition:"all 0.2s","&:hover":{borderColor:t?e.color.secondary:e.color.mediumlight}})),t_=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),n_=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),r_=Ye.span(({theme:e,mapped:t})=>({fontSize:"10px",fontWeight:500,padding:"2px 6px",borderRadius:"4px",backgroundColor:t?`${e.color.positive}20`:e.background.hoverable,color:t?e.color.positive:e.color.mediumdark})),o_=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),i_=Ye.div(({theme:e})=>({marginTop:"8px",padding:"8px",backgroundColor:`${e.color.positive}10`,borderRadius:"6px",fontSize:"11px",color:e.color.positive,display:"flex",alignItems:"center",gap:"8px",position:"relative"})),s_=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),a_=Ye.div({flex:1,overflow:"hidden"}),l_=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),c_=Ye.div(({theme:e})=>({position:"absolute",bottom:"100%",left:"0",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)",border:`1px solid ${e.appBorderColor}`,padding:"8px",zIndex:100,maxWidth:"280px",animation:"fadeIn 0.15s ease-out","@keyframes fadeIn":{from:{opacity:0,transform:"translateY(4px)"},to:{opacity:1,transform:"translateY(0)"}}})),u_=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),p_=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),d_=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),g_=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),eh=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),f_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),th=20,m_=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),h_=Ye.button(({theme:e,disabled:t})=>({padding:"8px 16px",fontSize:"13px",fontWeight:500,color:t?e.color.mediumdark:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${t?e.appBorderColor:e.color.secondary}`,borderRadius:"6px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"all 0.2s","&:hover":{backgroundColor:t?"transparent":`${e.color.secondary}10`}})),x_=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),y_=Ye.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"13px",fontWeight:500,color:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${e.color.secondary}`,borderRadius:"4px",cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:`${e.color.secondary}10`}})),b_=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),nh=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),rh=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),S_=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),w_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),uC=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),pC=Ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),dC=Ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"12px",animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),v_=()=>Q.createElement(w_,null,Array.from({length:8}).map((e,t)=>Q.createElement(uC,{key:t},Q.createElement(pC,null),Q.createElement(dC,{width:`${60+t%3*15}%`})))),k_=Ye.div(({theme:e})=>({padding:"12px 16px",backgroundColor:`${e.color.secondary}10`,borderBottom:`1px solid ${e.appBorderColor}`,fontSize:"13px",color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),C_=Ye.div({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.8)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:50,gap:"8px"}),T_=Ye.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),I_=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),gC=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=ta({projectId:i,limit:th,enabled:!!i}),[a,u]=Yi("all"),[c,l]=Yi(""),[d,g]=Yi(null),[p,m]=Yi(1),[k,I]=Yi(null),[A,C]=Yi(!1),D=Zm(()=>{let f=new Set;return e.forEach(T=>{T.componentTitle&&f.add(T.componentTitle)}),Array.from(f).sort()},[e]),R=Zm(()=>e.filter(f=>{if(a!=="all"&&f.componentTitle!==a)return!1;if(c){let T=c.toLowerCase();return f.name.toLowerCase().includes(T)||f.title.toLowerCase().includes(T)}return!0}),[e,a,c]),_=d?s.frames.find(f=>f.id===d):null,P=Zm(()=>{if(!d)return[];let f=s.variantChildren[d]||[];return f.length===0?[]:s.variantFilters.some(T=>T.value)?f.filter(T=>T.variantProperties?s.variantFilters.every(S=>S.value?T.variantProperties?.[S.property]===S.value:!0):!1):f},[d,s.variantChildren,s.variantFilters]),N=P.slice(0,p*th),x=P.length>p*th;iC(()=>{if(!d||N.length===0)return;let f=N.map(T=>T.id);s.fetchVariantThumbnails(d,f)},[d,N.length,p]),iC(()=>{C(!1)},[]);let v=sC(async f=>{if(n)try{let T=q(),S=localStorage.getItem("uicopilot_session_token");if(!(await ee(`${T}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:f.id,name:f.name})})).ok)throw new Error("Failed to save mapping");o(n,f.id,f.name)}catch(T){b.error("[MapStoriesTab] Error saving mapping:",T)}},[n,i,o]),w=sC((f,T)=>{if(T.stopPropagation(),d===f){g(null),m(1);return}g(f),m(1),!s.variantThumbnails[f]&&!s.loadingVariants.has(f)&&s.toggleExpanded(f,T)},[d,s]),E=e.find(f=>f.id===n);return t?Q.createElement(S_,null,"Loading stories..."):Q.createElement(KO,null,Q.createElement(XO,null,Q.createElement(aC,null,Q.createElement(lC,null,"Storybook Stories"),Q.createElement(ac,null,Q.createElement(JO,{value:a,onChange:f=>u(f.target.value)},Q.createElement("option",{value:"all"},"All Components"),D.map(f=>Q.createElement("option",{key:f,value:f},f)))),Q.createElement(ac,null,Q.createElement(cC,{type:"text",placeholder:"Search stories...",value:c,onChange:f=>l(f.target.value)}))),Q.createElement(ZO,null,R.length===0?Q.createElement(rh,null,"No stories found"):R.map(f=>Q.createElement(e_,{key:f.id,selected:f.id===n,mapped:!!f.figmaMapping,onClick:()=>r(f.id)},Q.createElement(t_,null,Q.createElement(n_,null,f.name),Q.createElement(r_,{mapped:!!f.figmaMapping},f.figmaMapping?"Mapped":"Unmapped")),Q.createElement(o_,null,f.title),f.figmaMapping&&Q.createElement(i_,{onMouseEnter:()=>I(f.id),onMouseLeave:()=>I(null)},(()=>{let T=f.figmaMapping?.figmaNodeId,S=T?s.resolveThumbnail(T):void 0;return Q.createElement(Q.Fragment,null,S?Q.createElement(s_,{src:S,alt:f.figmaMapping?.figmaFrameName||""}):Q.createElement("span",null,"\u{1F517}"),k===f.id&&S&&Q.createElement(c_,null,Q.createElement(u_,{src:S,alt:f.figmaMapping?.figmaFrameName||""}),Q.createElement(p_,null,f.figmaMapping?.figmaFrameName)))})(),Q.createElement(a_,null,Q.createElement(l_,null,f.figmaMapping.figmaFrameName))))))),Q.createElement(QO,null,n?Q.createElement(Q.Fragment,null,Q.createElement(k_,null,Q.createElement("span",null,"Click a Figma component below to link it to"," ",Q.createElement("strong",null,E?.name))),Q.createElement(aC,null,Q.createElement(lC,null,"Figma Components"),Q.createElement(ac,null,Q.createElement(g_,null,Q.createElement(eh,null,Q.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:f=>s.setShowComponentSets(f.target.checked)}),"Component Sets"),Q.createElement(eh,null,Q.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:f=>s.setShowFrames(f.target.checked)}),"Frames"),Q.createElement(eh,null,Q.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:f=>s.setShowComponents(f.target.checked)}),"Components")),s.availablePages.length>1&&Q.createElement(qi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:f=>s.setFigmaPage(f.target.value)},Q.createElement("option",{value:""},"All pages"),s.availablePages.map(f=>Q.createElement("option",{key:f,value:f},f)))),s.availableFilters.length>0&&Q.createElement(ic,null,Q.createElement(sa,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:f,values:T})=>{let S=s.variantFilters.find(y=>y.property===f);return Q.createElement(qi,{key:f,isActive:!!S?.value,value:S?.value||"",onChange:y=>s.handleFilterChange(f,y.target.value)},Q.createElement("option",{value:""},f),T.map(y=>Q.createElement("option",{key:y,value:y},f,"=",y)))}),s.availableFilters.length>5&&Q.createElement(sa,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(f=>f.value)&&Q.createElement(sc,{onClick:s.clearFilters},"Clear All")),Q.createElement(ac,null,Q.createElement(cC,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:f=>s.setSearch(f.target.value)}))),Q.createElement(d_,null,A&&Q.createElement(C_,null,Q.createElement(T_,null),Q.createElement(I_,null,"Loading thumbnails...")),s.isLoading?Q.createElement(v_,null):s.filteredFrames.length===0?Q.createElement(rh,null,Q.createElement("span",null,"No components match. Try a different search term, or check that your Figma file has component sets defined.")):Q.createElement(f_,null,d&&_?Q.createElement(Q.Fragment,null,Q.createElement(x_,null,Q.createElement(y_,{onClick:()=>{g(null),m(1)}},"Back"),Q.createElement(b_,null,_.name)),s.loadingVariants.has(d)?Q.createElement(Q.Fragment,null,Q.createElement(nh,null,"Loading ",_.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,_.childCount??8)}).map((f,T)=>Q.createElement(uC,{key:`variant-skeleton-${T}`},Q.createElement(pC,null),Q.createElement(dC,{width:`${60+T%3*15}%`})))):Q.createElement(Q.Fragment,null,Q.createElement(nh,null,"Showing ",N.length," of"," ",P.length," variants"),N.map(f=>Q.createElement(Jm,{key:f.id,variant:f,thumbnail:s.variantThumbnails[d]?.[f.id]||s.thumbnails[f.id],onSelect:v,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d),failed:s.variantFailed[d]?.has(f.id)})))):Q.createElement(Q.Fragment,null,Q.createElement(nh,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(f=>Q.createElement(aa,{key:f.id,frame:f,thumbnail:s.thumbnails[f.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[f.id],variantChildren:s.variantChildren[f.id],variantFailed:s.variantFailed[f.id],isLoadingVariants:s.loadingVariants.has(f.id),isExpanded:!1,onToggleExpand:w,onSelect:v,variantFilters:s.variantFilters}))),(d?x:s.hasMore)&&Q.createElement(m_,null,Q.createElement(h_,{disabled:s.loadingMore,onClick:async()=>{d?m(f=>f+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Q.createElement(rh,null,Q.createElement("span",null,"\u{1F448} Pick a story from the left, then browse your Figma file to find a matching frame. The mapping is saved per story."))))};He();import ot,{useState as oh,useMemo as fC,useCallback as mC}from"react";import{styled as _t}from"storybook/theming";ct();var F_=_t.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),E_=_t.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),A_=_t(bn)({width:"auto",minWidth:"200px"}),P_=_t(So)({fontSize:"13px",minWidth:"250px"}),L_=_t.button(({theme:e,active:t})=>({padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${t?e.color.positive:e.appBorderColor}`,borderRadius:"6px",backgroundColor:t?`${e.color.positive}15`:e.background.content,color:t?e.color.positive:e.color.mediumdark,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{borderColor:e.color.positive}})),M_=_t.button(({theme:e})=>({marginLeft:"auto",padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{backgroundColor:e.background.hoverable}})),B_=_t.div({flex:1,overflow:"auto"}),D_=_t.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),R_=_t.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),lc=_t.th(({theme:e})=>({padding:"12px 20px",textAlign:"left",fontWeight:600,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px",color:e.color.mediumdark,borderBottom:`1px solid ${e.appBorderColor}`})),z_=_t.tbody({}),N_=_t.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),cc=_t.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),O_=_t.div({display:"flex",flexDirection:"column",gap:"2px"}),__=_t.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),$_=_t.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),U_=_t.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),j_=_t.div({display:"flex",alignItems:"center",gap:"8px"}),H_=_t.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),W_=_t.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),hC=_t.button(({theme:e,variant:t})=>({padding:"6px 12px",fontSize:"12px",fontWeight:500,border:`1px solid ${t==="link"?e.color.secondary:e.color.negative}`,borderRadius:"4px",backgroundColor:t==="link"?`${e.color.secondary}10`:`${e.color.negative}10`,color:t==="link"?e.color.secondary:e.color.negative,cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:t==="link"?`${e.color.secondary}20`:`${e.color.negative}20`}})),V_=_t.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),G_=_t.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),xC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=oh("all"),[a,u]=oh(""),[c,l]=oh(!0),d=fC(()=>{let I=new Set;return e.forEach(A=>{A.componentTitle&&I.add(A.componentTitle)}),Array.from(I).sort()},[e]),g=fC(()=>e.filter(I=>{if(i!=="all"&&I.componentTitle!==i||!c&&!I.figmaMapping)return!1;if(a){let A=a.toLowerCase();return I.name.toLowerCase().includes(A)||I.title.toLowerCase().includes(A)||(I.figmaMapping?.figmaFrameName?.toLowerCase().includes(A)??!1)}return!0}),[e,i,a,c]),p=mC(async I=>{try{let A=q(),C=localStorage.getItem("uicopilot_session_token");if(!(await ee(`${A}/api/mappings?projectId=${o}&storyId=${I}`,{method:"DELETE",headers:{Authorization:`Bearer ${C}`}})).ok)throw new Error("Failed to delete mapping");r(I)}catch(A){console.error("[ViewAllMappingsTab] Error unlinking:",A)}},[o,r]),m=mC(()=>{let I=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),A=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),C=URL.createObjectURL(A),D=document.createElement("a");D.href=C,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(C)},[e]);if(t)return ot.createElement(G_,null,"Loading mappings...");let k=e.filter(I=>I.figmaMapping).length;return ot.createElement(F_,null,ot.createElement(E_,null,ot.createElement(A_,{value:i,onChange:I=>s(I.target.value)},ot.createElement("option",{value:"all"},"All Components"),d.map(I=>ot.createElement("option",{key:I,value:I},I))),ot.createElement(P_,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:I=>u(I.target.value)}),ot.createElement(L_,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),ot.createElement(M_,{onClick:m,disabled:k===0},"\u{1F4E5} Export JSON")),g.length===0?ot.createElement(V_,null,ot.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):ot.createElement(B_,null,ot.createElement(D_,null,ot.createElement(R_,null,ot.createElement("tr",null,ot.createElement(lc,{style:{width:"35%"}},"Story"),ot.createElement(lc,{style:{width:"35%"}},"Figma Component"),ot.createElement(lc,{style:{width:"15%"}},"Status"),ot.createElement(lc,{style:{width:"15%"}},"Actions"))),ot.createElement(z_,null,g.map(I=>ot.createElement(N_,{key:I.id,mapped:!!I.figmaMapping},ot.createElement(cc,null,ot.createElement(O_,null,ot.createElement(__,null,I.name),ot.createElement($_,null,I.title))),ot.createElement(cc,null,ot.createElement(U_,{mapped:!!I.figmaMapping},I.figmaMapping?ot.createElement(ot.Fragment,null,ot.createElement("span",null,"\u{1F3A8}"),I.figmaMapping.figmaFrameName):"\u2014")),ot.createElement(cc,null,ot.createElement(j_,null,ot.createElement(H_,{mapped:!!I.figmaMapping}),ot.createElement(W_,{mapped:!!I.figmaMapping},I.figmaMapping?"Mapped":"Unmapped"))),ot.createElement(cc,null,I.figmaMapping?ot.createElement(hC,{variant:"unlink",onClick:()=>p(I.id)},"Unlink"):ot.createElement(hC,{variant:"link",onClick:()=>n(I.id)},"Link"))))))))};import Ee,{useState as mc,useMemo as CC}from"react";import{styled as ft}from"storybook/theming";import yC from"react";import{styled as bC,keyframes as q_}from"storybook/theming";var Y_=q_`
41
+ `,TO=Wn.div(({theme:e})=>({position:"absolute",top:"100%",left:"0",marginTop:"6px",padding:"12px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:1e3,minWidth:"220px",fontSize:e.typography.size.s1})),IO=Wn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),FO=Wn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),EO=Wn.span(({score:e,theme:t})=>{let n=()=>e>=80?t.color.positive:e>=50?t.color.warning:t.color.negative;return{fontWeight:700,fontSize:t.typography.size.s3,color:n()}}),AO=Wn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),PO=Wn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),LO=Wn.span({display:"flex",alignItems:"center",gap:"4px"}),MO=Wn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),BO=Wn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),DO=Wn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),RO=Wn.ul(({theme:e})=>({margin:"8px 0 0 0",padding:"0 0 0 14px",fontSize:e.typography.size.s1,color:e.color.defaultText,"& li":{marginBottom:"2px"}})),yk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Je(),[n,r]=_m(!1),[o,i]=_m(!1),[s,a]=_m(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=q(),l=localStorage.getItem("uicopilot_session_token"),d=await ee(`${c}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({projectId:t,figmaFileUrl:e,figmaMetadata:{}})});if(!d.ok)throw new Error("Failed to check quality");let g=await d.json();a(g),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Vt.createElement(wO,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Vt.createElement(kO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Vt.createElement(Vt.Fragment,null,Vt.createElement(CO,null)," Checking..."):s?Vt.createElement(Vt.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Vt.createElement(Vt.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Vt.createElement(TO,null,Vt.createElement(IO,null,Vt.createElement(FO,null,"Figma Design Quality"),Vt.createElement(EO,{score:s.score},Math.round(s.score),"%")),Vt.createElement(AO,null,Object.entries(s.categories).map(([c,l])=>Vt.createElement(PO,{key:c},Vt.createElement(LO,null,Vt.createElement(MO,{status:l.status},SO(l.status)),bO[c]||c),Vt.createElement(BO,null,l.score)))),s.summary&&Vt.createElement(DO,null,s.summary),s.recommendations?.length>0&&Vt.createElement(RO,null,s.recommendations.slice(0,2).map((c,l)=>Vt.createElement("li",{key:l},c))))):null};var NO=Lo.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),OO=Lo.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),_O=Lo.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),$O=Lo.div({display:"flex",gap:"8px",alignItems:"center"}),UO=Lo.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:se,boxShadow:`0 0 0 1px ${se}`},"&::placeholder":{color:e.color.mediumlight}})),jO=Lo(on)({whiteSpace:"nowrap"}),HO=Lo.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"12px",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),WO=Lo.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),bk=()=>{let{selectedProjectId:e,projects:t}=Je(),{sessionToken:n}=ke(),{updateProject:r}=io(),o=t.find(R=>R.id===e),[i,s]=ra(""),[a,u]=ra(!1),[c,l]=ra(null),d=o?.figmaFileUrl||o?.figmaFileId||"";zO(()=>{s(d),l(null)},[o?.id,d]);let g=i!==d,p=$m(async()=>{if(!(!e||!g))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let R=q();try{await ee(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}ee(`${R}/api/figma/frames?projectId=${e}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${n}`}},6e4).catch(()=>{}),l({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>l(null),3e3)}catch(R){l({type:"error",message:R instanceof Error?R.message:"Failed to save"})}finally{u(!1)}},[e,i,g,r]),m=$m(R=>{R.key==="Enter"&&g&&!a&&p()},[g,a,p]),[v,I]=ra(!1),[A,C]=ra(!1),D=$m(async()=>{if(!(!e||!n))try{C(!0),await r(e,{figmaFileUrl:""});let R=q();await ee(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),await ee(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),s(""),I(!1),l({type:"success",message:"Figma file removed and cache cleared"}),setTimeout(()=>l(null),3e3)}catch{l({type:"error",message:"Failed to remove Figma file"})}finally{C(!1)}},[e,n,r]);return e?Hr.createElement(NO,null,Hr.createElement(OO,null,Hr.createElement(_O,null,"Figma File URL"),Hr.createElement(yk,{figmaFileUrl:d})),Hr.createElement($O,null,Hr.createElement(UO,{type:"text",value:i,onChange:R=>s(R.target.value),onKeyDown:m,placeholder:"https://www.figma.com/file/..."}),Hr.createElement(jO,{onClick:p,disabled:!g||a},a?"Saving...":"Save"),d&&Hr.createElement(HO,{onClick:()=>I(!0),title:"Remove Figma file and clear cache"},"\u{1F5D1}")),Hr.createElement(jr,{isOpen:v,title:"Remove Figma File",message:"This will remove the Figma file link and clear all cached data (thumbnails, enrichment). Component mappings will be preserved but won't have design data until a new file is linked.",confirmLabel:A?"Removing...":"Remove",variant:"danger",onConfirm:D,onCancel:()=>I(!1)}),c&&Hr.createElement(WO,{variant:c.type},c.message)):null};import It,{useState as hc,useEffect as t4}from"react";import{styled as rr}from"storybook/theming";Te();He();import et,{useState as Xi,useEffect as N$,useCallback as Ro}from"react";import{styled as tn}from"storybook/theming";He();He();_e();import Q,{useState as Yi,useEffect as sC,useMemo as Zm,useCallback as aC}from"react";import{styled as Ye}from"storybook/theming";ct();import Re,{useState as iC,useEffect as VO,memo as GO}from"react";import{styled as ye}from"storybook/theming";var Sk=ye.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10001}),wk=ye.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"6px",width:"90%",maxWidth:"900px",maxHeight:"85vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.3)",border:`1px solid ${e.appBorderColor}`})),vk=ye.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),kk=ye.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),Ck=ye(En)({fontSize:"20px",padding:"4px 8px"}),Tk=ye.div({flex:1,overflow:"auto",padding:"20px"}),Ik=ye(So)({fontSize:"14px",marginBottom:"16px"}),Um=ye.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Fk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s","&:hover":{borderColor:se,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),jm=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Ek=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Ak=ye.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),oa=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",height:"100%",minHeight:"80px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:e.color.mediumdark})),Hm=ye.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:se,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),ia=ye.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Wm=ye.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Vm=ye.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Gm=ye.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),qm=ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Pk=ye.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),rc=ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Lk=ye.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Mk=ye.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),Bk=ye.button(({theme:e})=>({position:"absolute",top:"8px",left:"8px",width:"24px",height:"24px",padding:0,background:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"14px",color:e.color.defaultText,zIndex:10,transition:"all 0.2s","&:hover":{background:e.background.hoverable,borderColor:se}})),Dk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${se}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.08)",height:"auto",minHeight:"200px","&:hover":{borderColor:se,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Rk=ye.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:se,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),zk=ye.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),Bte=ye.div(({theme:e})=>({padding:"20px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",backgroundColor:e.background.app,border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",gridColumn:"1 / -1"})),Nk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${se}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),Ok=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Ym=ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"8px 12px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"}})),_k=ye.span(({theme:e})=>({display:"inline-block",padding:"3px 8px",background:e.background.app,borderRadius:"4px",fontSize:"11px",color:e.color.defaultText,border:`1px solid ${e.appBorderColor}`,lineHeight:1.2})),$k=ye.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),Uk=ye.span(({theme:e})=>({color:e.color.defaultText})),oc=ye.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.appBorderColor,borderRadius:"4px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.hoverable}, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),jk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),Hk=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Wk=ye.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),Vk=ye(bn)({flex:1,width:"auto"}),Gk=ye.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),qk=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",marginBottom:"8px",backgroundColor:e.background.hoverable||"#f0f9ff",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s1,flexWrap:"wrap"})),Yk=ye.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),Kk=ye.span(({theme:e})=>({color:e.color.defaultText})),Xk=ye.button(({theme:e})=>({padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.lightest,backgroundColor:e.color.secondary,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer","&:hover":{opacity:.9}})),Qk=ye.button(({theme:e})=>({padding:"2px 6px",fontSize:e.typography.size.s1,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer","&:hover":{color:e.color.defaultText}})),Jk=ye.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),ic=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),sa=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),qi=ye(bn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),sc=ye.button(({theme:e})=>({padding:"6px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.color.negative,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:`${e.color.negative}15`}})),Zk=ye.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),eC=ye.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:se,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),tC=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Km=ye.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?se:e.appBorderColor}`,borderRadius:"8px",backgroundColor:t?"rgba(234, 88, 12, 0.06)":e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",position:"relative","&:hover":{borderColor:se,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Xm=ye.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?se:e.appBorderColor}`,backgroundColor:t?se:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),nC=ye.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),rC=ye.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:se,color:e.color.lightest,fontSize:"14px",fontWeight:500,cursor:t?"not-allowed":"pointer",opacity:t?.6:1,transition:"all 0.2s","&:hover":{backgroundColor:t?e.color.mediumdark:se,opacity:t?.6:.9}})),oC=ye.span(({theme:e})=>({display:"inline-block",padding:"1px 5px",marginLeft:"6px",borderRadius:"3px",fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:"rgba(16, 185, 129, 0.15)",color:e.color.positive,verticalAlign:"middle"}));_e();import{styled as qO}from"storybook/theming";var YO=qO.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover":{borderColor:e.color.secondary,color:e.color.secondary}})),Qm=GO(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=iC(!1),[a,u]=iC(!1);return VO(()=>{s(!1),u(!1)},[e]),i?Re.createElement(oa,null,Re.createElement(Wm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Re.createElement(ia,null,"Failed to load")):e?Re.createElement(Re.Fragment,null,!a&&Re.createElement(oa,{style:{position:"absolute",inset:0}},Re.createElement(Hm,null),Re.createElement(ia,null,"Loading...")),Re.createElement(Ak,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?Re.createElement(oa,null,Re.createElement(Wm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Re.createElement(ia,null,o?"Render failed":"No preview")):Re.createElement(oa,null,Re.createElement(Hm,null),Re.createElement(ia,null,"Loading..."))}),aa=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,variantFailed:i,isLoadingVariants:s=!1,isExpanded:a,isNew:u=!1,onToggleExpand:c,onSelect:l,multiSelect:d=!1,selectedFrames:g=new Set,variantFilters:p=[],variantPage:m=1,onShowMore:v})=>{let A=e.type==="COMPONENT_SET",C=A&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],R=Re.useMemo(()=>D.length===0?[]:p.some(N=>N.value)?D.filter(N=>N.variantProperties?p.every(x=>x.value?N.variantProperties?.[x.property]===x.value:!0):!1):D,[D,p]),_=N=>{if(A){c(e.id,N);return}l(e)},P=d?Km:Fk;return Re.createElement(Re.Fragment,null,Re.createElement(P,{onClick:_,title:e.name,isSelected:d?g.has(e.id):void 0,style:{cursor:"pointer"}},d&&!C&&Re.createElement(Xm,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),A?Re.createElement(Ek,null,C&&Re.createElement(Bk,{onClick:N=>c(e.id,N),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),C&&Re.createElement(Rk,null,R.length>0&&R.length!==D.length?`${R.length} / ${D.length}`:e.childCount??D.length," ","variants"),Re.createElement(Qm,{src:t,alt:e.name,isComponentSet:!0})):Re.createElement(jm,null,Re.createElement(Qm,{src:t,alt:e.name,isComponentSet:!1})),Re.createElement(Vm,null,Re.createElement(Gm,null,e.name,u&&Re.createElement(oC,null,"New")),Re.createElement(qm,null,e.type))),C&&a&&s&&Re.createElement(Re.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((N,x)=>Re.createElement(Nk,{key:`skeleton-${x}`},Re.createElement(Ok,null),Re.createElement(Ym,{width:"80%"}),Re.createElement(Ym,{width:"50%"})))),C&&a&&!s&&R.slice(0,m*50).map(N=>Re.createElement(Jm,{key:N.id,variant:N,thumbnail:r?.[N.id]||n[N.id],onSelect:l,multiSelect:d,isSelected:g.has(N.id),loadingDone:!!t||r!==void 0&&N.id in(r||{})||!!i?.has(N.id),failed:i?.has(N.id)})),C&&a&&!s&&R.length>m*50&&Re.createElement(YO,{onClick:()=>v?.(e.id)},"Show more (",R.length-m*50," ","remaining)"))},Jm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>Re.createElement(r?Km:Dk,{onClick:()=>{b.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Re.createElement(Xm,{isSelected:o},o?"\u2713":""),Re.createElement(jm,null,Re.createElement(Qm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),Re.createElement(Vm,null,Re.createElement(Gm,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Re.createElement(zk,null,Object.entries(e.variantProperties).map(([c,l])=>Re.createElement(_k,{key:c},Re.createElement($k,null,c,":")," ",Re.createElement(Uk,null,l)))),Re.createElement(qm,{style:{marginTop:"6px"}},"VARIANT")));var KO=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),XO=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),QO=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),lC=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),cC=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),ac=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),JO=Ye(bn)({flex:1,width:"auto"}),uC=Ye(So)({flex:1,fontSize:"13px"}),ZO=Ye.div({flex:1,overflow:"auto",padding:"8px"}),e_=Ye.div(({theme:e,selected:t,mapped:n})=>({padding:"12px",marginBottom:"8px",borderRadius:"8px",border:`2px solid ${t?e.color.secondary:n?e.color.positive:e.appBorderColor}`,backgroundColor:t?`${e.color.secondary}10`:e.background.content,cursor:"pointer",transition:"all 0.2s","&:hover":{borderColor:t?e.color.secondary:e.color.mediumlight}})),t_=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),n_=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),r_=Ye.span(({theme:e,mapped:t})=>({fontSize:"10px",fontWeight:500,padding:"2px 6px",borderRadius:"4px",backgroundColor:t?`${e.color.positive}20`:e.background.hoverable,color:t?e.color.positive:e.color.mediumdark})),o_=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),i_=Ye.div(({theme:e})=>({marginTop:"8px",padding:"8px",backgroundColor:`${e.color.positive}10`,borderRadius:"6px",fontSize:"11px",color:e.color.positive,display:"flex",alignItems:"center",gap:"8px",position:"relative"})),s_=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),a_=Ye.div({flex:1,overflow:"hidden"}),l_=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),c_=Ye.div(({theme:e})=>({position:"absolute",bottom:"100%",left:"0",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)",border:`1px solid ${e.appBorderColor}`,padding:"8px",zIndex:100,maxWidth:"280px",animation:"fadeIn 0.15s ease-out","@keyframes fadeIn":{from:{opacity:0,transform:"translateY(4px)"},to:{opacity:1,transform:"translateY(0)"}}})),u_=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),p_=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),d_=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),g_=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),eh=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),f_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),th=20,m_=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),h_=Ye.button(({theme:e,disabled:t})=>({padding:"8px 16px",fontSize:"13px",fontWeight:500,color:t?e.color.mediumdark:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${t?e.appBorderColor:e.color.secondary}`,borderRadius:"6px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"all 0.2s","&:hover":{backgroundColor:t?"transparent":`${e.color.secondary}10`}})),x_=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),y_=Ye.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"13px",fontWeight:500,color:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${e.color.secondary}`,borderRadius:"4px",cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:`${e.color.secondary}10`}})),b_=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),nh=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),rh=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),S_=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),w_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),pC=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),dC=Ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),gC=Ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"12px",animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),v_=()=>Q.createElement(w_,null,Array.from({length:8}).map((e,t)=>Q.createElement(pC,{key:t},Q.createElement(dC,null),Q.createElement(gC,{width:`${60+t%3*15}%`})))),k_=Ye.div(({theme:e})=>({padding:"12px 16px",backgroundColor:`${e.color.secondary}10`,borderBottom:`1px solid ${e.appBorderColor}`,fontSize:"13px",color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),C_=Ye.div({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.8)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:50,gap:"8px"}),T_=Ye.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),I_=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),fC=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=ta({projectId:i,limit:th,enabled:!!i}),[a,u]=Yi("all"),[c,l]=Yi(""),[d,g]=Yi(null),[p,m]=Yi(1),[v,I]=Yi(null),[A,C]=Yi(!1),D=Zm(()=>{let f=new Set;return e.forEach(T=>{T.componentTitle&&f.add(T.componentTitle)}),Array.from(f).sort()},[e]),R=Zm(()=>e.filter(f=>{if(a!=="all"&&f.componentTitle!==a)return!1;if(c){let T=c.toLowerCase();return f.name.toLowerCase().includes(T)||f.title.toLowerCase().includes(T)}return!0}),[e,a,c]),_=d?s.frames.find(f=>f.id===d):null,P=Zm(()=>{if(!d)return[];let f=s.variantChildren[d]||[];return f.length===0?[]:s.variantFilters.some(T=>T.value)?f.filter(T=>T.variantProperties?s.variantFilters.every(S=>S.value?T.variantProperties?.[S.property]===S.value:!0):!1):f},[d,s.variantChildren,s.variantFilters]),N=P.slice(0,p*th),x=P.length>p*th;sC(()=>{if(!d||N.length===0)return;let f=N.map(T=>T.id);s.fetchVariantThumbnails(d,f)},[d,N.length,p]),sC(()=>{C(!1)},[]);let k=aC(async f=>{if(n)try{let T=q(),S=localStorage.getItem("uicopilot_session_token");if(!(await ee(`${T}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:f.id,name:f.name})})).ok)throw new Error("Failed to save mapping");o(n,f.id,f.name)}catch(T){b.error("[MapStoriesTab] Error saving mapping:",T)}},[n,i,o]),w=aC((f,T)=>{if(T.stopPropagation(),d===f){g(null),m(1);return}g(f),m(1),!s.variantThumbnails[f]&&!s.loadingVariants.has(f)&&s.toggleExpanded(f,T)},[d,s]),E=e.find(f=>f.id===n);return t?Q.createElement(S_,null,"Loading stories..."):Q.createElement(KO,null,Q.createElement(XO,null,Q.createElement(lC,null,Q.createElement(cC,null,"Storybook Stories"),Q.createElement(ac,null,Q.createElement(JO,{value:a,onChange:f=>u(f.target.value)},Q.createElement("option",{value:"all"},"All Components"),D.map(f=>Q.createElement("option",{key:f,value:f},f)))),Q.createElement(ac,null,Q.createElement(uC,{type:"text",placeholder:"Search stories...",value:c,onChange:f=>l(f.target.value)}))),Q.createElement(ZO,null,R.length===0?Q.createElement(rh,null,"No stories found"):R.map(f=>Q.createElement(e_,{key:f.id,selected:f.id===n,mapped:!!f.figmaMapping,onClick:()=>r(f.id)},Q.createElement(t_,null,Q.createElement(n_,null,f.name),Q.createElement(r_,{mapped:!!f.figmaMapping},f.figmaMapping?"Mapped":"Unmapped")),Q.createElement(o_,null,f.title),f.figmaMapping&&Q.createElement(i_,{onMouseEnter:()=>I(f.id),onMouseLeave:()=>I(null)},(()=>{let T=f.figmaMapping?.figmaNodeId,S=T?s.resolveThumbnail(T):void 0;return Q.createElement(Q.Fragment,null,S?Q.createElement(s_,{src:S,alt:f.figmaMapping?.figmaFrameName||""}):Q.createElement("span",null,"\u{1F517}"),v===f.id&&S&&Q.createElement(c_,null,Q.createElement(u_,{src:S,alt:f.figmaMapping?.figmaFrameName||""}),Q.createElement(p_,null,f.figmaMapping?.figmaFrameName)))})(),Q.createElement(a_,null,Q.createElement(l_,null,f.figmaMapping.figmaFrameName))))))),Q.createElement(QO,null,n?Q.createElement(Q.Fragment,null,Q.createElement(k_,null,Q.createElement("span",null,"Click a Figma component below to link it to"," ",Q.createElement("strong",null,E?.name))),Q.createElement(lC,null,Q.createElement(cC,null,"Figma Components"),Q.createElement(ac,null,Q.createElement(g_,null,Q.createElement(eh,null,Q.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:f=>s.setShowComponentSets(f.target.checked)}),"Component Sets"),Q.createElement(eh,null,Q.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:f=>s.setShowFrames(f.target.checked)}),"Frames"),Q.createElement(eh,null,Q.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:f=>s.setShowComponents(f.target.checked)}),"Components")),s.availablePages.length>1&&Q.createElement(qi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:f=>s.setFigmaPage(f.target.value)},Q.createElement("option",{value:""},"All pages"),s.availablePages.map(f=>Q.createElement("option",{key:f,value:f},f)))),s.availableFilters.length>0&&Q.createElement(ic,null,Q.createElement(sa,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:f,values:T})=>{let S=s.variantFilters.find(y=>y.property===f);return Q.createElement(qi,{key:f,isActive:!!S?.value,value:S?.value||"",onChange:y=>s.handleFilterChange(f,y.target.value)},Q.createElement("option",{value:""},f),T.map(y=>Q.createElement("option",{key:y,value:y},f,"=",y)))}),s.availableFilters.length>5&&Q.createElement(sa,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(f=>f.value)&&Q.createElement(sc,{onClick:s.clearFilters},"Clear All")),Q.createElement(ac,null,Q.createElement(uC,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:f=>s.setSearch(f.target.value)}))),Q.createElement(d_,null,A&&Q.createElement(C_,null,Q.createElement(T_,null),Q.createElement(I_,null,"Loading thumbnails...")),s.isLoading?Q.createElement(v_,null):s.filteredFrames.length===0?Q.createElement(rh,null,Q.createElement("span",null,"No components match. Try a different search term, or check that your Figma file has component sets defined.")):Q.createElement(f_,null,d&&_?Q.createElement(Q.Fragment,null,Q.createElement(x_,null,Q.createElement(y_,{onClick:()=>{g(null),m(1)}},"Back"),Q.createElement(b_,null,_.name)),s.loadingVariants.has(d)?Q.createElement(Q.Fragment,null,Q.createElement(nh,null,"Loading ",_.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,_.childCount??8)}).map((f,T)=>Q.createElement(pC,{key:`variant-skeleton-${T}`},Q.createElement(dC,null),Q.createElement(gC,{width:`${60+T%3*15}%`})))):Q.createElement(Q.Fragment,null,Q.createElement(nh,null,"Showing ",N.length," of"," ",P.length," variants"),N.map(f=>Q.createElement(Jm,{key:f.id,variant:f,thumbnail:s.variantThumbnails[d]?.[f.id]||s.thumbnails[f.id],onSelect:k,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d),failed:s.variantFailed[d]?.has(f.id)})))):Q.createElement(Q.Fragment,null,Q.createElement(nh,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(f=>Q.createElement(aa,{key:f.id,frame:f,thumbnail:s.thumbnails[f.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[f.id],variantChildren:s.variantChildren[f.id],variantFailed:s.variantFailed[f.id],isLoadingVariants:s.loadingVariants.has(f.id),isExpanded:!1,onToggleExpand:w,onSelect:k,variantFilters:s.variantFilters}))),(d?x:s.hasMore)&&Q.createElement(m_,null,Q.createElement(h_,{disabled:s.loadingMore,onClick:async()=>{d?m(f=>f+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Q.createElement(rh,null,Q.createElement("span",null,"\u{1F448} Pick a story from the left, then browse your Figma file to find a matching frame. The mapping is saved per story."))))};He();import ot,{useState as oh,useMemo as mC,useCallback as hC}from"react";import{styled as _t}from"storybook/theming";ct();var F_=_t.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),E_=_t.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),A_=_t(bn)({width:"auto",minWidth:"200px"}),P_=_t(So)({fontSize:"13px",minWidth:"250px"}),L_=_t.button(({theme:e,active:t})=>({padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${t?e.color.positive:e.appBorderColor}`,borderRadius:"6px",backgroundColor:t?`${e.color.positive}15`:e.background.content,color:t?e.color.positive:e.color.mediumdark,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{borderColor:e.color.positive}})),M_=_t.button(({theme:e})=>({marginLeft:"auto",padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{backgroundColor:e.background.hoverable}})),B_=_t.div({flex:1,overflow:"auto"}),D_=_t.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),R_=_t.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),lc=_t.th(({theme:e})=>({padding:"12px 20px",textAlign:"left",fontWeight:600,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px",color:e.color.mediumdark,borderBottom:`1px solid ${e.appBorderColor}`})),z_=_t.tbody({}),N_=_t.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),cc=_t.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),O_=_t.div({display:"flex",flexDirection:"column",gap:"2px"}),__=_t.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),$_=_t.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),U_=_t.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),j_=_t.div({display:"flex",alignItems:"center",gap:"8px"}),H_=_t.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),W_=_t.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),xC=_t.button(({theme:e,variant:t})=>({padding:"6px 12px",fontSize:"12px",fontWeight:500,border:`1px solid ${t==="link"?e.color.secondary:e.color.negative}`,borderRadius:"4px",backgroundColor:t==="link"?`${e.color.secondary}10`:`${e.color.negative}10`,color:t==="link"?e.color.secondary:e.color.negative,cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:t==="link"?`${e.color.secondary}20`:`${e.color.negative}20`}})),V_=_t.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),G_=_t.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),yC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=oh("all"),[a,u]=oh(""),[c,l]=oh(!0),d=mC(()=>{let I=new Set;return e.forEach(A=>{A.componentTitle&&I.add(A.componentTitle)}),Array.from(I).sort()},[e]),g=mC(()=>e.filter(I=>{if(i!=="all"&&I.componentTitle!==i||!c&&!I.figmaMapping)return!1;if(a){let A=a.toLowerCase();return I.name.toLowerCase().includes(A)||I.title.toLowerCase().includes(A)||(I.figmaMapping?.figmaFrameName?.toLowerCase().includes(A)??!1)}return!0}),[e,i,a,c]),p=hC(async I=>{try{let A=q(),C=localStorage.getItem("uicopilot_session_token");if(!(await ee(`${A}/api/mappings?projectId=${o}&storyId=${I}`,{method:"DELETE",headers:{Authorization:`Bearer ${C}`}})).ok)throw new Error("Failed to delete mapping");r(I)}catch(A){console.error("[ViewAllMappingsTab] Error unlinking:",A)}},[o,r]),m=hC(()=>{let I=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),A=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),C=URL.createObjectURL(A),D=document.createElement("a");D.href=C,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(C)},[e]);if(t)return ot.createElement(G_,null,"Loading mappings...");let v=e.filter(I=>I.figmaMapping).length;return ot.createElement(F_,null,ot.createElement(E_,null,ot.createElement(A_,{value:i,onChange:I=>s(I.target.value)},ot.createElement("option",{value:"all"},"All Components"),d.map(I=>ot.createElement("option",{key:I,value:I},I))),ot.createElement(P_,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:I=>u(I.target.value)}),ot.createElement(L_,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),ot.createElement(M_,{onClick:m,disabled:v===0},"\u{1F4E5} Export JSON")),g.length===0?ot.createElement(V_,null,ot.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):ot.createElement(B_,null,ot.createElement(D_,null,ot.createElement(R_,null,ot.createElement("tr",null,ot.createElement(lc,{style:{width:"35%"}},"Story"),ot.createElement(lc,{style:{width:"35%"}},"Figma Component"),ot.createElement(lc,{style:{width:"15%"}},"Status"),ot.createElement(lc,{style:{width:"15%"}},"Actions"))),ot.createElement(z_,null,g.map(I=>ot.createElement(N_,{key:I.id,mapped:!!I.figmaMapping},ot.createElement(cc,null,ot.createElement(O_,null,ot.createElement(__,null,I.name),ot.createElement($_,null,I.title))),ot.createElement(cc,null,ot.createElement(U_,{mapped:!!I.figmaMapping},I.figmaMapping?ot.createElement(ot.Fragment,null,ot.createElement("span",null,"\u{1F3A8}"),I.figmaMapping.figmaFrameName):"\u2014")),ot.createElement(cc,null,ot.createElement(j_,null,ot.createElement(H_,{mapped:!!I.figmaMapping}),ot.createElement(W_,{mapped:!!I.figmaMapping},I.figmaMapping?"Mapped":"Unmapped"))),ot.createElement(cc,null,I.figmaMapping?ot.createElement(xC,{variant:"unlink",onClick:()=>p(I.id)},"Unlink"):ot.createElement(xC,{variant:"link",onClick:()=>n(I.id)},"Link"))))))))};import Ee,{useState as mc,useMemo as TC}from"react";import{styled as ft}from"storybook/theming";import bC from"react";import{styled as SC,keyframes as q_}from"storybook/theming";var Y_=q_`
42
42
  0% { transform: rotate(0deg); }
43
43
  100% { transform: rotate(360deg); }
44
- `,K_=bC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${Y_} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),X_=bC.button(({theme:e,variant:t="default",disabled:n})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"5px 12px",fontSize:"12px",fontWeight:600,border:`1px solid ${e.color.medium}`,borderRadius:"5px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transition:"all 0.2s",whiteSpace:"nowrap",...t==="default"&&{backgroundColor:e.background.content,color:e.color.defaultText,"&:hover":n?{}:{borderColor:e.color.secondary,color:e.color.secondary,backgroundColor:"rgba(30, 167, 253, 0.05)"}},...t==="ghost"&&{backgroundColor:"transparent",border:"none",color:e.color.mediumdark,padding:"5px 8px","&:hover":n?{}:{color:e.color.defaultText,backgroundColor:e.background.hoverable}}})),Pr=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>yC.createElement(X_,{variant:r,disabled:t||e,onClick:n},e&&yC.createElement(K_,null),e&&i?i:o);He();import un from"react";import{styled as la}from"storybook/theming";var SC=la.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",backgroundColor:e.background.hoverable,borderRadius:"6px",fontFamily:"Inter, sans-serif",fontSize:"11px",color:e.color.mediumdark,gap:"16px"})),Q_=la.div({display:"flex",alignItems:"center",gap:"12px"}),uc=la.span({whiteSpace:"nowrap"}),wC=la.div({display:"flex",alignItems:"center",gap:"8px"}),pc=la.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),dc=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Fw;return r?un.createElement(SC,null,un.createElement(uc,null,o.toLocaleString()," tokens"),un.createElement(wC,null,un.createElement(pc,null,"$",n.toFixed(4)),un.createElement("span",null,"\xB7"),un.createElement(pc,null,"\u20AA",i.toFixed(2)))):un.createElement(SC,null,un.createElement(Q_,null,un.createElement(uc,null,e.toLocaleString()," input"),un.createElement("span",null,"+"),un.createElement(uc,null,t.toLocaleString()," output"),un.createElement("span",null,"="),un.createElement(uc,null,un.createElement("strong",null,o.toLocaleString())," tokens")),un.createElement(wC,null,un.createElement(pc,null,"$",n.toFixed(4)),un.createElement("span",null,"\xB7"),un.createElement(pc,null,"\u20AA",i.toFixed(2))))};import Vn from"react";import{styled as Mo}from"storybook/theming";function ih(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var J_=Mo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),vC=Mo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),Z_=Mo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),e$=Mo.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.2}px`,padding:`1px ${e.layoutMargin*.5}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.mono})),t$=Mo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),n$=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),r$=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),o$=Mo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),kC=({data:e,color:t,compact:n})=>n?Vn.createElement(vC,{color:t},e.summary):Vn.createElement(J_,null,Vn.createElement(vC,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Vn.createElement(Z_,null,e.mappings.map((r,o)=>Vn.createElement(Vn.Fragment,{key:o},Vn.createElement(e$,null,r.from," ",Vn.createElement(t$,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Vn.createElement(n$,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Vn.createElement(Vn.Fragment,null,e.defaults.map((r,o)=>Vn.createElement(r$,{key:o},Vn.createElement(o$,null,r.choice),Vn.createElement("span",null,"\u2014 ",r.why)))));var i$=ft.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),s$=ft.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),a$=ft.div({display:"flex",flexDirection:"column",gap:"4px"}),l$=ft.div({display:"flex",alignItems:"center",gap:"10px"}),c$=ft.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,letterSpacing:"-0.3px"})),TC=ft.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="success"?`${e.color.positive}1a`:t==="danger"?`${e.color.negative}1a`:`${e.color.secondary}1a`,color:t==="success"?e.color.positive:t==="danger"?e.color.negative:e.color.secondary})),u$=ft.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),p$=ft.div({display:"flex",gap:"8px"}),d$=ft.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),g$=ft(So)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),f$=ft.div({display:"flex",gap:"4px"}),gc=ft.button(({theme:e,active:t})=>({padding:"6px 12px",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,border:t?"none":`1px solid ${e.appBorderColor}`,backgroundColor:t?e.color.defaultText:e.background.content,color:t?e.color.inverseText:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:t?e.color.defaultText:e.background.hoverable}})),m$=ft.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),h$=ft.div(({theme:e,dimmed:t})=>({display:"flex",alignItems:"center",padding:"12px 16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"10px",gap:"12px",backgroundColor:e.background.content,opacity:t?.6:1,transition:"opacity 0.15s",position:"relative",zIndex:0,"&:hover":{zIndex:10}})),x$=ft.div(({theme:e,checked:t})=>({width:"18px",height:"18px",borderRadius:"4px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"all 0.15s",...t?{backgroundColor:e.color.defaultText,color:e.color.inverseText,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold}:{border:`2px solid ${e.color.mediumlight}`}})),y$=ft.div(({theme:e,bgColor:t})=>({width:"48px",height:"40px",borderRadius:"6px",backgroundColor:t||e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"})),fc=ft.div(({theme:e})=>({width:"120px",height:"80px",borderRadius:"8px",backgroundColor:e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden",border:`1px solid ${e.appBorderColor}`})),b$=ft.img({width:"100%",height:"100%",objectFit:"contain"}),PC=ft.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"uicopilot-spin 0.8s linear infinite","@keyframes uicopilot-spin":{to:{transform:"rotate(360deg)"}}})),IC=ft.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),FC=ft.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),sh=ft.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),wne=ft.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,lineHeight:1.5,whiteSpace:"pre-line"})),S$=ft.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),w$=ft.span(({theme:e,level:t})=>({padding:"4px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,flexShrink:0,backgroundColor:t==="high"?`${e.color.positive}1a`:t==="medium"?`${e.color.warning}1a`:`${e.color.negative}1a`,color:t==="high"?e.color.positive:t==="medium"?e.color.warning:e.color.negative})),v$=ft.button(({theme:e})=>({padding:"4px 8px",borderRadius:e.appBorderRadius,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,border:`1px solid ${e.appBorderColor}`,backgroundColor:"transparent",color:e.color.mediumdark,cursor:"pointer",flexShrink:0,transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText}})),k$=ft.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),C$=ft.div({display:"flex",flexWrap:"wrap",gap:"6px"}),T$=ft.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),I$=ft.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="cache"?`${e.color.warning}1a`:`${e.color.positive}1a`,color:t==="cache"?e.color.warning:e.color.positive})),F$=ft.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"5px",padding:"5px 12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:"transparent",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),vne=ft.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 24px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:e.color.mediumdark})),EC=({src:e,alt:t})=>{let[n,r]=mc(!1);return Ee.createElement(Ee.Fragment,null,!n&&Ee.createElement(PC,null),Ee.createElement(b$,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function AC(e){return e>=90?"high":e>=70?"medium":"low"}function E$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var LC=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:d})=>{let[g,p]=mc(()=>{let w=new Set;for(let E of e.mappings)E.confidence>=90&&w.add(E.storyId);return w}),[m,k]=mc(""),[I,A]=mc("all"),C=CC(()=>{let w=new Map;for(let E of t)w.set(E.id,{name:E.name,title:E.title});return w},[t]),D=CC(()=>{let w=e.mappings;if(I!=="all"&&(w=w.filter(E=>AC(E.confidence)===I)),m.trim()){let E=m.toLowerCase();w=w.filter(f=>{let T=C.get(f.storyId);return T?.name.toLowerCase().includes(E)||T?.title.toLowerCase().includes(E)||f.componentSetName.toLowerCase().includes(E)||f.figmaFrameName.toLowerCase().includes(E)})}return w},[e.mappings,I,m,C]),R=w=>{p(E=>{let f=new Set(E);return f.has(w)?f.delete(w):f.add(w),f})},_=()=>{let w=e.mappings.filter(E=>g.has(E.storyId));n(w)},P=e.mappings.filter(w=>w.confidence>=90).length,N=e.mappings.filter(w=>w.confidence>=70&&w.confidence<90).length,x=e.mappings.filter(w=>w.confidence<70).length,v=e.usage;return Ee.createElement(i$,null,Ee.createElement(s$,null,Ee.createElement(a$,null,Ee.createElement(l$,null,Ee.createElement(c$,null,"Auto-Map Results"),Ee.createElement(TC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Ee.createElement(TC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Ee.createElement(I$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Ee.createElement(u$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Ee.createElement(p$,null,a==="cache"&&o&&Ee.createElement(F$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Ee.createElement(Pr,{onClick:r,variant:"ghost"},"Cancel"),Ee.createElement(Pr,{loading:i,onClick:_,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Ee.createElement(d$,null,Ee.createElement(g$,{type:"text",placeholder:"Filter stories...",value:m,onChange:w=>k(w.target.value)}),Ee.createElement(f$,null,Ee.createElement(gc,{active:I==="all",onClick:()=>A("all")},"All ",e.mappings.length),P>0&&Ee.createElement(gc,{active:I==="high",onClick:()=>A("high")},"\u226590% (",P,")"),N>0&&Ee.createElement(gc,{active:I==="medium",onClick:()=>A("medium")},"70-89% (",N,")"),x>0&&Ee.createElement(gc,{active:I==="low",onClick:()=>A("low")},"<70% (",x,")"))),Ee.createElement(m$,null,D.map(w=>{let E=C.get(w.storyId),f=AC(w.confidence),T=g.has(w.storyId),S=f==="low";return Ee.createElement(h$,{key:w.storyId,dimmed:S&&!T},Ee.createElement(x$,{checked:T,onClick:()=>R(w.storyId)},T?"\u2713":""),(()=>{let y=c?.(w.storyId);return y?Ee.createElement(fc,null,Ee.createElement(EC,{src:y,alt:E?.name||w.storyId})):l?Ee.createElement(fc,null,Ee.createElement(PC,null)):Ee.createElement(y$,{bgColor:S?"#f1f5f9":"#eff6ff"},Ee.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:S?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)))})(),Ee.createElement(IC,null,Ee.createElement(FC,null,E?.name||w.storyId),Ee.createElement(sh,null,E?.title||"")),Ee.createElement(S$,null,"\u2192"),(()=>{let y=u?.(w.figmaNodeId),F=ih(w.reason),L=F.summary+(F.candidates?` (${F.candidates} candidates)`:"");return y?Ee.createElement(fc,{title:L},Ee.createElement(EC,{src:y,alt:w.figmaFrameName})):Ee.createElement(fc,{title:L},Ee.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Ee.createElement(IC,null,Ee.createElement(FC,null,w.componentSetName),Ee.createElement(sh,null,w.figmaFrameName),Ee.createElement(kC,{data:ih(w.reason),color:E$(f)})),Ee.createElement(w$,{level:f},w.confidence,"%"),d&&Ee.createElement(v$,{onClick:()=>d(w.componentSetName)},"Browse"))}),e.unmatched.length>0&&Ee.createElement(k$,null,Ee.createElement(sh,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Ee.createElement(C$,null,e.unmatched.map(w=>{let E=C.get(w);return Ee.createElement(T$,{key:w},Ee.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:w)})))),v&&a!=="cache"&&Ee.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Ee.createElement(dc,{inputTokens:v.inputTokens||0,outputTokens:v.outputTokens||0,costUsd:v.costUsd||0})))};He();_e();import{useState as Bo,useCallback as Do,useRef as A$}from"react";import{useStorybookApi as P$}from"storybook/manager-api";function MC({projectId:e}){let t=P$(),n=A$(null),[r,o]=Bo(!1),[i,s]=Bo(!1),[a,u]=Bo(!1),[c,l]=Bo(null),[d,g]=Bo(null),[p,m]=Bo(null),[k,I]=Bo(""),[A,C]=Bo(null),D=Do(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let f=await E.json(),T=f.entries||f.stories||{},S=Object.keys(T).filter(L=>T[L].type==="story");b.debug(`[useAutoMap] Found ${S.length} stories in index.json`);let y=[];for(let L of S){let M=T[L],z=t.getData(L),h={...z?.initialArgs||{}},j=z?.argTypes||{};for(let[V,B]of Object.entries(j))if(!(V in h)){let G=B;if(G.defaultValue!==void 0)h[V]=G.defaultValue;else if(G.table?.defaultValue?.summary!==void 0){let te=G.table.defaultValue.summary;te==="false"?h[V]=!1:te==="true"?h[V]=!0:h[V]=te}}y.push({id:L,name:M.name||L.split("--").pop()||L,title:M.title||"",initialArgs:h,argTypes:j})}let F=y.filter(L=>Object.keys(L.initialArgs).length>0);return b.debug(`[useAutoMap] Manifest: ${y.length} stories, ${F.length} with args`),y},[t]),R=Do(async()=>{if(!e)return!1;try{let E=q(),f=localStorage.getItem("uicopilot_session_token");if(!f)return!1;let T=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${f}`}});if(!T.ok)return!1;let S=await T.json();return S.hasSuggestions&&S.mappings?.length>0?(g(S),C("cache"),I(`Loaded ${S.mappings.length} saved suggestions`),b.debug(`[useAutoMap] Loaded ${S.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),_=Do(async E=>{o(!0),I("Collecting story information...");let f;try{if(f=await D(),E?.length&&(f=f.filter(S=>!E.includes(S.id)),b.debug(`[useAutoMap] After excluding mapped: ${f.length} stories`)),f.length===0){l("No unmapped stories found"),o(!1);return}m(f)}catch(S){l(S instanceof Error?S.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),I(`Analyzing ${f.length} stories against Figma components...`);let T=new AbortController;n.current=T;try{let S=q(),y=localStorage.getItem("uicopilot_session_token");if(!y)throw new Error("Not authenticated");let F=await fetch(`${S}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({projectId:e,stories:f.map(M=>({id:M.id,name:M.name,title:M.title,initialArgs:M.initialArgs,argTypes:M.argTypes}))}),signal:T.signal});if(!F.ok){let M=await F.json();throw new Error(M.error||"Auto-map failed")}let L=await F.json();g(L),C("llm"),I(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),b.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(S){if(S instanceof DOMException&&S.name==="AbortError"){I("Cancelled");return}l(S instanceof Error?S.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),P=Do(async E=>{if(!e)return;if(l(null),g(null),C(null),o(!0),I("Checking for existing suggestions..."),await R()){o(!1);return}await _(E)},[e,R,_]),N=Do(async E=>{e&&(l(null),g(null),C(null),await _(E))},[e,_]),x=Do(async E=>{if(!(!e||E.length===0)){u(!0),I(`Applying ${E.length} mappings...`);try{let f=q(),T=localStorage.getItem("uicopilot_session_token");if(!T)throw new Error("Not authenticated");let S=0;for(let y of E)try{(await fetch(`${f}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:e,storyId:y.storyId,figmaNodeId:y.figmaNodeId,name:y.figmaFrameName||y.componentSetName})})).ok?S++:b.warn(`[useAutoMap] Failed to apply mapping for ${y.storyId}`)}catch(F){b.error(`[useAutoMap] Error applying mapping for ${y.storyId}:`,F)}I(`Applied ${S}/${E.length} mappings`),b.debug(`[useAutoMap] Applied ${S}/${E.length} mappings`)}catch(f){l(f instanceof Error?f.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),v=Do(()=>{n.current?.abort()},[]),w=Do(()=>{g(null),m(null),l(null),I(""),C(null)},[]);return{collectAndMap:P,rerun:N,loadExisting:R,applyMappings:x,cancel:v,reset:w,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:k,source:A}}_e();import{useState as ah,useEffect as L$,useRef as BC}from"react";var DC=2;async function M$(e,t){try{let n=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`,{signal:t});return n.ok&&(await n.json()).screenshot||null}catch{return null}}function RC(e){let[t,n]=ah({}),[r,o]=ah(0),[i,s]=ah(!1),a=BC(null),u=BC(""),c=e.join(",");return L$(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let d=0;return(async()=>{for(let p=0;p<e.length&&!l.signal.aborted;p+=DC){let m=e.slice(p,p+DC),k=await Promise.all(m.map(A=>M$(A,l.signal).then(C=>({id:A,img:C}))));if(l.signal.aborted)break;let I={};for(let{id:A,img:C}of k)d++,C&&(I[A]=C);Object.keys(I).length>0&&n(A=>({...A,...I})),o(d)}s(!1),b.debug(`[useStoryScreenshots] Captured ${d}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import we,{useState as lh,useEffect as ca,useMemo as B$,useCallback as D$}from"react";import{styled as R$}from"storybook/theming";_e();var z$=R$.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.secondary,color:e.color.secondary},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Ki=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=ta({projectId:r||"",enabled:e&&!!r}),d=we.useRef(!1);ca(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[g,p]=lh(new Set),[m,k]=lh(i||o[0]?.id||"");ca(()=>{i&&k(i)},[i]);let I=50,A=8,[C,D]=lh({}),R=D$(f=>{D(T=>({...T,[f]:(T[f]||1)+1}))},[]);ca(()=>{D({})},[l.variantFilters]),ca(()=>{l.expandedSets.forEach(f=>{let T=l.variantChildren[f];if(!T||T.length===0)return;let S=T;l.variantFilters.some(L=>L.value)&&(S=T.filter(L=>L.variantProperties?l.variantFilters.every(M=>M.value?L.variantProperties?.[M.property]===M.value:!0):!1));let y=C[f]||1,F=S.slice(0,y*I).map(L=>L.id);for(let L=0;L<F.length;L+=A){let M=F.slice(L,L+A),z=L/A*300;z===0?l.fetchVariantThumbnails(f,M):setTimeout(()=>l.fetchVariantThumbnails(f,M),z)}})},[l.expandedSets,l.variantChildren,l.variantFilters,C]),ca(()=>{p(new Set)},[m]);let _=B$(()=>{let f=[];return l.filteredFrames.forEach(T=>{if(T.type==="COMPONENT_SET"&&T.children){let S=l.variantFilters.some(y=>y.value)?T.children.filter(y=>y.variantProperties?l.variantFilters.every(F=>F.value?y.variantProperties?.[F.property]===F.value:!0):!1):T.children;f.push(...S)}else f.push(T)}),f},[l.filteredFrames,l.variantFilters]),P=f=>{if(a)p(T=>{let S=new Set(T);return S.has(f.id)?S.delete(f.id):S.add(f.id),S});else{let T=l.resolveThumbnail(f.id);try{n({...f,thumbnail:T})}catch(S){b.error("[ComponentBrowserModal] onSelect threw error:",S)}t()}},N=()=>{let f=_.map(S=>S.id),T=f.every(S=>g.has(S));p(T?new Set:new Set(f))},x=()=>{if(u&&g.size>0){let f=_.filter(T=>g.has(T.id)).map(T=>({...T,thumbnail:l.resolveThumbnail(T.id)}));u(f),p(new Set)}},v=f=>{k(f),s?.(f)},w=f=>{f.target===f.currentTarget&&t()},E=o.find(f=>f.id===m);return e?we.createElement(bk,{onClick:w},we.createElement(Sk,null,we.createElement(wk,null,we.createElement(vk,null,"Link Figma Frames"),we.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},we.createElement("button",{onClick:()=>l.refresh(),disabled:l.isLoading,style:{padding:"4px 8px",fontSize:"12px",cursor:l.isLoading?"not-allowed":"pointer",background:"transparent",border:"1px solid #ccc",borderRadius:"4px"},title:"Refresh from Figma"},"Refresh"),we.createElement(kk,{onClick:t},"\xD7"))),we.createElement(Ck,null,l.error&&we.createElement(Lk,null,l.error),!l.error&&we.createElement(we.Fragment,null,o.length>0&&we.createElement(jk,null,we.createElement(Hk,null,"Story:"),we.createElement(Wk,{value:m,onChange:f=>v(f.target.value)},o.map(f=>we.createElement("option",{key:f.id,value:f.id},f.name,f.mappingsCount?` (${f.mappingsCount} linked)`:""))),E?.mappingsCount?we.createElement(Vk,{hasMapping:!0},E.mappingsCount," frames linked"):null),we.createElement(Ak,null,we.createElement(rc,null,we.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:f=>l.setShowComponentSets(f.target.checked)}),"Component Sets"),we.createElement(rc,null,we.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:f=>l.setShowFrames(f.target.checked)}),"Frames"),we.createElement(rc,null,we.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:f=>l.setShowComponents(f.target.checked)}),"Components"),l.availablePages.length>1&&we.createElement(qi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:f=>l.setFigmaPage(f.target.value),style:{marginLeft:"auto"}},we.createElement("option",{value:""},"All pages"),l.availablePages.map(f=>we.createElement("option",{key:f,value:f},f)))),l.filterSuggestion&&we.createElement(Gk,null,we.createElement(qk,null,"AI suggests:"),we.createElement(Yk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([f,T])=>`${f}=${T}`).join(", ")),we.createElement(Kk,{onClick:l.applySuggestedFilters},"Apply"),we.createElement(Xk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&we.createElement(Qk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&we.createElement(ic,null,we.createElement(sa,null,"Filters:"),l.availableFilters.map(({property:f,values:T})=>{let S=l.variantFilters.find(y=>y.property===f);return we.createElement(qi,{key:f,isActive:!!S?.value,value:S?.value||"",onChange:y=>l.handleFilterChange(f,y.target.value)},we.createElement("option",{value:""},f),T.map(y=>we.createElement("option",{key:y,value:y},f,"=",y)))}),l.variantFilters.some(f=>f.value)&&we.createElement(sc,{onClick:l.clearFilters},"Clear All")),l.rateLimitError&&we.createElement("div",{style:{padding:"8px 12px",marginBottom:"8px",background:"rgba(234, 88, 12, 0.12)",border:"1px solid rgba(234, 88, 12, 0.3)",borderRadius:"6px",fontSize:"12px",color:"#ea580c"}},"\u26A0 Figma thumbnail previews unavailable \u2014"," ",l.rateLimitError,". You can still select by name."),we.createElement(Tk,{type:"text",placeholder:"Search frames...",value:l.search,onChange:f=>l.setSearch(f.target.value),autoFocus:!0}),a&&_.length>0&&we.createElement(Jk,null,we.createElement(Zk,{onClick:N},g.size===_.length?"Deselect All":"Select All Visible"),we.createElement(eC,null,g.size>0?`${g.size} selected of `:"Showing ",_.length," frames")),l.isLoading&&we.createElement(Um,null,Array.from({length:6}).map((f,T)=>we.createElement(Uk,{key:T},we.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},we.createElement(oc,{width:"100%",height:"100%"})),we.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},we.createElement(oc,{width:"80%",height:"16px"}),we.createElement(oc,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&we.createElement(Pk,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&we.createElement(Um,null,l.filteredFrames.map(f=>we.createElement(aa,{key:f.id,frame:f,thumbnail:l.thumbnails[f.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[f.id],variantChildren:l.variantChildren[f.id],variantFailed:l.variantFailed[f.id],isLoadingVariants:l.loadingVariants.has(f.id),isExpanded:l.expandedSets.has(f.id),isNew:l.recentlyAdded.has(f.name),onToggleExpand:l.toggleExpanded,onSelect:P,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:C[f.id]||1,onShowMore:R})),l.hasMore&&we.createElement(z$,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&we.createElement(tC,null,we.createElement(nC,{disabled:g.size===0,onClick:x},"Link ",g.size," Selected")))):null};Te();ct();var O$=tn.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4}),_$=tn.div(({theme:e})=>({width:"90vw",maxWidth:"1100px",height:"75vh",backgroundColor:e.background.content,borderRadius:"12px",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",overflow:"hidden"})),$$=tn.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),U$=tn.div({display:"flex",alignItems:"center",gap:"20px"}),j$=tn.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),H$=tn.div({display:"flex",gap:"4px"}),zC=tn(bo)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),W$=tn(En)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),V$=tn.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),G$=tn.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),q$=tn.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),Y$=tn.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),K$=tn.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),X$=tn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),Q$=tn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),J$=tn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),Z$=tn.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),e4=tn.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",backgroundColor:e.color.defaultText,color:"white",border:"none",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,cursor:"pointer",transition:"opacity 0.15s","&:hover":{opacity:.85},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),NC=tn.span(({theme:e,type:t})=>({display:"flex",alignItems:"center",gap:"6px","& .dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:t==="mapped"?e.color.positive:t==="unmapped"?e.color.mediumlight:"transparent"}})),OC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Xi("map"),[i,s]=Xi([]),[a,u]=Xi(!0),[c,l]=Xi(null),[d,g]=Xi(!1),[p,m]=Xi(null),k=MC({projectId:n}),{refreshMappings:I}=nt(),{featureFlags:A}=ce(),C=et.useMemo(()=>k.results?.mappings.map(y=>y.storyId)||[],[k.results]),D=RC(C),R=Ro(async()=>{u(!0);try{let y=await fetch("/index.json");if(!y.ok)throw new Error("Failed to fetch index.json");let F=await y.json(),L=F.entries||F.stories||{},M=Object.entries(L).filter(([,h])=>h.type==="story").map(([h,j])=>({id:h,name:j.name||h.split("--").pop()||h,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let h=q(),j=localStorage.getItem("uicopilot_session_token"),V=await ee(`${h}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(V.ok){let B=await V.json(),G=new Map((B.mappings||[]).map(te=>[te.storyId,te]));M.forEach(te=>{let le=G.get(te.id);le&&le.figmaNodeId&&(te.figmaMapping={figmaNodeId:le.figmaNodeId,figmaFrameName:le.name||le.figmaFrameName||""})})}}catch(h){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",h)}s(M);let z=M.find(h=>!h.figmaMapping);z?l(z.id):M.length>0&&l(M[0].id)}catch(y){console.error("[StoryMappingAssistant] Error fetching stories:",y)}finally{u(!1)}},[n]);N$(()=>{e&&R()},[e,R]);let _=Ro((y,F,L)=>{s(h=>h.map(j=>j.id===y?{...j,figmaMapping:{figmaNodeId:F,figmaFrameName:L}}:j));let M=i.findIndex(h=>h.id===y),z=i.find((h,j)=>j>M&&!h.figmaMapping);z&&l(z.id)},[i]),P=Ro(y=>{s(F=>F.map(L=>L.id===y?{...L,figmaMapping:null}:L))},[]),N=Ro(y=>{l(y),o("map")},[]),x=Ro(()=>{let y=i.filter(F=>F.figmaMapping).map(F=>F.id);k.collectAndMap(y)},[i,k]),v=Ro(()=>{let y=i.filter(F=>F.figmaMapping).map(F=>F.id);g(!1),k.rerun(y)},[i,k]),w=Ro(async y=>{await k.applyMappings(y),g(!1),k.reset(),R(),I()},[k,R,I]),E=Ro(()=>{g(!1),k.reset()},[k]);et.useEffect(()=>{k.results&&g(!0)},[k.results]);let f=y=>{y.target===y.currentTarget&&t()};if(!e)return null;let T=i.filter(y=>y.figmaMapping).length,S=i.length;return et.createElement(et.Fragment,null,et.createElement(O$,{onClick:f},et.createElement(_$,{onClick:y=>y.stopPropagation()},et.createElement($$,null,et.createElement(U$,null,et.createElement(j$,null,et.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),et.createElement(H$,null,et.createElement(zC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),et.createElement(zC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),et.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},A.enableAutoMap&&!d&&!k.isCollecting&&!k.isMapping&&et.createElement(e4,{onClick:x,disabled:a||i.length===0},et.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},et.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),et.createElement("path",{d:"M2 17l10 5 10-5"}),et.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),et.createElement(W$,{onClick:t},"\xD7"))),et.createElement(V$,null,(k.isCollecting||k.isMapping)&&et.createElement(Y$,null,et.createElement(K$,null,et.createElement(J$,null,et.createElement(Z$,null)),et.createElement(X$,null,"Auto-mapping stories to Figma"),et.createElement(Q$,null,k.progress),et.createElement(Pr,{onClick:k.cancel,variant:"ghost"},"Cancel"))),d&&k.results&&et.createElement(LC,{results:k.results,stories:i,onApply:w,onCancel:E,onRerun:v,isApplying:k.isApplying,isRerunning:k.isCollecting||k.isMapping,source:k.source,resolveThumbnail:y=>k.results?.thumbnailUrls?.[y],resolveStoryScreenshot:y=>D.screenshots[y],isCapturingScreenshots:D.isCapturing,onBrowse:y=>m(y)}),!d&&!k.isCollecting&&!k.isMapping&&(r==="map"?et.createElement(gC,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:_,projectId:n}):et.createElement(xC,{stories:i,loading:a,onLink:N,onUnlink:P,projectId:n}))),et.createElement(G$,null,et.createElement(q$,null,et.createElement("span",null,"Total: ",S," stories"),et.createElement(NC,{type:"mapped"},et.createElement("span",{className:"dot"}),T," mapped"),et.createElement(NC,{type:"unmapped"},et.createElement("span",{className:"dot"}),S-T," unmapped"))))),et.createElement(Ki,{isOpen:!!p,onClose:()=>m(null),onSelect:()=>m(null),projectId:n,initialSearch:p||void 0}))};ct();var _C=rr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",transition:"border-color 0.2s, box-shadow 0.2s","&:hover":{borderColor:e.color.mediumlight}})),n4=rr.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),r4=rr.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),o4=rr.div({display:"flex",alignItems:"center",gap:"8px"}),i4=rr.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),s4=rr.div(({theme:e,percent:t,state:n})=>({width:`${t}%`,height:"100%",borderRadius:"2px",backgroundColor:n==="complete"?e.color.positive:n==="partial"?e.color.warning:e.color.mediumlight,transition:"width 0.3s ease"})),a4=rr.span(({theme:e,state:t})=>({fontSize:"12px",fontWeight:600,color:t==="complete"?e.color.positive:t==="partial"?e.color.warning:e.color.mediumdark,whiteSpace:"nowrap"})),l4=rr.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),c4=rr(mu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),u4=rr(mu)(({theme:e})=>({padding:"4px 10px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626","&:hover":{textDecoration:"none",backgroundColor:"rgba(220, 38, 38, 0.08)"}})),p4=rr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),d4=rr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:se,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),g4=rr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),$C=()=>{let[e,t]=hc(!1),[n,r]=hc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Je(),{sessionToken:i}=ke();t4(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(_=>({..._,loading:!0}));try{let _=await fetch("/index.json");if(!_.ok)throw new Error("Failed to fetch Storybook index");let P=await _.json(),N=P.entries||P.stories||{},x=Object.keys(N).filter(T=>N[T].type==="story").length,v=Object.keys(N).filter(T=>N[T].type==="story"),w=q(),E=await ee(`${w}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),f=0;if(E.ok){let T=await E.json(),S=T.mappings||T||[];if(Array.isArray(S)){let y=new Set(S.map(F=>F.storyId).filter(Boolean));f=v.filter(F=>y.has(F)).length}else{let y=await ee(`${w}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(y.ok){let F=await y.json();f=Math.min(F.mappedStoriesCount||0,x)}}}r({totalStories:x,mappedStories:f,loading:!1})}catch(_){console.error("[FigmaMappingsSection] Error fetching stats:",_),r(P=>({...P,loading:!1}))}},[a,u]=hc(!1),[c,l]=hc(!1),d=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let _=q(),P=await ee(`${_}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!P.ok)throw new Error("Failed to fetch mappings");let x=(await P.json()).mappings||[];await Promise.all(x.map(v=>ee(`${_}/api/mappings?id=${encodeURIComponent(v.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(_){console.error("[FigmaMappingsSection] Unlink all failed:",_)}finally{u(!1)}},p=()=>t(!0),m=()=>{t(!1),o&&i&&s()};if(!o)return It.createElement(_C,null,It.createElement(p4,null,"Select a project to link Figma designs"));let{totalStories:k,loading:I}=n,A=Math.min(n.mappedStories,k),C=A===0?"none":A>=k?"complete":"partial",D=k>0?Math.min(100,Math.round(A/k*100)):0,R=C==="none"?"Link designs":"Manage";return It.createElement(It.Fragment,null,It.createElement(_C,null,It.createElement(n4,null,It.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},It.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),It.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),It.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),It.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),It.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),It.createElement(r4,null,It.createElement(l4,null,"Figma Mappings"),It.createElement(o4,null,I?It.createElement(It.Fragment,null,It.createElement(d4,null),It.createElement(g4,null,"Loading...")):It.createElement(It.Fragment,null,It.createElement(i4,null,It.createElement(s4,{percent:D,state:C})),It.createElement(a4,{state:C},`${A}/${k}`)))),A>0&&It.createElement(u4,{onClick:d,disabled:I||a},a?"Unlinking...":"Unlink All"),It.createElement(c4,{onClick:p,disabled:I},R)),e&&It.createElement(OC,{isOpen:e,onClose:m,projectId:o}),It.createElement(jr,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:g,onCancel:()=>l(!1)}))};import ae,{useState as Qi,useEffect as xc,useCallback as UC,useRef as ch}from"react";import{styled as or}from"storybook/theming";Te();He();ct();var uh=or.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),ph=or.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),dh=or.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),kre=or(Nr)({padding:"5px 12px",fontSize:"12px"}),gh=or.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),yc=or.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),f4=or.span(({theme:e,status:t})=>({display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="cached"?`${e.color.positive}1a`:t==="expired"?`${e.color.warning}1a`:e.background.hoverable,color:t==="cached"?e.color.positive:t==="expired"?e.color.warning:e.color.mediumdark})),m4=or.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),fh=or.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),h4=or.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),bc=or.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),Sc=or.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),zo=or.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),jC=new Set,HC=()=>{let{userRole:e,featureFlags:t}=ce(),[n,r]=Qi(null),[o,i]=Qi(!0),[s,a]=Qi(!1),[u,c]=Qi(!1),[l,d]=Qi(!1),[g,p]=Qi(!1),{selectedProjectId:m,projects:k}=Je(),{sessionToken:I}=ke(),A=ch(null),C=ch(null),D=ch(null),R=UC(()=>{A.current&&(clearInterval(A.current),A.current=null),C.current&&(clearInterval(C.current),C.current=null),D.current&&(clearTimeout(D.current),D.current=null)},[]);xc(()=>R,[R]);let _=UC(async()=>{if(!(!m||!I))try{let S=q(),y=await ee(`${S}/api/figma/cache-status?projectId=${m}`,{headers:{Authorization:`Bearer ${I}`}});if(y.ok){let F=await y.json();r(F)}}catch(S){console.error("[FigmaCacheSection] Error:",S)}finally{i(!1)}},[m,I]);xc(()=>{_()},[_]),xc(()=>{if(o||s||!n||n.structureStatus!=="none"||!m||jC.has(m))return;let S=k.find(F=>F.id===m);(S?.figmaFileUrl||S?.figmaFileId)&&(jC.add(m),P())},[o,s,n?.structureStatus,m,k]),xc(()=>{let S=n?.thumbnailProgress?.status,y=n?.enrichmentProgress?.status,F=n?.thumbnailProgress?.cached??0,L=n?.thumbnailProgress?.total??0,M=S==="in-progress"||S==="pending"||L>0&&F<L,z=y==="in-progress"||y==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(M||z||h)||!n||n.structureStatus==="none")return;let V=setInterval(()=>{_()},3e3);return()=>{clearInterval(V)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,_]);let P=async()=>{if(!(!m||!I)){a(!0);try{let S=q();await ee(`${S}/api/figma/frames?projectId=${m}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${I}`}},6e4),await new Promise(y=>setTimeout(y,1e3)),await _(),setTimeout(async()=>{await _()},3e3)}catch(S){console.error("[FigmaCacheSection] Reload error:",S)}finally{a(!1)}}},N=async()=>{if(!(!m||!I)){c(!0);try{let S=q(),y=await ee(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:m})});console.log("[FigmaCacheSection] Cache invalidate response:",y.status),await ee(`${S}/api/figma/frames/invalidate?projectId=${m}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(S){console.error("[FigmaCacheSection] Clear cache error:",S)}finally{c(!1)}}},x=async()=>{if(!(!m||!I)){R(),d(!0);try{let S=q();await ee(`${S}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:m})}),A.current=setInterval(async()=>{await _()},3e3),C.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(R(),d(!1),_())},3e3),D.current=setTimeout(()=>{R(),d(!1)},6e5)}catch(S){console.error("[FigmaCacheSection] Enrich error:",S),R(),d(!1)}}},v=async()=>{if(!(!m||!I)){p(!0);try{let S=q();await ee(`${S}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:m})}),await _()}catch(S){console.error("[FigmaCacheSection] Cancel error:",S)}finally{p(!1),d(!1),a(!1)}}},w=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!m)return null;if(o)return ae.createElement(uh,null,ae.createElement(ph,null,ae.createElement(dh,null,"Figma Cache")),ae.createElement(gh,null,ae.createElement(yc,null,"Loading cache status\u2026")),ae.createElement(bc,null,ae.createElement(Sc,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return ae.createElement(uh,null,ae.createElement(ph,null,ae.createElement(dh,null,"Figma Cache"),ae.createElement(Pr,{loading:s,onClick:P,loadingText:"Loading..."},"\u21BB Load")),s?ae.createElement(ae.Fragment,null,ae.createElement(bc,null,ae.createElement(Sc,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),ae.createElement(zo,null,ae.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):ae.createElement(gh,null,ae.createElement(yc,null,"No cache \u2014 click Load to fetch from Figma")));let E=S=>{let y=Date.now()-new Date(S).getTime(),F=Math.floor(y/6e4);if(F<1)return"just now";if(F<60)return`${F}m ago`;let L=Math.floor(F/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`},f=n.cacheDiff,T=f&&(f.added.length>0||f.removed.length>0||f.renamed.length>0);return ae.createElement(uh,null,ae.createElement(ph,null,ae.createElement(dh,null,"Figma Cache"," ",ae.createElement(f4,{status:n.structureStatus},n.structureStatus)),ae.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&ae.createElement(Pr,{loading:l,onClick:x,loadingText:"Enriching..."},"Enrich"),ae.createElement(Pr,{loading:u,onClick:N,variant:"ghost",loadingText:"Clearing..."},"Clear"),ae.createElement(Pr,{loading:s,onClick:P,loadingText:"Reloading..."},"\u21BB Reload"),w&&ae.createElement(Pr,{loading:g,onClick:v,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),s&&ae.createElement(zo,null,ae.createElement("span",null,"Downloading structure from Figma...")),ae.createElement(gh,null,ae.createElement(yc,null,ae.createElement("strong",null,n.componentSetCount)," component sets"),ae.createElement(yc,null,ae.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&ae.createElement(h4,null,"Updated ",E(n.structureCachedAt))),T&&ae.createElement(m4,null,"Since last reload:"," ",f.added.length>0&&ae.createElement(fh,{type:"added"},"+",f.added.length," added"),f.added.length>0&&f.removed.length>0&&" \xB7 ",f.removed.length>0&&ae.createElement(fh,{type:"removed"},"\u2212",f.removed.length," removed"),(f.added.length>0||f.removed.length>0)&&f.renamed.length>0&&" \xB7 ",f.renamed.length>0&&ae.createElement(fh,{type:"renamed"},f.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&ae.createElement(ae.Fragment,null,ae.createElement(bc,null,ae.createElement(Sc,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&ae.createElement(ae.Fragment,null," ",n.thumbnailProgress.currentName)),ae.createElement("span",null,n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached===0)&&ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: not yet cached",n.thumbnailProgress?.total?` (${n.thumbnailProgress.total} components)`:""," ","\u2014 click Reload to generate")),n.thumbnailProgress&&n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached>0&&ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&ae.createElement(ae.Fragment,null,ae.createElement(bc,null,ae.createElement(Sc,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),ae.createElement(zo,null,ae.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&ae.createElement(ae.Fragment,null," ",n.enrichmentProgress.currentName)),ae.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&ae.createElement(ae.Fragment,null,ae.createElement(zo,null,ae.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&ae.createElement("div",{style:{marginTop:"6px"}},ae.createElement(dc,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import St,{useState as Ji}from"react";import{styled as Wr}from"storybook/theming";Te();He();ct();var mh=Wr.div({padding:"12px 16px"}),x4=Wr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),WC=Wr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),VC=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:se,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),y4=Wr.div({display:"flex",gap:"8px",alignItems:"center"}),b4=Wr.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none",fontFamily:"monospace","&:focus":{borderColor:se,boxShadow:`0 0 0 1px ${se}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),GC=Wr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),S4=Wr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:se,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),w4=Wr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"6px",backgroundColor:"#16a34a10",border:"1px solid #16a34a30",fontSize:"12px",color:e.color.defaultText})),v4=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),qC=({onConnected:e})=>{let{sessionToken:t}=ke(),[n,r]=Ji(!1),[o,i]=Ji(""),[s,a]=Ji(!1),[u,c]=Ji(null),[l,d]=Ji(null),[g,p]=Ji(!1),m=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let k=q(),I=await ee(`${k}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),A=await I.json();if(!I.ok){c({type:"error",message:A.error||"Failed to save token"});return}d(A.figmaUser?.handle||A.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${A.figmaUser?.handle||"Figma user"}`}),i(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{a(!1)}}};return l?St.createElement(mh,null,St.createElement(WC,null,"Figma Personal Access Token"),St.createElement(w4,null,St.createElement("span",null,"\u2713 Connected as ",St.createElement("strong",null,l)),St.createElement(v4,{onClick:()=>{d(null),c(null)}},"Change token"))):n?St.createElement(mh,null,St.createElement(x4,null,St.createElement(WC,null,"Figma Personal Access Token"),St.createElement(VC,{onClick:()=>p(!g)},g?"Hide instructions":"How to generate")),g&&St.createElement(S4,null,St.createElement("ol",null,St.createElement("li",null,"Open ",St.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),St.createElement("li",null,"Click the ",St.createElement("strong",null,"Security")," tab"),St.createElement("li",null,"Scroll to ",St.createElement("strong",null,"Personal access tokens")),St.createElement("li",null,"Click ",St.createElement("strong",null,"Generate new token")),St.createElement("li",null,"Enable ",St.createElement("strong",null,"File content: Read only")," under Scopes"),St.createElement("li",null,"Copy the token and paste it below"))),St.createElement(y4,null,St.createElement(b4,{type:"password",value:o,onChange:k=>i(k.target.value),placeholder:"figd_...",onKeyDown:k=>{k.key==="Enter"&&o.trim()&&m()}}),St.createElement(on,{onClick:m,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&St.createElement(GC,{variant:u.type},u.message),St.createElement(GC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):St.createElement(mh,null,St.createElement(VC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};Te();He();ct();var C4=wt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},wt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),wt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),wt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),wt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),wt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"})),hh=Lr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),T4=Lr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),I4=Lr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),F4=Lr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),xh=Lr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),E4=Lr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",margin:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"})),A4=Lr.div({display:"flex",alignItems:"center",gap:"8px"}),P4=Lr(Fn)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),L4=Lr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Hre=Lr.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:"#A259FF",color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:"#8a3de8"}}),M4=Lr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.mediumdark,"&::before, &::after":{content:'""',flex:1,height:"1px",backgroundColor:e.appBorderColor}})),KC=({hideHeader:e=!1})=>{let{sessionToken:t}=ke(),[n,r]=wc(!1),[o,i]=wc(()=>{try{let p=sessionStorage.getItem("uicopilot_figma_connection");if(p){let{connected:m,ts:k}=JSON.parse(p);if(Date.now()-k<300*1e3)return m}}catch{}return null}),[s,a]=wc(!1),[u,c]=wc(!1);k4(()=>{if(!t)return;let p=q();ee(`${p}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(m=>m.json()).then(m=>{let k=!!m.connected;a(!!m.expired),i(k);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:k,ts:Date.now()}))}catch{}}).catch(()=>i(!1))},[t]);let l=YC(()=>{let p=q(),m=`${p}/api/auth/figma/login?addon=true`;window.open(m,"figma-oauth","width=600,height=700,left=200,top=100");let k=setInterval(async()=>{try{(await(await ee(`${p}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(k),i(!0))}catch{}},2e3);setTimeout(()=>clearInterval(k),300*1e3)},[t]),d=YC(async()=>{try{r(!0);let p=q(),m=await ee(`${p}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(m.ok||m.status===404){i(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{r(!1)}},[t]),g=e?null:wt.createElement(T4,null,wt.createElement(I4,null,C4),wt.createElement(F4,null,"Figma Integration"));return o===null?wt.createElement(hh,null,g,wt.createElement(xh,null,wt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?wt.createElement(hh,null,g,wt.createElement(xh,null,wt.createElement(L4,null,s&&wt.createElement("div",{style:{padding:"10px 12px",backgroundColor:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#92400e"}},"\u26A0\uFE0F Your Figma access has expired. Please reconnect."),wt.createElement(on,{onClick:l,style:{width:"100%"}},s?"Reconnect Figma":"Connect with Figma"),wt.createElement(M4,null,"or"),wt.createElement(qC,{onConnected:()=>i(!0)})))):wt.createElement(hh,null,g,wt.createElement(E4,null,wt.createElement(A4,null,wt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),wt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),wt.createElement(P4,{onClick:()=>c(!0),disabled:n},n?"Disconnecting...":"Disconnect")),wt.createElement(jr,{isOpen:u,title:"Disconnect Figma",message:"Your mappings, cache, and review history will be preserved. You will need to re-authenticate to make new Figma API calls.",confirmLabel:"Disconnect",variant:"danger",onConfirm:()=>{c(!1),d()},onCancel:()=>c(!1)}),wt.createElement(xh,null,wt.createElement(yk,null),wt.createElement($C,null),wt.createElement(HC,null)))};Te();_n();var R4=hr.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"32px"}),z4=hr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"14px",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.22)",width:"520px",maxWidth:"94%",maxHeight:"calc(100vh - 64px)",overflow:"auto",position:"relative"})),N4=hr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",position:"sticky",top:0,backgroundColor:e.background.content,borderRadius:"14px 14px 0 0",zIndex:1})),O4=hr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),_4=hr(En)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),$4=hr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),XC=hr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),QC=hr.div({display:"flex",alignItems:"center",gap:"10px"}),JC=hr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),U4=hr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:se,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),j4=hr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),ZC=hr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"12px",fontSize:"12px","& > div, & > section":{padding:0},'[class*="AuthPanelContainer"], [class*="SectionContainer"]':{padding:0},"h3, h4":{fontSize:"12px",margin:"0 0 6px 0"},label:{fontSize:"12px"},"input, select":{fontSize:"12px",padding:"6px 10px",height:"auto"},button:{fontSize:"11px"},p:{fontSize:"11px",margin:"2px 0"}})),e1=({onClose:e})=>{let{isConnected:t}=ke(),{selectedProjectId:n}=Je(),r=D4(t);return B4(()=>{!r.current&&t&&n&&e(),r.current=t},[t,n,e]),Bt.createElement(R4,{onClick:e},Bt.createElement(z4,{onClick:o=>o.stopPropagation()},Bt.createElement(N4,null,Bt.createElement(O4,null,"Settings"),Bt.createElement(_4,{onClick:e,title:"Close settings"},"\xD7")),Bt.createElement($4,null,Bt.createElement(XC,null,Bt.createElement(QC,null,Bt.createElement(U4,null,"UI"),Bt.createElement(JC,null,Pt.NAME)),Bt.createElement(ZC,null,Bt.createElement(gk,{onConnect:e}),t&&Bt.createElement(hk,null))),t&&n&&Bt.createElement(XC,null,Bt.createElement(QC,null,Bt.createElement(j4,null,Bt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Bt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),Bt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),Bt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Bt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),Bt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),Bt.createElement(JC,null,"Figma Integration")),Bt.createElement(ZC,null,Bt.createElement(KC,{hideHeader:!0}))))))};import ht,{useEffect as u1,useMemo as m3,useState as h3,useRef as x3}from"react";import{styled as qn,keyframes as y3}from"storybook/theming";Te();_n();Te();import Qt,{useState as H4}from"react";import{styled as Gn}from"storybook/theming";var co=[{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Latest Claude model, best balance of speed and quality"},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",provider:"anthropic",description:"Previous generation Sonnet"},{id:"claude-3-5-sonnet-20241022",name:"Claude 3.5 Sonnet",provider:"anthropic",description:"Best balance of speed and quality"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",provider:"anthropic",description:"Fastest, most affordable"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus",provider:"anthropic",description:"Most capable Claude 3 model"},{id:"gpt-5.2",name:"GPT-5.2 Thinking",provider:"openai",description:"47% cheaper, reasoning"},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Instant",provider:"openai",description:"86% cheaper (default)"},{id:"gpt-4o",name:"GPT-4o",provider:"openai",description:"GPT-4 multimodal flagship"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai",description:"GPT-4 affordable model"},{id:"o1-preview",name:"o1 Preview",provider:"openai",description:"Reasoning model (slower, advanced)"},{id:"o1-mini",name:"o1 Mini",provider:"openai",description:"Faster reasoning model"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"Fast & cheap, great vision"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"Best Gemini quality"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"google",description:"Previous gen, very fast"}];var W4=Gn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),V4=Gn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),G4=Gn.div(({theme:e,disabled:t,provider:n})=>{let r={anthropic:{background:"#D4A574",text:"#ffffff"},openai:{background:e.color.positive||"#10b981",text:"#ffffff"},google:{background:"#4285F4",text:"#ffffff"}},o=n?r[n]:r.anthropic;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:o.background,color:o.text,fontSize:"11px",fontWeight:500,borderRadius:"12px",opacity:t?.6:1,cursor:t?"not-allowed":"default",transition:"opacity 0.15s"}}),q4=Gn.button(({theme:e,disabled:t})=>({background:"none",border:"none",color:e.color.inverseText,fontSize:"12px",cursor:t?"not-allowed":"pointer",padding:"0 2px",lineHeight:1,opacity:t?.5:.8,transition:"opacity 0.15s","&:hover":{opacity:t?.5:1}})),Y4=Gn.div({position:"relative",display:"inline-block"}),K4=Gn.button(({disabled:e,isOpen:t,theme:n})=>({padding:`${n.layoutMargin*.8}px 32px ${n.layoutMargin*.8}px ${n.layoutMargin}px`,fontSize:n.typography.size.s2,fontFamily:n.typography.fonts.base,fontWeight:500,color:n.color.defaultText,backgroundColor:n.input.background,border:`1px solid ${t?n.color.secondary:n.appBorderColor}`,borderRadius:n.appBorderRadius,cursor:e?"not-allowed":"pointer",opacity:e?.6:1,whiteSpace:"nowrap",display:"flex",gap:`${n.layoutMargin*.8}px`,alignItems:"center",justifyContent:"space-between",minWidth:"200px",transition:"border-color 0.15s, box-shadow 0.15s",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px","&:hover":{borderColor:e?n.appBorderColor:n.color.mediumdark}})),X4=Gn.div(({theme:e})=>({position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:e.base==="dark"?"0 4px 12px rgba(0, 0, 0, 0.3)":"0 4px 12px rgba(0, 0, 0, 0.1)",zIndex:1e3,maxHeight:"280px",overflowY:"auto"})),yh=Gn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),bh=Gn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),Q4=Gn.div(({theme:e,disabled:t})=>({padding:"8px 12px",fontSize:"12px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,display:"flex",alignItems:"center",gap:"8px",transition:"background-color 0.15s",color:e.color.defaultText,"&:hover":{backgroundColor:t?"transparent":e.background.hoverable}})),J4=Gn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),Z4=Gn.div({flex:1,minWidth:0}),e3=Gn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),t3=Gn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),n3=5,t1=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ce(),[r,o]=H4(!1),i=co.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=co.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=co.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=co.filter(p=>e.includes(p.id)),c=e.length<n3,l=(p,m)=>{m.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let m=e.includes(p);m&&e.length===1||!m&&!c||n||(t(p),o(!1))},g=p=>{let m=e.includes(p.id),k=m&&e.length===1,I=n||k||!m&&!c;return Qt.createElement(Q4,{key:p.id,disabled:I,onClick:()=>d(p.id)},Qt.createElement(J4,{type:"checkbox",checked:m,disabled:I,onChange:()=>{},onClick:A=>A.stopPropagation()}),Qt.createElement(Z4,null,Qt.createElement(e3,null,p.name),p.description&&Qt.createElement(t3,null,p.description)))};return Qt.createElement(W4,null,Qt.createElement(Y4,null,Qt.createElement(K4,{disabled:n,isOpen:r,onClick:()=>o(!r)},Qt.createElement("span",null,"Select model"),Qt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Qt.createElement(X4,null,Qt.createElement(yh,null,Qt.createElement(bh,null,"Anthropic"),i.map(g)),Qt.createElement(yh,null,Qt.createElement(bh,null,"OpenAI"),s.map(g)),Qt.createElement(yh,null,Qt.createElement(bh,null,"Google"),a.map(g)))),Qt.createElement(V4,null,u.map(p=>Qt.createElement(G4,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Qt.createElement(q4,{disabled:n,onClick:m=>l(p.id,m),title:"Remove model"},"\xD7")))))};import ze,{useState as r3,useEffect as o3}from"react";import{styled as nn,keyframes as Zi}from"storybook/theming";Te();var i3=Zi`
44
+ `,K_=SC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${Y_} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),X_=SC.button(({theme:e,variant:t="default",disabled:n})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"5px 12px",fontSize:"12px",fontWeight:600,border:`1px solid ${e.color.medium}`,borderRadius:"5px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transition:"all 0.2s",whiteSpace:"nowrap",...t==="default"&&{backgroundColor:e.background.content,color:e.color.defaultText,"&:hover":n?{}:{borderColor:e.color.secondary,color:e.color.secondary,backgroundColor:"rgba(30, 167, 253, 0.05)"}},...t==="ghost"&&{backgroundColor:"transparent",border:"none",color:e.color.mediumdark,padding:"5px 8px","&:hover":n?{}:{color:e.color.defaultText,backgroundColor:e.background.hoverable}}})),Pr=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>bC.createElement(X_,{variant:r,disabled:t||e,onClick:n},e&&bC.createElement(K_,null),e&&i?i:o);He();import un from"react";import{styled as la}from"storybook/theming";var wC=la.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",backgroundColor:e.background.hoverable,borderRadius:"6px",fontFamily:"Inter, sans-serif",fontSize:"11px",color:e.color.mediumdark,gap:"16px"})),Q_=la.div({display:"flex",alignItems:"center",gap:"12px"}),uc=la.span({whiteSpace:"nowrap"}),vC=la.div({display:"flex",alignItems:"center",gap:"8px"}),pc=la.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),dc=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Fw;return r?un.createElement(wC,null,un.createElement(uc,null,o.toLocaleString()," tokens"),un.createElement(vC,null,un.createElement(pc,null,"$",n.toFixed(4)),un.createElement("span",null,"\xB7"),un.createElement(pc,null,"\u20AA",i.toFixed(2)))):un.createElement(wC,null,un.createElement(Q_,null,un.createElement(uc,null,e.toLocaleString()," input"),un.createElement("span",null,"+"),un.createElement(uc,null,t.toLocaleString()," output"),un.createElement("span",null,"="),un.createElement(uc,null,un.createElement("strong",null,o.toLocaleString())," tokens")),un.createElement(vC,null,un.createElement(pc,null,"$",n.toFixed(4)),un.createElement("span",null,"\xB7"),un.createElement(pc,null,"\u20AA",i.toFixed(2))))};import Vn from"react";import{styled as Mo}from"storybook/theming";function ih(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var J_=Mo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),kC=Mo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),Z_=Mo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),e$=Mo.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.2}px`,padding:`1px ${e.layoutMargin*.5}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.mono})),t$=Mo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),n$=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),r$=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),o$=Mo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),CC=({data:e,color:t,compact:n})=>n?Vn.createElement(kC,{color:t},e.summary):Vn.createElement(J_,null,Vn.createElement(kC,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Vn.createElement(Z_,null,e.mappings.map((r,o)=>Vn.createElement(Vn.Fragment,{key:o},Vn.createElement(e$,null,r.from," ",Vn.createElement(t$,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Vn.createElement(n$,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Vn.createElement(Vn.Fragment,null,e.defaults.map((r,o)=>Vn.createElement(r$,{key:o},Vn.createElement(o$,null,r.choice),Vn.createElement("span",null,"\u2014 ",r.why)))));var i$=ft.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),s$=ft.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),a$=ft.div({display:"flex",flexDirection:"column",gap:"4px"}),l$=ft.div({display:"flex",alignItems:"center",gap:"10px"}),c$=ft.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,letterSpacing:"-0.3px"})),IC=ft.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="success"?`${e.color.positive}1a`:t==="danger"?`${e.color.negative}1a`:`${e.color.secondary}1a`,color:t==="success"?e.color.positive:t==="danger"?e.color.negative:e.color.secondary})),u$=ft.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),p$=ft.div({display:"flex",gap:"8px"}),d$=ft.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),g$=ft(So)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),f$=ft.div({display:"flex",gap:"4px"}),gc=ft.button(({theme:e,active:t})=>({padding:"6px 12px",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,border:t?"none":`1px solid ${e.appBorderColor}`,backgroundColor:t?e.color.defaultText:e.background.content,color:t?e.color.inverseText:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:t?e.color.defaultText:e.background.hoverable}})),m$=ft.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),h$=ft.div(({theme:e,dimmed:t})=>({display:"flex",alignItems:"center",padding:"12px 16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"10px",gap:"12px",backgroundColor:e.background.content,opacity:t?.6:1,transition:"opacity 0.15s",position:"relative",zIndex:0,"&:hover":{zIndex:10}})),x$=ft.div(({theme:e,checked:t})=>({width:"18px",height:"18px",borderRadius:"4px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"all 0.15s",...t?{backgroundColor:e.color.defaultText,color:e.color.inverseText,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold}:{border:`2px solid ${e.color.mediumlight}`}})),y$=ft.div(({theme:e,bgColor:t})=>({width:"48px",height:"40px",borderRadius:"6px",backgroundColor:t||e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"})),fc=ft.div(({theme:e})=>({width:"120px",height:"80px",borderRadius:"8px",backgroundColor:e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden",border:`1px solid ${e.appBorderColor}`})),b$=ft.img({width:"100%",height:"100%",objectFit:"contain"}),LC=ft.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"uicopilot-spin 0.8s linear infinite","@keyframes uicopilot-spin":{to:{transform:"rotate(360deg)"}}})),FC=ft.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),EC=ft.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),sh=ft.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),wne=ft.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,lineHeight:1.5,whiteSpace:"pre-line"})),S$=ft.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),w$=ft.span(({theme:e,level:t})=>({padding:"4px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,flexShrink:0,backgroundColor:t==="high"?`${e.color.positive}1a`:t==="medium"?`${e.color.warning}1a`:`${e.color.negative}1a`,color:t==="high"?e.color.positive:t==="medium"?e.color.warning:e.color.negative})),v$=ft.button(({theme:e})=>({padding:"4px 8px",borderRadius:e.appBorderRadius,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,border:`1px solid ${e.appBorderColor}`,backgroundColor:"transparent",color:e.color.mediumdark,cursor:"pointer",flexShrink:0,transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText}})),k$=ft.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),C$=ft.div({display:"flex",flexWrap:"wrap",gap:"6px"}),T$=ft.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),I$=ft.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="cache"?`${e.color.warning}1a`:`${e.color.positive}1a`,color:t==="cache"?e.color.warning:e.color.positive})),F$=ft.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"5px",padding:"5px 12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:"transparent",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),vne=ft.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 24px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:e.color.mediumdark})),AC=({src:e,alt:t})=>{let[n,r]=mc(!1);return Ee.createElement(Ee.Fragment,null,!n&&Ee.createElement(LC,null),Ee.createElement(b$,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function PC(e){return e>=90?"high":e>=70?"medium":"low"}function E$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var MC=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:d})=>{let[g,p]=mc(()=>{let w=new Set;for(let E of e.mappings)E.confidence>=90&&w.add(E.storyId);return w}),[m,v]=mc(""),[I,A]=mc("all"),C=TC(()=>{let w=new Map;for(let E of t)w.set(E.id,{name:E.name,title:E.title});return w},[t]),D=TC(()=>{let w=e.mappings;if(I!=="all"&&(w=w.filter(E=>PC(E.confidence)===I)),m.trim()){let E=m.toLowerCase();w=w.filter(f=>{let T=C.get(f.storyId);return T?.name.toLowerCase().includes(E)||T?.title.toLowerCase().includes(E)||f.componentSetName.toLowerCase().includes(E)||f.figmaFrameName.toLowerCase().includes(E)})}return w},[e.mappings,I,m,C]),R=w=>{p(E=>{let f=new Set(E);return f.has(w)?f.delete(w):f.add(w),f})},_=()=>{let w=e.mappings.filter(E=>g.has(E.storyId));n(w)},P=e.mappings.filter(w=>w.confidence>=90).length,N=e.mappings.filter(w=>w.confidence>=70&&w.confidence<90).length,x=e.mappings.filter(w=>w.confidence<70).length,k=e.usage;return Ee.createElement(i$,null,Ee.createElement(s$,null,Ee.createElement(a$,null,Ee.createElement(l$,null,Ee.createElement(c$,null,"Auto-Map Results"),Ee.createElement(IC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Ee.createElement(IC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Ee.createElement(I$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Ee.createElement(u$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Ee.createElement(p$,null,a==="cache"&&o&&Ee.createElement(F$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Ee.createElement(Pr,{onClick:r,variant:"ghost"},"Cancel"),Ee.createElement(Pr,{loading:i,onClick:_,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Ee.createElement(d$,null,Ee.createElement(g$,{type:"text",placeholder:"Filter stories...",value:m,onChange:w=>v(w.target.value)}),Ee.createElement(f$,null,Ee.createElement(gc,{active:I==="all",onClick:()=>A("all")},"All ",e.mappings.length),P>0&&Ee.createElement(gc,{active:I==="high",onClick:()=>A("high")},"\u226590% (",P,")"),N>0&&Ee.createElement(gc,{active:I==="medium",onClick:()=>A("medium")},"70-89% (",N,")"),x>0&&Ee.createElement(gc,{active:I==="low",onClick:()=>A("low")},"<70% (",x,")"))),Ee.createElement(m$,null,D.map(w=>{let E=C.get(w.storyId),f=PC(w.confidence),T=g.has(w.storyId),S=f==="low";return Ee.createElement(h$,{key:w.storyId,dimmed:S&&!T},Ee.createElement(x$,{checked:T,onClick:()=>R(w.storyId)},T?"\u2713":""),(()=>{let y=c?.(w.storyId);return y?Ee.createElement(fc,null,Ee.createElement(AC,{src:y,alt:E?.name||w.storyId})):l?Ee.createElement(fc,null,Ee.createElement(LC,null)):Ee.createElement(y$,{bgColor:S?"#f1f5f9":"#eff6ff"},Ee.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:S?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)))})(),Ee.createElement(FC,null,Ee.createElement(EC,null,E?.name||w.storyId),Ee.createElement(sh,null,E?.title||"")),Ee.createElement(S$,null,"\u2192"),(()=>{let y=u?.(w.figmaNodeId),F=ih(w.reason),L=F.summary+(F.candidates?` (${F.candidates} candidates)`:"");return y?Ee.createElement(fc,{title:L},Ee.createElement(AC,{src:y,alt:w.figmaFrameName})):Ee.createElement(fc,{title:L},Ee.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Ee.createElement(FC,null,Ee.createElement(EC,null,w.componentSetName),Ee.createElement(sh,null,w.figmaFrameName),Ee.createElement(CC,{data:ih(w.reason),color:E$(f)})),Ee.createElement(w$,{level:f},w.confidence,"%"),d&&Ee.createElement(v$,{onClick:()=>d(w.componentSetName)},"Browse"))}),e.unmatched.length>0&&Ee.createElement(k$,null,Ee.createElement(sh,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Ee.createElement(C$,null,e.unmatched.map(w=>{let E=C.get(w);return Ee.createElement(T$,{key:w},Ee.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:w)})))),k&&a!=="cache"&&Ee.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Ee.createElement(dc,{inputTokens:k.inputTokens||0,outputTokens:k.outputTokens||0,costUsd:k.costUsd||0})))};He();_e();import{useState as Bo,useCallback as Do,useRef as A$}from"react";import{useStorybookApi as P$}from"storybook/manager-api";function BC({projectId:e}){let t=P$(),n=A$(null),[r,o]=Bo(!1),[i,s]=Bo(!1),[a,u]=Bo(!1),[c,l]=Bo(null),[d,g]=Bo(null),[p,m]=Bo(null),[v,I]=Bo(""),[A,C]=Bo(null),D=Do(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let f=await E.json(),T=f.entries||f.stories||{},S=Object.keys(T).filter(L=>T[L].type==="story");b.debug(`[useAutoMap] Found ${S.length} stories in index.json`);let y=[];for(let L of S){let M=T[L],z=t.getData(L),h={...z?.initialArgs||{}},j=z?.argTypes||{};for(let[V,B]of Object.entries(j))if(!(V in h)){let G=B;if(G.defaultValue!==void 0)h[V]=G.defaultValue;else if(G.table?.defaultValue?.summary!==void 0){let te=G.table.defaultValue.summary;te==="false"?h[V]=!1:te==="true"?h[V]=!0:h[V]=te}}y.push({id:L,name:M.name||L.split("--").pop()||L,title:M.title||"",initialArgs:h,argTypes:j})}let F=y.filter(L=>Object.keys(L.initialArgs).length>0);return b.debug(`[useAutoMap] Manifest: ${y.length} stories, ${F.length} with args`),y},[t]),R=Do(async()=>{if(!e)return!1;try{let E=q(),f=localStorage.getItem("uicopilot_session_token");if(!f)return!1;let T=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${f}`}});if(!T.ok)return!1;let S=await T.json();return S.hasSuggestions&&S.mappings?.length>0?(g(S),C("cache"),I(`Loaded ${S.mappings.length} saved suggestions`),b.debug(`[useAutoMap] Loaded ${S.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),_=Do(async E=>{o(!0),I("Collecting story information...");let f;try{if(f=await D(),E?.length&&(f=f.filter(S=>!E.includes(S.id)),b.debug(`[useAutoMap] After excluding mapped: ${f.length} stories`)),f.length===0){l("No unmapped stories found"),o(!1);return}m(f)}catch(S){l(S instanceof Error?S.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),I(`Analyzing ${f.length} stories against Figma components...`);let T=new AbortController;n.current=T;try{let S=q(),y=localStorage.getItem("uicopilot_session_token");if(!y)throw new Error("Not authenticated");let F=await fetch(`${S}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({projectId:e,stories:f.map(M=>({id:M.id,name:M.name,title:M.title,initialArgs:M.initialArgs,argTypes:M.argTypes}))}),signal:T.signal});if(!F.ok){let M=await F.json();throw new Error(M.error||"Auto-map failed")}let L=await F.json();g(L),C("llm"),I(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),b.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(S){if(S instanceof DOMException&&S.name==="AbortError"){I("Cancelled");return}l(S instanceof Error?S.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),P=Do(async E=>{if(!e)return;if(l(null),g(null),C(null),o(!0),I("Checking for existing suggestions..."),await R()){o(!1);return}await _(E)},[e,R,_]),N=Do(async E=>{e&&(l(null),g(null),C(null),await _(E))},[e,_]),x=Do(async E=>{if(!(!e||E.length===0)){u(!0),I(`Applying ${E.length} mappings...`);try{let f=q(),T=localStorage.getItem("uicopilot_session_token");if(!T)throw new Error("Not authenticated");let S=0;for(let y of E)try{(await fetch(`${f}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:e,storyId:y.storyId,figmaNodeId:y.figmaNodeId,name:y.figmaFrameName||y.componentSetName})})).ok?S++:b.warn(`[useAutoMap] Failed to apply mapping for ${y.storyId}`)}catch(F){b.error(`[useAutoMap] Error applying mapping for ${y.storyId}:`,F)}I(`Applied ${S}/${E.length} mappings`),b.debug(`[useAutoMap] Applied ${S}/${E.length} mappings`)}catch(f){l(f instanceof Error?f.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),k=Do(()=>{n.current?.abort()},[]),w=Do(()=>{g(null),m(null),l(null),I(""),C(null)},[]);return{collectAndMap:P,rerun:N,loadExisting:R,applyMappings:x,cancel:k,reset:w,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:v,source:A}}_e();import{useState as ah,useEffect as L$,useRef as DC}from"react";var RC=2;async function M$(e,t){try{let n=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`,{signal:t});return n.ok&&(await n.json()).screenshot||null}catch{return null}}function zC(e){let[t,n]=ah({}),[r,o]=ah(0),[i,s]=ah(!1),a=DC(null),u=DC(""),c=e.join(",");return L$(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let d=0;return(async()=>{for(let p=0;p<e.length&&!l.signal.aborted;p+=RC){let m=e.slice(p,p+RC),v=await Promise.all(m.map(A=>M$(A,l.signal).then(C=>({id:A,img:C}))));if(l.signal.aborted)break;let I={};for(let{id:A,img:C}of v)d++,C&&(I[A]=C);Object.keys(I).length>0&&n(A=>({...A,...I})),o(d)}s(!1),b.debug(`[useStoryScreenshots] Captured ${d}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import we,{useState as lh,useEffect as ca,useMemo as B$,useCallback as D$}from"react";import{styled as R$}from"storybook/theming";_e();var z$=R$.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.secondary,color:e.color.secondary},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Ki=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=ta({projectId:r||"",enabled:e&&!!r}),d=we.useRef(!1);ca(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[g,p]=lh(new Set),[m,v]=lh(i||o[0]?.id||"");ca(()=>{i&&v(i)},[i]);let I=50,A=8,[C,D]=lh({}),R=D$(f=>{D(T=>({...T,[f]:(T[f]||1)+1}))},[]);ca(()=>{D({})},[l.variantFilters]),ca(()=>{l.expandedSets.forEach(f=>{let T=l.variantChildren[f];if(!T||T.length===0)return;let S=T;l.variantFilters.some(L=>L.value)&&(S=T.filter(L=>L.variantProperties?l.variantFilters.every(M=>M.value?L.variantProperties?.[M.property]===M.value:!0):!1));let y=C[f]||1,F=S.slice(0,y*I).map(L=>L.id);for(let L=0;L<F.length;L+=A){let M=F.slice(L,L+A),z=L/A*300;z===0?l.fetchVariantThumbnails(f,M):setTimeout(()=>l.fetchVariantThumbnails(f,M),z)}})},[l.expandedSets,l.variantChildren,l.variantFilters,C]),ca(()=>{p(new Set)},[m]);let _=B$(()=>{let f=[];return l.filteredFrames.forEach(T=>{if(T.type==="COMPONENT_SET"&&T.children){let S=l.variantFilters.some(y=>y.value)?T.children.filter(y=>y.variantProperties?l.variantFilters.every(F=>F.value?y.variantProperties?.[F.property]===F.value:!0):!1):T.children;f.push(...S)}else f.push(T)}),f},[l.filteredFrames,l.variantFilters]),P=f=>{if(a)p(T=>{let S=new Set(T);return S.has(f.id)?S.delete(f.id):S.add(f.id),S});else{let T=l.resolveThumbnail(f.id);try{n({...f,thumbnail:T})}catch(S){b.error("[ComponentBrowserModal] onSelect threw error:",S)}t()}},N=()=>{let f=_.map(S=>S.id),T=f.every(S=>g.has(S));p(T?new Set:new Set(f))},x=()=>{if(u&&g.size>0){let f=_.filter(T=>g.has(T.id)).map(T=>({...T,thumbnail:l.resolveThumbnail(T.id)}));u(f),p(new Set)}},k=f=>{v(f),s?.(f)},w=f=>{f.target===f.currentTarget&&t()},E=o.find(f=>f.id===m);return e?we.createElement(Sk,{onClick:w},we.createElement(wk,null,we.createElement(vk,null,we.createElement(kk,null,"Link Figma Frames"),we.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},we.createElement("button",{onClick:()=>l.refresh(),disabled:l.isLoading,style:{padding:"4px 8px",fontSize:"12px",cursor:l.isLoading?"not-allowed":"pointer",background:"transparent",border:"1px solid #ccc",borderRadius:"4px"},title:"Refresh from Figma"},"Refresh"),we.createElement(Ck,{onClick:t},"\xD7"))),we.createElement(Tk,null,l.error&&we.createElement(Mk,null,l.error),!l.error&&we.createElement(we.Fragment,null,o.length>0&&we.createElement(Hk,null,we.createElement(Wk,null,"Story:"),we.createElement(Vk,{value:m,onChange:f=>k(f.target.value)},o.map(f=>we.createElement("option",{key:f.id,value:f.id},f.name,f.mappingsCount?` (${f.mappingsCount} linked)`:""))),E?.mappingsCount?we.createElement(Gk,{hasMapping:!0},E.mappingsCount," frames linked"):null),we.createElement(Pk,null,we.createElement(rc,null,we.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:f=>l.setShowComponentSets(f.target.checked)}),"Component Sets"),we.createElement(rc,null,we.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:f=>l.setShowFrames(f.target.checked)}),"Frames"),we.createElement(rc,null,we.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:f=>l.setShowComponents(f.target.checked)}),"Components"),l.availablePages.length>1&&we.createElement(qi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:f=>l.setFigmaPage(f.target.value),style:{marginLeft:"auto"}},we.createElement("option",{value:""},"All pages"),l.availablePages.map(f=>we.createElement("option",{key:f,value:f},f)))),l.filterSuggestion&&we.createElement(qk,null,we.createElement(Yk,null,"AI suggests:"),we.createElement(Kk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([f,T])=>`${f}=${T}`).join(", ")),we.createElement(Xk,{onClick:l.applySuggestedFilters},"Apply"),we.createElement(Qk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&we.createElement(Jk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&we.createElement(ic,null,we.createElement(sa,null,"Filters:"),l.availableFilters.map(({property:f,values:T})=>{let S=l.variantFilters.find(y=>y.property===f);return we.createElement(qi,{key:f,isActive:!!S?.value,value:S?.value||"",onChange:y=>l.handleFilterChange(f,y.target.value)},we.createElement("option",{value:""},f),T.map(y=>we.createElement("option",{key:y,value:y},f,"=",y)))}),l.variantFilters.some(f=>f.value)&&we.createElement(sc,{onClick:l.clearFilters},"Clear All")),l.rateLimitError&&we.createElement("div",{style:{padding:"8px 12px",marginBottom:"8px",background:"rgba(234, 88, 12, 0.12)",border:"1px solid rgba(234, 88, 12, 0.3)",borderRadius:"6px",fontSize:"12px",color:"#ea580c"}},"\u26A0 Figma thumbnail previews unavailable \u2014"," ",l.rateLimitError,". You can still select by name."),we.createElement(Ik,{type:"text",placeholder:"Search frames...",value:l.search,onChange:f=>l.setSearch(f.target.value),autoFocus:!0}),a&&_.length>0&&we.createElement(Zk,null,we.createElement(eC,{onClick:N},g.size===_.length?"Deselect All":"Select All Visible"),we.createElement(tC,null,g.size>0?`${g.size} selected of `:"Showing ",_.length," frames")),l.isLoading&&we.createElement(Um,null,Array.from({length:6}).map((f,T)=>we.createElement(jk,{key:T},we.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},we.createElement(oc,{width:"100%",height:"100%"})),we.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},we.createElement(oc,{width:"80%",height:"16px"}),we.createElement(oc,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&we.createElement(Lk,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&we.createElement(Um,null,l.filteredFrames.map(f=>we.createElement(aa,{key:f.id,frame:f,thumbnail:l.thumbnails[f.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[f.id],variantChildren:l.variantChildren[f.id],variantFailed:l.variantFailed[f.id],isLoadingVariants:l.loadingVariants.has(f.id),isExpanded:l.expandedSets.has(f.id),isNew:l.recentlyAdded.has(f.name),onToggleExpand:l.toggleExpanded,onSelect:P,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:C[f.id]||1,onShowMore:R})),l.hasMore&&we.createElement(z$,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&we.createElement(nC,null,we.createElement(rC,{disabled:g.size===0,onClick:x},"Link ",g.size," Selected")))):null};Te();ct();var O$=tn.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4}),_$=tn.div(({theme:e})=>({width:"90vw",maxWidth:"1100px",height:"75vh",backgroundColor:e.background.content,borderRadius:"12px",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",overflow:"hidden"})),$$=tn.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),U$=tn.div({display:"flex",alignItems:"center",gap:"20px"}),j$=tn.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),H$=tn.div({display:"flex",gap:"4px"}),NC=tn(bo)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),W$=tn(En)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),V$=tn.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),G$=tn.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),q$=tn.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),Y$=tn.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),K$=tn.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),X$=tn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),Q$=tn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),J$=tn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),Z$=tn.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),e4=tn.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",backgroundColor:e.color.defaultText,color:"white",border:"none",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,cursor:"pointer",transition:"opacity 0.15s","&:hover":{opacity:.85},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),OC=tn.span(({theme:e,type:t})=>({display:"flex",alignItems:"center",gap:"6px","& .dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:t==="mapped"?e.color.positive:t==="unmapped"?e.color.mediumlight:"transparent"}})),_C=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Xi("map"),[i,s]=Xi([]),[a,u]=Xi(!0),[c,l]=Xi(null),[d,g]=Xi(!1),[p,m]=Xi(null),v=BC({projectId:n}),{refreshMappings:I}=nt(),{featureFlags:A}=ce(),C=et.useMemo(()=>v.results?.mappings.map(y=>y.storyId)||[],[v.results]),D=zC(C),R=Ro(async()=>{u(!0);try{let y=await fetch("/index.json");if(!y.ok)throw new Error("Failed to fetch index.json");let F=await y.json(),L=F.entries||F.stories||{},M=Object.entries(L).filter(([,h])=>h.type==="story").map(([h,j])=>({id:h,name:j.name||h.split("--").pop()||h,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let h=q(),j=localStorage.getItem("uicopilot_session_token"),V=await ee(`${h}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(V.ok){let B=await V.json(),G=new Map((B.mappings||[]).map(te=>[te.storyId,te]));M.forEach(te=>{let le=G.get(te.id);le&&le.figmaNodeId&&(te.figmaMapping={figmaNodeId:le.figmaNodeId,figmaFrameName:le.name||le.figmaFrameName||""})})}}catch(h){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",h)}s(M);let z=M.find(h=>!h.figmaMapping);z?l(z.id):M.length>0&&l(M[0].id)}catch(y){console.error("[StoryMappingAssistant] Error fetching stories:",y)}finally{u(!1)}},[n]);N$(()=>{e&&R()},[e,R]);let _=Ro((y,F,L)=>{s(h=>h.map(j=>j.id===y?{...j,figmaMapping:{figmaNodeId:F,figmaFrameName:L}}:j));let M=i.findIndex(h=>h.id===y),z=i.find((h,j)=>j>M&&!h.figmaMapping);z&&l(z.id)},[i]),P=Ro(y=>{s(F=>F.map(L=>L.id===y?{...L,figmaMapping:null}:L))},[]),N=Ro(y=>{l(y),o("map")},[]),x=Ro(()=>{let y=i.filter(F=>F.figmaMapping).map(F=>F.id);v.collectAndMap(y)},[i,v]),k=Ro(()=>{let y=i.filter(F=>F.figmaMapping).map(F=>F.id);g(!1),v.rerun(y)},[i,v]),w=Ro(async y=>{await v.applyMappings(y),g(!1),v.reset(),R(),I()},[v,R,I]),E=Ro(()=>{g(!1),v.reset()},[v]);et.useEffect(()=>{v.results&&g(!0)},[v.results]);let f=y=>{y.target===y.currentTarget&&t()};if(!e)return null;let T=i.filter(y=>y.figmaMapping).length,S=i.length;return et.createElement(et.Fragment,null,et.createElement(O$,{onClick:f},et.createElement(_$,{onClick:y=>y.stopPropagation()},et.createElement($$,null,et.createElement(U$,null,et.createElement(j$,null,et.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),et.createElement(H$,null,et.createElement(NC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),et.createElement(NC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),et.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},A.enableAutoMap&&!d&&!v.isCollecting&&!v.isMapping&&et.createElement(e4,{onClick:x,disabled:a||i.length===0},et.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},et.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),et.createElement("path",{d:"M2 17l10 5 10-5"}),et.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),et.createElement(W$,{onClick:t},"\xD7"))),et.createElement(V$,null,(v.isCollecting||v.isMapping)&&et.createElement(Y$,null,et.createElement(K$,null,et.createElement(J$,null,et.createElement(Z$,null)),et.createElement(X$,null,"Auto-mapping stories to Figma"),et.createElement(Q$,null,v.progress),et.createElement(Pr,{onClick:v.cancel,variant:"ghost"},"Cancel"))),d&&v.results&&et.createElement(MC,{results:v.results,stories:i,onApply:w,onCancel:E,onRerun:k,isApplying:v.isApplying,isRerunning:v.isCollecting||v.isMapping,source:v.source,resolveThumbnail:y=>v.results?.thumbnailUrls?.[y],resolveStoryScreenshot:y=>D.screenshots[y],isCapturingScreenshots:D.isCapturing,onBrowse:y=>m(y)}),!d&&!v.isCollecting&&!v.isMapping&&(r==="map"?et.createElement(fC,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:_,projectId:n}):et.createElement(yC,{stories:i,loading:a,onLink:N,onUnlink:P,projectId:n}))),et.createElement(G$,null,et.createElement(q$,null,et.createElement("span",null,"Total: ",S," stories"),et.createElement(OC,{type:"mapped"},et.createElement("span",{className:"dot"}),T," mapped"),et.createElement(OC,{type:"unmapped"},et.createElement("span",{className:"dot"}),S-T," unmapped"))))),et.createElement(Ki,{isOpen:!!p,onClose:()=>m(null),onSelect:()=>m(null),projectId:n,initialSearch:p||void 0}))};ct();var $C=rr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",transition:"border-color 0.2s, box-shadow 0.2s","&:hover":{borderColor:e.color.mediumlight}})),n4=rr.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),r4=rr.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),o4=rr.div({display:"flex",alignItems:"center",gap:"8px"}),i4=rr.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),s4=rr.div(({theme:e,percent:t,state:n})=>({width:`${t}%`,height:"100%",borderRadius:"2px",backgroundColor:n==="complete"?e.color.positive:n==="partial"?e.color.warning:e.color.mediumlight,transition:"width 0.3s ease"})),a4=rr.span(({theme:e,state:t})=>({fontSize:"12px",fontWeight:600,color:t==="complete"?e.color.positive:t==="partial"?e.color.warning:e.color.mediumdark,whiteSpace:"nowrap"})),l4=rr.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),c4=rr(mu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),u4=rr(mu)(({theme:e})=>({padding:"4px 10px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626","&:hover":{textDecoration:"none",backgroundColor:"rgba(220, 38, 38, 0.08)"}})),p4=rr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),d4=rr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:se,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),g4=rr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),UC=()=>{let[e,t]=hc(!1),[n,r]=hc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Je(),{sessionToken:i}=ke();t4(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(_=>({..._,loading:!0}));try{let _=await fetch("/index.json");if(!_.ok)throw new Error("Failed to fetch Storybook index");let P=await _.json(),N=P.entries||P.stories||{},x=Object.keys(N).filter(T=>N[T].type==="story").length,k=Object.keys(N).filter(T=>N[T].type==="story"),w=q(),E=await ee(`${w}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),f=0;if(E.ok){let T=await E.json(),S=T.mappings||T||[];if(Array.isArray(S)){let y=new Set(S.map(F=>F.storyId).filter(Boolean));f=k.filter(F=>y.has(F)).length}else{let y=await ee(`${w}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(y.ok){let F=await y.json();f=Math.min(F.mappedStoriesCount||0,x)}}}r({totalStories:x,mappedStories:f,loading:!1})}catch(_){console.error("[FigmaMappingsSection] Error fetching stats:",_),r(P=>({...P,loading:!1}))}},[a,u]=hc(!1),[c,l]=hc(!1),d=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let _=q(),P=await ee(`${_}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!P.ok)throw new Error("Failed to fetch mappings");let x=(await P.json()).mappings||[];await Promise.all(x.map(k=>ee(`${_}/api/mappings?id=${encodeURIComponent(k.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(_){console.error("[FigmaMappingsSection] Unlink all failed:",_)}finally{u(!1)}},p=()=>t(!0),m=()=>{t(!1),o&&i&&s()};if(!o)return It.createElement($C,null,It.createElement(p4,null,"Select a project to link Figma designs"));let{totalStories:v,loading:I}=n,A=Math.min(n.mappedStories,v),C=A===0?"none":A>=v?"complete":"partial",D=v>0?Math.min(100,Math.round(A/v*100)):0,R=C==="none"?"Link designs":"Manage";return It.createElement(It.Fragment,null,It.createElement($C,null,It.createElement(n4,null,It.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},It.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),It.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),It.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),It.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),It.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),It.createElement(r4,null,It.createElement(l4,null,"Figma Mappings"),It.createElement(o4,null,I?It.createElement(It.Fragment,null,It.createElement(d4,null),It.createElement(g4,null,"Loading...")):It.createElement(It.Fragment,null,It.createElement(i4,null,It.createElement(s4,{percent:D,state:C})),It.createElement(a4,{state:C},`${A}/${v}`)))),A>0&&It.createElement(u4,{onClick:d,disabled:I||a},a?"Unlinking...":"Unlink All"),It.createElement(c4,{onClick:p,disabled:I},R)),e&&It.createElement(_C,{isOpen:e,onClose:m,projectId:o}),It.createElement(jr,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:g,onCancel:()=>l(!1)}))};import ae,{useState as Qi,useEffect as xc,useCallback as jC,useRef as ch}from"react";import{styled as or}from"storybook/theming";Te();He();ct();var uh=or.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),ph=or.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),dh=or.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),kre=or(Nr)({padding:"5px 12px",fontSize:"12px"}),gh=or.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),yc=or.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),f4=or.span(({theme:e,status:t})=>({display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="cached"?`${e.color.positive}1a`:t==="expired"?`${e.color.warning}1a`:e.background.hoverable,color:t==="cached"?e.color.positive:t==="expired"?e.color.warning:e.color.mediumdark})),m4=or.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),fh=or.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),h4=or.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),bc=or.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),Sc=or.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),zo=or.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),HC=new Set,WC=()=>{let{userRole:e,featureFlags:t}=ce(),[n,r]=Qi(null),[o,i]=Qi(!0),[s,a]=Qi(!1),[u,c]=Qi(!1),[l,d]=Qi(!1),[g,p]=Qi(!1),{selectedProjectId:m,projects:v}=Je(),{sessionToken:I}=ke(),A=ch(null),C=ch(null),D=ch(null),R=jC(()=>{A.current&&(clearInterval(A.current),A.current=null),C.current&&(clearInterval(C.current),C.current=null),D.current&&(clearTimeout(D.current),D.current=null)},[]);xc(()=>R,[R]);let _=jC(async()=>{if(!(!m||!I))try{let S=q(),y=await ee(`${S}/api/figma/cache-status?projectId=${m}`,{headers:{Authorization:`Bearer ${I}`}});if(y.ok){let F=await y.json();r(F)}}catch(S){console.error("[FigmaCacheSection] Error:",S)}finally{i(!1)}},[m,I]);xc(()=>{_()},[_]),xc(()=>{if(o||s||!n||n.structureStatus!=="none"||!m||HC.has(m))return;let S=v.find(F=>F.id===m);(S?.figmaFileUrl||S?.figmaFileId)&&(HC.add(m),P())},[o,s,n?.structureStatus,m,v]),xc(()=>{let S=n?.thumbnailProgress?.status,y=n?.enrichmentProgress?.status,F=n?.thumbnailProgress?.cached??0,L=n?.thumbnailProgress?.total??0,M=S==="in-progress"||S==="pending"||L>0&&F<L,z=y==="in-progress"||y==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(M||z||h)||!n||n.structureStatus==="none")return;let V=setInterval(()=>{_()},3e3);return()=>{clearInterval(V)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,_]);let P=async()=>{if(!(!m||!I)){a(!0);try{let S=q();await ee(`${S}/api/figma/frames?projectId=${m}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${I}`}},6e4),await new Promise(y=>setTimeout(y,1e3)),await _(),setTimeout(async()=>{await _()},3e3)}catch(S){console.error("[FigmaCacheSection] Reload error:",S)}finally{a(!1)}}},N=async()=>{if(!(!m||!I)){c(!0);try{let S=q(),y=await ee(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:m})});console.log("[FigmaCacheSection] Cache invalidate response:",y.status),await ee(`${S}/api/figma/frames/invalidate?projectId=${m}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(S){console.error("[FigmaCacheSection] Clear cache error:",S)}finally{c(!1)}}},x=async()=>{if(!(!m||!I)){R(),d(!0);try{let S=q();await ee(`${S}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:m})}),A.current=setInterval(async()=>{await _()},3e3),C.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(R(),d(!1),_())},3e3),D.current=setTimeout(()=>{R(),d(!1)},6e5)}catch(S){console.error("[FigmaCacheSection] Enrich error:",S),R(),d(!1)}}},k=async()=>{if(!(!m||!I)){p(!0);try{let S=q();await ee(`${S}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:m})}),await _()}catch(S){console.error("[FigmaCacheSection] Cancel error:",S)}finally{p(!1),d(!1),a(!1)}}},w=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!m)return null;if(o)return ae.createElement(uh,null,ae.createElement(ph,null,ae.createElement(dh,null,"Figma Cache")),ae.createElement(gh,null,ae.createElement(yc,null,"Loading cache status\u2026")),ae.createElement(bc,null,ae.createElement(Sc,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return ae.createElement(uh,null,ae.createElement(ph,null,ae.createElement(dh,null,"Figma Cache"),ae.createElement(Pr,{loading:s,onClick:P,loadingText:"Loading..."},"\u21BB Load")),s?ae.createElement(ae.Fragment,null,ae.createElement(bc,null,ae.createElement(Sc,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),ae.createElement(zo,null,ae.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):ae.createElement(gh,null,ae.createElement(yc,null,"No cache \u2014 click Load to fetch from Figma")));let E=S=>{let y=Date.now()-new Date(S).getTime(),F=Math.floor(y/6e4);if(F<1)return"just now";if(F<60)return`${F}m ago`;let L=Math.floor(F/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`},f=n.cacheDiff,T=f&&(f.added.length>0||f.removed.length>0||f.renamed.length>0);return ae.createElement(uh,null,ae.createElement(ph,null,ae.createElement(dh,null,"Figma Cache"," ",ae.createElement(f4,{status:n.structureStatus},n.structureStatus)),ae.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&ae.createElement(Pr,{loading:l,onClick:x,loadingText:"Enriching..."},"Enrich"),ae.createElement(Pr,{loading:u,onClick:N,variant:"ghost",loadingText:"Clearing..."},"Clear"),ae.createElement(Pr,{loading:s,onClick:P,loadingText:"Reloading..."},"\u21BB Reload"),w&&ae.createElement(Pr,{loading:g,onClick:k,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),s&&ae.createElement(zo,null,ae.createElement("span",null,"Downloading structure from Figma...")),ae.createElement(gh,null,ae.createElement(yc,null,ae.createElement("strong",null,n.componentSetCount)," component sets"),ae.createElement(yc,null,ae.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&ae.createElement(h4,null,"Updated ",E(n.structureCachedAt))),T&&ae.createElement(m4,null,"Since last reload:"," ",f.added.length>0&&ae.createElement(fh,{type:"added"},"+",f.added.length," added"),f.added.length>0&&f.removed.length>0&&" \xB7 ",f.removed.length>0&&ae.createElement(fh,{type:"removed"},"\u2212",f.removed.length," removed"),(f.added.length>0||f.removed.length>0)&&f.renamed.length>0&&" \xB7 ",f.renamed.length>0&&ae.createElement(fh,{type:"renamed"},f.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&ae.createElement(ae.Fragment,null,ae.createElement(bc,null,ae.createElement(Sc,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&ae.createElement(ae.Fragment,null," ",n.thumbnailProgress.currentName)),ae.createElement("span",null,n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached===0)&&ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: not yet cached",n.thumbnailProgress?.total?` (${n.thumbnailProgress.total} components)`:""," ","\u2014 click Reload to generate")),n.thumbnailProgress&&n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached>0&&ae.createElement(zo,null,ae.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&ae.createElement(ae.Fragment,null,ae.createElement(bc,null,ae.createElement(Sc,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),ae.createElement(zo,null,ae.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&ae.createElement(ae.Fragment,null," ",n.enrichmentProgress.currentName)),ae.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&ae.createElement(ae.Fragment,null,ae.createElement(zo,null,ae.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&ae.createElement("div",{style:{marginTop:"6px"}},ae.createElement(dc,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import St,{useState as Ji}from"react";import{styled as Wr}from"storybook/theming";Te();He();ct();var mh=Wr.div({padding:"12px 16px"}),x4=Wr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),VC=Wr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),GC=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:se,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),y4=Wr.div({display:"flex",gap:"8px",alignItems:"center"}),b4=Wr.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none",fontFamily:"monospace","&:focus":{borderColor:se,boxShadow:`0 0 0 1px ${se}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),qC=Wr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),S4=Wr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:se,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),w4=Wr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"6px",backgroundColor:"#16a34a10",border:"1px solid #16a34a30",fontSize:"12px",color:e.color.defaultText})),v4=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),YC=({onConnected:e})=>{let{sessionToken:t}=ke(),[n,r]=Ji(!1),[o,i]=Ji(""),[s,a]=Ji(!1),[u,c]=Ji(null),[l,d]=Ji(null),[g,p]=Ji(!1),m=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let v=q(),I=await ee(`${v}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),A=await I.json();if(!I.ok){c({type:"error",message:A.error||"Failed to save token"});return}d(A.figmaUser?.handle||A.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${A.figmaUser?.handle||"Figma user"}`}),i(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{a(!1)}}};return l?St.createElement(mh,null,St.createElement(VC,null,"Figma Personal Access Token"),St.createElement(w4,null,St.createElement("span",null,"\u2713 Connected as ",St.createElement("strong",null,l)),St.createElement(v4,{onClick:()=>{d(null),c(null)}},"Change token"))):n?St.createElement(mh,null,St.createElement(x4,null,St.createElement(VC,null,"Figma Personal Access Token"),St.createElement(GC,{onClick:()=>p(!g)},g?"Hide instructions":"How to generate")),g&&St.createElement(S4,null,St.createElement("ol",null,St.createElement("li",null,"Open ",St.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),St.createElement("li",null,"Click the ",St.createElement("strong",null,"Security")," tab"),St.createElement("li",null,"Scroll to ",St.createElement("strong",null,"Personal access tokens")),St.createElement("li",null,"Click ",St.createElement("strong",null,"Generate new token")),St.createElement("li",null,"Enable ",St.createElement("strong",null,"File content: Read only")," under Scopes"),St.createElement("li",null,"Copy the token and paste it below"))),St.createElement(y4,null,St.createElement(b4,{type:"password",value:o,onChange:v=>i(v.target.value),placeholder:"figd_...",onKeyDown:v=>{v.key==="Enter"&&o.trim()&&m()}}),St.createElement(on,{onClick:m,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&St.createElement(qC,{variant:u.type},u.message),St.createElement(qC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):St.createElement(mh,null,St.createElement(GC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};Te();He();ct();var C4=wt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},wt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),wt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),wt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),wt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),wt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"})),hh=Lr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),T4=Lr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),I4=Lr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),F4=Lr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),xh=Lr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),E4=Lr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",margin:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"})),A4=Lr.div({display:"flex",alignItems:"center",gap:"8px"}),P4=Lr(Fn)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),L4=Lr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Hre=Lr.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:"#A259FF",color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:"#8a3de8"}}),M4=Lr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.mediumdark,"&::before, &::after":{content:'""',flex:1,height:"1px",backgroundColor:e.appBorderColor}})),XC=({hideHeader:e=!1})=>{let{sessionToken:t}=ke(),[n,r]=wc(!1),[o,i]=wc(()=>{try{let p=sessionStorage.getItem("uicopilot_figma_connection");if(p){let{connected:m,ts:v}=JSON.parse(p);if(Date.now()-v<300*1e3)return m}}catch{}return null}),[s,a]=wc(!1),[u,c]=wc(!1);k4(()=>{if(!t)return;let p=q();ee(`${p}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(m=>m.json()).then(m=>{let v=!!m.connected;a(!!m.expired),i(v);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:v,ts:Date.now()}))}catch{}}).catch(()=>i(!1))},[t]);let l=KC(()=>{let p=q(),m=`${p}/api/auth/figma/login?addon=true`;window.open(m,"figma-oauth","width=600,height=700,left=200,top=100");let v=setInterval(async()=>{try{(await(await ee(`${p}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(v),i(!0))}catch{}},2e3);setTimeout(()=>clearInterval(v),300*1e3)},[t]),d=KC(async()=>{try{r(!0);let p=q(),m=await ee(`${p}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(m.ok||m.status===404){i(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{r(!1)}},[t]),g=e?null:wt.createElement(T4,null,wt.createElement(I4,null,C4),wt.createElement(F4,null,"Figma Integration"));return o===null?wt.createElement(hh,null,g,wt.createElement(xh,null,wt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?wt.createElement(hh,null,g,wt.createElement(xh,null,wt.createElement(L4,null,s&&wt.createElement("div",{style:{padding:"10px 12px",backgroundColor:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#92400e"}},"\u26A0\uFE0F Your Figma access has expired. Please reconnect."),wt.createElement(on,{onClick:l,style:{width:"100%"}},s?"Reconnect Figma":"Connect with Figma"),wt.createElement(M4,null,"or"),wt.createElement(YC,{onConnected:()=>i(!0)})))):wt.createElement(hh,null,g,wt.createElement(E4,null,wt.createElement(A4,null,wt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),wt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),wt.createElement(P4,{onClick:()=>c(!0),disabled:n},n?"Disconnecting...":"Disconnect")),wt.createElement(jr,{isOpen:u,title:"Disconnect Figma",message:"Your mappings, cache, and review history will be preserved. You will need to re-authenticate to make new Figma API calls.",confirmLabel:"Disconnect",variant:"danger",onConfirm:()=>{c(!1),d()},onCancel:()=>c(!1)}),wt.createElement(xh,null,wt.createElement(bk,null),wt.createElement(UC,null),wt.createElement(WC,null)))};Te();_n();var R4=hr.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"32px"}),z4=hr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"14px",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.22)",width:"520px",maxWidth:"94%",maxHeight:"calc(100vh - 64px)",overflow:"auto",position:"relative"})),N4=hr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",position:"sticky",top:0,backgroundColor:e.background.content,borderRadius:"14px 14px 0 0",zIndex:1})),O4=hr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),_4=hr(En)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),$4=hr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),QC=hr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),JC=hr.div({display:"flex",alignItems:"center",gap:"10px"}),ZC=hr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),U4=hr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:se,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),j4=hr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),e1=hr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"12px",fontSize:"12px","& > div, & > section":{padding:0},'[class*="AuthPanelContainer"], [class*="SectionContainer"]':{padding:0},"h3, h4":{fontSize:"12px",margin:"0 0 6px 0"},label:{fontSize:"12px"},"input, select":{fontSize:"12px",padding:"6px 10px",height:"auto"},button:{fontSize:"11px"},p:{fontSize:"11px",margin:"2px 0"}})),t1=({onClose:e})=>{let{isConnected:t}=ke(),{selectedProjectId:n}=Je(),r=D4(t);return B4(()=>{!r.current&&t&&n&&e(),r.current=t},[t,n,e]),Bt.createElement(R4,{onClick:e},Bt.createElement(z4,{onClick:o=>o.stopPropagation()},Bt.createElement(N4,null,Bt.createElement(O4,null,"Settings"),Bt.createElement(_4,{onClick:e,title:"Close settings"},"\xD7")),Bt.createElement($4,null,Bt.createElement(QC,null,Bt.createElement(JC,null,Bt.createElement(U4,null,"UI"),Bt.createElement(ZC,null,Pt.NAME)),Bt.createElement(e1,null,Bt.createElement(gk,{onConnect:e}),t&&Bt.createElement(xk,null))),t&&n&&Bt.createElement(QC,null,Bt.createElement(JC,null,Bt.createElement(j4,null,Bt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Bt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),Bt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),Bt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Bt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),Bt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),Bt.createElement(ZC,null,"Figma Integration")),Bt.createElement(e1,null,Bt.createElement(XC,{hideHeader:!0}))))))};import ht,{useEffect as p1,useMemo as m3,useState as h3,useRef as x3}from"react";import{styled as qn,keyframes as y3}from"storybook/theming";Te();_n();Te();import Qt,{useState as H4}from"react";import{styled as Gn}from"storybook/theming";var co=[{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Latest Claude model, best balance of speed and quality"},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",provider:"anthropic",description:"Previous generation Sonnet"},{id:"claude-3-5-sonnet-20241022",name:"Claude 3.5 Sonnet",provider:"anthropic",description:"Best balance of speed and quality"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",provider:"anthropic",description:"Fastest, most affordable"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus",provider:"anthropic",description:"Most capable Claude 3 model"},{id:"gpt-5.2",name:"GPT-5.2 Thinking",provider:"openai",description:"47% cheaper, reasoning"},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Instant",provider:"openai",description:"86% cheaper (default)"},{id:"gpt-4o",name:"GPT-4o",provider:"openai",description:"GPT-4 multimodal flagship"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai",description:"GPT-4 affordable model"},{id:"o1-preview",name:"o1 Preview",provider:"openai",description:"Reasoning model (slower, advanced)"},{id:"o1-mini",name:"o1 Mini",provider:"openai",description:"Faster reasoning model"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"Fast & cheap, great vision"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"Best Gemini quality"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"google",description:"Previous gen, very fast"}];var W4=Gn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),V4=Gn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),G4=Gn.div(({theme:e,disabled:t,provider:n})=>{let r={anthropic:{background:"#D4A574",text:"#ffffff"},openai:{background:e.color.positive||"#10b981",text:"#ffffff"},google:{background:"#4285F4",text:"#ffffff"}},o=n?r[n]:r.anthropic;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:o.background,color:o.text,fontSize:"11px",fontWeight:500,borderRadius:"12px",opacity:t?.6:1,cursor:t?"not-allowed":"default",transition:"opacity 0.15s"}}),q4=Gn.button(({theme:e,disabled:t})=>({background:"none",border:"none",color:e.color.inverseText,fontSize:"12px",cursor:t?"not-allowed":"pointer",padding:"0 2px",lineHeight:1,opacity:t?.5:.8,transition:"opacity 0.15s","&:hover":{opacity:t?.5:1}})),Y4=Gn.div({position:"relative",display:"inline-block"}),K4=Gn.button(({disabled:e,isOpen:t,theme:n})=>({padding:`${n.layoutMargin*.8}px 32px ${n.layoutMargin*.8}px ${n.layoutMargin}px`,fontSize:n.typography.size.s2,fontFamily:n.typography.fonts.base,fontWeight:500,color:n.color.defaultText,backgroundColor:n.input.background,border:`1px solid ${t?n.color.secondary:n.appBorderColor}`,borderRadius:n.appBorderRadius,cursor:e?"not-allowed":"pointer",opacity:e?.6:1,whiteSpace:"nowrap",display:"flex",gap:`${n.layoutMargin*.8}px`,alignItems:"center",justifyContent:"space-between",minWidth:"200px",transition:"border-color 0.15s, box-shadow 0.15s",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px","&:hover":{borderColor:e?n.appBorderColor:n.color.mediumdark}})),X4=Gn.div(({theme:e})=>({position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:e.base==="dark"?"0 4px 12px rgba(0, 0, 0, 0.3)":"0 4px 12px rgba(0, 0, 0, 0.1)",zIndex:1e3,maxHeight:"280px",overflowY:"auto"})),yh=Gn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),bh=Gn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),Q4=Gn.div(({theme:e,disabled:t})=>({padding:"8px 12px",fontSize:"12px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,display:"flex",alignItems:"center",gap:"8px",transition:"background-color 0.15s",color:e.color.defaultText,"&:hover":{backgroundColor:t?"transparent":e.background.hoverable}})),J4=Gn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),Z4=Gn.div({flex:1,minWidth:0}),e3=Gn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),t3=Gn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),n3=5,n1=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ce(),[r,o]=H4(!1),i=co.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=co.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=co.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=co.filter(p=>e.includes(p.id)),c=e.length<n3,l=(p,m)=>{m.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let m=e.includes(p);m&&e.length===1||!m&&!c||n||(t(p),o(!1))},g=p=>{let m=e.includes(p.id),v=m&&e.length===1,I=n||v||!m&&!c;return Qt.createElement(Q4,{key:p.id,disabled:I,onClick:()=>d(p.id)},Qt.createElement(J4,{type:"checkbox",checked:m,disabled:I,onChange:()=>{},onClick:A=>A.stopPropagation()}),Qt.createElement(Z4,null,Qt.createElement(e3,null,p.name),p.description&&Qt.createElement(t3,null,p.description)))};return Qt.createElement(W4,null,Qt.createElement(Y4,null,Qt.createElement(K4,{disabled:n,isOpen:r,onClick:()=>o(!r)},Qt.createElement("span",null,"Select model"),Qt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Qt.createElement(X4,null,Qt.createElement(yh,null,Qt.createElement(bh,null,"Anthropic"),i.map(g)),Qt.createElement(yh,null,Qt.createElement(bh,null,"OpenAI"),s.map(g)),Qt.createElement(yh,null,Qt.createElement(bh,null,"Google"),a.map(g)))),Qt.createElement(V4,null,u.map(p=>Qt.createElement(G4,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Qt.createElement(q4,{disabled:n,onClick:m=>l(p.id,m),title:"Remove model"},"\xD7")))))};import ze,{useState as r3,useEffect as o3}from"react";import{styled as nn,keyframes as Zi}from"storybook/theming";Te();var i3=Zi`
45
45
  0%, 100% {
46
46
  opacity: 1;
47
47
  transform: scale(1);
@@ -53,7 +53,7 @@ ${at}`).join(`
53
53
  `,s3=Zi`
54
54
  0% { transform: rotate(0deg); }
55
55
  100% { transform: rotate(360deg); }
56
- `,o1=Zi`
56
+ `,i1=Zi`
57
57
  0% { opacity: 0; transform: translateY(2px); }
58
58
  100% { opacity: 1; transform: translateY(0); }
59
59
  `,a3=Zi`
@@ -75,44 +75,44 @@ ${at}`).join(`
75
75
  transform: translateY(60px) rotate(720deg) scale(0.5);
76
76
  opacity: 0;
77
77
  }
78
- `;var xoe=nn.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),Sh=nn.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),yoe=nn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.6}px`,padding:`${e.layoutMargin*.4}px ${e.layoutMargin}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.regular,color:e.textMutedColor,animation:`${o1} 0.3s ease-out`})),c3=Zi`
78
+ `;var xoe=nn.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),Sh=nn.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),yoe=nn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.6}px`,padding:`${e.layoutMargin*.4}px ${e.layoutMargin}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.regular,color:e.textMutedColor,animation:`${i1} 0.3s ease-out`})),c3=Zi`
79
79
  from { transform: rotate(0deg); }
80
80
  to { transform: rotate(360deg); }
81
- `,boe=nn.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${c3} 0.8s linear infinite`,flexShrink:0})),n1=nn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(220, 38, 38, 0.18)":"#fee2e2",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626",whiteSpace:"nowrap"})),u3=nn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(22, 163, 74, 0.18)":"#dcfce7",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.positive||"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"})),Soe=nn.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"-10px",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>6?"50%":"2px",animation:`${l3} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var ua=nn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),pa=nn.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),r1=nn.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),da=nn.span(({color:e})=>({fontWeight:700,color:e})),p3=nn.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:`${t.layoutMargin*.6}px`,padding:`${t.layoutMargin*.3}px ${t.layoutMargin}px`,borderRadius:t.appBorderRadius*2,backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:t.typography.size.s1,color:t.textMutedColor},"& .score-value":{fontFamily:t.typography.fonts.mono,fontSize:t.typography.size.s2,fontWeight:t.typography.weight.bold,color:e,lineHeight:1},"& .score-dot":{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:e}})),woe=nn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),voe=nn.span(({color:e=se})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${i3} 1.2s ease-in-out infinite`,marginRight:"4px"})),koe=nn.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return se;case"score-high":return"#16a34a";case"score-medium":return"#ca8a04";case"score-low":return"#dc2626";case"cost":return"#7c3aed";case"tokens":return e.color.mediumdark;case"analyzing":return se;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${a3} 1.5s ease-in-out infinite`}:{}})),Coe=nn.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Toe=nn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),d3=nn.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${s3} 1.2s linear infinite`,flexShrink:0}),g3=({color:e=se})=>ze.createElement(d3,null,ze.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},Array.from({length:8}).map((t,n)=>{let o=n*360/8*Math.PI/180,i=12+Math.cos(o)*4,s=12+Math.sin(o)*4,a=12+Math.cos(o)*10,u=12+Math.sin(o)*10;return ze.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Ioe=nn.span(({color:e="#6b7280"})=>({fontSize:"12px",fontWeight:500,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",animation:`${o1} 0.3s ease-out`}));function f3(e){let[t,n]=r3(0);return o3(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var i1=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,visualSimilarity:i,costUsd:s,inputTokens:a,outputTokens:u,showTimer:c=!0,cacheCreationTokens:l,cacheReadTokens:d,durationSeconds:g})=>{let p=f3(e||t),{featureFlags:m}=ce(),k=m.showCosts,I=3.65,A=P=>P<.01?`$${P.toFixed(4)}`:P<.1?`$${P.toFixed(3)}`:`$${P.toFixed(2)}`,C=P=>{let N=P*I;return N<.01?`\u20AA${N.toFixed(4)}`:N<.1?`\u20AA${N.toFixed(3)}`:`\u20AA${N.toFixed(2)}`},D=P=>P>=1e3?`${(P/1e3).toFixed(1)}K`:P.toString(),R=P=>P>=80?"score-high":P>=50?"score-medium":"score-low",_=P=>P>=80?"high":P>=50?"medium":"low";if(e)return ze.createElement(Sh,null,ze.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},p,"s \xB7 Esc to stop"));if(t)return ze.createElement(Sh,null,ze.createElement(n1,null,ze.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement(g3,{color:"#7c3aed"}),ze.createElement(da,{color:"#7c3aed"},"Verifying...")),c&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement("span",{style:{color:"#6b7280"}},p,"s"))));if(r>0||o!==void 0){let P=(a||0)+(u||0),N=(d||0)>0,x=N&&a?Math.round(d/a*100):0,v=Math.max(o??0,i??0),w=f=>f>=80?"#16a34a":f>=50?"#ca8a04":"#dc2626",E=f=>f>=100?"\u25CF":f>=50?"\u25D0":"\u25CB";return ze.createElement(Sh,null,r===0?ze.createElement(u3,null,ze.createElement("span",null,"\u2713"),"Perfect!"):ze.createElement(n1,null,ze.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ze.createElement(p3,{tint:w(v),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},ze.createElement("span",{className:"score-dot"}),ze.createElement("span",{className:"score-label"},"Score"),ze.createElement("span",{className:"score-value"},v)),k&&s!==void 0&&s>0&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement(da,{color:"#16a34a"},A(s)),ze.createElement("span",{style:{color:"#6b7280"}},"/"),ze.createElement(da,{color:"#16a34a"},C(s)))),k&&P>0&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${N?` \xB7 Cached: ${d?.toLocaleString()}`:""}`},ze.createElement(r1,{color:"#7c3aed"},"#"),ze.createElement(da,{color:"#7c3aed"},D(P)),ze.createElement("span",{style:{color:"#6b7280"}},"tokens"),N&&ze.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",x,"%"))),g!==void 0&&g>0&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement(r1,{color:"#6b7280"},"\u23F1"),ze.createElement(da,{color:"#6b7280"},g,"s"))))}return null};var b3=qn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),zoe=qn.div({display:"flex",gap:"8px",alignItems:"center"}),S3=y3({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),w3=qn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${S3} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),v3=qn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),k3=qn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin}px`,padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.2}px`,borderRadius:e.appBorderRadius*2,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.03)",flexWrap:"wrap"})),C3=qn.button(({theme:e,variant:t="orange",disabled:n})=>{let r={green:n?e.textMutedColor:e.color.positive||"#10b981",purple:n?e.textMutedColor:"#7c3aed",yellow:n?e.textMutedColor:"#c4b5fd",orange:n?e.textMutedColor:Ga},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:e.color.inverseText,border:"none",padding:`${e.layoutMargin*.7}px ${e.layoutMargin*1.4}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,borderRadius:e.appBorderRadius,cursor:n?"not-allowed":"pointer",opacity:n?.6:1,whiteSpace:"nowrap",transition:"all 0.2s",boxShadow:n?"none":`0 2px 6px rgba(${o}, 0.3)`,flexShrink:0,"&:hover":{opacity:n?.6:.9,transform:n?"none":"translateY(-1px)",boxShadow:n?"none":`0 4px 10px rgba(${o}, 0.4)`}}}),T3=qn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),I3=qn.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),F3=qn(bn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),E3=qn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),s1=qn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),a1=qn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?Ga:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),l1=qn.div(({checked:e})=>({width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#fff",position:"absolute",top:"2px",left:e?"16px":"2px",transition:"left 0.2s ease",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)"})),c1=qn.input({position:"absolute",opacity:0,width:0,height:0}),A3=()=>{let[e,t]=h3(0),n=x3();u1(()=>(n.current=setInterval(()=>t(s=>s+1),1e3),()=>clearInterval(n.current)),[]);let r=Math.floor(e/60),o=e%60,i=`${r}:${o.toString().padStart(2,"0")}`;return ht.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},wh=()=>{let{sessionToken:e}=Ws(),{usageData:t}=ke(),{selectedProjectId:n}=io(),{currentMapping:r,hasMapping:o}=ri(),{loadingMapping:i,currentStoryId:s}=nt(),{startReview:a,cancelReview:u,isReviewing:c}=xm(),{isLoadingScreenshots:l}=ti(),{storybookImageUrl:d,figmaImageUrl:g,currentReviewId:p,reviewHistory:m,setReviewDetailTab:k,setReviewResults:I,setFigmaImageUrl:A,setStorybookImageUrl:C,setFullPrompt:D,setFullResponse:R,includeTextComparison:_,setIncludeTextComparison:P,usePromptCache:N,setUsePromptCache:x,isValidating:v,validationUsage:w,isGenerating:E,isApplying:f,streamingStatus:T,featureFlags:S,userRole:y,roleOverride:F,isReviewing:L}=ce(),M=t?.reviewCredits??Math.floor(t?.creditBalance??0),z=m.find(fe=>fe.id===p),j=(z?.issues||[]).filter(fe=>!fe.dismissed).length,V=z?.complianceScore,B=z?.visualSimilarity,G=(z?.costUsd||0)+(w?.costUsd||0),te=(z?.inputTokens||0)+(w?.inputTokens||0),le=(z?.outputTokens||0)+(w?.outputTokens||0),xe=m3(()=>{let fe=s?m.filter(me=>me.storyId===s):m,tt=fe.filter(me=>!me.parentReviewId).sort((me,oe)=>new Date(oe.createdAt).getTime()-new Date(me.createdAt).getTime()),he=fe.filter(me=>me.parentReviewId),re=[];for(let me of tt){re.push(me);let oe=he.filter(O=>O.parentReviewId===me.id).sort((O,U)=>(O.iterationNumber||0)-(U.iterationNumber||0));re.push(...oe)}let K=he.filter(me=>!tt.some(oe=>oe.id===me.parentReviewId));return re.push(...K),re},[m,s]);u1(()=>{if(!c)return;let fe=tt=>{tt.key==="Escape"&&(tt.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let ie=o&&r?.figmaNodeId,Ke=E||f,be=M>0,Ie=!!(e&&n&&!c&&!l&&!Ke&&s&&d&&ie&&g&&be),ve=async(fe=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{k("chat"),await a({isIteration:fe,parentReviewId:fe?p:void 0})}catch(tt){console.error("[ReviewActions] Review error:",tt)}},ue=()=>ve(!1),$e=fe=>{let tt=fe.target.value;if(tt){let he=m.find(re=>re.id===tt);he&&(I({id:he.id,componentId:he.componentId,storyId:he.storyId,modelId:he.modelId,complianceScore:he.complianceScore,issuesCount:he.issuesCount,issues:he.issues,createdAt:new Date(he.createdAt),visualSimilarity:he.visualSimilarity,timestamp:new Date(he.createdAt).toISOString(),costUsd:he.costUsd,inputTokens:he.inputTokens,outputTokens:he.outputTokens,cacheCreationTokens:he.cacheCreationTokens,cacheReadTokens:he.cacheReadTokens,reviewDurationMs:he.reviewDurationMs}),he.figmaImageData&&A(he.figmaImageData),he.storybookImageData&&C(he.storybookImageData),(F??y)==="admin"&&(D(he.aiPrompt||""),R(he.aiResponse||"")),k("issues"))}},pe=fe=>{let tt=new Date(fe),re=new Date().getTime()-tt.getTime(),K=Math.floor(re/6e4),me=Math.floor(re/36e5),oe=Math.floor(re/864e5);return K<1?"Just now":K<60?`${K}m ago`:me<24?`${me}h ago`:oe<7?`${oe}d ago`:tt.toLocaleDateString()},yt=fe=>fe?fe.includes("haiku")?"Haiku":fe.includes("sonnet")?"Sonnet":fe.includes("opus")?"Opus":fe.includes("gpt-4o-mini")?"GPT-4o mini":fe.includes("gpt-4o")?"GPT-4o":fe.includes("gpt-4")?"GPT-4":fe.includes("o3")?"o3":fe.includes("o1")?"o1":fe.split("-")[0]||"":"",$t=fe=>{let tt=fe.split("--"),he=tt[tt.length-1]||fe;return he.charAt(0).toUpperCase()+he.slice(1)},yn=(F??y)==="admin";return ht.createElement("div",null,ht.createElement(b3,null,S.enableModelSelection&&ht.createElement(t1,null),yn&&ht.createElement(E3,null,ht.createElement(s1,{title:"Compare text content between Figma design and Storybook component"},ht.createElement(c1,{type:"checkbox",checked:_,onChange:fe=>P(fe.target.checked)}),ht.createElement(a1,{checked:_},ht.createElement(l1,{checked:_})),"Compare text"),S.showCosts&&ht.createElement(s1,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ht.createElement(c1,{type:"checkbox",checked:N,onChange:fe=>x(fe.target.checked)}),ht.createElement(a1,{checked:N},ht.createElement(l1,{checked:N})),"Cache prompt")),ht.createElement(k3,null,ht.createElement(C3,{variant:c?"yellow":"purple",disabled:c?!1:!Ie,onClick:c?u:ue,title:c?"Click to stop review":e?n?s?ie?l?"Loading screenshots...":Ke?"Wait for fixes to complete...":d?g?be?"Review this component implementation":"No credits \u2014 click \u26A1 in the toolbar to get more":"Waiting for Figma design image...":"Waiting for Storybook screenshot...":'Figma mapping required - use "Map to Figma" in the Review tab':"No story selected":"Please select a project first":`Please connect to ${Pt.NAME} first`},c?ht.createElement(ht.Fragment,null,ht.createElement(w3,null),"Reviewing",ht.createElement(A3,null)):ht.createElement(ht.Fragment,null,ht.createElement(v3,null,ht.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ht.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),L?null:v||z?ht.createElement(i1,{isReviewing:!1,isValidating:v,streamingStatus:T,issueCount:j,score:V,visualSimilarity:B,costUsd:G||z?.costUsd,inputTokens:te||z?.inputTokens,outputTokens:le||z?.outputTokens,cacheCreationTokens:z?.cacheCreationTokens,cacheReadTokens:z?.cacheReadTokens,durationSeconds:z?.reviewDurationMs?Math.round(z.reviewDurationMs/1e3):void 0}):null,xe.length>0&&ht.createElement(I3,null,ht.createElement(F3,{value:p||"",onChange:$e,title:"Review history"},ht.createElement("option",{value:""},"Select a review..."),xe.map(fe=>{let tt=!!fe.parentReviewId,he=tt?" \u21B3 ":"\u25CF ",re=tt&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",K=fe.issuesCount??fe.issues?.length??0,me=fe.complianceScore??"--",oe=yt(fe.modelId);return ht.createElement("option",{key:fe.id,value:fe.id},he,re,pe(fe.createdAt)," - ",K," issues (",me,"%)",oe?` \xB7 ${oe}`:"",fe.storyId?` \xB7 ${$t(fe.storyId)}`:"")}))))),!ie&&!i&&ht.createElement(T3,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import _oe,{useState as $oe}from"react";import{styled as p1}from"storybook/theming";var Hoe=p1.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Woe=p1(bo)({padding:"8px 12px",fontSize:"12px"});import qoe,{useState as Yoe}from"react";import{styled as vh}from"storybook/theming";Te();He();_e();ct();var tie=vh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),nie=vh(Nr)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),rie=vh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import sie from"react";import{styled as P3}from"storybook/theming";var cie=P3.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));Te();import die from"react";import{styled as Vr}from"storybook/theming";var mie=Vr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),hie=Vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),xie=Vr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),yie=Vr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),bie=Vr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Sie=Vr.div(({theme:e,progress:t})=>({height:"100%",backgroundColor:t===100?e.color.positive||"#10b981":e.color.secondary,width:`${t}%`,transition:"width 0.3s ease, background-color 0.3s ease"})),wie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),vie=Vr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),kie=Vr.div(({theme:e})=>({display:"inline-block",width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"spin 0.8s linear infinite",marginLeft:"8px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Cie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));Te();import Fie,{useState as Eie}from"react";import{styled as Gr}from"storybook/theming";var Lie=Gr.div(({theme:e})=>{let t=(e.base==="dark","102, 126, 234");return{padding:"10px 12px",backgroundColor:`rgba(${t}, 0.08)`,borderRadius:"6px",marginBottom:"16px",border:`1px solid rgba(${t}, 0.2)`}}),Mie=Gr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Bie=Gr.div({display:"flex",alignItems:"center",gap:"8px"}),Die=Gr.span({fontSize:"12px",opacity:.7}),Rie=Gr.span({fontSize:"13px",fontWeight:500}),zie=Gr.div(({score:e,theme:t})=>({display:"inline-block",padding:"4px 10px",borderRadius:"12px",fontSize:"13px",fontWeight:600,backgroundColor:e>=90?t.color.positive||"#10b981":e>=70?t.color.warning||"#f59e0b":t.color.negative||"#ef4444",color:t.color.inverseText})),Nie=Gr.div({marginTop:"12px",fontSize:"11px"}),Oie=Gr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),_ie=Gr.div(({status:e,theme:t})=>({display:"flex",alignItems:"center",gap:"4px",color:e==="success"?"inherit":e==="success"?t.color.positive||"#10b981":e==="warning"?t.color.warning||"#f59e0b":t.color.negative||"#ef4444"})),$ie=Gr.span({fontSize:"12px"});_e();He();import Jt from"react";import{styled as cs}from"storybook/theming";import Dr,{useEffect as AW}from"react";import{styled as Aa}from"storybook/theming";Te();import gi,{useState as G6}from"react";import{styled as ss}from"storybook/theming";var d1={fontBase:'"Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontMono:'"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace',sizeXs:"11px",sizeSm:"12px",sizeMd:"13px",sizeLg:"14px",sizeXl:"16px",weightRegular:400,weightMedium:500,weightBold:600};function g1(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var L3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,M3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,B3={};function vc(e,t){return((t||B3).jsx?M3:L3).test(e)}var D3=/[ \t\n\f\r]/g;function kh(e){return typeof e=="object"?e.type==="text"?f1(e.value):!1:f1(e)}function f1(e){return e.replace(D3,"")===""}var uo=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};uo.prototype.normal={};uo.prototype.property={};uo.prototype.space=void 0;function Ch(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new uo(n,r,t)}function ga(e){return e.toLowerCase()}var pn=class{constructor(t,n){this.attribute=n,this.property=t}};pn.prototype.attribute="";pn.prototype.booleanish=!1;pn.prototype.boolean=!1;pn.prototype.commaOrSpaceSeparated=!1;pn.prototype.commaSeparated=!1;pn.prototype.defined=!1;pn.prototype.mustUseProperty=!1;pn.prototype.number=!1;pn.prototype.overloadedBoolean=!1;pn.prototype.property="";pn.prototype.spaceSeparated=!1;pn.prototype.space=void 0;var fa={};Se(fa,{boolean:()=>Ge,booleanish:()=>Ut,commaOrSpaceSeparated:()=>Yn,commaSeparated:()=>No,number:()=>X,overloadedBoolean:()=>kc,spaceSeparated:()=>Ct});var R3=0,Ge=si(),Ut=si(),kc=si(),X=si(),Ct=si(),No=si(),Yn=si();function si(){return 2**++R3}var Th=Object.keys(fa),ai=class extends pn{constructor(t,n,r,o){let i=-1;if(super(t,n),m1(this,"space",o),typeof r=="number")for(;++i<Th.length;){let s=Th[i];m1(this,Th[i],(r&fa[s])===fa[s])}}};ai.prototype.defined=!0;function m1(e,t,n){n&&(e[t]=n)}function xr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new ai(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ga(r)]=r,n[ga(i.attribute)]=r}return new uo(t,n,e.space)}var Ih=xr({properties:{ariaActiveDescendant:null,ariaAtomic:Ut,ariaAutoComplete:null,ariaBusy:Ut,ariaChecked:Ut,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:Ct,ariaCurrent:null,ariaDescribedBy:Ct,ariaDetails:null,ariaDisabled:Ut,ariaDropEffect:Ct,ariaErrorMessage:null,ariaExpanded:Ut,ariaFlowTo:Ct,ariaGrabbed:Ut,ariaHasPopup:null,ariaHidden:Ut,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ct,ariaLevel:X,ariaLive:null,ariaModal:Ut,ariaMultiLine:Ut,ariaMultiSelectable:Ut,ariaOrientation:null,ariaOwns:Ct,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:Ut,ariaReadOnly:Ut,ariaRelevant:null,ariaRequired:Ut,ariaRoleDescription:Ct,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:Ut,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Cc(e,t){return t in e?e[t]:t}function Tc(e,t){return Cc(e,t.toLowerCase())}var h1=xr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:No,acceptCharset:Ct,accessKey:Ct,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:Ct,autoFocus:Ge,autoPlay:Ge,blocking:Ct,capture:null,charSet:null,checked:Ge,cite:null,className:Ct,cols:X,colSpan:null,content:null,contentEditable:Ut,controls:Ge,controlsList:Ct,coords:X|No,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:kc,draggable:Ut,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:Ct,height:X,hidden:kc,high:X,href:null,hrefLang:null,htmlFor:Ct,httpEquiv:Ct,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:Ct,itemRef:Ct,itemScope:Ge,itemType:Ct,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ge,optimum:X,pattern:null,ping:Ct,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:Ct,required:Ge,reversed:Ge,rows:X,rowSpan:X,sandbox:Ct,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:Ut,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Ut,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ct,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:Ut,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:Tc});var x1=xr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Yn,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:Ct,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:No,g2:No,glyphName:No,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:Yn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ct,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yn,rev:Yn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yn,requiredFeatures:Yn,requiredFonts:Yn,requiredFormats:Yn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:Yn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yn,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Cc});var Fh=xr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var Eh=xr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Tc});var Ah=xr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Ph={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var z3=/[A-Z]/g,y1=/-[a-z]/g,N3=/^data[-\w.:]+$/i;function Lh(e,t){let n=ga(t),r=t,o=pn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&N3.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(y1,_3);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!y1.test(i)){let s=i.replace(z3,O3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=ai}return new o(r,t)}function O3(e){return"-"+e.toLowerCase()}function _3(e){return e.charAt(1).toUpperCase()}var b1=Ch([Ih,h1,Fh,Eh,Ah],"html"),Ic=Ch([Ih,x1,Fh,Eh,Ah],"svg");function S1(e){return e.join(" ").trim()}var R1=Va(L1(),1);var Ec=M1("end"),es=M1("start");function M1(e){return t;function t(n){let r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Dh(e){let t=es(e),n=Ec(e);if(t&&n)return{start:t,end:n}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?B1(e.position):"start"in e||"end"in e?B1(e):"line"in e||"column"in e?Rh(e):""}function Rh(e){return D1(e&&e.line)+":"+D1(e&&e.column)}function B1(e){return Rh(e&&e.start)+"-"+Rh(e&&e.end)}function D1(e){return e&&typeof e=="number"?e:1}var Gt=class extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},s=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(s=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){let u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){let u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}let a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=a?a.line:void 0,this.name=Oo(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=s&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;var zh={}.hasOwnProperty,p5=new Map,d5=/[A-Z]/g,g5=new Set(["table","tbody","thead","tfoot","tr"]),f5=new Set(["td","th"]),z1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Nh(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=v5(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=w5(n,t.jsx,t.jsxs)}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ic:b1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=N1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function N1(e,t,n){if(t.type==="element")return m5(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return h5(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return y5(e,t,n);if(t.type==="mdxjsEsm")return x5(e,t);if(t.type==="root")return b5(e,t,n);if(t.type==="text")return S5(e,t)}function m5(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=Ic,e.schema=o),e.ancestors.push(t);let i=_1(e,t.tagName,!1),s=k5(e,t),a=_h(e,t);return g5.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!kh(u):!0})),O1(e,s,i,t),Oh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function h5(e,t){if(t.data&&t.data.estree&&e.evaluater){let r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ha(e,t.position)}function x5(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ha(e,t.position)}function y5(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=Ic,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:_1(e,t.name,!0),s=C5(e,t),a=_h(e,t);return O1(e,s,i,t),Oh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function b5(e,t,n){let r={};return Oh(r,_h(e,t)),e.create(t,e.Fragment,r,n)}function S5(e,t){return t.value}function O1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Oh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function w5(e,t,n){return r;function r(o,i,s,a){let c=Array.isArray(s.children)?n:t;return a?c(i,s,a):c(i,s)}}function v5(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=es(r);return t(o,i,s,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function k5(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&zh.call(t.properties,o)){let i=T5(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&f5.has(t.tagName)?r=a:n[s]=a}}if(r){let i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function C5(e,t){let n={};for(let r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){let i=r.data.estree.body[0];i.type;let s=i.expression;s.type;let a=s.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ha(e,t.position);else{let o=r.name,i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){let a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else ha(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function _h(e,t){let n=[],r=-1,o=e.passKeys?new Map:p5;for(;++r<t.children.length;){let i=t.children[r],s;if(e.passKeys){let u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){let c=o.get(u)||0;s=u+"-"+c,o.set(u,c+1)}}let a=N1(e,i,s);a!==void 0&&n.push(a)}return n}function T5(e,t,n){let r=Lh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?g1(n):S1(n)),r.property==="style"){let o=typeof n=="object"?n:I5(e,String(n));return e.stylePropertyNameCase==="css"&&(o=F5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Ph[r.property]||r.property:r.attribute,n]}}function I5(e,t){try{return(0,R1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Gt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=z1+"#cannot-parse-style-attribute",o}}function _1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){let o=t.split("."),i=-1,s;for(;++i<o.length;){let a=vc(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};s=s?{type:"MemberExpression",object:s,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}r=s}else r=vc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return zh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ha(e)}function ha(e,t){let n=new Gt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=z1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function F5(e){let t={},n;for(n in e)zh.call(e,n)&&(t[E5(n)]=e[n]);return t}function E5(e){let t=e.replace(d5,A5);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function A5(e){return"-"+e.toLowerCase()}var xa={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};import{Fragment as N6,jsx as O6,jsxs as _6}from"react/jsx-runtime";import{useEffect as Jde,useState as Zde}from"react";var P5={};function $h(e,t){let n=t||P5,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return U1(e,r,o)}function U1(e,t,n){if(L5(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return $1(e.children,t,n)}return Array.isArray(e)?$1(e,t,n):""}function $1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=U1(e[o],t,n);return r.join("")}function L5(e){return!!(e&&typeof e=="object")}var j1=document.createElement("i");function ts(e){let t="&"+e+";";j1.innerHTML=t;let n=j1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function hn(e,t,n,r){let o=e.length,i=0,s;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function Ln(e,t){return e.length>0?(hn(e,e.length,0,t),e):t}var H1={}.hasOwnProperty;function W1(e){let t={},n=-1;for(;++n<e.length;)M5(t,e[n]);return t}function M5(e,t){let n;for(n in t){let o=(H1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){H1.call(o,s)||(o[s]=[]);let a=i[s];B5(o[s],Array.isArray(a)?a:a?[a]:[])}}}function B5(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);hn(e,0,0,r)}function Ac(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function po(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var ir=_o(/[A-Za-z]/),dn=_o(/[\dA-Za-z]/),V1=_o(/[#-'*+\--9=?A-Z^-~]/);function ya(e){return e!==null&&(e<32||e===127)}var ba=_o(/\d/),G1=_o(/[\dA-Fa-f]/),q1=_o(/[!-/:-@[-`{-~]/);function de(e){return e!==null&&e<-2}function qt(e){return e!==null&&(e<0||e===32)}function We(e){return e===-2||e===-1||e===32}var Y1=_o(/\p{P}|\p{S}/u),K1=_o(/\s/);function _o(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function yr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&dn(e.charCodeAt(n+1))&&dn(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(s=String.fromCharCode(i));else if(i>55295&&i<57344){let a=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(s=String.fromCharCode(i,a),o=1):s="\uFFFD"}else s=String.fromCharCode(i);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+o+1,s=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return We(u)?(e.enter(n),a(u)):t(u)}function a(u){return We(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var X1={tokenize:D5};function D5(e){let t=e.attempt(this.parser.constructs.contentInitial,r,o),n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),i(a)}function i(a){let u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,s(a)}function s(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return de(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var J1={tokenize:R5},Q1={tokenize:z5};function R5(e){let t=this,n=[],r=0,o,i,s;return a;function a(D){if(r<n.length){let R=n[r];return t.containerState=R[1],e.attempt(R[0].continuation,u,c)(D)}return c(D)}function u(D){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&C();let R=t.events.length,_=R,P;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){P=t.events[_][1].end;break}A(r);let N=R;for(;N<t.events.length;)t.events[N][1].end={...P},N++;return hn(t.events,_+1,0,t.events.slice(R)),t.events.length=N,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return m(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Q1,l,d)(D)}function l(D){return o&&C(),A(r),g(D)}function d(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(D)}function g(D){return t.containerState={},e.attempt(Q1,p,m)(D)}function p(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function m(D){if(D===null){o&&C(),A(0),e.consume(D);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),k(D)}function k(D){if(D===null){I(e.exit("chunkFlow"),!0),A(0),e.consume(D);return}return de(D)?(e.consume(D),I(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),k)}function I(D,R){let _=t.sliceStream(D);if(R&&_.push(null),D.previous=i,i&&(i.next=D),i=D,o.defineSkip(D.start),o.write(_),t.parser.lazy[D.start.line]){let P=o.events.length;for(;P--;)if(o.events[P][1].start.offset<s&&(!o.events[P][1].end||o.events[P][1].end.offset>s))return;let N=t.events.length,x=N,v,w;for(;x--;)if(t.events[x][0]==="exit"&&t.events[x][1].type==="chunkFlow"){if(v){w=t.events[x][1].end;break}v=!0}for(A(r),P=N;P<t.events.length;)t.events[P][1].end={...w},P++;hn(t.events,x+1,0,t.events.slice(N)),t.events.length=P}}function A(D){let R=n.length;for(;R-- >D;){let _=n[R];t.containerState=_[1],_[0].exit.call(t,e)}n.length=D}function C(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function z5(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Uh(e){if(e===null||qt(e)||K1(e))return 1;if(Y1(e))return 2}function ns(e,t,n){let r=[],o=-1;for(;++o<e.length;){let i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}var Sa={name:"attention",resolveAll:N5,tokenize:O5};function N5(e,t){let n=-1,r,o,i,s,a,u,c,l;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},g={...e[n][1].start};Z1(d,-u),Z1(g,u),s={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[r][1].end={...s.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Ln(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Ln(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Ln(c,ns(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ln(c,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(l=2,c=Ln(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,hn(e,r-1,n-r+3,c),n=r+c.length-l-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function O5(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Uh(r),i;return s;function s(u){return i=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===i)return e.consume(u),a;let c=e.exit("attentionSequence"),l=Uh(u),d=!l||l===2&&o||n.includes(u),g=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!g)),c._close=!!(i===42?g:g&&(l||!d)),t(u)}}function Z1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var jh={name:"autolink",tokenize:_5};function _5(e,t,n){let r=0;return o;function o(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return ir(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||dn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,u):(p===43||p===45||p===46||dn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function u(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ya(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):V1(p)?(e.consume(p),c):n(p)}function l(p){return dn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,l):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):g(p)}function g(p){if((p===45||dn(p))&&r++<63){let m=p===45?g:d;return e.consume(p),m}return n(p)}}var $o={partial:!0,tokenize:$5};function $5(e,t,n){return r;function r(i){return We(i)?qe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||de(i)?t(i):n(i)}}var Pc={continuation:{tokenize:j5},exit:H5,name:"blockQuote",tokenize:U5};function U5(e,t,n){let r=this;return o;function o(s){if(s===62){let a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),i}return n(s)}function i(s){return We(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function j5(e,t,n){let r=this;return o;function o(s){return We(s)?qe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(Pc,t,n)(s)}}function H5(e){e.exit("blockQuote")}var Lc={name:"characterEscape",tokenize:W5};function W5(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return q1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Mc={name:"characterReference",tokenize:V5};function V5(e,t,n){let r=this,o=0,i,s;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),u}function u(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=dn,l(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=G1,l):(e.enter("characterReferenceValue"),i=7,s=ba,l(d))}function l(d){if(d===59&&o){let g=e.exit("characterReferenceValue");return s===dn&&!ts(r.sliceSerialize(g))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(d)&&o++<i?(e.consume(d),l):n(d)}}var eT={partial:!0,tokenize:q5},Bc={concrete:!0,name:"codeFenced",tokenize:G5};function G5(e,t,n){let r=this,o={partial:!0,tokenize:_},i=0,s=0,a;return u;function u(P){return c(P)}function c(P){let N=r.events[r.events.length-1];return i=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(P)}function l(P){return P===a?(s++,e.consume(P),l):s<3?n(P):(e.exit("codeFencedFenceSequence"),We(P)?qe(e,d,"whitespace")(P):d(P))}function d(P){return P===null||de(P)?(e.exit("codeFencedFence"),r.interrupt?t(P):e.check(eT,k,R)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(P))}function g(P){return P===null||de(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(P)):We(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,p,"whitespace")(P)):P===96&&P===a?n(P):(e.consume(P),g)}function p(P){return P===null||de(P)?d(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(P))}function m(P){return P===null||de(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(P)):P===96&&P===a?n(P):(e.consume(P),m)}function k(P){return e.attempt(o,R,I)(P)}function I(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),A}function A(P){return i>0&&We(P)?qe(e,C,"linePrefix",i+1)(P):C(P)}function C(P){return P===null||de(P)?e.check(eT,k,R)(P):(e.enter("codeFlowValue"),D(P))}function D(P){return P===null||de(P)?(e.exit("codeFlowValue"),C(P)):(e.consume(P),D)}function R(P){return e.exit("codeFenced"),t(P)}function _(P,N,x){let v=0;return w;function w(y){return P.enter("lineEnding"),P.consume(y),P.exit("lineEnding"),E}function E(y){return P.enter("codeFencedFence"),We(y)?qe(P,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):f(y)}function f(y){return y===a?(P.enter("codeFencedFenceSequence"),T(y)):x(y)}function T(y){return y===a?(v++,P.consume(y),T):v>=s?(P.exit("codeFencedFenceSequence"),We(y)?qe(P,S,"whitespace")(y):S(y)):x(y)}function S(y){return y===null||de(y)?(P.exit("codeFencedFence"),N(y)):x(y)}}}function q5(e,t,n){let r=this;return o;function o(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}var wa={name:"codeIndented",tokenize:K5},Y5={partial:!0,tokenize:X5};function K5(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),qe(e,i,"linePrefix",5)(c)}function i(c){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?u(c):de(c)?e.attempt(Y5,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||de(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function X5(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):de(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):qe(e,i,"linePrefix",5)(s)}function i(s){let a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):de(s)?o(s):n(s)}}var Hh={name:"codeText",previous:J5,resolve:Q5,tokenize:Z5};function Q5(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function J5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Z5(e,t,n){let r=this,o=0,i,s;return a;function a(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),o++,u):(e.exit("codeTextSequence"),c(g))}function c(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),c):g===96?(s=e.enter("codeTextSequence"),i=0,d(g)):de(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(g))}function l(g){return g===null||g===32||g===96||de(g)?(e.exit("codeTextData"),c(g)):(e.consume(g),l)}function d(g){return g===96?(e.consume(g),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(s.type="codeTextData",l(g))}}var Dc=class{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){let r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){let o=n||0;this.setCursor(Math.trunc(t));let i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&va(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),va(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),va(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){let n=this.left.splice(t,Number.POSITIVE_INFINITY);va(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);va(this.left,n.reverse())}}};function va(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Rc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Dc(e);for(;++n<l.length;){for(;n in t;)n=t[n];if(r=l.get(n),n&&r[1].type==="chunkFlow"&&l.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,eU(l,n)),n=t[n],c=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(s=l.get(i),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(l.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=i);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;o&&(r[1].end={...l.get(o)[1].start},a=l.slice(o,n),a.unshift(r),l.splice(o,n-o+1,a))}}return hn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function eU(e,t){let n=e.get(t)[1],r=e.get(t)[2],o=t-1,i=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let a=s.events,u=[],c={},l,d,g=-1,p=n,m=0,k=0,I=[k];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(l=r.sliceStream(p),p.next||l.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++g<a.length;)a[g][0]==="exit"&&a[g-1][0]==="enter"&&a[g][1].type===a[g-1][1].type&&a[g][1].start.line!==a[g][1].end.line&&(k=g+1,I.push(k),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):I.pop(),g=I.length;g--;){let A=a.slice(I[g],I[g+1]),C=i.pop();u.push([C,C+A.length-1]),e.splice(C,2,A)}for(u.reverse(),g=-1;++g<u.length;)c[m+u[g][0]]=m+u[g][1],m+=u[g][1]-u[g][0]-1;return c}var Wh={resolve:nU,tokenize:rU},tU={partial:!0,tokenize:oU};function nU(e){return Rc(e),e}function rU(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(a)}function o(a){return a===null?i(a):de(a)?e.check(tU,s,i)(a):(e.consume(a),o)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function s(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function oU(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),qe(e,i,"linePrefix")}function i(s){if(s===null||de(s))return n(s);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function zc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return d;function d(A){return A===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(A),e.exit(i),g):A===null||A===32||A===41||ya(A)?n(A):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),k(A))}function g(A){return A===62?(e.enter(i),e.consume(A),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(A))}function p(A){return A===62?(e.exit("chunkString"),e.exit(a),g(A)):A===null||A===60||de(A)?n(A):(e.consume(A),A===92?m:p)}function m(A){return A===60||A===62||A===92?(e.consume(A),p):p(A)}function k(A){return!l&&(A===null||A===41||qt(A))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(A)):l<c&&A===40?(e.consume(A),l++,k):A===41?(e.consume(A),l--,k):A===null||A===32||A===40||ya(A)?n(A):(e.consume(A),A===92?I:k)}function I(A){return A===40||A===41||A===92?(e.consume(A),k):k(A)}}function Nc(e,t,n,r,o,i){let s=this,a=0,u;return c;function c(p){return e.enter(r),e.enter(o),e.consume(p),e.exit(o),e.enter(i),l}function l(p){return a>999||p===null||p===91||p===93&&!u||p===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(p):p===93?(e.exit(i),e.enter(o),e.consume(p),e.exit(o),e.exit(r),t):de(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||de(p)||a++>999?(e.exit("chunkString"),l(p)):(e.consume(p),u||(u=!We(p)),p===92?g:d)}function g(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Oc(e,t,n,r,o,i){let s;return a;function a(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),s=g===40?41:g,u):n(g)}function u(g){return g===s?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),c(g))}function c(g){return g===s?(e.exit(i),u(s)):g===null?n(g):de(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(g))}function l(g){return g===s||g===null||de(g)?(e.exit("chunkString"),c(g)):(e.consume(g),g===92?d:l)}function d(g){return g===s||g===92?(e.consume(g),l):l(g)}}function ci(e,t){let n;return r;function r(o){return de(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):We(o)?qe(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Vh={name:"definition",tokenize:sU},iU={partial:!0,tokenize:aU};function sU(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return Nc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=po(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):n(p)}function u(p){return qt(p)?ci(e,c)(p):c(p)}function c(p){return zc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(iU,d,d)(p)}function d(p){return We(p)?qe(e,g,"whitespace")(p):g(p)}function g(p){return p===null||de(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function aU(e,t,n){return r;function r(a){return qt(a)?ci(e,o)(a):n(a)}function o(a){return Oc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return We(a)?qe(e,s,"whitespace")(a):s(a)}function s(a){return a===null||de(a)?t(a):n(a)}}var Gh={name:"hardBreakEscape",tokenize:lU};function lU(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return de(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var qh={name:"headingAtx",resolve:cU,tokenize:uU};function cU(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},hn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function uU(e,t,n){let r=0;return o;function o(l){return e.enter("atxHeading"),i(l)}function i(l){return e.enter("atxHeadingSequence"),s(l)}function s(l){return l===35&&r++<6?(e.consume(l),s):l===null||qt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||de(l)?(e.exit("atxHeading"),t(l)):We(l)?qe(e,a,"whitespace")(l):(e.enter("atxHeadingText"),c(l))}function u(l){return l===35?(e.consume(l),u):(e.exit("atxHeadingSequence"),a(l))}function c(l){return l===null||l===35||qt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var tT=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Yh=["pre","script","style","textarea"];var Kh={concrete:!0,name:"htmlFlow",resolveTo:gU,tokenize:fU},pU={partial:!0,tokenize:hU},dU={partial:!0,tokenize:mU};function gU(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function fU(e,t,n){let r=this,o,i,s,a,u;return c;function c(B){return l(B)}function l(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),d}function d(B){return B===33?(e.consume(B),g):B===47?(e.consume(B),i=!0,k):B===63?(e.consume(B),o=3,r.interrupt?t:h):ir(B)?(e.consume(B),s=String.fromCharCode(B),I):n(B)}function g(B){return B===45?(e.consume(B),o=2,p):B===91?(e.consume(B),o=5,a=0,m):ir(B)?(e.consume(B),o=4,r.interrupt?t:h):n(B)}function p(B){return B===45?(e.consume(B),r.interrupt?t:h):n(B)}function m(B){let G="CDATA[";return B===G.charCodeAt(a++)?(e.consume(B),a===G.length?r.interrupt?t:f:m):n(B)}function k(B){return ir(B)?(e.consume(B),s=String.fromCharCode(B),I):n(B)}function I(B){if(B===null||B===47||B===62||qt(B)){let G=B===47,te=s.toLowerCase();return!G&&!i&&Yh.includes(te)?(o=1,r.interrupt?t(B):f(B)):tT.includes(s.toLowerCase())?(o=6,G?(e.consume(B),A):r.interrupt?t(B):f(B)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?C(B):D(B))}return B===45||dn(B)?(e.consume(B),s+=String.fromCharCode(B),I):n(B)}function A(B){return B===62?(e.consume(B),r.interrupt?t:f):n(B)}function C(B){return We(B)?(e.consume(B),C):w(B)}function D(B){return B===47?(e.consume(B),w):B===58||B===95||ir(B)?(e.consume(B),R):We(B)?(e.consume(B),D):w(B)}function R(B){return B===45||B===46||B===58||B===95||dn(B)?(e.consume(B),R):_(B)}function _(B){return B===61?(e.consume(B),P):We(B)?(e.consume(B),_):D(B)}function P(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),u=B,N):We(B)?(e.consume(B),P):x(B)}function N(B){return B===u?(e.consume(B),u=null,v):B===null||de(B)?n(B):(e.consume(B),N)}function x(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||qt(B)?_(B):(e.consume(B),x)}function v(B){return B===47||B===62||We(B)?D(B):n(B)}function w(B){return B===62?(e.consume(B),E):n(B)}function E(B){return B===null||de(B)?f(B):We(B)?(e.consume(B),E):n(B)}function f(B){return B===45&&o===2?(e.consume(B),F):B===60&&o===1?(e.consume(B),L):B===62&&o===4?(e.consume(B),j):B===63&&o===3?(e.consume(B),h):B===93&&o===5?(e.consume(B),z):de(B)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(pU,V,T)(B)):B===null||de(B)?(e.exit("htmlFlowData"),T(B)):(e.consume(B),f)}function T(B){return e.check(dU,S,V)(B)}function S(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),y}function y(B){return B===null||de(B)?T(B):(e.enter("htmlFlowData"),f(B))}function F(B){return B===45?(e.consume(B),h):f(B)}function L(B){return B===47?(e.consume(B),s="",M):f(B)}function M(B){if(B===62){let G=s.toLowerCase();return Yh.includes(G)?(e.consume(B),j):f(B)}return ir(B)&&s.length<8?(e.consume(B),s+=String.fromCharCode(B),M):f(B)}function z(B){return B===93?(e.consume(B),h):f(B)}function h(B){return B===62?(e.consume(B),j):B===45&&o===2?(e.consume(B),h):f(B)}function j(B){return B===null||de(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),j)}function V(B){return e.exit("htmlFlow"),t(B)}}function mU(e,t,n){let r=this;return o;function o(s){return de(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):n(s)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function hU(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt($o,t,n)}}var Xh={name:"htmlText",tokenize:xU};function xU(e,t,n){let r=this,o,i,s;return a;function a(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),u}function u(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),_):h===63?(e.consume(h),D):ir(h)?(e.consume(h),x):n(h)}function c(h){return h===45?(e.consume(h),l):h===91?(e.consume(h),i=0,m):ir(h)?(e.consume(h),C):n(h)}function l(h){return h===45?(e.consume(h),p):n(h)}function d(h){return h===null?n(h):h===45?(e.consume(h),g):de(h)?(s=d,L(h)):(e.consume(h),d)}function g(h){return h===45?(e.consume(h),p):d(h)}function p(h){return h===62?F(h):h===45?g(h):d(h)}function m(h){let j="CDATA[";return h===j.charCodeAt(i++)?(e.consume(h),i===j.length?k:m):n(h)}function k(h){return h===null?n(h):h===93?(e.consume(h),I):de(h)?(s=k,L(h)):(e.consume(h),k)}function I(h){return h===93?(e.consume(h),A):k(h)}function A(h){return h===62?F(h):h===93?(e.consume(h),A):k(h)}function C(h){return h===null||h===62?F(h):de(h)?(s=C,L(h)):(e.consume(h),C)}function D(h){return h===null?n(h):h===63?(e.consume(h),R):de(h)?(s=D,L(h)):(e.consume(h),D)}function R(h){return h===62?F(h):D(h)}function _(h){return ir(h)?(e.consume(h),P):n(h)}function P(h){return h===45||dn(h)?(e.consume(h),P):N(h)}function N(h){return de(h)?(s=N,L(h)):We(h)?(e.consume(h),N):F(h)}function x(h){return h===45||dn(h)?(e.consume(h),x):h===47||h===62||qt(h)?v(h):n(h)}function v(h){return h===47?(e.consume(h),F):h===58||h===95||ir(h)?(e.consume(h),w):de(h)?(s=v,L(h)):We(h)?(e.consume(h),v):F(h)}function w(h){return h===45||h===46||h===58||h===95||dn(h)?(e.consume(h),w):E(h)}function E(h){return h===61?(e.consume(h),f):de(h)?(s=E,L(h)):We(h)?(e.consume(h),E):v(h)}function f(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),o=h,T):de(h)?(s=f,L(h)):We(h)?(e.consume(h),f):(e.consume(h),S)}function T(h){return h===o?(e.consume(h),o=void 0,y):h===null?n(h):de(h)?(s=T,L(h)):(e.consume(h),T)}function S(h){return h===null||h===34||h===39||h===60||h===61||h===96?n(h):h===47||h===62||qt(h)?v(h):(e.consume(h),S)}function y(h){return h===47||h===62||qt(h)?v(h):n(h)}function F(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),t):n(h)}function L(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),M}function M(h){return We(h)?qe(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):z(h)}function z(h){return e.enter("htmlTextData"),s(h)}}var ui={name:"labelEnd",resolveAll:wU,resolveTo:vU,tokenize:kU},yU={tokenize:CU},bU={tokenize:TU},SU={tokenize:IU};function wU(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&hn(e,0,e.length,n),e}function vU(e,t){let n=e.length,r=0,o,i,s,a;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(s=n);let u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[i][1].start},end:{...e[s][1].end}},l={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[s-2][1].start}};return a=[["enter",u,t],["enter",c,t]],a=Ln(a,e.slice(i+1,i+r+3)),a=Ln(a,[["enter",l,t]]),a=Ln(a,ns(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Ln(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Ln(a,e.slice(s+1)),a=Ln(a,[["exit",u,t]]),hn(e,i,e.length,a),e}function kU(e,t,n){let r=this,o=r.events.length,i,s;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return a;function a(g){return i?i._inactive?d(g):(s=r.parser.defined.includes(po(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(yU,l,s?l:d)(g):g===91?e.attempt(bU,l,s?c:d)(g):s?l(g):d(g)}function c(g){return e.attempt(SU,l,d)(g)}function l(g){return t(g)}function d(g){return i._balanced=!0,n(g)}}function CU(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),o}function o(d){return qt(d)?ci(e,i)(d):i(d)}function i(d){return d===41?l(d):zc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return qt(d)?ci(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?Oc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return qt(d)?ci(e,l)(d):l(d)}function l(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function TU(e,t,n){let r=this;return o;function o(a){return Nc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(po(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function IU(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}var Qh={name:"labelStartImage",resolveAll:ui.resolveAll,tokenize:FU};function FU(e,t,n){let r=this;return o;function o(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),s):n(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}var Jh={name:"labelStartLink",resolveAll:ui.resolveAll,tokenize:EU};function EU(e,t,n){let r=this;return o;function o(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),i}function i(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}var ka={name:"lineEnding",tokenize:AU};function AU(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}var pi={name:"thematicBreak",tokenize:PU};function PU(e,t,n){let r=0,o;return i;function i(c){return e.enter("thematicBreak"),s(c)}function s(c){return o=c,a(c)}function a(c){return c===o?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||de(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),We(c)?qe(e,a,"whitespace")(c):a(c))}}var kn={continuation:{tokenize:DU},exit:zU,name:"list",tokenize:BU},LU={partial:!0,tokenize:NU},MU={partial:!0,tokenize:RU};function BU(e,t,n){let r=this,o=r.events[r.events.length-1],i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,s=0;return a;function a(p){let m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ba(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(pi,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return n(p)}function u(p){return ba(p)&&++s<10?(e.consume(p),u):(!r.interrupt||s<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check($o,r.interrupt?n:l,e.attempt(LU,g,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,g(p)}function d(p){return We(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),g):n(p)}function g(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function DU(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($o,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!We(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(MU,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(kn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function RU(e,t,n){let r=this;return qe(e,o,"listItemIndent",r.containerState.size+1);function o(i){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(i):n(i)}}function zU(e){e.exit(this.containerState.type)}function NU(e,t,n){let r=this;return qe(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let s=r.events[r.events.length-1];return!We(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var _c={name:"setextUnderline",resolveTo:OU,tokenize:_U};function OU(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);let s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",s,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=s,e.push(["exit",s,t]),e}function _U(e,t,n){let r=this,o;return i;function i(c){let l=r.events.length,d;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){d=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),o=c,s(c)):n(c)}function s(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===o?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),We(c)?qe(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||de(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var nT={tokenize:$U};function $U(e){let t=this,n=e.attempt($o,r,e.attempt(this.parser.constructs.flowInitial,o,qe(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Wh,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}var rT={resolveAll:aT()},oT=sT("string"),iT=sT("text");function sT(e){return{resolveAll:aT(e==="text"?UU:void 0),tokenize:t};function t(n){let r=this,o=this.parser.constructs[e],i=n.attempt(o,s,a);return s;function s(l){return c(l)?i(l):a(l)}function a(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),u}function u(l){return c(l)?(n.exit("data"),i(l)):(n.consume(l),u)}function c(l){if(l===null)return!0;let d=o[l],g=-1;if(d)for(;++g<d.length;){let p=d[g];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function aT(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function UU(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],o=t.sliceStream(r),i=o.length,s=-1,a=0,u;for(;i--;){let c=o[i];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)u=!0,a++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){let c={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:r.start._bufferIndex+s,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}var Zh={};Se(Zh,{attentionMarkers:()=>KU,contentInitial:()=>HU,disable:()=>XU,document:()=>jU,flow:()=>VU,flowInitial:()=>WU,insideSpan:()=>YU,string:()=>GU,text:()=>qU});var jU={42:kn,43:kn,45:kn,48:kn,49:kn,50:kn,51:kn,52:kn,53:kn,54:kn,55:kn,56:kn,57:kn,62:Pc},HU={91:Vh},WU={[-2]:wa,[-1]:wa,32:wa},VU={35:qh,42:pi,45:[_c,pi],60:Kh,61:_c,95:pi,96:Bc,126:Bc},GU={38:Mc,92:Lc},qU={[-5]:ka,[-4]:ka,[-3]:ka,33:Qh,38:Mc,42:Sa,60:[jh,Xh],91:Jh,92:[Gh,Lc],93:ui,95:Sa,96:Hh},YU={null:[Sa,rT]},KU={null:[42,95]},XU={null:[]};function lT(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},o={},i=[],s=[],a=[],u=!0,c={attempt:v(N),check:v(x),consume:R,enter:_,exit:P,interrupt:v(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:A,events:[],now:I,parser:e,previous:null,sliceSerialize:m,sliceStream:k,write:p},d=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function p(T){return s=Ln(s,T),C(),s[s.length-1]!==null?[]:(w(t,0),l.events=ns(i,l.events,l),l.events)}function m(T,S){return JU(k(T),S)}function k(T){return QU(s,T)}function I(){let{_bufferIndex:T,_index:S,line:y,column:F,offset:L}=r;return{_bufferIndex:T,_index:S,line:y,column:F,offset:L}}function A(T){o[T.line]=T.column,f()}function C(){let T;for(;r._index<s.length;){let S=s[r._index];if(typeof S=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<S.length;)D(S.charCodeAt(r._bufferIndex));else D(S)}}function D(T){u=void 0,g=T,d=d(T)}function R(T){de(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,f()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T,u=!0}function _(T,S){let y=S||{};return y.type=T,y.start=I(),l.events.push(["enter",y,l]),a.push(y),y}function P(T){let S=a.pop();return S.end=I(),l.events.push(["exit",S,l]),S}function N(T,S){w(T,S.from)}function x(T,S){S.restore()}function v(T,S){return y;function y(F,L,M){let z,h,j,V;return Array.isArray(F)?G(F):"tokenize"in F?G([F]):B(F);function B(ie){return Ke;function Ke(be){let Ie=be!==null&&ie[be],ve=be!==null&&ie.null,ue=[...Array.isArray(Ie)?Ie:Ie?[Ie]:[],...Array.isArray(ve)?ve:ve?[ve]:[]];return G(ue)(be)}}function G(ie){return z=ie,h=0,ie.length===0?M:te(ie[h])}function te(ie){return Ke;function Ke(be){return V=E(),j=ie,ie.partial||(l.currentConstruct=ie),ie.name&&l.parser.constructs.disable.null.includes(ie.name)?xe(be):ie.tokenize.call(S?Object.assign(Object.create(l),S):l,c,le,xe)(be)}}function le(ie){return u=!0,T(j,V),L}function xe(ie){return u=!0,V.restore(),++h<z.length?te(z[h]):M}}}function w(T,S){T.resolveAll&&!i.includes(T)&&i.push(T),T.resolve&&hn(l.events,S,l.events.length-S,T.resolve(l.events.slice(S),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function E(){let T=I(),S=l.previous,y=l.currentConstruct,F=l.events.length,L=Array.from(a);return{from:F,restore:M};function M(){r=T,l.previous=S,l.currentConstruct=y,l.events.length=F,a=L,f()}}function f(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function QU(e,t){let n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex,s;if(n===o)s=[e[n].slice(r,i)];else{if(s=e.slice(n,o),r>-1){let a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}function JU(e,t){let n=-1,r=[],o;for(;++n<e.length;){let i=e[n],s;if(typeof i=="string")s=i;else switch(i){case-5:{s="\r";break}case-4:{s=`
81
+ `,boe=nn.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${c3} 0.8s linear infinite`,flexShrink:0})),r1=nn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(220, 38, 38, 0.18)":"#fee2e2",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626",whiteSpace:"nowrap"})),u3=nn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(22, 163, 74, 0.18)":"#dcfce7",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.positive||"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"})),Soe=nn.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"-10px",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>6?"50%":"2px",animation:`${l3} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var ua=nn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),pa=nn.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),o1=nn.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),da=nn.span(({color:e})=>({fontWeight:700,color:e})),p3=nn.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:`${t.layoutMargin*.6}px`,padding:`${t.layoutMargin*.3}px ${t.layoutMargin}px`,borderRadius:t.appBorderRadius*2,backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:t.typography.size.s1,color:t.textMutedColor},"& .score-value":{fontFamily:t.typography.fonts.mono,fontSize:t.typography.size.s2,fontWeight:t.typography.weight.bold,color:e,lineHeight:1},"& .score-dot":{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:e}})),woe=nn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),voe=nn.span(({color:e=se})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${i3} 1.2s ease-in-out infinite`,marginRight:"4px"})),koe=nn.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return se;case"score-high":return"#16a34a";case"score-medium":return"#ca8a04";case"score-low":return"#dc2626";case"cost":return"#7c3aed";case"tokens":return e.color.mediumdark;case"analyzing":return se;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${a3} 1.5s ease-in-out infinite`}:{}})),Coe=nn.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Toe=nn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),d3=nn.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${s3} 1.2s linear infinite`,flexShrink:0}),g3=({color:e=se})=>ze.createElement(d3,null,ze.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},Array.from({length:8}).map((t,n)=>{let o=n*360/8*Math.PI/180,i=12+Math.cos(o)*4,s=12+Math.sin(o)*4,a=12+Math.cos(o)*10,u=12+Math.sin(o)*10;return ze.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Ioe=nn.span(({color:e="#6b7280"})=>({fontSize:"12px",fontWeight:500,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",animation:`${i1} 0.3s ease-out`}));function f3(e){let[t,n]=r3(0);return o3(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var s1=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,visualSimilarity:i,costUsd:s,inputTokens:a,outputTokens:u,showTimer:c=!0,cacheCreationTokens:l,cacheReadTokens:d,durationSeconds:g})=>{let p=f3(e||t),{featureFlags:m}=ce(),v=m.showCosts,I=3.65,A=P=>P<.01?`$${P.toFixed(4)}`:P<.1?`$${P.toFixed(3)}`:`$${P.toFixed(2)}`,C=P=>{let N=P*I;return N<.01?`\u20AA${N.toFixed(4)}`:N<.1?`\u20AA${N.toFixed(3)}`:`\u20AA${N.toFixed(2)}`},D=P=>P>=1e3?`${(P/1e3).toFixed(1)}K`:P.toString(),R=P=>P>=80?"score-high":P>=50?"score-medium":"score-low",_=P=>P>=80?"high":P>=50?"medium":"low";if(e)return ze.createElement(Sh,null,ze.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},p,"s \xB7 Esc to stop"));if(t)return ze.createElement(Sh,null,ze.createElement(r1,null,ze.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement(g3,{color:"#7c3aed"}),ze.createElement(da,{color:"#7c3aed"},"Verifying...")),c&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement("span",{style:{color:"#6b7280"}},p,"s"))));if(r>0||o!==void 0){let P=(a||0)+(u||0),N=(d||0)>0,x=N&&a?Math.round(d/a*100):0,k=Math.max(o??0,i??0),w=f=>f>=80?"#16a34a":f>=50?"#ca8a04":"#dc2626",E=f=>f>=100?"\u25CF":f>=50?"\u25D0":"\u25CB";return ze.createElement(Sh,null,r===0?ze.createElement(u3,null,ze.createElement("span",null,"\u2713"),"Perfect!"):ze.createElement(r1,null,ze.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ze.createElement(p3,{tint:w(k),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},ze.createElement("span",{className:"score-dot"}),ze.createElement("span",{className:"score-label"},"Score"),ze.createElement("span",{className:"score-value"},k)),v&&s!==void 0&&s>0&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement(da,{color:"#16a34a"},A(s)),ze.createElement("span",{style:{color:"#6b7280"}},"/"),ze.createElement(da,{color:"#16a34a"},C(s)))),v&&P>0&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${N?` \xB7 Cached: ${d?.toLocaleString()}`:""}`},ze.createElement(o1,{color:"#7c3aed"},"#"),ze.createElement(da,{color:"#7c3aed"},D(P)),ze.createElement("span",{style:{color:"#6b7280"}},"tokens"),N&&ze.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",x,"%"))),g!==void 0&&g>0&&ze.createElement(ze.Fragment,null,ze.createElement(ua,null,"|"),ze.createElement(pa,null,ze.createElement(o1,{color:"#6b7280"},"\u23F1"),ze.createElement(da,{color:"#6b7280"},g,"s"))))}return null};var b3=qn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),zoe=qn.div({display:"flex",gap:"8px",alignItems:"center"}),S3=y3({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),w3=qn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${S3} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),v3=qn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),k3=qn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin}px`,padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.2}px`,borderRadius:e.appBorderRadius*2,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.03)",flexWrap:"wrap"})),C3=qn.button(({theme:e,variant:t="orange",disabled:n})=>{let r={green:n?e.textMutedColor:e.color.positive||"#10b981",purple:n?e.textMutedColor:"#7c3aed",yellow:n?e.textMutedColor:"#c4b5fd",orange:n?e.textMutedColor:Ga},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:e.color.inverseText,border:"none",padding:`${e.layoutMargin*.7}px ${e.layoutMargin*1.4}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,borderRadius:e.appBorderRadius,cursor:n?"not-allowed":"pointer",opacity:n?.6:1,whiteSpace:"nowrap",transition:"all 0.2s",boxShadow:n?"none":`0 2px 6px rgba(${o}, 0.3)`,flexShrink:0,"&:hover":{opacity:n?.6:.9,transform:n?"none":"translateY(-1px)",boxShadow:n?"none":`0 4px 10px rgba(${o}, 0.4)`}}}),T3=qn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),I3=qn.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),F3=qn(bn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),E3=qn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),a1=qn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),l1=qn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?Ga:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),c1=qn.div(({checked:e})=>({width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#fff",position:"absolute",top:"2px",left:e?"16px":"2px",transition:"left 0.2s ease",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)"})),u1=qn.input({position:"absolute",opacity:0,width:0,height:0}),A3=()=>{let[e,t]=h3(0),n=x3();p1(()=>(n.current=setInterval(()=>t(s=>s+1),1e3),()=>clearInterval(n.current)),[]);let r=Math.floor(e/60),o=e%60,i=`${r}:${o.toString().padStart(2,"0")}`;return ht.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},wh=()=>{let{sessionToken:e}=Ws(),{usageData:t}=ke(),{selectedProjectId:n}=io(),{currentMapping:r,hasMapping:o}=ri(),{loadingMapping:i,currentStoryId:s}=nt(),{startReview:a,cancelReview:u,isReviewing:c}=xm(),{isLoadingScreenshots:l}=ti(),{storybookImageUrl:d,figmaImageUrl:g,currentReviewId:p,reviewHistory:m,setReviewDetailTab:v,setReviewResults:I,setFigmaImageUrl:A,setStorybookImageUrl:C,setFullPrompt:D,setFullResponse:R,includeTextComparison:_,setIncludeTextComparison:P,usePromptCache:N,setUsePromptCache:x,isValidating:k,validationUsage:w,isGenerating:E,isApplying:f,streamingStatus:T,featureFlags:S,userRole:y,roleOverride:F,isReviewing:L}=ce(),M=t?.reviewCredits??Math.floor(t?.creditBalance??0),z=m.find(fe=>fe.id===p),j=(z?.issues||[]).filter(fe=>!fe.dismissed).length,V=z?.complianceScore,B=z?.visualSimilarity,G=(z?.costUsd||0)+(w?.costUsd||0),te=(z?.inputTokens||0)+(w?.inputTokens||0),le=(z?.outputTokens||0)+(w?.outputTokens||0),xe=m3(()=>{let fe=s?m.filter(me=>me.storyId===s):m,tt=fe.filter(me=>!me.parentReviewId).sort((me,oe)=>new Date(oe.createdAt).getTime()-new Date(me.createdAt).getTime()),he=fe.filter(me=>me.parentReviewId),re=[];for(let me of tt){re.push(me);let oe=he.filter(O=>O.parentReviewId===me.id).sort((O,U)=>(O.iterationNumber||0)-(U.iterationNumber||0));re.push(...oe)}let K=he.filter(me=>!tt.some(oe=>oe.id===me.parentReviewId));return re.push(...K),re},[m,s]);p1(()=>{if(!c)return;let fe=tt=>{tt.key==="Escape"&&(tt.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let ie=o&&r?.figmaNodeId,Ke=E||f,be=M>0,Ie=!!(e&&n&&!c&&!l&&!Ke&&s&&d&&ie&&g&&be),ve=async(fe=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{v("chat"),await a({isIteration:fe,parentReviewId:fe?p:void 0})}catch(tt){console.error("[ReviewActions] Review error:",tt)}},ue=()=>ve(!1),$e=fe=>{let tt=fe.target.value;if(tt){let he=m.find(re=>re.id===tt);he&&(I({id:he.id,componentId:he.componentId,storyId:he.storyId,modelId:he.modelId,complianceScore:he.complianceScore,issuesCount:he.issuesCount,issues:he.issues,createdAt:new Date(he.createdAt),visualSimilarity:he.visualSimilarity,timestamp:new Date(he.createdAt).toISOString(),costUsd:he.costUsd,inputTokens:he.inputTokens,outputTokens:he.outputTokens,cacheCreationTokens:he.cacheCreationTokens,cacheReadTokens:he.cacheReadTokens,reviewDurationMs:he.reviewDurationMs}),he.figmaImageData&&A(he.figmaImageData),he.storybookImageData&&C(he.storybookImageData),(F??y)==="admin"&&(D(he.aiPrompt||""),R(he.aiResponse||"")),v("issues"))}},pe=fe=>{let tt=new Date(fe),re=new Date().getTime()-tt.getTime(),K=Math.floor(re/6e4),me=Math.floor(re/36e5),oe=Math.floor(re/864e5);return K<1?"Just now":K<60?`${K}m ago`:me<24?`${me}h ago`:oe<7?`${oe}d ago`:tt.toLocaleDateString()},yt=fe=>fe?fe.includes("haiku")?"Haiku":fe.includes("sonnet")?"Sonnet":fe.includes("opus")?"Opus":fe.includes("gpt-4o-mini")?"GPT-4o mini":fe.includes("gpt-4o")?"GPT-4o":fe.includes("gpt-4")?"GPT-4":fe.includes("o3")?"o3":fe.includes("o1")?"o1":fe.split("-")[0]||"":"",$t=fe=>{let tt=fe.split("--"),he=tt[tt.length-1]||fe;return he.charAt(0).toUpperCase()+he.slice(1)},yn=(F??y)==="admin";return ht.createElement("div",null,ht.createElement(b3,null,S.enableModelSelection&&ht.createElement(n1,null),yn&&ht.createElement(E3,null,ht.createElement(a1,{title:"Compare text content between Figma design and Storybook component"},ht.createElement(u1,{type:"checkbox",checked:_,onChange:fe=>P(fe.target.checked)}),ht.createElement(l1,{checked:_},ht.createElement(c1,{checked:_})),"Compare text"),S.showCosts&&ht.createElement(a1,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ht.createElement(u1,{type:"checkbox",checked:N,onChange:fe=>x(fe.target.checked)}),ht.createElement(l1,{checked:N},ht.createElement(c1,{checked:N})),"Cache prompt")),ht.createElement(k3,null,ht.createElement(C3,{variant:c?"yellow":"purple",disabled:c?!1:!Ie,onClick:c?u:ue,title:c?"Click to stop review":e?n?s?ie?l?"Loading screenshots...":Ke?"Wait for fixes to complete...":d?g?be?"Review this component implementation":"No credits \u2014 click \u26A1 in the toolbar to get more":"Waiting for Figma design image...":"Waiting for Storybook screenshot...":'Figma mapping required - use "Map to Figma" in the Review tab':"No story selected":"Please select a project first":`Please connect to ${Pt.NAME} first`},c?ht.createElement(ht.Fragment,null,ht.createElement(w3,null),"Reviewing",ht.createElement(A3,null)):ht.createElement(ht.Fragment,null,ht.createElement(v3,null,ht.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ht.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),L?null:k||z?ht.createElement(s1,{isReviewing:!1,isValidating:k,streamingStatus:T,issueCount:j,score:V,visualSimilarity:B,costUsd:G||z?.costUsd,inputTokens:te||z?.inputTokens,outputTokens:le||z?.outputTokens,cacheCreationTokens:z?.cacheCreationTokens,cacheReadTokens:z?.cacheReadTokens,durationSeconds:z?.reviewDurationMs?Math.round(z.reviewDurationMs/1e3):void 0}):null,xe.length>0&&ht.createElement(I3,null,ht.createElement(F3,{value:p||"",onChange:$e,title:"Review history"},ht.createElement("option",{value:""},"Select a review..."),xe.map(fe=>{let tt=!!fe.parentReviewId,he=tt?" \u21B3 ":"\u25CF ",re=tt&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",K=fe.issuesCount??fe.issues?.length??0,me=fe.complianceScore??"--",oe=yt(fe.modelId);return ht.createElement("option",{key:fe.id,value:fe.id},he,re,pe(fe.createdAt)," - ",K," issues (",me,"%)",oe?` \xB7 ${oe}`:"",fe.storyId?` \xB7 ${$t(fe.storyId)}`:"")}))))),!ie&&!i&&ht.createElement(T3,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import _oe,{useState as $oe}from"react";import{styled as d1}from"storybook/theming";var Hoe=d1.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Woe=d1(bo)({padding:"8px 12px",fontSize:"12px"});import qoe,{useState as Yoe}from"react";import{styled as vh}from"storybook/theming";Te();He();_e();ct();var tie=vh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),nie=vh(Nr)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),rie=vh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import sie from"react";import{styled as P3}from"storybook/theming";var cie=P3.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));Te();import die from"react";import{styled as Vr}from"storybook/theming";var mie=Vr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),hie=Vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),xie=Vr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),yie=Vr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),bie=Vr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Sie=Vr.div(({theme:e,progress:t})=>({height:"100%",backgroundColor:t===100?e.color.positive||"#10b981":e.color.secondary,width:`${t}%`,transition:"width 0.3s ease, background-color 0.3s ease"})),wie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),vie=Vr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),kie=Vr.div(({theme:e})=>({display:"inline-block",width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"spin 0.8s linear infinite",marginLeft:"8px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Cie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));Te();import Fie,{useState as Eie}from"react";import{styled as Gr}from"storybook/theming";var Lie=Gr.div(({theme:e})=>{let t=(e.base==="dark","102, 126, 234");return{padding:"10px 12px",backgroundColor:`rgba(${t}, 0.08)`,borderRadius:"6px",marginBottom:"16px",border:`1px solid rgba(${t}, 0.2)`}}),Mie=Gr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Bie=Gr.div({display:"flex",alignItems:"center",gap:"8px"}),Die=Gr.span({fontSize:"12px",opacity:.7}),Rie=Gr.span({fontSize:"13px",fontWeight:500}),zie=Gr.div(({score:e,theme:t})=>({display:"inline-block",padding:"4px 10px",borderRadius:"12px",fontSize:"13px",fontWeight:600,backgroundColor:e>=90?t.color.positive||"#10b981":e>=70?t.color.warning||"#f59e0b":t.color.negative||"#ef4444",color:t.color.inverseText})),Nie=Gr.div({marginTop:"12px",fontSize:"11px"}),Oie=Gr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),_ie=Gr.div(({status:e,theme:t})=>({display:"flex",alignItems:"center",gap:"4px",color:e==="success"?"inherit":e==="success"?t.color.positive||"#10b981":e==="warning"?t.color.warning||"#f59e0b":t.color.negative||"#ef4444"})),$ie=Gr.span({fontSize:"12px"});_e();He();import Jt from"react";import{styled as cs}from"storybook/theming";import Dr,{useEffect as AW}from"react";import{styled as Aa}from"storybook/theming";Te();import gi,{useState as G6}from"react";import{styled as ss}from"storybook/theming";var g1={fontBase:'"Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontMono:'"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace',sizeXs:"11px",sizeSm:"12px",sizeMd:"13px",sizeLg:"14px",sizeXl:"16px",weightRegular:400,weightMedium:500,weightBold:600};function f1(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var L3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,M3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,B3={};function vc(e,t){return((t||B3).jsx?M3:L3).test(e)}var D3=/[ \t\n\f\r]/g;function kh(e){return typeof e=="object"?e.type==="text"?m1(e.value):!1:m1(e)}function m1(e){return e.replace(D3,"")===""}var uo=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};uo.prototype.normal={};uo.prototype.property={};uo.prototype.space=void 0;function Ch(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new uo(n,r,t)}function ga(e){return e.toLowerCase()}var pn=class{constructor(t,n){this.attribute=n,this.property=t}};pn.prototype.attribute="";pn.prototype.booleanish=!1;pn.prototype.boolean=!1;pn.prototype.commaOrSpaceSeparated=!1;pn.prototype.commaSeparated=!1;pn.prototype.defined=!1;pn.prototype.mustUseProperty=!1;pn.prototype.number=!1;pn.prototype.overloadedBoolean=!1;pn.prototype.property="";pn.prototype.spaceSeparated=!1;pn.prototype.space=void 0;var fa={};Se(fa,{boolean:()=>Ge,booleanish:()=>Ut,commaOrSpaceSeparated:()=>Yn,commaSeparated:()=>No,number:()=>X,overloadedBoolean:()=>kc,spaceSeparated:()=>Ct});var R3=0,Ge=si(),Ut=si(),kc=si(),X=si(),Ct=si(),No=si(),Yn=si();function si(){return 2**++R3}var Th=Object.keys(fa),ai=class extends pn{constructor(t,n,r,o){let i=-1;if(super(t,n),h1(this,"space",o),typeof r=="number")for(;++i<Th.length;){let s=Th[i];h1(this,Th[i],(r&fa[s])===fa[s])}}};ai.prototype.defined=!0;function h1(e,t,n){n&&(e[t]=n)}function xr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new ai(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ga(r)]=r,n[ga(i.attribute)]=r}return new uo(t,n,e.space)}var Ih=xr({properties:{ariaActiveDescendant:null,ariaAtomic:Ut,ariaAutoComplete:null,ariaBusy:Ut,ariaChecked:Ut,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:Ct,ariaCurrent:null,ariaDescribedBy:Ct,ariaDetails:null,ariaDisabled:Ut,ariaDropEffect:Ct,ariaErrorMessage:null,ariaExpanded:Ut,ariaFlowTo:Ct,ariaGrabbed:Ut,ariaHasPopup:null,ariaHidden:Ut,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ct,ariaLevel:X,ariaLive:null,ariaModal:Ut,ariaMultiLine:Ut,ariaMultiSelectable:Ut,ariaOrientation:null,ariaOwns:Ct,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:Ut,ariaReadOnly:Ut,ariaRelevant:null,ariaRequired:Ut,ariaRoleDescription:Ct,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:Ut,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Cc(e,t){return t in e?e[t]:t}function Tc(e,t){return Cc(e,t.toLowerCase())}var x1=xr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:No,acceptCharset:Ct,accessKey:Ct,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:Ct,autoFocus:Ge,autoPlay:Ge,blocking:Ct,capture:null,charSet:null,checked:Ge,cite:null,className:Ct,cols:X,colSpan:null,content:null,contentEditable:Ut,controls:Ge,controlsList:Ct,coords:X|No,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:kc,draggable:Ut,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:Ct,height:X,hidden:kc,high:X,href:null,hrefLang:null,htmlFor:Ct,httpEquiv:Ct,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:Ct,itemRef:Ct,itemScope:Ge,itemType:Ct,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ge,optimum:X,pattern:null,ping:Ct,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:Ct,required:Ge,reversed:Ge,rows:X,rowSpan:X,sandbox:Ct,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:Ut,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Ut,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ct,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:Ut,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:Tc});var y1=xr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Yn,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:Ct,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:No,g2:No,glyphName:No,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:Yn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ct,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yn,rev:Yn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yn,requiredFeatures:Yn,requiredFonts:Yn,requiredFormats:Yn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:Yn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yn,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Cc});var Fh=xr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var Eh=xr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Tc});var Ah=xr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Ph={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var z3=/[A-Z]/g,b1=/-[a-z]/g,N3=/^data[-\w.:]+$/i;function Lh(e,t){let n=ga(t),r=t,o=pn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&N3.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(b1,_3);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!b1.test(i)){let s=i.replace(z3,O3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=ai}return new o(r,t)}function O3(e){return"-"+e.toLowerCase()}function _3(e){return e.charAt(1).toUpperCase()}var S1=Ch([Ih,x1,Fh,Eh,Ah],"html"),Ic=Ch([Ih,y1,Fh,Eh,Ah],"svg");function w1(e){return e.join(" ").trim()}var z1=Va(M1(),1);var Ec=B1("end"),es=B1("start");function B1(e){return t;function t(n){let r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Dh(e){let t=es(e),n=Ec(e);if(t&&n)return{start:t,end:n}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?D1(e.position):"start"in e||"end"in e?D1(e):"line"in e||"column"in e?Rh(e):""}function Rh(e){return R1(e&&e.line)+":"+R1(e&&e.column)}function D1(e){return Rh(e&&e.start)+"-"+Rh(e&&e.end)}function R1(e){return e&&typeof e=="number"?e:1}var Gt=class extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},s=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(s=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){let u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){let u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}let a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=a?a.line:void 0,this.name=Oo(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=s&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;var zh={}.hasOwnProperty,pU=new Map,dU=/[A-Z]/g,gU=new Set(["table","tbody","thead","tfoot","tr"]),fU=new Set(["td","th"]),N1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Nh(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=vU(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=wU(n,t.jsx,t.jsxs)}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ic:S1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=O1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function O1(e,t,n){if(t.type==="element")return mU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return hU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return yU(e,t,n);if(t.type==="mdxjsEsm")return xU(e,t);if(t.type==="root")return bU(e,t,n);if(t.type==="text")return SU(e,t)}function mU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=Ic,e.schema=o),e.ancestors.push(t);let i=$1(e,t.tagName,!1),s=kU(e,t),a=_h(e,t);return gU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!kh(u):!0})),_1(e,s,i,t),Oh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function hU(e,t){if(t.data&&t.data.estree&&e.evaluater){let r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ha(e,t.position)}function xU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ha(e,t.position)}function yU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=Ic,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:$1(e,t.name,!0),s=CU(e,t),a=_h(e,t);return _1(e,s,i,t),Oh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function bU(e,t,n){let r={};return Oh(r,_h(e,t)),e.create(t,e.Fragment,r,n)}function SU(e,t){return t.value}function _1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Oh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function wU(e,t,n){return r;function r(o,i,s,a){let c=Array.isArray(s.children)?n:t;return a?c(i,s,a):c(i,s)}}function vU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=es(r);return t(o,i,s,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function kU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&zh.call(t.properties,o)){let i=TU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&fU.has(t.tagName)?r=a:n[s]=a}}if(r){let i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function CU(e,t){let n={};for(let r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){let i=r.data.estree.body[0];i.type;let s=i.expression;s.type;let a=s.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ha(e,t.position);else{let o=r.name,i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){let a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else ha(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function _h(e,t){let n=[],r=-1,o=e.passKeys?new Map:pU;for(;++r<t.children.length;){let i=t.children[r],s;if(e.passKeys){let u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){let c=o.get(u)||0;s=u+"-"+c,o.set(u,c+1)}}let a=O1(e,i,s);a!==void 0&&n.push(a)}return n}function TU(e,t,n){let r=Lh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?f1(n):w1(n)),r.property==="style"){let o=typeof n=="object"?n:IU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=FU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Ph[r.property]||r.property:r.attribute,n]}}function IU(e,t){try{return(0,z1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Gt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=N1+"#cannot-parse-style-attribute",o}}function $1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){let o=t.split("."),i=-1,s;for(;++i<o.length;){let a=vc(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};s=s?{type:"MemberExpression",object:s,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}r=s}else r=vc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return zh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ha(e)}function ha(e,t){let n=new Gt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=N1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function FU(e){let t={},n;for(n in e)zh.call(e,n)&&(t[EU(n)]=e[n]);return t}function EU(e){let t=e.replace(dU,AU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function AU(e){return"-"+e.toLowerCase()}var xa={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};import{Fragment as N6,jsx as O6,jsxs as _6}from"react/jsx-runtime";import{useEffect as Jde,useState as Zde}from"react";var PU={};function $h(e,t){let n=t||PU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return j1(e,r,o)}function j1(e,t,n){if(LU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return U1(e.children,t,n)}return Array.isArray(e)?U1(e,t,n):""}function U1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=j1(e[o],t,n);return r.join("")}function LU(e){return!!(e&&typeof e=="object")}var H1=document.createElement("i");function ts(e){let t="&"+e+";";H1.innerHTML=t;let n=H1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function hn(e,t,n,r){let o=e.length,i=0,s;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function Ln(e,t){return e.length>0?(hn(e,e.length,0,t),e):t}var W1={}.hasOwnProperty;function V1(e){let t={},n=-1;for(;++n<e.length;)MU(t,e[n]);return t}function MU(e,t){let n;for(n in t){let o=(W1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){W1.call(o,s)||(o[s]=[]);let a=i[s];BU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function BU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);hn(e,0,0,r)}function Ac(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function po(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var ir=_o(/[A-Za-z]/),dn=_o(/[\dA-Za-z]/),G1=_o(/[#-'*+\--9=?A-Z^-~]/);function ya(e){return e!==null&&(e<32||e===127)}var ba=_o(/\d/),q1=_o(/[\dA-Fa-f]/),Y1=_o(/[!-/:-@[-`{-~]/);function de(e){return e!==null&&e<-2}function qt(e){return e!==null&&(e<0||e===32)}function We(e){return e===-2||e===-1||e===32}var K1=_o(/\p{P}|\p{S}/u),X1=_o(/\s/);function _o(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function yr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&dn(e.charCodeAt(n+1))&&dn(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(s=String.fromCharCode(i));else if(i>55295&&i<57344){let a=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(s=String.fromCharCode(i,a),o=1):s="\uFFFD"}else s=String.fromCharCode(i);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+o+1,s=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return We(u)?(e.enter(n),a(u)):t(u)}function a(u){return We(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var Q1={tokenize:DU};function DU(e){let t=e.attempt(this.parser.constructs.contentInitial,r,o),n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),i(a)}function i(a){let u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,s(a)}function s(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return de(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var Z1={tokenize:RU},J1={tokenize:zU};function RU(e){let t=this,n=[],r=0,o,i,s;return a;function a(D){if(r<n.length){let R=n[r];return t.containerState=R[1],e.attempt(R[0].continuation,u,c)(D)}return c(D)}function u(D){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&C();let R=t.events.length,_=R,P;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){P=t.events[_][1].end;break}A(r);let N=R;for(;N<t.events.length;)t.events[N][1].end={...P},N++;return hn(t.events,_+1,0,t.events.slice(R)),t.events.length=N,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return m(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(J1,l,d)(D)}function l(D){return o&&C(),A(r),g(D)}function d(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(D)}function g(D){return t.containerState={},e.attempt(J1,p,m)(D)}function p(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function m(D){if(D===null){o&&C(),A(0),e.consume(D);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),v(D)}function v(D){if(D===null){I(e.exit("chunkFlow"),!0),A(0),e.consume(D);return}return de(D)?(e.consume(D),I(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),v)}function I(D,R){let _=t.sliceStream(D);if(R&&_.push(null),D.previous=i,i&&(i.next=D),i=D,o.defineSkip(D.start),o.write(_),t.parser.lazy[D.start.line]){let P=o.events.length;for(;P--;)if(o.events[P][1].start.offset<s&&(!o.events[P][1].end||o.events[P][1].end.offset>s))return;let N=t.events.length,x=N,k,w;for(;x--;)if(t.events[x][0]==="exit"&&t.events[x][1].type==="chunkFlow"){if(k){w=t.events[x][1].end;break}k=!0}for(A(r),P=N;P<t.events.length;)t.events[P][1].end={...w},P++;hn(t.events,x+1,0,t.events.slice(N)),t.events.length=P}}function A(D){let R=n.length;for(;R-- >D;){let _=n[R];t.containerState=_[1],_[0].exit.call(t,e)}n.length=D}function C(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function zU(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Uh(e){if(e===null||qt(e)||X1(e))return 1;if(K1(e))return 2}function ns(e,t,n){let r=[],o=-1;for(;++o<e.length;){let i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}var Sa={name:"attention",resolveAll:NU,tokenize:OU};function NU(e,t){let n=-1,r,o,i,s,a,u,c,l;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},g={...e[n][1].start};eT(d,-u),eT(g,u),s={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[r][1].end={...s.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Ln(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Ln(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Ln(c,ns(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ln(c,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(l=2,c=Ln(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,hn(e,r-1,n-r+3,c),n=r+c.length-l-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function OU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Uh(r),i;return s;function s(u){return i=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===i)return e.consume(u),a;let c=e.exit("attentionSequence"),l=Uh(u),d=!l||l===2&&o||n.includes(u),g=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!g)),c._close=!!(i===42?g:g&&(l||!d)),t(u)}}function eT(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var jh={name:"autolink",tokenize:_U};function _U(e,t,n){let r=0;return o;function o(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return ir(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||dn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,u):(p===43||p===45||p===46||dn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function u(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ya(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):G1(p)?(e.consume(p),c):n(p)}function l(p){return dn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,l):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):g(p)}function g(p){if((p===45||dn(p))&&r++<63){let m=p===45?g:d;return e.consume(p),m}return n(p)}}var $o={partial:!0,tokenize:$U};function $U(e,t,n){return r;function r(i){return We(i)?qe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||de(i)?t(i):n(i)}}var Pc={continuation:{tokenize:jU},exit:HU,name:"blockQuote",tokenize:UU};function UU(e,t,n){let r=this;return o;function o(s){if(s===62){let a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),i}return n(s)}function i(s){return We(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function jU(e,t,n){let r=this;return o;function o(s){return We(s)?qe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(Pc,t,n)(s)}}function HU(e){e.exit("blockQuote")}var Lc={name:"characterEscape",tokenize:WU};function WU(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return Y1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Mc={name:"characterReference",tokenize:VU};function VU(e,t,n){let r=this,o=0,i,s;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),u}function u(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=dn,l(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=q1,l):(e.enter("characterReferenceValue"),i=7,s=ba,l(d))}function l(d){if(d===59&&o){let g=e.exit("characterReferenceValue");return s===dn&&!ts(r.sliceSerialize(g))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(d)&&o++<i?(e.consume(d),l):n(d)}}var tT={partial:!0,tokenize:qU},Bc={concrete:!0,name:"codeFenced",tokenize:GU};function GU(e,t,n){let r=this,o={partial:!0,tokenize:_},i=0,s=0,a;return u;function u(P){return c(P)}function c(P){let N=r.events[r.events.length-1];return i=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(P)}function l(P){return P===a?(s++,e.consume(P),l):s<3?n(P):(e.exit("codeFencedFenceSequence"),We(P)?qe(e,d,"whitespace")(P):d(P))}function d(P){return P===null||de(P)?(e.exit("codeFencedFence"),r.interrupt?t(P):e.check(tT,v,R)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(P))}function g(P){return P===null||de(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(P)):We(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,p,"whitespace")(P)):P===96&&P===a?n(P):(e.consume(P),g)}function p(P){return P===null||de(P)?d(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(P))}function m(P){return P===null||de(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(P)):P===96&&P===a?n(P):(e.consume(P),m)}function v(P){return e.attempt(o,R,I)(P)}function I(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),A}function A(P){return i>0&&We(P)?qe(e,C,"linePrefix",i+1)(P):C(P)}function C(P){return P===null||de(P)?e.check(tT,v,R)(P):(e.enter("codeFlowValue"),D(P))}function D(P){return P===null||de(P)?(e.exit("codeFlowValue"),C(P)):(e.consume(P),D)}function R(P){return e.exit("codeFenced"),t(P)}function _(P,N,x){let k=0;return w;function w(y){return P.enter("lineEnding"),P.consume(y),P.exit("lineEnding"),E}function E(y){return P.enter("codeFencedFence"),We(y)?qe(P,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):f(y)}function f(y){return y===a?(P.enter("codeFencedFenceSequence"),T(y)):x(y)}function T(y){return y===a?(k++,P.consume(y),T):k>=s?(P.exit("codeFencedFenceSequence"),We(y)?qe(P,S,"whitespace")(y):S(y)):x(y)}function S(y){return y===null||de(y)?(P.exit("codeFencedFence"),N(y)):x(y)}}}function qU(e,t,n){let r=this;return o;function o(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}var wa={name:"codeIndented",tokenize:KU},YU={partial:!0,tokenize:XU};function KU(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),qe(e,i,"linePrefix",5)(c)}function i(c){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?u(c):de(c)?e.attempt(YU,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||de(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function XU(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):de(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):qe(e,i,"linePrefix",5)(s)}function i(s){let a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):de(s)?o(s):n(s)}}var Hh={name:"codeText",previous:JU,resolve:QU,tokenize:ZU};function QU(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function JU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ZU(e,t,n){let r=this,o=0,i,s;return a;function a(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),o++,u):(e.exit("codeTextSequence"),c(g))}function c(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),c):g===96?(s=e.enter("codeTextSequence"),i=0,d(g)):de(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(g))}function l(g){return g===null||g===32||g===96||de(g)?(e.exit("codeTextData"),c(g)):(e.consume(g),l)}function d(g){return g===96?(e.consume(g),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(s.type="codeTextData",l(g))}}var Dc=class{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){let r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){let o=n||0;this.setCursor(Math.trunc(t));let i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&va(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),va(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),va(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){let n=this.left.splice(t,Number.POSITIVE_INFINITY);va(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);va(this.left,n.reverse())}}};function va(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Rc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Dc(e);for(;++n<l.length;){for(;n in t;)n=t[n];if(r=l.get(n),n&&r[1].type==="chunkFlow"&&l.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,e5(l,n)),n=t[n],c=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(s=l.get(i),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(l.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=i);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;o&&(r[1].end={...l.get(o)[1].start},a=l.slice(o,n),a.unshift(r),l.splice(o,n-o+1,a))}}return hn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function e5(e,t){let n=e.get(t)[1],r=e.get(t)[2],o=t-1,i=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let a=s.events,u=[],c={},l,d,g=-1,p=n,m=0,v=0,I=[v];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(l=r.sliceStream(p),p.next||l.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++g<a.length;)a[g][0]==="exit"&&a[g-1][0]==="enter"&&a[g][1].type===a[g-1][1].type&&a[g][1].start.line!==a[g][1].end.line&&(v=g+1,I.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):I.pop(),g=I.length;g--;){let A=a.slice(I[g],I[g+1]),C=i.pop();u.push([C,C+A.length-1]),e.splice(C,2,A)}for(u.reverse(),g=-1;++g<u.length;)c[m+u[g][0]]=m+u[g][1],m+=u[g][1]-u[g][0]-1;return c}var Wh={resolve:n5,tokenize:r5},t5={partial:!0,tokenize:o5};function n5(e){return Rc(e),e}function r5(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(a)}function o(a){return a===null?i(a):de(a)?e.check(t5,s,i)(a):(e.consume(a),o)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function s(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function o5(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),qe(e,i,"linePrefix")}function i(s){if(s===null||de(s))return n(s);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function zc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return d;function d(A){return A===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(A),e.exit(i),g):A===null||A===32||A===41||ya(A)?n(A):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(A))}function g(A){return A===62?(e.enter(i),e.consume(A),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(A))}function p(A){return A===62?(e.exit("chunkString"),e.exit(a),g(A)):A===null||A===60||de(A)?n(A):(e.consume(A),A===92?m:p)}function m(A){return A===60||A===62||A===92?(e.consume(A),p):p(A)}function v(A){return!l&&(A===null||A===41||qt(A))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(A)):l<c&&A===40?(e.consume(A),l++,v):A===41?(e.consume(A),l--,v):A===null||A===32||A===40||ya(A)?n(A):(e.consume(A),A===92?I:v)}function I(A){return A===40||A===41||A===92?(e.consume(A),v):v(A)}}function Nc(e,t,n,r,o,i){let s=this,a=0,u;return c;function c(p){return e.enter(r),e.enter(o),e.consume(p),e.exit(o),e.enter(i),l}function l(p){return a>999||p===null||p===91||p===93&&!u||p===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(p):p===93?(e.exit(i),e.enter(o),e.consume(p),e.exit(o),e.exit(r),t):de(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||de(p)||a++>999?(e.exit("chunkString"),l(p)):(e.consume(p),u||(u=!We(p)),p===92?g:d)}function g(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Oc(e,t,n,r,o,i){let s;return a;function a(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),s=g===40?41:g,u):n(g)}function u(g){return g===s?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),c(g))}function c(g){return g===s?(e.exit(i),u(s)):g===null?n(g):de(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(g))}function l(g){return g===s||g===null||de(g)?(e.exit("chunkString"),c(g)):(e.consume(g),g===92?d:l)}function d(g){return g===s||g===92?(e.consume(g),l):l(g)}}function ci(e,t){let n;return r;function r(o){return de(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):We(o)?qe(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Vh={name:"definition",tokenize:s5},i5={partial:!0,tokenize:a5};function s5(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return Nc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=po(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):n(p)}function u(p){return qt(p)?ci(e,c)(p):c(p)}function c(p){return zc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(i5,d,d)(p)}function d(p){return We(p)?qe(e,g,"whitespace")(p):g(p)}function g(p){return p===null||de(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function a5(e,t,n){return r;function r(a){return qt(a)?ci(e,o)(a):n(a)}function o(a){return Oc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return We(a)?qe(e,s,"whitespace")(a):s(a)}function s(a){return a===null||de(a)?t(a):n(a)}}var Gh={name:"hardBreakEscape",tokenize:l5};function l5(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return de(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var qh={name:"headingAtx",resolve:c5,tokenize:u5};function c5(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},hn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function u5(e,t,n){let r=0;return o;function o(l){return e.enter("atxHeading"),i(l)}function i(l){return e.enter("atxHeadingSequence"),s(l)}function s(l){return l===35&&r++<6?(e.consume(l),s):l===null||qt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||de(l)?(e.exit("atxHeading"),t(l)):We(l)?qe(e,a,"whitespace")(l):(e.enter("atxHeadingText"),c(l))}function u(l){return l===35?(e.consume(l),u):(e.exit("atxHeadingSequence"),a(l))}function c(l){return l===null||l===35||qt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var nT=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Yh=["pre","script","style","textarea"];var Kh={concrete:!0,name:"htmlFlow",resolveTo:g5,tokenize:f5},p5={partial:!0,tokenize:h5},d5={partial:!0,tokenize:m5};function g5(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function f5(e,t,n){let r=this,o,i,s,a,u;return c;function c(B){return l(B)}function l(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),d}function d(B){return B===33?(e.consume(B),g):B===47?(e.consume(B),i=!0,v):B===63?(e.consume(B),o=3,r.interrupt?t:h):ir(B)?(e.consume(B),s=String.fromCharCode(B),I):n(B)}function g(B){return B===45?(e.consume(B),o=2,p):B===91?(e.consume(B),o=5,a=0,m):ir(B)?(e.consume(B),o=4,r.interrupt?t:h):n(B)}function p(B){return B===45?(e.consume(B),r.interrupt?t:h):n(B)}function m(B){let G="CDATA[";return B===G.charCodeAt(a++)?(e.consume(B),a===G.length?r.interrupt?t:f:m):n(B)}function v(B){return ir(B)?(e.consume(B),s=String.fromCharCode(B),I):n(B)}function I(B){if(B===null||B===47||B===62||qt(B)){let G=B===47,te=s.toLowerCase();return!G&&!i&&Yh.includes(te)?(o=1,r.interrupt?t(B):f(B)):nT.includes(s.toLowerCase())?(o=6,G?(e.consume(B),A):r.interrupt?t(B):f(B)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?C(B):D(B))}return B===45||dn(B)?(e.consume(B),s+=String.fromCharCode(B),I):n(B)}function A(B){return B===62?(e.consume(B),r.interrupt?t:f):n(B)}function C(B){return We(B)?(e.consume(B),C):w(B)}function D(B){return B===47?(e.consume(B),w):B===58||B===95||ir(B)?(e.consume(B),R):We(B)?(e.consume(B),D):w(B)}function R(B){return B===45||B===46||B===58||B===95||dn(B)?(e.consume(B),R):_(B)}function _(B){return B===61?(e.consume(B),P):We(B)?(e.consume(B),_):D(B)}function P(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),u=B,N):We(B)?(e.consume(B),P):x(B)}function N(B){return B===u?(e.consume(B),u=null,k):B===null||de(B)?n(B):(e.consume(B),N)}function x(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||qt(B)?_(B):(e.consume(B),x)}function k(B){return B===47||B===62||We(B)?D(B):n(B)}function w(B){return B===62?(e.consume(B),E):n(B)}function E(B){return B===null||de(B)?f(B):We(B)?(e.consume(B),E):n(B)}function f(B){return B===45&&o===2?(e.consume(B),F):B===60&&o===1?(e.consume(B),L):B===62&&o===4?(e.consume(B),j):B===63&&o===3?(e.consume(B),h):B===93&&o===5?(e.consume(B),z):de(B)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(p5,V,T)(B)):B===null||de(B)?(e.exit("htmlFlowData"),T(B)):(e.consume(B),f)}function T(B){return e.check(d5,S,V)(B)}function S(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),y}function y(B){return B===null||de(B)?T(B):(e.enter("htmlFlowData"),f(B))}function F(B){return B===45?(e.consume(B),h):f(B)}function L(B){return B===47?(e.consume(B),s="",M):f(B)}function M(B){if(B===62){let G=s.toLowerCase();return Yh.includes(G)?(e.consume(B),j):f(B)}return ir(B)&&s.length<8?(e.consume(B),s+=String.fromCharCode(B),M):f(B)}function z(B){return B===93?(e.consume(B),h):f(B)}function h(B){return B===62?(e.consume(B),j):B===45&&o===2?(e.consume(B),h):f(B)}function j(B){return B===null||de(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),j)}function V(B){return e.exit("htmlFlow"),t(B)}}function m5(e,t,n){let r=this;return o;function o(s){return de(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):n(s)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function h5(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt($o,t,n)}}var Xh={name:"htmlText",tokenize:x5};function x5(e,t,n){let r=this,o,i,s;return a;function a(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),u}function u(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),_):h===63?(e.consume(h),D):ir(h)?(e.consume(h),x):n(h)}function c(h){return h===45?(e.consume(h),l):h===91?(e.consume(h),i=0,m):ir(h)?(e.consume(h),C):n(h)}function l(h){return h===45?(e.consume(h),p):n(h)}function d(h){return h===null?n(h):h===45?(e.consume(h),g):de(h)?(s=d,L(h)):(e.consume(h),d)}function g(h){return h===45?(e.consume(h),p):d(h)}function p(h){return h===62?F(h):h===45?g(h):d(h)}function m(h){let j="CDATA[";return h===j.charCodeAt(i++)?(e.consume(h),i===j.length?v:m):n(h)}function v(h){return h===null?n(h):h===93?(e.consume(h),I):de(h)?(s=v,L(h)):(e.consume(h),v)}function I(h){return h===93?(e.consume(h),A):v(h)}function A(h){return h===62?F(h):h===93?(e.consume(h),A):v(h)}function C(h){return h===null||h===62?F(h):de(h)?(s=C,L(h)):(e.consume(h),C)}function D(h){return h===null?n(h):h===63?(e.consume(h),R):de(h)?(s=D,L(h)):(e.consume(h),D)}function R(h){return h===62?F(h):D(h)}function _(h){return ir(h)?(e.consume(h),P):n(h)}function P(h){return h===45||dn(h)?(e.consume(h),P):N(h)}function N(h){return de(h)?(s=N,L(h)):We(h)?(e.consume(h),N):F(h)}function x(h){return h===45||dn(h)?(e.consume(h),x):h===47||h===62||qt(h)?k(h):n(h)}function k(h){return h===47?(e.consume(h),F):h===58||h===95||ir(h)?(e.consume(h),w):de(h)?(s=k,L(h)):We(h)?(e.consume(h),k):F(h)}function w(h){return h===45||h===46||h===58||h===95||dn(h)?(e.consume(h),w):E(h)}function E(h){return h===61?(e.consume(h),f):de(h)?(s=E,L(h)):We(h)?(e.consume(h),E):k(h)}function f(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),o=h,T):de(h)?(s=f,L(h)):We(h)?(e.consume(h),f):(e.consume(h),S)}function T(h){return h===o?(e.consume(h),o=void 0,y):h===null?n(h):de(h)?(s=T,L(h)):(e.consume(h),T)}function S(h){return h===null||h===34||h===39||h===60||h===61||h===96?n(h):h===47||h===62||qt(h)?k(h):(e.consume(h),S)}function y(h){return h===47||h===62||qt(h)?k(h):n(h)}function F(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),t):n(h)}function L(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),M}function M(h){return We(h)?qe(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):z(h)}function z(h){return e.enter("htmlTextData"),s(h)}}var ui={name:"labelEnd",resolveAll:w5,resolveTo:v5,tokenize:k5},y5={tokenize:C5},b5={tokenize:T5},S5={tokenize:I5};function w5(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&hn(e,0,e.length,n),e}function v5(e,t){let n=e.length,r=0,o,i,s,a;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(s=n);let u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[i][1].start},end:{...e[s][1].end}},l={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[s-2][1].start}};return a=[["enter",u,t],["enter",c,t]],a=Ln(a,e.slice(i+1,i+r+3)),a=Ln(a,[["enter",l,t]]),a=Ln(a,ns(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Ln(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Ln(a,e.slice(s+1)),a=Ln(a,[["exit",u,t]]),hn(e,i,e.length,a),e}function k5(e,t,n){let r=this,o=r.events.length,i,s;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return a;function a(g){return i?i._inactive?d(g):(s=r.parser.defined.includes(po(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(y5,l,s?l:d)(g):g===91?e.attempt(b5,l,s?c:d)(g):s?l(g):d(g)}function c(g){return e.attempt(S5,l,d)(g)}function l(g){return t(g)}function d(g){return i._balanced=!0,n(g)}}function C5(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),o}function o(d){return qt(d)?ci(e,i)(d):i(d)}function i(d){return d===41?l(d):zc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return qt(d)?ci(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?Oc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return qt(d)?ci(e,l)(d):l(d)}function l(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function T5(e,t,n){let r=this;return o;function o(a){return Nc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(po(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function I5(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}var Qh={name:"labelStartImage",resolveAll:ui.resolveAll,tokenize:F5};function F5(e,t,n){let r=this;return o;function o(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),s):n(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}var Jh={name:"labelStartLink",resolveAll:ui.resolveAll,tokenize:E5};function E5(e,t,n){let r=this;return o;function o(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),i}function i(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}var ka={name:"lineEnding",tokenize:A5};function A5(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}var pi={name:"thematicBreak",tokenize:P5};function P5(e,t,n){let r=0,o;return i;function i(c){return e.enter("thematicBreak"),s(c)}function s(c){return o=c,a(c)}function a(c){return c===o?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||de(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),We(c)?qe(e,a,"whitespace")(c):a(c))}}var kn={continuation:{tokenize:D5},exit:z5,name:"list",tokenize:B5},L5={partial:!0,tokenize:N5},M5={partial:!0,tokenize:R5};function B5(e,t,n){let r=this,o=r.events[r.events.length-1],i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,s=0;return a;function a(p){let m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ba(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(pi,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return n(p)}function u(p){return ba(p)&&++s<10?(e.consume(p),u):(!r.interrupt||s<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check($o,r.interrupt?n:l,e.attempt(L5,g,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,g(p)}function d(p){return We(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),g):n(p)}function g(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function D5(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($o,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!We(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(M5,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(kn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function R5(e,t,n){let r=this;return qe(e,o,"listItemIndent",r.containerState.size+1);function o(i){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(i):n(i)}}function z5(e){e.exit(this.containerState.type)}function N5(e,t,n){let r=this;return qe(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let s=r.events[r.events.length-1];return!We(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var _c={name:"setextUnderline",resolveTo:O5,tokenize:_5};function O5(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);let s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",s,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=s,e.push(["exit",s,t]),e}function _5(e,t,n){let r=this,o;return i;function i(c){let l=r.events.length,d;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){d=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),o=c,s(c)):n(c)}function s(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===o?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),We(c)?qe(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||de(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var rT={tokenize:$5};function $5(e){let t=this,n=e.attempt($o,r,e.attempt(this.parser.constructs.flowInitial,o,qe(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Wh,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}var oT={resolveAll:lT()},iT=aT("string"),sT=aT("text");function aT(e){return{resolveAll:lT(e==="text"?U5:void 0),tokenize:t};function t(n){let r=this,o=this.parser.constructs[e],i=n.attempt(o,s,a);return s;function s(l){return c(l)?i(l):a(l)}function a(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),u}function u(l){return c(l)?(n.exit("data"),i(l)):(n.consume(l),u)}function c(l){if(l===null)return!0;let d=o[l],g=-1;if(d)for(;++g<d.length;){let p=d[g];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function lT(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function U5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],o=t.sliceStream(r),i=o.length,s=-1,a=0,u;for(;i--;){let c=o[i];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)u=!0,a++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){let c={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:r.start._bufferIndex+s,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}var Zh={};Se(Zh,{attentionMarkers:()=>K5,contentInitial:()=>H5,disable:()=>X5,document:()=>j5,flow:()=>V5,flowInitial:()=>W5,insideSpan:()=>Y5,string:()=>G5,text:()=>q5});var j5={42:kn,43:kn,45:kn,48:kn,49:kn,50:kn,51:kn,52:kn,53:kn,54:kn,55:kn,56:kn,57:kn,62:Pc},H5={91:Vh},W5={[-2]:wa,[-1]:wa,32:wa},V5={35:qh,42:pi,45:[_c,pi],60:Kh,61:_c,95:pi,96:Bc,126:Bc},G5={38:Mc,92:Lc},q5={[-5]:ka,[-4]:ka,[-3]:ka,33:Qh,38:Mc,42:Sa,60:[jh,Xh],91:Jh,92:[Gh,Lc],93:ui,95:Sa,96:Hh},Y5={null:[Sa,oT]},K5={null:[42,95]},X5={null:[]};function cT(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},o={},i=[],s=[],a=[],u=!0,c={attempt:k(N),check:k(x),consume:R,enter:_,exit:P,interrupt:k(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:A,events:[],now:I,parser:e,previous:null,sliceSerialize:m,sliceStream:v,write:p},d=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function p(T){return s=Ln(s,T),C(),s[s.length-1]!==null?[]:(w(t,0),l.events=ns(i,l.events,l),l.events)}function m(T,S){return J5(v(T),S)}function v(T){return Q5(s,T)}function I(){let{_bufferIndex:T,_index:S,line:y,column:F,offset:L}=r;return{_bufferIndex:T,_index:S,line:y,column:F,offset:L}}function A(T){o[T.line]=T.column,f()}function C(){let T;for(;r._index<s.length;){let S=s[r._index];if(typeof S=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<S.length;)D(S.charCodeAt(r._bufferIndex));else D(S)}}function D(T){u=void 0,g=T,d=d(T)}function R(T){de(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,f()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T,u=!0}function _(T,S){let y=S||{};return y.type=T,y.start=I(),l.events.push(["enter",y,l]),a.push(y),y}function P(T){let S=a.pop();return S.end=I(),l.events.push(["exit",S,l]),S}function N(T,S){w(T,S.from)}function x(T,S){S.restore()}function k(T,S){return y;function y(F,L,M){let z,h,j,V;return Array.isArray(F)?G(F):"tokenize"in F?G([F]):B(F);function B(ie){return Ke;function Ke(be){let Ie=be!==null&&ie[be],ve=be!==null&&ie.null,ue=[...Array.isArray(Ie)?Ie:Ie?[Ie]:[],...Array.isArray(ve)?ve:ve?[ve]:[]];return G(ue)(be)}}function G(ie){return z=ie,h=0,ie.length===0?M:te(ie[h])}function te(ie){return Ke;function Ke(be){return V=E(),j=ie,ie.partial||(l.currentConstruct=ie),ie.name&&l.parser.constructs.disable.null.includes(ie.name)?xe(be):ie.tokenize.call(S?Object.assign(Object.create(l),S):l,c,le,xe)(be)}}function le(ie){return u=!0,T(j,V),L}function xe(ie){return u=!0,V.restore(),++h<z.length?te(z[h]):M}}}function w(T,S){T.resolveAll&&!i.includes(T)&&i.push(T),T.resolve&&hn(l.events,S,l.events.length-S,T.resolve(l.events.slice(S),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function E(){let T=I(),S=l.previous,y=l.currentConstruct,F=l.events.length,L=Array.from(a);return{from:F,restore:M};function M(){r=T,l.previous=S,l.currentConstruct=y,l.events.length=F,a=L,f()}}function f(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function Q5(e,t){let n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex,s;if(n===o)s=[e[n].slice(r,i)];else{if(s=e.slice(n,o),r>-1){let a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}function J5(e,t){let n=-1,r=[],o;for(;++n<e.length;){let i=e[n],s;if(typeof i=="string")s=i;else switch(i){case-5:{s="\r";break}case-4:{s=`
82
82
  `;break}case-3:{s=`\r
83
- `;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&o)continue;s=" ";break}default:s=String.fromCharCode(i)}o=i===-2,r.push(s)}return r.join("")}function ex(e){let r={constructs:W1([Zh,...(e||{}).extensions||[]]),content:o(X1),defined:[],document:o(J1),flow:o(nT),lazy:{},string:o(oT),text:o(iT)};return r;function o(i){return s;function s(a){return lT(r,i,a)}}}function tx(e){for(;!Rc(e););return e}var cT=/[\0\t\n\r]/g;function nx(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,g,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(cT.lastIndex=d,c=cT.exec(i),g=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(g),!c){t=i.slice(d);break}if(p===10&&d===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<g&&(u.push(i.slice(d,g)),e+=g-d),p){case 0:{u.push(65533),e++;break}case 9:{for(l=Math.ceil(e/4)*4,u.push(-2);e++<l;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}d=g+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var ZU=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uT(e){return e.replace(ZU,e6)}function e6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Ac(n.slice(i?2:1),i?16:10)}return ts(n)||e}var dT={}.hasOwnProperty;function rx(e,t,n){return typeof t!="string"&&(n=t,t=void 0),t6(n)(tx(ex(n).document().write(nx()(e,t,!0))))}function t6(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(fe),autolinkProtocol:v,autolinkEmail:v,atxHeading:i(pe),blockQuote:i(be),characterEscape:v,characterReference:v,codeFenced:i(Ie),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Ie,s),codeText:i(ve,s),codeTextData:v,data:v,codeFlowValue:v,definition:i(ue),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i($e),hardBreakEscape:i(yt),hardBreakTrailing:i(yt),htmlFlow:i($t,s),htmlFlowData:v,htmlText:i($t,s),htmlTextData:v,image:i(yn),label:s,link:i(fe),listItem:i(he),listItemValue:g,listOrdered:i(tt,d),listUnordered:i(tt),paragraph:i(re),reference:B,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(pe),strong:i(K),thematicBreak:i(oe)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:Ke,autolinkProtocol:ie,blockQuote:u(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:le,characterReference:xe,codeFenced:u(I),codeFencedFence:k,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:u(A),codeText:u(y),codeTextData:w,data:w,definition:u(),definitionDestinationString:R,definitionLabelString:C,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(f),hardBreakTrailing:u(f),htmlFlow:u(T),htmlFlowData:w,htmlText:u(S),htmlTextData:w,image:u(L),label:z,labelText:M,lineEnding:E,link:u(F),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:G,resourceDestinationString:h,resourceTitleString:j,resource:V,setextHeading:u(x),setextHeadingLineSequence:N,setextHeadingText:P,strong:u(),thematicBreak:u()}};gT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let U={type:"root",children:[]},H={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Ae=[],Be=-1;for(;++Be<O.length;)if(O[Be][1].type==="listOrdered"||O[Be][1].type==="listUnordered")if(O[Be][0]==="enter")Ae.push(Be);else{let vt=Ae.pop();Be=o(O,vt,Be)}for(Be=-1;++Be<O.length;){let vt=t[O[Be][0]];dT.call(vt,O[Be][1].type)&&vt[O[Be][1].type].call(Object.assign({sliceSerialize:O[Be][2].sliceSerialize},H),O[Be][1])}if(H.tokenStack.length>0){let vt=H.tokenStack[H.tokenStack.length-1];(vt[1]||pT).call(H,void 0,vt[0])}for(U.position={start:Uo(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Uo(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},Be=-1;++Be<t.transforms.length;)U=t.transforms[Be](U)||U;return U}function o(O,U,H){let Ae=U-1,Be=-1,vt=!1,Xn,sr,Mn,ho;for(;++Ae<=H;){let Tn=O[Ae];switch(Tn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Tn[0]==="enter"?Be++:Be--,ho=void 0;break}case"lineEndingBlank":{Tn[0]==="enter"&&(Xn&&!ho&&!Be&&!Mn&&(Mn=Ae),ho=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ho=void 0}if(!Be&&Tn[0]==="enter"&&Tn[1].type==="listItemPrefix"||Be===-1&&Tn[0]==="exit"&&(Tn[1].type==="listUnordered"||Tn[1].type==="listOrdered")){if(Xn){let Rr=Ae;for(sr=void 0;Rr--;){let rn=O[Rr];if(rn[1].type==="lineEnding"||rn[1].type==="lineEndingBlank"){if(rn[0]==="exit")continue;sr&&(O[sr][1].type="lineEndingBlank",vt=!0),rn[1].type="lineEnding",sr=Rr}else if(!(rn[1].type==="linePrefix"||rn[1].type==="blockQuotePrefix"||rn[1].type==="blockQuotePrefixWhitespace"||rn[1].type==="blockQuoteMarker"||rn[1].type==="listItemIndent"))break}Mn&&(!sr||Mn<sr)&&(Xn._spread=!0),Xn.end=Object.assign({},sr?O[sr][1].start:Tn[1].end),O.splice(sr||Ae,0,["exit",Xn,Tn[2]]),Ae++,H++}if(Tn[1].type==="listItemPrefix"){let Rr={type:"listItem",_spread:!1,start:Object.assign({},Tn[1].start),end:void 0};Xn=Rr,O.splice(Ae,0,["enter",Rr,Tn[2]]),Ae++,H++,Mn=void 0,ho=!0}}}return O[U][1]._spread=vt,H}function i(O,U){return H;function H(Ae){a.call(this,O(Ae),Ae),U&&U.call(this,Ae)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,U,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([U,H||void 0]),O.position={start:Uo(U.start),end:void 0}}function u(O){return U;function U(H){O&&O.call(this,H),c.call(this,H)}}function c(O,U){let H=this.stack.pop(),Ae=this.tokenStack.pop();if(Ae)Ae[0].type!==O.type&&(U?U.call(this,O,Ae[0]):(Ae[1]||pT).call(this,O,Ae[0]));else throw new Error("Cannot close `"+O.type+"` ("+Oo({start:O.start,end:O.end})+"): it\u2019s not open");H.position.end=Uo(O.end)}function l(){return $h(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),U=this.stack[this.stack.length-1];U.lang=O}function m(){let O=this.resume(),U=this.stack[this.stack.length-1];U.meta=O}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function I(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/(\r?\n|\r)$/g,"")}function C(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=po(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function R(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function _(O){let U=this.stack[this.stack.length-1];if(!U.depth){let H=this.sliceSerialize(O).length;U.depth=H}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function N(O){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function x(){this.data.setextHeadingSlurpLineEnding=void 0}function v(O){let H=this.stack[this.stack.length-1].children,Ae=H[H.length-1];(!Ae||Ae.type!=="text")&&(Ae=me(),Ae.position={start:Uo(O.start),end:void 0},H.push(Ae)),this.stack.push(Ae)}function w(O){let U=this.stack.pop();U.value+=this.sliceSerialize(O),U.position.end=Uo(O.end)}function E(O){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=U.children[U.children.length-1];H.position.end=Uo(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(v.call(this,O),w.call(this,O))}function f(){this.data.atHardBreak=!0}function T(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function S(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function y(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function F(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function L(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function M(O){let U=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=uT(U),H.identifier=po(U).toLowerCase()}function z(){let O=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Ae=O.children;H.children=Ae}else H.alt=U}function h(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function j(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function V(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function G(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=po(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function te(O){this.data.characterReferenceType=O.type}function le(O){let U=this.sliceSerialize(O),H=this.data.characterReferenceType,Ae;H?(Ae=Ac(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ae=ts(U);let Be=this.stack[this.stack.length-1];Be.value+=Ae}function xe(O){let U=this.stack.pop();U.position.end=Uo(O.end)}function ie(O){w.call(this,O);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(O)}function Ke(O){w.call(this,O);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(O)}function be(){return{type:"blockquote",children:[]}}function Ie(){return{type:"code",lang:null,meta:null,value:""}}function ve(){return{type:"inlineCode",value:""}}function ue(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $e(){return{type:"emphasis",children:[]}}function pe(){return{type:"heading",depth:0,children:[]}}function yt(){return{type:"break"}}function $t(){return{type:"html",value:""}}function yn(){return{type:"image",title:null,url:"",alt:null}}function fe(){return{type:"link",title:null,url:"",children:[]}}function tt(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function he(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function K(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}function Uo(e){return{line:e.line,column:e.column,offset:e.offset}}function gT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?gT(e,r):n6(e,r)}}function n6(e,t){let n;for(n in t)if(dT.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r);break}}}function pT(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Oo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Oo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Oo({start:t.start,end:t.end})+") is still open")}function $c(e){let t=this;t.parser=n;function n(r){return rx(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function fT(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function mT(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
- `}]}function hT(e,t){let n=t.value?t.value+`
85
- `:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function xT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bT(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=yr(r.toLowerCase()),i=e.footnoteOrder.indexOf(r),s,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=i+1,a+=1,e.footnoteCounts.set(r,a);let u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,u);let c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,c),e.applyData(t,c)}function ST(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wT(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Uc(e,t){let n=t.referenceType,r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];let o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});let s=o[o.length-1];return s&&s.type==="text"?s.value+=r:o.push({type:"text",value:r}),o}function vT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uc(e,t);let o={src:yr(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)}function kT(e,t){let n={src:yr(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function CT(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function TT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uc(e,t);let o={href:yr(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function IT(e,t){let n={href:yr(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function FT(e,t,n){let r=e.all(t),o=n?r6(n):ET(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],d;l&&l.type==="element"&&l.tagName==="p"?d=l:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let l=r[a];(o||a!==0||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:`
83
+ `;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&o)continue;s=" ";break}default:s=String.fromCharCode(i)}o=i===-2,r.push(s)}return r.join("")}function ex(e){let r={constructs:V1([Zh,...(e||{}).extensions||[]]),content:o(Q1),defined:[],document:o(Z1),flow:o(rT),lazy:{},string:o(iT),text:o(sT)};return r;function o(i){return s;function s(a){return cT(r,i,a)}}}function tx(e){for(;!Rc(e););return e}var uT=/[\0\t\n\r]/g;function nx(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,g,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(uT.lastIndex=d,c=uT.exec(i),g=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(g),!c){t=i.slice(d);break}if(p===10&&d===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<g&&(u.push(i.slice(d,g)),e+=g-d),p){case 0:{u.push(65533),e++;break}case 9:{for(l=Math.ceil(e/4)*4,u.push(-2);e++<l;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}d=g+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var Z5=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function pT(e){return e.replace(Z5,e6)}function e6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Ac(n.slice(i?2:1),i?16:10)}return ts(n)||e}var gT={}.hasOwnProperty;function rx(e,t,n){return typeof t!="string"&&(n=t,t=void 0),t6(n)(tx(ex(n).document().write(nx()(e,t,!0))))}function t6(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(fe),autolinkProtocol:k,autolinkEmail:k,atxHeading:i(pe),blockQuote:i(be),characterEscape:k,characterReference:k,codeFenced:i(Ie),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Ie,s),codeText:i(ve,s),codeTextData:k,data:k,codeFlowValue:k,definition:i(ue),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i($e),hardBreakEscape:i(yt),hardBreakTrailing:i(yt),htmlFlow:i($t,s),htmlFlowData:k,htmlText:i($t,s),htmlTextData:k,image:i(yn),label:s,link:i(fe),listItem:i(he),listItemValue:g,listOrdered:i(tt,d),listUnordered:i(tt),paragraph:i(re),reference:B,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(pe),strong:i(K),thematicBreak:i(oe)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:Ke,autolinkProtocol:ie,blockQuote:u(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:le,characterReference:xe,codeFenced:u(I),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:u(A),codeText:u(y),codeTextData:w,data:w,definition:u(),definitionDestinationString:R,definitionLabelString:C,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(f),hardBreakTrailing:u(f),htmlFlow:u(T),htmlFlowData:w,htmlText:u(S),htmlTextData:w,image:u(L),label:z,labelText:M,lineEnding:E,link:u(F),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:G,resourceDestinationString:h,resourceTitleString:j,resource:V,setextHeading:u(x),setextHeadingLineSequence:N,setextHeadingText:P,strong:u(),thematicBreak:u()}};fT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let U={type:"root",children:[]},H={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Ae=[],Be=-1;for(;++Be<O.length;)if(O[Be][1].type==="listOrdered"||O[Be][1].type==="listUnordered")if(O[Be][0]==="enter")Ae.push(Be);else{let vt=Ae.pop();Be=o(O,vt,Be)}for(Be=-1;++Be<O.length;){let vt=t[O[Be][0]];gT.call(vt,O[Be][1].type)&&vt[O[Be][1].type].call(Object.assign({sliceSerialize:O[Be][2].sliceSerialize},H),O[Be][1])}if(H.tokenStack.length>0){let vt=H.tokenStack[H.tokenStack.length-1];(vt[1]||dT).call(H,void 0,vt[0])}for(U.position={start:Uo(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Uo(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},Be=-1;++Be<t.transforms.length;)U=t.transforms[Be](U)||U;return U}function o(O,U,H){let Ae=U-1,Be=-1,vt=!1,Xn,sr,Mn,ho;for(;++Ae<=H;){let Tn=O[Ae];switch(Tn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Tn[0]==="enter"?Be++:Be--,ho=void 0;break}case"lineEndingBlank":{Tn[0]==="enter"&&(Xn&&!ho&&!Be&&!Mn&&(Mn=Ae),ho=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ho=void 0}if(!Be&&Tn[0]==="enter"&&Tn[1].type==="listItemPrefix"||Be===-1&&Tn[0]==="exit"&&(Tn[1].type==="listUnordered"||Tn[1].type==="listOrdered")){if(Xn){let Rr=Ae;for(sr=void 0;Rr--;){let rn=O[Rr];if(rn[1].type==="lineEnding"||rn[1].type==="lineEndingBlank"){if(rn[0]==="exit")continue;sr&&(O[sr][1].type="lineEndingBlank",vt=!0),rn[1].type="lineEnding",sr=Rr}else if(!(rn[1].type==="linePrefix"||rn[1].type==="blockQuotePrefix"||rn[1].type==="blockQuotePrefixWhitespace"||rn[1].type==="blockQuoteMarker"||rn[1].type==="listItemIndent"))break}Mn&&(!sr||Mn<sr)&&(Xn._spread=!0),Xn.end=Object.assign({},sr?O[sr][1].start:Tn[1].end),O.splice(sr||Ae,0,["exit",Xn,Tn[2]]),Ae++,H++}if(Tn[1].type==="listItemPrefix"){let Rr={type:"listItem",_spread:!1,start:Object.assign({},Tn[1].start),end:void 0};Xn=Rr,O.splice(Ae,0,["enter",Rr,Tn[2]]),Ae++,H++,Mn=void 0,ho=!0}}}return O[U][1]._spread=vt,H}function i(O,U){return H;function H(Ae){a.call(this,O(Ae),Ae),U&&U.call(this,Ae)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,U,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([U,H||void 0]),O.position={start:Uo(U.start),end:void 0}}function u(O){return U;function U(H){O&&O.call(this,H),c.call(this,H)}}function c(O,U){let H=this.stack.pop(),Ae=this.tokenStack.pop();if(Ae)Ae[0].type!==O.type&&(U?U.call(this,O,Ae[0]):(Ae[1]||dT).call(this,O,Ae[0]));else throw new Error("Cannot close `"+O.type+"` ("+Oo({start:O.start,end:O.end})+"): it\u2019s not open");H.position.end=Uo(O.end)}function l(){return $h(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),U=this.stack[this.stack.length-1];U.lang=O}function m(){let O=this.resume(),U=this.stack[this.stack.length-1];U.meta=O}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function I(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/(\r?\n|\r)$/g,"")}function C(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=po(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function R(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function _(O){let U=this.stack[this.stack.length-1];if(!U.depth){let H=this.sliceSerialize(O).length;U.depth=H}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function N(O){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function x(){this.data.setextHeadingSlurpLineEnding=void 0}function k(O){let H=this.stack[this.stack.length-1].children,Ae=H[H.length-1];(!Ae||Ae.type!=="text")&&(Ae=me(),Ae.position={start:Uo(O.start),end:void 0},H.push(Ae)),this.stack.push(Ae)}function w(O){let U=this.stack.pop();U.value+=this.sliceSerialize(O),U.position.end=Uo(O.end)}function E(O){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=U.children[U.children.length-1];H.position.end=Uo(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(k.call(this,O),w.call(this,O))}function f(){this.data.atHardBreak=!0}function T(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function S(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function y(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function F(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function L(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function M(O){let U=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=pT(U),H.identifier=po(U).toLowerCase()}function z(){let O=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Ae=O.children;H.children=Ae}else H.alt=U}function h(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function j(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function V(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function G(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=po(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function te(O){this.data.characterReferenceType=O.type}function le(O){let U=this.sliceSerialize(O),H=this.data.characterReferenceType,Ae;H?(Ae=Ac(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ae=ts(U);let Be=this.stack[this.stack.length-1];Be.value+=Ae}function xe(O){let U=this.stack.pop();U.position.end=Uo(O.end)}function ie(O){w.call(this,O);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(O)}function Ke(O){w.call(this,O);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(O)}function be(){return{type:"blockquote",children:[]}}function Ie(){return{type:"code",lang:null,meta:null,value:""}}function ve(){return{type:"inlineCode",value:""}}function ue(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $e(){return{type:"emphasis",children:[]}}function pe(){return{type:"heading",depth:0,children:[]}}function yt(){return{type:"break"}}function $t(){return{type:"html",value:""}}function yn(){return{type:"image",title:null,url:"",alt:null}}function fe(){return{type:"link",title:null,url:"",children:[]}}function tt(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function he(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function K(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}function Uo(e){return{line:e.line,column:e.column,offset:e.offset}}function fT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?fT(e,r):n6(e,r)}}function n6(e,t){let n;for(n in t)if(gT.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r);break}}}function dT(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Oo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Oo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Oo({start:t.start,end:t.end})+") is still open")}function $c(e){let t=this;t.parser=n;function n(r){return rx(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function mT(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function hT(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
+ `}]}function xT(e,t){let n=t.value?t.value+`
85
+ `:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function yT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ST(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=yr(r.toLowerCase()),i=e.footnoteOrder.indexOf(r),s,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=i+1,a+=1,e.footnoteCounts.set(r,a);let u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,u);let c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,c),e.applyData(t,c)}function wT(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vT(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Uc(e,t){let n=t.referenceType,r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];let o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});let s=o[o.length-1];return s&&s.type==="text"?s.value+=r:o.push({type:"text",value:r}),o}function kT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uc(e,t);let o={src:yr(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)}function CT(e,t){let n={src:yr(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function TT(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function IT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uc(e,t);let o={href:yr(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function FT(e,t){let n={href:yr(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ET(e,t,n){let r=e.all(t),o=n?r6(n):AT(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],d;l&&l.type==="element"&&l.tagName==="p"?d=l:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let l=r[a];(o||a!==0||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:`
86
86
  `}),l.type==="element"&&l.tagName==="p"&&!o?s.push(...l.children):s.push(l)}let u=r[r.length-1];u&&(o||u.type!=="element"||u.tagName!=="p")&&s.push({type:"text",value:`
87
- `});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function r6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=ET(n[r])}return t}function ET(e){let t=e.spread;return t??e.children.length>1}function AT(e,t){let n={},r=e.all(t),o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){let s=r[o];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function PT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function LT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function MT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BT(e,t){let n=e.all(t),r=n.shift(),o=[];if(r){let s={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],s),o.push(s)}if(n.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=es(t.children[1]),u=Ec(t.children[t.children.length-1]);a&&u&&(s.position={start:a,end:u}),o.push(s)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)}function DT(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length,u=-1,c=[];for(;++u<a;){let d=t.children[u],g={},p=s?s[u]:void 0;p&&(g.align=p);let m={type:"element",tagName:i,properties:g,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function RT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(zT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(zT(t.slice(o),o>0,!1)),i.join("")}function zT(e,t,n){let r=0,o=e.length;if(t){let i=e.codePointAt(r);for(;i===9||i===32;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(o-1);for(;i===9||i===32;)o--,i=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function OT(e,t){let n={type:"text",value:NT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function _T(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var $T={blockquote:fT,break:mT,code:hT,delete:xT,emphasis:yT,footnoteReference:bT,heading:ST,html:wT,imageReference:vT,image:kT,inlineCode:CT,linkReference:TT,link:IT,listItem:FT,list:AT,paragraph:PT,root:LT,strong:MT,table:BT,tableCell:RT,tableRow:DT,text:OT,thematicBreak:_T,toml:jc,yaml:jc,definition:jc,footnoteDefinition:jc};function jc(){}var UT=typeof self=="object"?self:globalThis,a6=(e,t)=>{let n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);let[i,s]=t[o];switch(i){case 0:case-1:return n(s,o);case 1:{let a=n([],o);for(let u of s)a.push(r(u));return a}case 2:{let a=n({},o);for(let[u,c]of s)a[r(u)]=r(c);return a}case 3:return n(new Date(s),o);case 4:{let{source:a,flags:u}=s;return n(new RegExp(a,u),o)}case 5:{let a=n(new Map,o);for(let[u,c]of s)a.set(r(u),r(c));return a}case 6:{let a=n(new Set,o);for(let u of s)a.add(r(u));return a}case 7:{let{name:a,message:u}=s;return n(new UT[a](u),o)}case 8:return n(BigInt(s),o);case"BigInt":return n(Object(BigInt(s)),o);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new UT[i](s),o)};return r},sx=e=>a6(new Map,e)(0);var rs="",{toString:l6}={},{keys:c6}=Object,Ca=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=l6.call(e).slice(8,-1);switch(n){case"Array":return[1,rs];case"Object":return[2,rs];case"Date":return[3,rs];case"RegExp":return[4,rs];case"Map":return[5,rs];case"Set":return[6,rs];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Wc=([e,t])=>e===0&&(t==="function"||t==="symbol"),u6=(e,t,n,r)=>{let o=(s,a)=>{let u=r.push(s)-1;return n.set(a,u),u},i=s=>{if(n.has(s))return n.get(s);let[a,u]=Ca(s);switch(a){case 0:{let l=s;switch(u){case"bigint":a=8,l=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);l=null;break;case"undefined":return o([-1],s)}return o([a,l],s)}case 1:{if(u){let g=s;return u==="DataView"?g=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(s)),o([u,[...g]],s)}let l=[],d=o([a,l],s);for(let g of s)l.push(i(g));return d}case 2:{if(u)switch(u){case"BigInt":return o([u,s.toString()],s);case"Boolean":case"Number":case"String":return o([u,s.valueOf()],s)}if(t&&"toJSON"in s)return i(s.toJSON());let l=[],d=o([a,l],s);for(let g of c6(s))(e||!Wc(Ca(s[g])))&&l.push([i(g),i(s[g])]);return d}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:d}=s;return o([a,{source:l,flags:d}],s)}case 5:{let l=[],d=o([a,l],s);for(let[g,p]of s)(e||!(Wc(Ca(g))||Wc(Ca(p))))&&l.push([i(g),i(p)]);return d}case 6:{let l=[],d=o([a,l],s);for(let g of s)(e||!Wc(Ca(g)))&&l.push(i(g));return d}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},ax=(e,{json:t,lossy:n}={})=>{let r=[];return u6(!(t||n),!!t,new Map,r)(e),r};var os=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?sx(ax(e,t)):structuredClone(e):(e,t)=>sx(ax(e,t));function p6(e,t){let n=[{type:"text",value:"\u21A9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function d6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function GT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||p6,r=e.options.footnoteBackLabel||d6,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],u=-1;for(;++u<e.footnoteOrder.length;){let c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;let l=e.all(c),d=String(c.identifier).toUpperCase(),g=yr(d.toLowerCase()),p=0,m=[],k=e.footnoteCounts.get(d);for(;k!==void 0&&++p<=k;){m.length>0&&m.push({type:"text",value:" "});let C=typeof n=="string"?n:n(u,p);typeof C=="string"&&(C={type:"text",value:C}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,p),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}let I=l[l.length-1];if(I&&I.type==="element"&&I.tagName==="p"){let C=I.children[I.children.length-1];C&&C.type==="text"?C.value+=" ":I.children.push({type:"text",value:" "}),I.children.push(...m)}else l.push(...m);let A={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(l,!0)};e.patch(c,A),a.push(A)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...os(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
87
+ `});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function r6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=AT(n[r])}return t}function AT(e){let t=e.spread;return t??e.children.length>1}function PT(e,t){let n={},r=e.all(t),o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){let s=r[o];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function LT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function MT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function BT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DT(e,t){let n=e.all(t),r=n.shift(),o=[];if(r){let s={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],s),o.push(s)}if(n.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=es(t.children[1]),u=Ec(t.children[t.children.length-1]);a&&u&&(s.position={start:a,end:u}),o.push(s)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)}function RT(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length,u=-1,c=[];for(;++u<a;){let d=t.children[u],g={},p=s?s[u]:void 0;p&&(g.align=p);let m={type:"element",tagName:i,properties:g,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function zT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function OT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(NT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(NT(t.slice(o),o>0,!1)),i.join("")}function NT(e,t,n){let r=0,o=e.length;if(t){let i=e.codePointAt(r);for(;i===9||i===32;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(o-1);for(;i===9||i===32;)o--,i=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function _T(e,t){let n={type:"text",value:OT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function $T(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var UT={blockquote:mT,break:hT,code:xT,delete:yT,emphasis:bT,footnoteReference:ST,heading:wT,html:vT,imageReference:kT,image:CT,inlineCode:TT,linkReference:IT,link:FT,listItem:ET,list:PT,paragraph:LT,root:MT,strong:BT,table:DT,tableCell:zT,tableRow:RT,text:_T,thematicBreak:$T,toml:jc,yaml:jc,definition:jc,footnoteDefinition:jc};function jc(){}var jT=typeof self=="object"?self:globalThis,a6=(e,t)=>{let n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);let[i,s]=t[o];switch(i){case 0:case-1:return n(s,o);case 1:{let a=n([],o);for(let u of s)a.push(r(u));return a}case 2:{let a=n({},o);for(let[u,c]of s)a[r(u)]=r(c);return a}case 3:return n(new Date(s),o);case 4:{let{source:a,flags:u}=s;return n(new RegExp(a,u),o)}case 5:{let a=n(new Map,o);for(let[u,c]of s)a.set(r(u),r(c));return a}case 6:{let a=n(new Set,o);for(let u of s)a.add(r(u));return a}case 7:{let{name:a,message:u}=s;return n(new jT[a](u),o)}case 8:return n(BigInt(s),o);case"BigInt":return n(Object(BigInt(s)),o);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new jT[i](s),o)};return r},sx=e=>a6(new Map,e)(0);var rs="",{toString:l6}={},{keys:c6}=Object,Ca=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=l6.call(e).slice(8,-1);switch(n){case"Array":return[1,rs];case"Object":return[2,rs];case"Date":return[3,rs];case"RegExp":return[4,rs];case"Map":return[5,rs];case"Set":return[6,rs];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Wc=([e,t])=>e===0&&(t==="function"||t==="symbol"),u6=(e,t,n,r)=>{let o=(s,a)=>{let u=r.push(s)-1;return n.set(a,u),u},i=s=>{if(n.has(s))return n.get(s);let[a,u]=Ca(s);switch(a){case 0:{let l=s;switch(u){case"bigint":a=8,l=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);l=null;break;case"undefined":return o([-1],s)}return o([a,l],s)}case 1:{if(u){let g=s;return u==="DataView"?g=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(s)),o([u,[...g]],s)}let l=[],d=o([a,l],s);for(let g of s)l.push(i(g));return d}case 2:{if(u)switch(u){case"BigInt":return o([u,s.toString()],s);case"Boolean":case"Number":case"String":return o([u,s.valueOf()],s)}if(t&&"toJSON"in s)return i(s.toJSON());let l=[],d=o([a,l],s);for(let g of c6(s))(e||!Wc(Ca(s[g])))&&l.push([i(g),i(s[g])]);return d}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:d}=s;return o([a,{source:l,flags:d}],s)}case 5:{let l=[],d=o([a,l],s);for(let[g,p]of s)(e||!(Wc(Ca(g))||Wc(Ca(p))))&&l.push([i(g),i(p)]);return d}case 6:{let l=[],d=o([a,l],s);for(let g of s)(e||!Wc(Ca(g)))&&l.push(i(g));return d}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},ax=(e,{json:t,lossy:n}={})=>{let r=[];return u6(!(t||n),!!t,new Map,r)(e),r};var os=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?sx(ax(e,t)):structuredClone(e):(e,t)=>sx(ax(e,t));function p6(e,t){let n=[{type:"text",value:"\u21A9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function d6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function qT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||p6,r=e.options.footnoteBackLabel||d6,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],u=-1;for(;++u<e.footnoteOrder.length;){let c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;let l=e.all(c),d=String(c.identifier).toUpperCase(),g=yr(d.toLowerCase()),p=0,m=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++p<=v;){m.length>0&&m.push({type:"text",value:" "});let C=typeof n=="string"?n:n(u,p);typeof C=="string"&&(C={type:"text",value:C}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,p),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}let I=l[l.length-1];if(I&&I.type==="element"&&I.tagName==="p"){let C=I.children[I.children.length-1];C&&C.type==="text"?C.value+=" ":I.children.push({type:"text",value:" "}),I.children.push(...m)}else l.push(...m);let A={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(l,!0)};e.patch(c,A),a.push(A)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...os(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
88
88
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
89
- `}]}}var Vc=(function(e){if(e==null)return h6;if(typeof e=="function")return Gc(e);if(typeof e=="object")return Array.isArray(e)?g6(e):f6(e);if(typeof e=="string")return m6(e);throw new Error("Expected function, string, or object as test")});function g6(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Vc(e[n]);return Gc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function f6(e){let t=e;return Gc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function m6(e){return Gc(t);function t(n){return n&&n.type===e}}function Gc(e){return t;function t(n,r,o){return!!(x6(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function h6(){return!0}function x6(e){return e!==null&&typeof e=="object"&&"type"in e}var qT=[],lx=!0,qc=!1,cx="skip";function ux(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Vc(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let d=u&&typeof u=="object"?u:{};if(typeof d.type=="string"){let p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(p?"<"+p+">":""))+")"})}return g;function g(){let p=qT,m,k,I;if((!t||i(u,c,l[l.length-1]||void 0))&&(p=y6(n(u,l)),p[0]===qc))return p;if("children"in u&&u.children){let A=u;if(A.children&&p[0]!==cx)for(k=(r?A.children.length:-1)+s,I=l.concat(A);k>-1&&k<A.children.length;){let C=A.children[k];if(m=a(C,k,I)(),m[0]===qc)return m;k=typeof m[1]=="number"?m[1]:k+s}}return p}}}function y6(e){return Array.isArray(e)?e:typeof e=="number"?[lx,e]:e==null?qT:[e]}function Ta(e,t,n,r){let o,i,s;typeof t=="function"&&typeof n!="function"?(i=void 0,s=t,o=n):(i=t,s=n,o=r),ux(e,i,a,o);function a(u,c){let l=c[c.length-1],d=l?l.children.indexOf(u):void 0;return s(u,d,l)}}var px={}.hasOwnProperty,b6={};function KT(e,t){let n=t||b6,r=new Map,o=new Map,i=new Map,s={...$T,...n.handlers},a={all:c,applyData:w6,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:S6,wrap:k6};return Ta(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let d=l.type==="definition"?r:o,g=String(l.identifier).toUpperCase();d.has(g)||d.set(g,l)}}),a;function u(l,d){let g=l.type,p=a.handlers[g];if(px.call(a.handlers,g)&&p)return p(a,l,d);if(a.options.passThrough&&a.options.passThrough.includes(g)){if("children"in l){let{children:k,...I}=l,A=os(I);return A.children=a.all(l),A}return os(l)}return(a.options.unknownHandler||v6)(a,l,d)}function c(l){let d=[];if("children"in l){let g=l.children,p=-1;for(;++p<g.length;){let m=a.one(g[p],l);if(m){if(p&&g[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=YT(m.value)),!Array.isArray(m)&&m.type==="element")){let k=m.children[0];k&&k.type==="text"&&(k.value=YT(k.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function S6(e,t){e.position&&(t.position=Dh(e))}function w6(e,t){let n=t;if(e&&e.data){let r=e.data.hName,o=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{let s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&i&&Object.assign(n.properties,os(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function v6(e,t){let n=t.data||{},r="value"in t&&!(px.call(n,"hProperties")||px.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function k6(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
89
+ `}]}}var Vc=(function(e){if(e==null)return h6;if(typeof e=="function")return Gc(e);if(typeof e=="object")return Array.isArray(e)?g6(e):f6(e);if(typeof e=="string")return m6(e);throw new Error("Expected function, string, or object as test")});function g6(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Vc(e[n]);return Gc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function f6(e){let t=e;return Gc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function m6(e){return Gc(t);function t(n){return n&&n.type===e}}function Gc(e){return t;function t(n,r,o){return!!(x6(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function h6(){return!0}function x6(e){return e!==null&&typeof e=="object"&&"type"in e}var YT=[],lx=!0,qc=!1,cx="skip";function ux(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Vc(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let d=u&&typeof u=="object"?u:{};if(typeof d.type=="string"){let p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(p?"<"+p+">":""))+")"})}return g;function g(){let p=YT,m,v,I;if((!t||i(u,c,l[l.length-1]||void 0))&&(p=y6(n(u,l)),p[0]===qc))return p;if("children"in u&&u.children){let A=u;if(A.children&&p[0]!==cx)for(v=(r?A.children.length:-1)+s,I=l.concat(A);v>-1&&v<A.children.length;){let C=A.children[v];if(m=a(C,v,I)(),m[0]===qc)return m;v=typeof m[1]=="number"?m[1]:v+s}}return p}}}function y6(e){return Array.isArray(e)?e:typeof e=="number"?[lx,e]:e==null?YT:[e]}function Ta(e,t,n,r){let o,i,s;typeof t=="function"&&typeof n!="function"?(i=void 0,s=t,o=n):(i=t,s=n,o=r),ux(e,i,a,o);function a(u,c){let l=c[c.length-1],d=l?l.children.indexOf(u):void 0;return s(u,d,l)}}var px={}.hasOwnProperty,b6={};function XT(e,t){let n=t||b6,r=new Map,o=new Map,i=new Map,s={...UT,...n.handlers},a={all:c,applyData:w6,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:S6,wrap:k6};return Ta(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let d=l.type==="definition"?r:o,g=String(l.identifier).toUpperCase();d.has(g)||d.set(g,l)}}),a;function u(l,d){let g=l.type,p=a.handlers[g];if(px.call(a.handlers,g)&&p)return p(a,l,d);if(a.options.passThrough&&a.options.passThrough.includes(g)){if("children"in l){let{children:v,...I}=l,A=os(I);return A.children=a.all(l),A}return os(l)}return(a.options.unknownHandler||v6)(a,l,d)}function c(l){let d=[];if("children"in l){let g=l.children,p=-1;for(;++p<g.length;){let m=a.one(g[p],l);if(m){if(p&&g[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=KT(m.value)),!Array.isArray(m)&&m.type==="element")){let v=m.children[0];v&&v.type==="text"&&(v.value=KT(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function S6(e,t){e.position&&(t.position=Dh(e))}function w6(e,t){let n=t;if(e&&e.data){let r=e.data.hName,o=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{let s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&i&&Object.assign(n.properties,os(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function v6(e,t){let n=t.data||{},r="value"in t&&!(px.call(n,"hProperties")||px.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function k6(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
90
90
  `});++r<e.length;)r&&n.push({type:"text",value:`
91
91
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
92
- `}),n}function YT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Yc(e,t){let n=KT(e,t),r=n.one(e,void 0),o=GT(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&("children"in i,i.children.push({type:"text",value:`
93
- `},o)),i}function Kc(e,t){return e&&"run"in e?async function(n,r){let o=Yc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Yc(n,{file:r,...e||t})}}function dx(e){if(e)throw e}var Jc=Va(oI(),1);function Ia(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function gx(){let e=[],t={run:n,use:r};return t;function n(...o){let i=-1,s=o.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...o);function a(u,...c){let l=e[++i],d=-1;if(u){s(u);return}for(;++d<o.length;)(c[d]===null||c[d]===void 0)&&(c[d]=o[d]);o=c,l?iI(l,a)(...c):s(null,...c)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function iI(e,t){let n;return r;function r(...s){let a=e.length>s.length,u;a&&s.push(o);try{u=e.apply(this,s)}catch(c){let l=c;if(a&&n)throw l;return o(l)}a||(u&&u.then&&typeof u.then=="function"?u.then(i,o):u instanceof Error?o(u):i(u))}function o(s,...a){n||(n=!0,t(s,...a))}function i(s){o(null,s)}}var Mr={basename:C6,dirname:T6,extname:I6,join:F6,sep:"/"};function C6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Fa(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else s<0&&(i=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(r=o):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function T6(e){if(Fa(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function I6(e){Fa(e);let t=e.length,n=-1,r=0,o=-1,i=0,s;for(;t--;){let a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function F6(...e){let t=-1,n;for(;++t<e.length;)Fa(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":E6(n)}function E6(e){Fa(e);let t=e.codePointAt(0)===47,n=A6(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function A6(e,t){let n="",r=0,o=-1,i=0,s=-1,a,u;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(o===s-1||i===1))if(o!==s-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),o=s,i=0;continue}}else if(n.length>0){n="",r=0,o=s,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,s):n=e.slice(o+1,s),r=s-o-1;o=s,i=0}else a===46&&i>-1?i++:i=-1}return n}function Fa(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var sI={cwd:P6};function P6(){return"/"}function is(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function aI(e){if(typeof e=="string")e=new URL(e);else if(!is(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return L6(e)}function L6(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let r=t.codePointAt(n+2);if(r===70||r===102){let o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}var fx=["history","path","basename","stem","extname","dirname"],di=class{constructor(t){let n;t?is(t)?n={path:t}:typeof t=="string"||M6(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":sI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<fx.length;){let i=fx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let o;for(o in n)fx.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Mr.basename(this.path):void 0}set basename(t){hx(t,"basename"),mx(t,"basename"),this.path=Mr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Mr.dirname(this.path):void 0}set dirname(t){lI(this.basename,"dirname"),this.path=Mr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Mr.extname(this.path):void 0}set extname(t){if(mx(t,"extname"),lI(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Mr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){is(t)&&(t=aI(t)),hx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Mr.basename(this.path,this.extname):void 0}set stem(t){hx(t,"stem"),mx(t,"stem"),this.path=Mr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){let o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){let o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){let o=new Gt(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function mx(e,t){if(e&&e.includes(Mr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Mr.sep+"`")}function hx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function lI(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function M6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var cI=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var B6={}.hasOwnProperty,Sx=class e extends cI{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=gx()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,Jc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(bx("data",this.frozen),this.namespace[t]=n,this):B6.call(this.namespace,t)&&this.namespace[t]||void 0:t?(bx("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=Qc(t),r=this.parser||this.Parser;return xx("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),xx("process",this.parser||this.Parser),yx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Qc(t),u=r.parse(a);r.run(u,a,function(l,d,g){if(l||!d||!g)return c(l);let p=d,m=r.stringify(p,g);R6(m)?g.value=m:g.result=m,c(l,g)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),xx("processSync",this.parser||this.Parser),yx("processSync",this.compiler||this.Compiler),this.process(t,o),pI("processSync","process",n),r;function o(i,s){n=!0,dx(i),r=s}}run(t,n,r){uI(t),this.freeze();let o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(s,a){let u=Qc(n);o.run(t,u,c);function c(l,d,g){let p=d||t;l?a(l):s?s(p):r(void 0,p,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),pI("runSync","run",r),o;function i(s,a){dx(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Qc(n),o=this.compiler||this.Compiler;return yx("stringify",o),uI(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(bx("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[l,...d]=c;u(l,d)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(o.settings=(0,Jc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let d=c[l];i(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let d=-1,g=-1;for(;++d<r.length;)if(r[d][0]===c){g=d;break}if(g===-1)r.push([c,...l]);else if(l.length>0){let[p,...m]=l,k=r[g][1];Ia(k)&&Ia(p)&&(p=(0,Jc.default)(!0,k,p)),r[g]=[c,p,...m]}}}},wx=new Sx().freeze();function xx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bx(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function uI(e){if(!Ia(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function pI(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qc(e){return D6(e)?e:new di(e)}function D6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function R6(e){return typeof e=="string"||z6(e)}function z6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var $6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",dI=[],gI={allowDangerousHtml:!0},U6=/^(https?|ircs?|mailto|xmpp)$/i,j6=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function vx(e){let t=H6(e),n=W6(e);return V6(t.runSync(t.parse(n),n),e)}function H6(e){let t=e.rehypePlugins||dI,n=e.remarkPlugins||dI,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gI}:gI;return wx().use($c).use(n).use(Kc,r).use(t)}function W6(e){let t=e.children||"",n=new di;return typeof t=="string"?n.value=t:(""+t,void 0),n}function V6(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||fI;for(let l of j6)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+$6+l.id,void 0);return n&&i&&void 0,Ta(e,c),Nh(e,{Fragment:N6,components:o,ignoreInvalidStyle:!0,jsx:O6,jsxs:_6,passKeys:!0,passNode:!0});function c(l,d,g){if(l.type==="raw"&&g&&typeof d=="number")return s?g.children.splice(d,1):g.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in xa)if(Object.hasOwn(xa,p)&&Object.hasOwn(l.properties,p)){let m=l.properties[p],k=xa[p];(k===null||k.includes(l.tagName))&&(l.properties[p]=u(String(m||""),p,l))}}if(l.type==="element"){let p=n?!n.includes(l.tagName):i?i.includes(l.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(l,d,g)),p&&g&&typeof d=="number")return a&&l.children?g.children.splice(d,1,...l.children):g.children.splice(d,1),d}}}function fI(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||U6.test(e.slice(0,t))?e:""}Te();var q6=ss.div({display:"flex",flexDirection:"column",gap:"12px"}),Y6=ss.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),K6=ss.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),X6=ss(Fn)({padding:"6px 12px",fontSize:"12px"}),Q6=ss.div(({theme:e})=>({backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"12px",fontSize:"12px",color:e.color.defaultText,overflowY:"auto",maxHeight:"400px",lineHeight:"1.6","& h1, & h2, & h3, & h4":{marginTop:"16px",marginBottom:"8px",fontWeight:600,color:e.color.defaultText},"& h1":{fontSize:"18px"},"& h2":{fontSize:"16px"},"& h3":{fontSize:"14px"},"& h4":{fontSize:"13px"},"& p":{margin:"8px 0"},"& ul, & ol":{paddingLeft:"20px",margin:"8px 0"},"& li":{margin:"4px 0"},"& code":{backgroundColor:e.background.app,padding:"2px 4px",borderRadius:"3px",fontFamily:d1.fontMono,fontSize:"11px"},"& pre":{backgroundColor:e.background.app,padding:"8px",borderRadius:"4px",overflowX:"auto","& code":{backgroundColor:"transparent",padding:0}},"& strong":{fontWeight:600},"& blockquote":{borderLeft:`3px solid ${e.color.secondary}`,paddingLeft:"12px",margin:"8px 0",color:e.color.mediumdark}})),J6=ss.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),kx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ce(),[r,o]=G6(!1);if((n??t)!=="admin")return null;let s=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(a){console.error("Failed to copy:",a)}};return e?gi.createElement(q6,null,gi.createElement(Y6,null,gi.createElement(K6,null,"Full Prompt"),gi.createElement(X6,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),gi.createElement(Q6,null,gi.createElement(vx,null,e))):gi.createElement(J6,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import go,{useRef as Z6}from"react";import{styled as Br}from"storybook/theming";Te();var ej=Br.div({display:"flex",flexDirection:"column",gap:"8px"}),wge=Br.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"11px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"3px 10px",borderRadius:"12px",border:`1px solid ${o.border}`,whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:"6px"}}),tj=Br.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflowY:"auto",scrollBehavior:"smooth",padding:"6px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app})),nj=Br.div(({role:e,theme:t})=>({padding:"8px 10px",borderRadius:"4px",fontSize:"11px",lineHeight:"1.4",backgroundColor:e==="system"?t.background.hoverable:t.background.content,border:`1px solid ${t.appBorderColor}`,color:t.color.defaultText})),vge=Br.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),mI=Br.div(({theme:e})=>({whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"10px","& .section-header":{fontSize:"11px",fontWeight:700,color:e.color.secondary,marginTop:"8px",marginBottom:"4px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"6px",marginBottom:"2px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||se,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"11px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"1px 6px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"3px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||se,backgroundColor:e.background.warning||"#ffedd5"}})),rj=Br.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),oj=Br.div(({theme:e})=>({padding:"12px 16px",borderRadius:"8px",backgroundColor:e.background.positive||"#dcfce7",border:`1px solid ${e.color.positive||"#86efac"}`,color:e.color.positive||"#166534",fontSize:"13px",fontWeight:500,lineHeight:1.5,marginBottom:"12px"})),ij=Br.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),sj=Br.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),kge=Br.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function aj(e){let t=e;return t=t.replace(/^(?:\*?\*?)?(?:##?)?\s*SCORE:\s*\d+.*$/gm,""),t=t.replace(/^(ISSUES:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t}var Cx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ce(),s=Z6(null);if((i??o)!=="admin")return null;let u=r?n.find(m=>m.id===r):null,c=u?u.issues.length>0&&u.issues.every(m=>m.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(m=>m.role==="assistant"||m.role==="system"&&m.content.includes("auto-dismissed")),g=d.length===0&&!!t;if(d.length===0&&!g)return go.createElement(rj,null,"No AI response yet. The AI's analysis will appear here as it streams.");let p=d.length>0?d:[{role:"assistant",content:t}];return go.createElement(ej,null,l&&go.createElement(oj,null,go.createElement(ij,null,"Component Matches Design"),go.createElement(sj,null,c&&u?.issues.length?`All ${u.issues.length} issue${u.issues.length===1?"":"s"} identified by the AI ${u.issues.length===1?"was":"were"} validated as false positive${u.issues.length===1?"":"s"} and auto-dismissed.`:"No design discrepancies found. The implementation matches the Figma design.")),go.createElement(tj,{ref:s},p.map((m,k)=>go.createElement(nj,{key:k,role:m.role},m.role==="system"?go.createElement(mI,null,m.content):go.createElement(mI,{dangerouslySetInnerHTML:{__html:aj(m.content)}})))))};import br from"react";import{styled as jo}from"storybook/theming";Te();_e();var lj=jo.div({display:"flex",flexDirection:"column",gap:"12px"}),cj=jo.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),uj=jo.button(({theme:e,isActive:t,provider:n})=>{let o={anthropic:{background:"#D4A574",text:"#ffffff",hover:"#C49564"},openai:{background:e.color.positive||"#10b981",text:"#ffffff",hover:e.base==="dark"?"#34d399":"#059669"},google:{background:"#4285F4",text:"#ffffff",hover:"#3367D6"}}[n];return{display:"flex",alignItems:"center",gap:"6px",padding:"8px 16px",fontSize:"12px",fontWeight:600,color:t?o.text:e.textMutedColor,backgroundColor:t?o.background:"transparent",border:"none",borderRadius:"6px 6px 0 0",cursor:"pointer",whiteSpace:"nowrap",transition:"all 0.2s",opacity:t?1:.6,"&:hover":{opacity:1,backgroundColor:t?o.hover:e.background.hoverable}}}),hI=jo.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"10px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${o.border}`,whiteSpace:"nowrap"}}),pj=jo.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),xI=jo.div(({theme:e})=>({fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',color:e.color.defaultText,"& .section-header":{fontSize:"13px",fontWeight:700,color:e.color.secondary,marginTop:"12px",marginBottom:"6px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"10px",marginBottom:"4px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||se,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"14px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"2px 8px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"4px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||se,backgroundColor:e.background.warning||"#ffedd5"}})),yI=jo.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),dj=jo.div({width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite",display:"inline-block",marginLeft:"6px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}});function bI(e){let t=e;return t=t.replace(/^(ISSUES:|SCORE:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t=t.replace(/SCORE:\s*(\d+)/g,(n,r)=>{let o=parseInt(r,10);return`SCORE: <span class="${o>=80?"score":o>=60?"score score-medium":"score score-low"}">${r}</span>`}),t}function gj(e){let t=e.match(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-/g),n=t?t.length:0,r=e.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i),o=r?parseInt(r[1],10):null;return{issueCount:n,score:o}}var SI=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ce();if((i??o)!=="admin")return null;br.useEffect(()=>{e&&(b.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([l,d])=>{b.debug(`[ModelResultsTabs] ${l}:`,{hasStreamingMessages:!!d.streamingMessages,streamingMessagesLength:d.streamingMessages?.length||0,streamingMessagesPreview:d.streamingMessages?.[0]?.content?.substring(0,100),hasFullResponse:!!d.fullResponse,fullResponsePreview:d.fullResponse?.substring(0,100)})}))},[e]);let a=e&&Object.keys(e.byModel).length>0?Object.keys(e.byModel):r,u=e?.activeModelId||(a.length>0?a[0]:""),c=e?.byModel||{};return a.length===0?br.createElement(yI,null,"No models selected. Select multiple models to compare results."):br.createElement(lj,null,br.createElement(cj,null,a.map(l=>{let d=co.find(A=>A.id===l),g=c[l],m=gj(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),k=l===u;if(!d)return null;let I=t&&!g?.completed;return br.createElement(uj,{key:l,isActive:k,provider:d.provider,onClick:()=>n(l)},d.name,g&&m.issueCount>0&&br.createElement(hI,{variant:"issues",value:m.issueCount},m.issueCount," issues"),g&&m.score!==null&&br.createElement(hI,{variant:"score",value:m.score},"Score: ",m.score),I&&br.createElement(dj,null))})),br.createElement(pj,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>br.createElement(xI,{key:d,dangerouslySetInnerHTML:{__html:bI(l.content)}})):c[u]?.fullResponse?br.createElement(xI,{dangerouslySetInnerHTML:{__html:bI(c[u].fullResponse)}}):br.createElement(yI,null,t?`Waiting for ${co.find(l=>l.id===u)?.name}...`:`No response yet for ${co.find(l=>l.id===u)?.name}`)))};import Oe from"react";import{styled as Ft}from"storybook/theming";Te();_n();Te();import{useCallback as Tx}from"react";_e();function wI(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ce(),{sessionToken:r}=ke(),o=Tx(a=>{for(let u of n){let c=u.issues.find(l=>l.id===a);if(c)return c.dbId||c.id||null}return null},[n]),i=Tx((a,u)=>{e(a,u,"user");let c=o(a);if(!c){b.debug("[useIssuePersistence] Dismiss skipped server sync \u2014 no dbId for",a);return}if(!r){b.debug("[useIssuePersistence] Dismiss skipped \u2014 no session token");return}Zl(c,!0,u,"user",r).then(l=>{l.success||b.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=Tx(a=>{t(a);let u=o(a);if(!u){b.debug("[useIssuePersistence] Undismiss skipped server sync \u2014 no dbId for",a);return}if(!r){b.debug("[useIssuePersistence] Undismiss skipped \u2014 no session token");return}Zl(u,!1,void 0,"user",r).then(c=>{c.success||b.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import Y,{useMemo as RH,useState as zH,useEffect as NH}from"react";import{styled as st,keyframes as OH}from"storybook/theming";import Z,{useState as Px,useRef as T8,useCallback as OI,memo as I8}from"react";import{styled as Me}from"storybook/theming";import pt,{useState as vI}from"react";import{styled as Cn}from"storybook/theming";var fj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),mj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("polyline",{points:"12 6 12 12 16 14"})),hj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})),xj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})),yj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("path",{d:"M12 3l1.68 5.17L19 10l-5.32 1.83L12 17l-1.68-5.17L5 10l5.32-1.83z"}),pt.createElement("path",{d:"M5 3l.74 2.26L8 6l-2.26.74L5 9l-.74-2.26L2 6l2.26-.74z"}),pt.createElement("path",{d:"M19 15l.74 2.26L22 18l-2.26.74L19 21l-.74-2.26L16 18l2.26-.74z"})),kI=[{id:"false-positive",Icon:fj,label:"False positive",description:"The AI flagged something that isn't actually a design issue",color:"#9ca3af",bg:"rgba(156,163,175,0.15)"},{id:"planned",Icon:mj,label:"Planned",description:"Valid issue \u2014 logged and scheduled to fix in a future sprint",color:"#60a5fa",bg:"rgba(96,165,250,0.15)"},{id:"wont-fix",Icon:hj,label:"Won't fix",description:"Intentional deviation \u2014 design has approved this difference",color:"#fbbf24",bg:"rgba(251,191,36,0.15)"},{id:"no-figma-state",Icon:xj,label:"No Figma state",description:"No Figma frame exists for this specific story variant or state",color:"#a78bfa",bg:"rgba(167,139,250,0.15)"},{id:"design-pending",Icon:yj,label:"Design pending",description:"Code was built first \u2014 designer will add the Figma spec later",color:"#34d399",bg:"rgba(52,211,153,0.15)"}],bj=Cn.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999}),Sj=Cn.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"10px",padding:"24px",maxWidth:"480px",width:"90%",boxShadow:"0 10px 40px rgba(0,0,0,0.25)",border:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"20px"})),wj=Cn.div({display:"flex",flexDirection:"column",gap:"4px"}),vj=Cn.h3(({theme:e})=>({fontSize:"17px",fontWeight:700,color:e.color.defaultText,margin:0})),kj=Cn.p(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,margin:0,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Cj=Cn.div({display:"flex",flexDirection:"column",gap:"6px"}),Tj=Cn.button(({theme:e,selected:t,accentColor:n})=>({display:"flex",alignItems:"flex-start",gap:"12px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${t?n:e.appBorderColor}`,backgroundColor:t?`${n}10`:e.background.app,boxShadow:t?`0 0 0 1px ${n}`:"none",cursor:"pointer",textAlign:"left",width:"100%",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),Ij=Cn.div(({color:e,bg:t})=>({width:"36px",height:"36px",borderRadius:"7px",backgroundColor:t,color:e,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),Fj=Cn.div({display:"flex",flexDirection:"column",gap:"2px",minWidth:0,flex:1}),Ej=Cn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,lineHeight:"1.3"})),Aj=Cn.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,lineHeight:"1.4"})),Pj=Cn.div({display:"flex",flexDirection:"column",gap:"6px"}),Lj=Cn.label(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.defaultText})),Mj=Cn.textarea(({theme:e})=>({width:"100%",minHeight:"72px",padding:"8px 10px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary},"&::placeholder":{color:e.textMutedColor}})),Bj=Cn.div({display:"flex",justifyContent:"flex-end",gap:"8px"}),Dj=Cn.button(({theme:e,disabled:t,accentColor:n})=>({padding:"8px 18px",fontSize:"13px",fontWeight:600,borderRadius:"6px",border:"none",cursor:t?"not-allowed":"pointer",backgroundColor:t?e.color.medium:n||e.color.secondary,color:"#ffffff",opacity:t?.5:1,transition:"opacity 0.15s","&:hover":{opacity:t?.5:.85}})),CI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=vI(null),[s,a]=vI("");if(!e)return null;let u=kI.find(d=>d.id===o),c=()=>{o&&(n(o,s.trim()||void 0),i(null),a(""))},l=()=>{i(null),a(""),r()};return pt.createElement(bj,{onClick:d=>d.target===d.currentTarget&&l()},pt.createElement(Sj,null,pt.createElement(wj,null,pt.createElement(vj,null,"Dismiss Issue"),pt.createElement(kj,{title:t},t)),pt.createElement(Cj,{role:"radiogroup"},kI.map(({id:d,Icon:g,label:p,description:m,color:k,bg:I})=>pt.createElement(Tj,{key:d,selected:o===d,accentColor:k,onClick:()=>i(d),role:"radio","aria-checked":o===d},pt.createElement(Ij,{color:k,bg:I},pt.createElement(g,null)),pt.createElement(Fj,null,pt.createElement(Ej,null,p),pt.createElement(Aj,null,m))))),pt.createElement(Pj,null,pt.createElement(Lj,{htmlFor:"dismiss-note"},"Note (optional)"),pt.createElement(Mj,{id:"dismiss-note",placeholder:"Add context\u2026",value:s,onChange:d=>a(d.target.value),rows:3})),pt.createElement(Bj,null,pt.createElement(Nr,{onClick:l},"Cancel"),pt.createElement(Dj,{disabled:!o,accentColor:u?.color,onClick:c},"Dismiss Issue"))))};Te();import Le from"react";import{styled as it}from"storybook/theming";var Ne={outerBg:"#f0f0f0",borderBoxBg:"#fff",borderBoxStroke:"#999",paddingBg:"#dceefb",paddingStroke:"rgba(0,0,0,0.08)",contentStroke:"#888",text:"#333",dim:"#999",dash:"#aaa",blue:"#4a90d9",pink:"#e91e8c",err:"#d32f2f",errBg:"rgba(211,47,47,0.12)",ok:"#2e7d32"},Rj=it.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),zj=it.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),Nj=it.div({position:"relative",backgroundColor:Ne.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Wge=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Ne.dash,padding:"0 8px",height:18,fontSize:11}),Vge=it.div({position:"absolute",color:Ne.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Gge=it.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"1px 6px",borderRadius:3,zIndex:2,...e.side==="top"&&{top:4,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:4,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:4,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:4,top:"50%",transform:"translateY(-50%)"}})),qge=it.div(e=>({position:"absolute",backgroundColor:e.color,zIndex:1,...e.orient==="v"&&{width:1,left:"50%"},...e.orient==="h"&&{height:1,top:"50%"},...e.side==="top"&&{top:18,height:10},...e.side==="bottom"&&{bottom:18,height:10},...e.side==="left"&&{left:30,width:20},...e.side==="right"&&{right:30,width:20}})),Oj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Ne.errBg:Ne.borderBoxBg,border:`1px solid ${e.isErr?Ne.err:Ne.borderBoxStroke}`,borderRadius:6,padding:0})),_j=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Ne.text}),$j=it.span({fontWeight:500,fontSize:11}),Yge=it.span({color:Ne.dash}),Uj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Ne.errBg:Ne.paddingBg,border:`1px solid ${e.isErr?Ne.err:Ne.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),jj=it.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Ne.text,fontStyle:"italic"}),Zc=it.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Ne.err:Ne.text,fontWeight:e.isErr?700:400,...e.side==="top"&&{top:3,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:3,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:8,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:8,top:"50%",transform:"translateY(-50%)"}})),Hj=it.div(e=>({backgroundColor:e.isErr?Ne.errBg:"#fff",border:`1.5px dashed ${e.isErr?Ne.err:Ne.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Ne.err:Ne.text,fontWeight:e.isErr?600:400})),Wj=it.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Ne.dim,fontFamily:"monospace"}),Vj=it.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Ne.ok,padding:"4px 8px 6px"}),Kge=it.div({fontSize:11,fontWeight:600,color:Ne.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Xge=it.span({fontSize:12,color:Ne.dim}),Gj=it.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),qj=it.div({fontSize:9,color:Ne.dim,marginTop:2}),Yj=({property:e,currentValue:t,expectedValue:n,figmaContext:r,elementName:o})=>{let i=e.toLowerCase(),s=i.includes("padding"),a=i.includes("border")||i.includes("stroke")||i.includes("box-shadow"),u=i.includes("width")||i.includes("height")||i==="dimensions",c=i.includes("radius"),{figmaImageUrl:l}=ce(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?n8(n):null,m=d.padding||p||{top:0,right:0,bottom:0,left:0},k=d.strokeWeight??(a?as(n)??0:0),I=d.width??(u?r8(n)??"\u2014":"\u2014"),A=d.height??(u?o8(n)??"\u2014":"\u2014");return Le.createElement(Le.Fragment,null,Le.createElement(Nj,null,Le.createElement(Oj,{isErr:a},Le.createElement(_j,null,Le.createElement($j,null,"Border"),Le.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Ne.err:Ne.dim}},k)),Le.createElement(Uj,{isErr:s},Le.createElement(jj,null,"Padding"),Le.createElement(Zc,{side:"top",isErr:s},m.top),Le.createElement(Zc,{side:"right",isErr:s},m.right),Le.createElement(Zc,{side:"bottom",isErr:s},m.bottom),Le.createElement(Zc,{side:"left",isErr:s},m.left),Le.createElement(Hj,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Le.createElement(Gj,{src:l,alt:"Figma element"}),Le.createElement(qj,null,I," \xD7 ",A)))),Le.createElement(Wj,null,"border-box")),Le.createElement(Vj,null,"\u2192 ",n))},TI=it.div({backgroundColor:Ne.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),Kj=it.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),Ix=it.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Ne.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),Xj=it.div({position:"absolute",border:`1.5px dashed ${Ne.err}`,pointerEvents:"none",zIndex:0}),Qj=it.div({position:"absolute",border:`1.5px dashed ${Ne.blue}`,pointerEvents:"none",zIndex:0}),II=it.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"2px 6px",borderRadius:3,zIndex:2,whiteSpace:"nowrap",...e.side==="left"&&{left:-4,top:"50%",transform:"translate(-100%, -50%)"},...e.side==="right"&&{right:-4,top:"50%",transform:"translate(100%, -50%)"}})),Qge=it.div({fontSize:12,color:Ne.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),Jj=it.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),FI=it.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Ne.err:Ne.ok})),Zj=it.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),EI=it.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),AI=it.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Ne.err:Ne.ok})),PI=it.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Ne.err:Ne.ok,textDecoration:e.variant==="err"?"line-through":"none"})),e8=it.span({fontSize:16,color:Ne.dim,paddingBottom:20}),LI=it.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function MI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var t8=({property:e,currentValue:t,expectedValue:n,figmaContext:r})=>{let o=r||{},i=e.toLowerCase(),s=i.includes("size"),a=i.includes("weight"),u=i.includes("lineheight")||i.includes("line-height"),c=i.includes("text")||i.includes("content"),l=i.includes("family"),d=s||u,g=o.fontSize??(s?as(n):14),p=o.fontWeight??(a?as(n):600),k=(o.lineHeight??(u?as(n):null))||Math.round((g||14)*1.43),I=`${Math.min(Math.max(g||14,24),48)}px`;if(d)return Le.createElement(Le.Fragment,null,Le.createElement(TI,null,Le.createElement(Kj,null,Le.createElement(Qj,{style:{top:-6,left:0,right:0,bottom:-6}}),Le.createElement(Xj,{style:{top:2,left:8,right:8,bottom:2}}),Le.createElement(II,{color:s?Ne.err:"#7b3030",side:"left"},s?t:`${g}px`),Le.createElement(II,{color:u?Ne.err:"#7b3030",side:"right"},u?t:`${k}px`),Le.createElement(Ix,{fSize:I,fWeight:String(p||600)},"Ag")),Le.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Le.createElement(LI,{color:Ne.err},"\u2508\u2508 font-size",s?" \u2717":""),Le.createElement(LI,{color:Ne.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Le.createElement(Jj,null,Le.createElement(FI,{variant:"err"},t),Le.createElement("span",{style:{color:Ne.dim}},"\u2192"),Le.createElement(FI,{variant:"ok"},n))));let A=a?t:String(p||600),C=a?n:A,D=as(t),R=as(n);return Le.createElement(Le.Fragment,null,Le.createElement(TI,null,Le.createElement(Zj,null,Le.createElement(EI,null,Le.createElement(AI,{variant:"err"},"Current"),Le.createElement(Ix,{fSize:I,fWeight:a?A:String(p||600),style:{color:Ne.err}},c?t:"Ag"),Le.createElement(PI,{variant:"err"},a&&D?`${t} (${MI(D)})`:t)),Le.createElement(e8,null,"\u2192"),Le.createElement(EI,null,Le.createElement(AI,{variant:"ok"},"Figma"),Le.createElement(Ix,{fSize:I,fWeight:a?C:String(p||600),style:{color:Ne.ok}},c?n:"Ag"),Le.createElement(PI,{variant:"ok"},a&&R?`${n} (${MI(R)})`:n)))))};function n8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/g);if(!t)return null;let n=t.map(r=>parseFloat(r));return n.length===1?{top:n[0],right:n[0],bottom:n[0],left:n[0]}:n.length===2?{top:n[0],right:n[1],bottom:n[0],left:n[1]}:n.length===3?{top:n[0],right:n[1],bottom:n[2],left:n[1]}:n.length>=4?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:null}function as(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function r8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function o8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var BI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function i8(e){if(BI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return BI.has(t)}var DI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=i8(e.property);return Le.createElement(Rj,null,Le.createElement(zj,null,"\u25BE Layer properties",t?"":" (from review)"),n?Le.createElement(t8,{...e}):Le.createElement(Yj,{...e}))};import qr from"react";import{styled as Yr}from"storybook/theming";var s8={color:{text:"#3b82f6",bg:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.25)"},border:{text:"#10b981",bg:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.25)"},spacing:{text:"#f97316",bg:"rgba(249, 115, 22, 0.1)",border:"rgba(249, 115, 22, 0.25)"},layout:{text:"#14b8a6",bg:"rgba(20, 184, 166, 0.1)",border:"rgba(20, 184, 166, 0.25)"},sizing:{text:"#8b5cf6",bg:"rgba(139, 92, 246, 0.1)",border:"rgba(139, 92, 246, 0.25)"},typography:{text:"#ec4899",bg:"rgba(236, 72, 153, 0.1)",border:"rgba(236, 72, 153, 0.25)"}},a8=Yr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),l8=Yr.div(({theme:e,category:t})=>{let n=s8[t||""]||{text:e.textMutedColor,bg:"rgba(148, 163, 184, 0.1)",border:"rgba(148, 163, 184, 0.2)"};return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",border:`1px solid ${n.border}`}}),c8=Yr.div(({status:e})=>{let n=(()=>{switch(e){case"pending":return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"};case"applied":return{bg:"rgba(245, 158, 11, 0.1)",text:"#d97706",dot:"#f59e0b"};case"verified":return{bg:"rgba(16, 185, 129, 0.1)",text:"#059669",dot:"#10b981"};case"failed":return{bg:"rgba(239, 68, 68, 0.1)",text:"#dc2626",dot:"#ef4444"};default:return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"}}})();return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:n.dot}}}),u8=Yr.div({fontSize:"11px",fontWeight:500,color:"#059669",backgroundColor:"rgba(16, 185, 129, 0.1)",padding:"2px 8px",borderRadius:"4px",border:"1px solid rgba(16, 185, 129, 0.2)",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#10b981"}}),p8=Yr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),d8=Yr.div({fontSize:"10px",fontWeight:600,color:"#0891b2",backgroundColor:"#ecfeff",padding:"2px 8px",borderRadius:"10px",border:"1px solid #0891b2",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F9E0}"',fontSize:"9px"}}),g8=Yr.div({fontSize:"10px",fontWeight:600,color:"#7c3aed",backgroundColor:"#ede9fe",padding:"2px 8px",borderRadius:"10px",border:"1px solid #7c3aed",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F50D}"',fontSize:"9px"}}),f8=Yr.div({fontSize:"10px",fontWeight:600,color:"#d97706",backgroundColor:"#fef3c7",padding:"2px 8px",borderRadius:"10px",border:"1px solid #d97706",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u26A0\uFE0F"',fontSize:"9px"}}),m8=Yr.div(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:600,color:e.color.negative,backgroundColor:e.background.negative,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${e.color.negative}`})),h8=Yr.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),x8=e=>{if(!e)return{};let t={};if(e.includes("+")){let n=e.split("+");for(let r of n)r.startsWith("programmatic-")?t.programmatic=r.replace("programmatic-","").replace("-detection",""):r==="ai"||r==="ai-review"?t.ai="AI Review":r==="ai-validation"&&(t.ai="AI Validation");return t}return e.startsWith("programmatic-")?t.programmatic=e.replace("programmatic-","").replace("-detection",""):e==="ai-review"?t.ai="AI Review":e==="ai-validation"&&(t.ai="AI Validation"),t},RI=({issue:e,modelDisplayName:t,showModel:n=!1,showDetection:r=!1,dominantDetector:o,showFilePath:i=!0,enableFilePath:s=!1,unreliable:a=!1,validationErrorMessage:u})=>{let c=x8(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),g=e.generatedFix?.filePath||e.file;return qr.createElement(a8,null,qr.createElement(l8,{category:e.type},e.type),e.status!=="pending"&&qr.createElement(c8,{status:e.status},e.status),n&&t&&qr.createElement(u8,null,t),d&&qr.createElement(p8,null,c.ai&&!l&&qr.createElement(d8,null,c.ai),c.programmatic&&qr.createElement(g8,null,"Pre-filter: ",c.programmatic)),a&&qr.createElement(f8,{title:u},"Unreliable"),e.dismissed&&qr.createElement(m8,null,"Dismissed"),i&&s&&g&&qr.createElement(h8,null,g))};import Kn from"react";import{styled as Ho}from"storybook/theming";var y8=e=>{if(!e)return null;let n=(typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e)).match(/#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/);return n?n[0]:null},b8=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",S8=Ho.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"2px",fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"8px",padding:"8px 10px",backgroundColor:e.background.app,borderRadius:"4px"})),Fx=Ho.div({display:"flex",gap:"8px",alignItems:"baseline"}),Ex=Ho.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),Ax=Ho.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),w8=Ho(Ax)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),v8=Ho(Ax)(({theme:e})=>({color:e.color.positive,fontWeight:600})),k8=Ho.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
92
+ `}),n}function KT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Yc(e,t){let n=XT(e,t),r=n.one(e,void 0),o=qT(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&("children"in i,i.children.push({type:"text",value:`
93
+ `},o)),i}function Kc(e,t){return e&&"run"in e?async function(n,r){let o=Yc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Yc(n,{file:r,...e||t})}}function dx(e){if(e)throw e}var Jc=Va(iI(),1);function Ia(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function gx(){let e=[],t={run:n,use:r};return t;function n(...o){let i=-1,s=o.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...o);function a(u,...c){let l=e[++i],d=-1;if(u){s(u);return}for(;++d<o.length;)(c[d]===null||c[d]===void 0)&&(c[d]=o[d]);o=c,l?sI(l,a)(...c):s(null,...c)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function sI(e,t){let n;return r;function r(...s){let a=e.length>s.length,u;a&&s.push(o);try{u=e.apply(this,s)}catch(c){let l=c;if(a&&n)throw l;return o(l)}a||(u&&u.then&&typeof u.then=="function"?u.then(i,o):u instanceof Error?o(u):i(u))}function o(s,...a){n||(n=!0,t(s,...a))}function i(s){o(null,s)}}var Mr={basename:C6,dirname:T6,extname:I6,join:F6,sep:"/"};function C6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Fa(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else s<0&&(i=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(r=o):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function T6(e){if(Fa(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function I6(e){Fa(e);let t=e.length,n=-1,r=0,o=-1,i=0,s;for(;t--;){let a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function F6(...e){let t=-1,n;for(;++t<e.length;)Fa(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":E6(n)}function E6(e){Fa(e);let t=e.codePointAt(0)===47,n=A6(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function A6(e,t){let n="",r=0,o=-1,i=0,s=-1,a,u;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(o===s-1||i===1))if(o!==s-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),o=s,i=0;continue}}else if(n.length>0){n="",r=0,o=s,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,s):n=e.slice(o+1,s),r=s-o-1;o=s,i=0}else a===46&&i>-1?i++:i=-1}return n}function Fa(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var aI={cwd:P6};function P6(){return"/"}function is(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function lI(e){if(typeof e=="string")e=new URL(e);else if(!is(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return L6(e)}function L6(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let r=t.codePointAt(n+2);if(r===70||r===102){let o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}var fx=["history","path","basename","stem","extname","dirname"],di=class{constructor(t){let n;t?is(t)?n={path:t}:typeof t=="string"||M6(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":aI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<fx.length;){let i=fx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let o;for(o in n)fx.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Mr.basename(this.path):void 0}set basename(t){hx(t,"basename"),mx(t,"basename"),this.path=Mr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Mr.dirname(this.path):void 0}set dirname(t){cI(this.basename,"dirname"),this.path=Mr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Mr.extname(this.path):void 0}set extname(t){if(mx(t,"extname"),cI(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Mr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){is(t)&&(t=lI(t)),hx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Mr.basename(this.path,this.extname):void 0}set stem(t){hx(t,"stem"),mx(t,"stem"),this.path=Mr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){let o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){let o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){let o=new Gt(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function mx(e,t){if(e&&e.includes(Mr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Mr.sep+"`")}function hx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function cI(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function M6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var uI=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var B6={}.hasOwnProperty,Sx=class e extends uI{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=gx()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,Jc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(bx("data",this.frozen),this.namespace[t]=n,this):B6.call(this.namespace,t)&&this.namespace[t]||void 0:t?(bx("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=Qc(t),r=this.parser||this.Parser;return xx("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),xx("process",this.parser||this.Parser),yx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Qc(t),u=r.parse(a);r.run(u,a,function(l,d,g){if(l||!d||!g)return c(l);let p=d,m=r.stringify(p,g);R6(m)?g.value=m:g.result=m,c(l,g)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),xx("processSync",this.parser||this.Parser),yx("processSync",this.compiler||this.Compiler),this.process(t,o),dI("processSync","process",n),r;function o(i,s){n=!0,dx(i),r=s}}run(t,n,r){pI(t),this.freeze();let o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(s,a){let u=Qc(n);o.run(t,u,c);function c(l,d,g){let p=d||t;l?a(l):s?s(p):r(void 0,p,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),dI("runSync","run",r),o;function i(s,a){dx(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Qc(n),o=this.compiler||this.Compiler;return yx("stringify",o),pI(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(bx("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[l,...d]=c;u(l,d)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(o.settings=(0,Jc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let d=c[l];i(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let d=-1,g=-1;for(;++d<r.length;)if(r[d][0]===c){g=d;break}if(g===-1)r.push([c,...l]);else if(l.length>0){let[p,...m]=l,v=r[g][1];Ia(v)&&Ia(p)&&(p=(0,Jc.default)(!0,v,p)),r[g]=[c,p,...m]}}}},wx=new Sx().freeze();function xx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bx(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function pI(e){if(!Ia(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function dI(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qc(e){return D6(e)?e:new di(e)}function D6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function R6(e){return typeof e=="string"||z6(e)}function z6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var $6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gI=[],fI={allowDangerousHtml:!0},U6=/^(https?|ircs?|mailto|xmpp)$/i,j6=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function vx(e){let t=H6(e),n=W6(e);return V6(t.runSync(t.parse(n),n),e)}function H6(e){let t=e.rehypePlugins||gI,n=e.remarkPlugins||gI,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...fI}:fI;return wx().use($c).use(n).use(Kc,r).use(t)}function W6(e){let t=e.children||"",n=new di;return typeof t=="string"?n.value=t:(""+t,void 0),n}function V6(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||mI;for(let l of j6)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+$6+l.id,void 0);return n&&i&&void 0,Ta(e,c),Nh(e,{Fragment:N6,components:o,ignoreInvalidStyle:!0,jsx:O6,jsxs:_6,passKeys:!0,passNode:!0});function c(l,d,g){if(l.type==="raw"&&g&&typeof d=="number")return s?g.children.splice(d,1):g.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in xa)if(Object.hasOwn(xa,p)&&Object.hasOwn(l.properties,p)){let m=l.properties[p],v=xa[p];(v===null||v.includes(l.tagName))&&(l.properties[p]=u(String(m||""),p,l))}}if(l.type==="element"){let p=n?!n.includes(l.tagName):i?i.includes(l.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(l,d,g)),p&&g&&typeof d=="number")return a&&l.children?g.children.splice(d,1,...l.children):g.children.splice(d,1),d}}}function mI(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||U6.test(e.slice(0,t))?e:""}Te();var q6=ss.div({display:"flex",flexDirection:"column",gap:"12px"}),Y6=ss.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),K6=ss.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),X6=ss(Fn)({padding:"6px 12px",fontSize:"12px"}),Q6=ss.div(({theme:e})=>({backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"12px",fontSize:"12px",color:e.color.defaultText,overflowY:"auto",maxHeight:"400px",lineHeight:"1.6","& h1, & h2, & h3, & h4":{marginTop:"16px",marginBottom:"8px",fontWeight:600,color:e.color.defaultText},"& h1":{fontSize:"18px"},"& h2":{fontSize:"16px"},"& h3":{fontSize:"14px"},"& h4":{fontSize:"13px"},"& p":{margin:"8px 0"},"& ul, & ol":{paddingLeft:"20px",margin:"8px 0"},"& li":{margin:"4px 0"},"& code":{backgroundColor:e.background.app,padding:"2px 4px",borderRadius:"3px",fontFamily:g1.fontMono,fontSize:"11px"},"& pre":{backgroundColor:e.background.app,padding:"8px",borderRadius:"4px",overflowX:"auto","& code":{backgroundColor:"transparent",padding:0}},"& strong":{fontWeight:600},"& blockquote":{borderLeft:`3px solid ${e.color.secondary}`,paddingLeft:"12px",margin:"8px 0",color:e.color.mediumdark}})),J6=ss.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),kx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ce(),[r,o]=G6(!1);if((n??t)!=="admin")return null;let s=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(a){console.error("Failed to copy:",a)}};return e?gi.createElement(q6,null,gi.createElement(Y6,null,gi.createElement(K6,null,"Full Prompt"),gi.createElement(X6,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),gi.createElement(Q6,null,gi.createElement(vx,null,e))):gi.createElement(J6,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import go,{useRef as Z6}from"react";import{styled as Br}from"storybook/theming";Te();var ej=Br.div({display:"flex",flexDirection:"column",gap:"8px"}),wge=Br.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"11px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"3px 10px",borderRadius:"12px",border:`1px solid ${o.border}`,whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:"6px"}}),tj=Br.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflowY:"auto",scrollBehavior:"smooth",padding:"6px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app})),nj=Br.div(({role:e,theme:t})=>({padding:"8px 10px",borderRadius:"4px",fontSize:"11px",lineHeight:"1.4",backgroundColor:e==="system"?t.background.hoverable:t.background.content,border:`1px solid ${t.appBorderColor}`,color:t.color.defaultText})),vge=Br.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),hI=Br.div(({theme:e})=>({whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"10px","& .section-header":{fontSize:"11px",fontWeight:700,color:e.color.secondary,marginTop:"8px",marginBottom:"4px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"6px",marginBottom:"2px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||se,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"11px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"1px 6px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"3px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||se,backgroundColor:e.background.warning||"#ffedd5"}})),rj=Br.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),oj=Br.div(({theme:e})=>({padding:"12px 16px",borderRadius:"8px",backgroundColor:e.background.positive||"#dcfce7",border:`1px solid ${e.color.positive||"#86efac"}`,color:e.color.positive||"#166534",fontSize:"13px",fontWeight:500,lineHeight:1.5,marginBottom:"12px"})),ij=Br.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),sj=Br.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),kge=Br.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function aj(e){let t=e;return t=t.replace(/^(?:\*?\*?)?(?:##?)?\s*SCORE:\s*\d+.*$/gm,""),t=t.replace(/^(ISSUES:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t}var Cx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ce(),s=Z6(null);if((i??o)!=="admin")return null;let u=r?n.find(m=>m.id===r):null,c=u?u.issues.length>0&&u.issues.every(m=>m.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(m=>m.role==="assistant"||m.role==="system"&&m.content.includes("auto-dismissed")),g=d.length===0&&!!t;if(d.length===0&&!g)return go.createElement(rj,null,"No AI response yet. The AI's analysis will appear here as it streams.");let p=d.length>0?d:[{role:"assistant",content:t}];return go.createElement(ej,null,l&&go.createElement(oj,null,go.createElement(ij,null,"Component Matches Design"),go.createElement(sj,null,c&&u?.issues.length?`All ${u.issues.length} issue${u.issues.length===1?"":"s"} identified by the AI ${u.issues.length===1?"was":"were"} validated as false positive${u.issues.length===1?"":"s"} and auto-dismissed.`:"No design discrepancies found. The implementation matches the Figma design.")),go.createElement(tj,{ref:s},p.map((m,v)=>go.createElement(nj,{key:v,role:m.role},m.role==="system"?go.createElement(hI,null,m.content):go.createElement(hI,{dangerouslySetInnerHTML:{__html:aj(m.content)}})))))};import br from"react";import{styled as jo}from"storybook/theming";Te();_e();var lj=jo.div({display:"flex",flexDirection:"column",gap:"12px"}),cj=jo.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),uj=jo.button(({theme:e,isActive:t,provider:n})=>{let o={anthropic:{background:"#D4A574",text:"#ffffff",hover:"#C49564"},openai:{background:e.color.positive||"#10b981",text:"#ffffff",hover:e.base==="dark"?"#34d399":"#059669"},google:{background:"#4285F4",text:"#ffffff",hover:"#3367D6"}}[n];return{display:"flex",alignItems:"center",gap:"6px",padding:"8px 16px",fontSize:"12px",fontWeight:600,color:t?o.text:e.textMutedColor,backgroundColor:t?o.background:"transparent",border:"none",borderRadius:"6px 6px 0 0",cursor:"pointer",whiteSpace:"nowrap",transition:"all 0.2s",opacity:t?1:.6,"&:hover":{opacity:1,backgroundColor:t?o.hover:e.background.hoverable}}}),xI=jo.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"10px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${o.border}`,whiteSpace:"nowrap"}}),pj=jo.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),yI=jo.div(({theme:e})=>({fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',color:e.color.defaultText,"& .section-header":{fontSize:"13px",fontWeight:700,color:e.color.secondary,marginTop:"12px",marginBottom:"6px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"10px",marginBottom:"4px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||se,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"14px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"2px 8px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"4px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||se,backgroundColor:e.background.warning||"#ffedd5"}})),bI=jo.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),dj=jo.div({width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite",display:"inline-block",marginLeft:"6px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}});function SI(e){let t=e;return t=t.replace(/^(ISSUES:|SCORE:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t=t.replace(/SCORE:\s*(\d+)/g,(n,r)=>{let o=parseInt(r,10);return`SCORE: <span class="${o>=80?"score":o>=60?"score score-medium":"score score-low"}">${r}</span>`}),t}function gj(e){let t=e.match(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-/g),n=t?t.length:0,r=e.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i),o=r?parseInt(r[1],10):null;return{issueCount:n,score:o}}var wI=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ce();if((i??o)!=="admin")return null;br.useEffect(()=>{e&&(b.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([l,d])=>{b.debug(`[ModelResultsTabs] ${l}:`,{hasStreamingMessages:!!d.streamingMessages,streamingMessagesLength:d.streamingMessages?.length||0,streamingMessagesPreview:d.streamingMessages?.[0]?.content?.substring(0,100),hasFullResponse:!!d.fullResponse,fullResponsePreview:d.fullResponse?.substring(0,100)})}))},[e]);let a=e&&Object.keys(e.byModel).length>0?Object.keys(e.byModel):r,u=e?.activeModelId||(a.length>0?a[0]:""),c=e?.byModel||{};return a.length===0?br.createElement(bI,null,"No models selected. Select multiple models to compare results."):br.createElement(lj,null,br.createElement(cj,null,a.map(l=>{let d=co.find(A=>A.id===l),g=c[l],m=gj(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),v=l===u;if(!d)return null;let I=t&&!g?.completed;return br.createElement(uj,{key:l,isActive:v,provider:d.provider,onClick:()=>n(l)},d.name,g&&m.issueCount>0&&br.createElement(xI,{variant:"issues",value:m.issueCount},m.issueCount," issues"),g&&m.score!==null&&br.createElement(xI,{variant:"score",value:m.score},"Score: ",m.score),I&&br.createElement(dj,null))})),br.createElement(pj,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>br.createElement(yI,{key:d,dangerouslySetInnerHTML:{__html:SI(l.content)}})):c[u]?.fullResponse?br.createElement(yI,{dangerouslySetInnerHTML:{__html:SI(c[u].fullResponse)}}):br.createElement(bI,null,t?`Waiting for ${co.find(l=>l.id===u)?.name}...`:`No response yet for ${co.find(l=>l.id===u)?.name}`)))};import Oe from"react";import{styled as Ft}from"storybook/theming";Te();_n();Te();import{useCallback as Tx}from"react";_e();function vI(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ce(),{sessionToken:r}=ke(),o=Tx(a=>{for(let u of n){let c=u.issues.find(l=>l.id===a);if(c)return c.dbId||c.id||null}return null},[n]),i=Tx((a,u)=>{e(a,u,"user");let c=o(a);if(!c){b.debug("[useIssuePersistence] Dismiss skipped server sync \u2014 no dbId for",a);return}if(!r){b.debug("[useIssuePersistence] Dismiss skipped \u2014 no session token");return}Zl(c,!0,u,"user",r).then(l=>{l.success||b.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=Tx(a=>{t(a);let u=o(a);if(!u){b.debug("[useIssuePersistence] Undismiss skipped server sync \u2014 no dbId for",a);return}if(!r){b.debug("[useIssuePersistence] Undismiss skipped \u2014 no session token");return}Zl(u,!1,void 0,"user",r).then(c=>{c.success||b.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import Y,{useMemo as RH,useState as zH,useEffect as NH}from"react";import{styled as st,keyframes as OH}from"storybook/theming";import Z,{useState as Px,useRef as T8,useCallback as _I,memo as I8}from"react";import{styled as Me}from"storybook/theming";import pt,{useState as kI}from"react";import{styled as Cn}from"storybook/theming";var fj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),mj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("polyline",{points:"12 6 12 12 16 14"})),hj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})),xj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})),yj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("path",{d:"M12 3l1.68 5.17L19 10l-5.32 1.83L12 17l-1.68-5.17L5 10l5.32-1.83z"}),pt.createElement("path",{d:"M5 3l.74 2.26L8 6l-2.26.74L5 9l-.74-2.26L2 6l2.26-.74z"}),pt.createElement("path",{d:"M19 15l.74 2.26L22 18l-2.26.74L19 21l-.74-2.26L16 18l2.26-.74z"})),CI=[{id:"false-positive",Icon:fj,label:"False positive",description:"The AI flagged something that isn't actually a design issue",color:"#9ca3af",bg:"rgba(156,163,175,0.15)"},{id:"planned",Icon:mj,label:"Planned",description:"Valid issue \u2014 logged and scheduled to fix in a future sprint",color:"#60a5fa",bg:"rgba(96,165,250,0.15)"},{id:"wont-fix",Icon:hj,label:"Won't fix",description:"Intentional deviation \u2014 design has approved this difference",color:"#fbbf24",bg:"rgba(251,191,36,0.15)"},{id:"no-figma-state",Icon:xj,label:"No Figma state",description:"No Figma frame exists for this specific story variant or state",color:"#a78bfa",bg:"rgba(167,139,250,0.15)"},{id:"design-pending",Icon:yj,label:"Design pending",description:"Code was built first \u2014 designer will add the Figma spec later",color:"#34d399",bg:"rgba(52,211,153,0.15)"}],bj=Cn.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999}),Sj=Cn.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"10px",padding:"24px",maxWidth:"480px",width:"90%",boxShadow:"0 10px 40px rgba(0,0,0,0.25)",border:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"20px"})),wj=Cn.div({display:"flex",flexDirection:"column",gap:"4px"}),vj=Cn.h3(({theme:e})=>({fontSize:"17px",fontWeight:700,color:e.color.defaultText,margin:0})),kj=Cn.p(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,margin:0,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Cj=Cn.div({display:"flex",flexDirection:"column",gap:"6px"}),Tj=Cn.button(({theme:e,selected:t,accentColor:n})=>({display:"flex",alignItems:"flex-start",gap:"12px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${t?n:e.appBorderColor}`,backgroundColor:t?`${n}10`:e.background.app,boxShadow:t?`0 0 0 1px ${n}`:"none",cursor:"pointer",textAlign:"left",width:"100%",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),Ij=Cn.div(({color:e,bg:t})=>({width:"36px",height:"36px",borderRadius:"7px",backgroundColor:t,color:e,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),Fj=Cn.div({display:"flex",flexDirection:"column",gap:"2px",minWidth:0,flex:1}),Ej=Cn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,lineHeight:"1.3"})),Aj=Cn.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,lineHeight:"1.4"})),Pj=Cn.div({display:"flex",flexDirection:"column",gap:"6px"}),Lj=Cn.label(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.defaultText})),Mj=Cn.textarea(({theme:e})=>({width:"100%",minHeight:"72px",padding:"8px 10px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary},"&::placeholder":{color:e.textMutedColor}})),Bj=Cn.div({display:"flex",justifyContent:"flex-end",gap:"8px"}),Dj=Cn.button(({theme:e,disabled:t,accentColor:n})=>({padding:"8px 18px",fontSize:"13px",fontWeight:600,borderRadius:"6px",border:"none",cursor:t?"not-allowed":"pointer",backgroundColor:t?e.color.medium:n||e.color.secondary,color:"#ffffff",opacity:t?.5:1,transition:"opacity 0.15s","&:hover":{opacity:t?.5:.85}})),TI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=kI(null),[s,a]=kI("");if(!e)return null;let u=CI.find(d=>d.id===o),c=()=>{o&&(n(o,s.trim()||void 0),i(null),a(""))},l=()=>{i(null),a(""),r()};return pt.createElement(bj,{onClick:d=>d.target===d.currentTarget&&l()},pt.createElement(Sj,null,pt.createElement(wj,null,pt.createElement(vj,null,"Dismiss Issue"),pt.createElement(kj,{title:t},t)),pt.createElement(Cj,{role:"radiogroup"},CI.map(({id:d,Icon:g,label:p,description:m,color:v,bg:I})=>pt.createElement(Tj,{key:d,selected:o===d,accentColor:v,onClick:()=>i(d),role:"radio","aria-checked":o===d},pt.createElement(Ij,{color:v,bg:I},pt.createElement(g,null)),pt.createElement(Fj,null,pt.createElement(Ej,null,p),pt.createElement(Aj,null,m))))),pt.createElement(Pj,null,pt.createElement(Lj,{htmlFor:"dismiss-note"},"Note (optional)"),pt.createElement(Mj,{id:"dismiss-note",placeholder:"Add context\u2026",value:s,onChange:d=>a(d.target.value),rows:3})),pt.createElement(Bj,null,pt.createElement(Nr,{onClick:l},"Cancel"),pt.createElement(Dj,{disabled:!o,accentColor:u?.color,onClick:c},"Dismiss Issue"))))};Te();import Le from"react";import{styled as it}from"storybook/theming";var Ne={outerBg:"#f0f0f0",borderBoxBg:"#fff",borderBoxStroke:"#999",paddingBg:"#dceefb",paddingStroke:"rgba(0,0,0,0.08)",contentStroke:"#888",text:"#333",dim:"#999",dash:"#aaa",blue:"#4a90d9",pink:"#e91e8c",err:"#d32f2f",errBg:"rgba(211,47,47,0.12)",ok:"#2e7d32"},Rj=it.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),zj=it.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),Nj=it.div({position:"relative",backgroundColor:Ne.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Wge=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Ne.dash,padding:"0 8px",height:18,fontSize:11}),Vge=it.div({position:"absolute",color:Ne.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Gge=it.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"1px 6px",borderRadius:3,zIndex:2,...e.side==="top"&&{top:4,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:4,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:4,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:4,top:"50%",transform:"translateY(-50%)"}})),qge=it.div(e=>({position:"absolute",backgroundColor:e.color,zIndex:1,...e.orient==="v"&&{width:1,left:"50%"},...e.orient==="h"&&{height:1,top:"50%"},...e.side==="top"&&{top:18,height:10},...e.side==="bottom"&&{bottom:18,height:10},...e.side==="left"&&{left:30,width:20},...e.side==="right"&&{right:30,width:20}})),Oj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Ne.errBg:Ne.borderBoxBg,border:`1px solid ${e.isErr?Ne.err:Ne.borderBoxStroke}`,borderRadius:6,padding:0})),_j=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Ne.text}),$j=it.span({fontWeight:500,fontSize:11}),Yge=it.span({color:Ne.dash}),Uj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Ne.errBg:Ne.paddingBg,border:`1px solid ${e.isErr?Ne.err:Ne.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),jj=it.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Ne.text,fontStyle:"italic"}),Zc=it.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Ne.err:Ne.text,fontWeight:e.isErr?700:400,...e.side==="top"&&{top:3,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:3,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:8,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:8,top:"50%",transform:"translateY(-50%)"}})),Hj=it.div(e=>({backgroundColor:e.isErr?Ne.errBg:"#fff",border:`1.5px dashed ${e.isErr?Ne.err:Ne.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Ne.err:Ne.text,fontWeight:e.isErr?600:400})),Wj=it.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Ne.dim,fontFamily:"monospace"}),Vj=it.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Ne.ok,padding:"4px 8px 6px"}),Kge=it.div({fontSize:11,fontWeight:600,color:Ne.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Xge=it.span({fontSize:12,color:Ne.dim}),Gj=it.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),qj=it.div({fontSize:9,color:Ne.dim,marginTop:2}),Yj=({property:e,currentValue:t,expectedValue:n,figmaContext:r,elementName:o})=>{let i=e.toLowerCase(),s=i.includes("padding"),a=i.includes("border")||i.includes("stroke")||i.includes("box-shadow"),u=i.includes("width")||i.includes("height")||i==="dimensions",c=i.includes("radius"),{figmaImageUrl:l}=ce(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?n8(n):null,m=d.padding||p||{top:0,right:0,bottom:0,left:0},v=d.strokeWeight??(a?as(n)??0:0),I=d.width??(u?r8(n)??"\u2014":"\u2014"),A=d.height??(u?o8(n)??"\u2014":"\u2014");return Le.createElement(Le.Fragment,null,Le.createElement(Nj,null,Le.createElement(Oj,{isErr:a},Le.createElement(_j,null,Le.createElement($j,null,"Border"),Le.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Ne.err:Ne.dim}},v)),Le.createElement(Uj,{isErr:s},Le.createElement(jj,null,"Padding"),Le.createElement(Zc,{side:"top",isErr:s},m.top),Le.createElement(Zc,{side:"right",isErr:s},m.right),Le.createElement(Zc,{side:"bottom",isErr:s},m.bottom),Le.createElement(Zc,{side:"left",isErr:s},m.left),Le.createElement(Hj,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Le.createElement(Gj,{src:l,alt:"Figma element"}),Le.createElement(qj,null,I," \xD7 ",A)))),Le.createElement(Wj,null,"border-box")),Le.createElement(Vj,null,"\u2192 ",n))},II=it.div({backgroundColor:Ne.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),Kj=it.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),Ix=it.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Ne.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),Xj=it.div({position:"absolute",border:`1.5px dashed ${Ne.err}`,pointerEvents:"none",zIndex:0}),Qj=it.div({position:"absolute",border:`1.5px dashed ${Ne.blue}`,pointerEvents:"none",zIndex:0}),FI=it.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"2px 6px",borderRadius:3,zIndex:2,whiteSpace:"nowrap",...e.side==="left"&&{left:-4,top:"50%",transform:"translate(-100%, -50%)"},...e.side==="right"&&{right:-4,top:"50%",transform:"translate(100%, -50%)"}})),Qge=it.div({fontSize:12,color:Ne.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),Jj=it.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),EI=it.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Ne.err:Ne.ok})),Zj=it.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),AI=it.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),PI=it.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Ne.err:Ne.ok})),LI=it.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Ne.err:Ne.ok,textDecoration:e.variant==="err"?"line-through":"none"})),e8=it.span({fontSize:16,color:Ne.dim,paddingBottom:20}),MI=it.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function BI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var t8=({property:e,currentValue:t,expectedValue:n,figmaContext:r})=>{let o=r||{},i=e.toLowerCase(),s=i.includes("size"),a=i.includes("weight"),u=i.includes("lineheight")||i.includes("line-height"),c=i.includes("text")||i.includes("content"),l=i.includes("family"),d=s||u,g=o.fontSize??(s?as(n):14),p=o.fontWeight??(a?as(n):600),v=(o.lineHeight??(u?as(n):null))||Math.round((g||14)*1.43),I=`${Math.min(Math.max(g||14,24),48)}px`;if(d)return Le.createElement(Le.Fragment,null,Le.createElement(II,null,Le.createElement(Kj,null,Le.createElement(Qj,{style:{top:-6,left:0,right:0,bottom:-6}}),Le.createElement(Xj,{style:{top:2,left:8,right:8,bottom:2}}),Le.createElement(FI,{color:s?Ne.err:"#7b3030",side:"left"},s?t:`${g}px`),Le.createElement(FI,{color:u?Ne.err:"#7b3030",side:"right"},u?t:`${v}px`),Le.createElement(Ix,{fSize:I,fWeight:String(p||600)},"Ag")),Le.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Le.createElement(MI,{color:Ne.err},"\u2508\u2508 font-size",s?" \u2717":""),Le.createElement(MI,{color:Ne.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Le.createElement(Jj,null,Le.createElement(EI,{variant:"err"},t),Le.createElement("span",{style:{color:Ne.dim}},"\u2192"),Le.createElement(EI,{variant:"ok"},n))));let A=a?t:String(p||600),C=a?n:A,D=as(t),R=as(n);return Le.createElement(Le.Fragment,null,Le.createElement(II,null,Le.createElement(Zj,null,Le.createElement(AI,null,Le.createElement(PI,{variant:"err"},"Current"),Le.createElement(Ix,{fSize:I,fWeight:a?A:String(p||600),style:{color:Ne.err}},c?t:"Ag"),Le.createElement(LI,{variant:"err"},a&&D?`${t} (${BI(D)})`:t)),Le.createElement(e8,null,"\u2192"),Le.createElement(AI,null,Le.createElement(PI,{variant:"ok"},"Figma"),Le.createElement(Ix,{fSize:I,fWeight:a?C:String(p||600),style:{color:Ne.ok}},c?n:"Ag"),Le.createElement(LI,{variant:"ok"},a&&R?`${n} (${BI(R)})`:n)))))};function n8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/g);if(!t)return null;let n=t.map(r=>parseFloat(r));return n.length===1?{top:n[0],right:n[0],bottom:n[0],left:n[0]}:n.length===2?{top:n[0],right:n[1],bottom:n[0],left:n[1]}:n.length===3?{top:n[0],right:n[1],bottom:n[2],left:n[1]}:n.length>=4?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:null}function as(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function r8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function o8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var DI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function i8(e){if(DI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return DI.has(t)}var RI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=i8(e.property);return Le.createElement(Rj,null,Le.createElement(zj,null,"\u25BE Layer properties",t?"":" (from review)"),n?Le.createElement(t8,{...e}):Le.createElement(Yj,{...e}))};import qr from"react";import{styled as Yr}from"storybook/theming";var s8={color:{text:"#3b82f6",bg:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.25)"},border:{text:"#10b981",bg:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.25)"},spacing:{text:"#f97316",bg:"rgba(249, 115, 22, 0.1)",border:"rgba(249, 115, 22, 0.25)"},layout:{text:"#14b8a6",bg:"rgba(20, 184, 166, 0.1)",border:"rgba(20, 184, 166, 0.25)"},sizing:{text:"#8b5cf6",bg:"rgba(139, 92, 246, 0.1)",border:"rgba(139, 92, 246, 0.25)"},typography:{text:"#ec4899",bg:"rgba(236, 72, 153, 0.1)",border:"rgba(236, 72, 153, 0.25)"}},a8=Yr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),l8=Yr.div(({theme:e,category:t})=>{let n=s8[t||""]||{text:e.textMutedColor,bg:"rgba(148, 163, 184, 0.1)",border:"rgba(148, 163, 184, 0.2)"};return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",border:`1px solid ${n.border}`}}),c8=Yr.div(({status:e})=>{let n=(()=>{switch(e){case"pending":return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"};case"applied":return{bg:"rgba(245, 158, 11, 0.1)",text:"#d97706",dot:"#f59e0b"};case"verified":return{bg:"rgba(16, 185, 129, 0.1)",text:"#059669",dot:"#10b981"};case"failed":return{bg:"rgba(239, 68, 68, 0.1)",text:"#dc2626",dot:"#ef4444"};default:return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"}}})();return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:n.dot}}}),u8=Yr.div({fontSize:"11px",fontWeight:500,color:"#059669",backgroundColor:"rgba(16, 185, 129, 0.1)",padding:"2px 8px",borderRadius:"4px",border:"1px solid rgba(16, 185, 129, 0.2)",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#10b981"}}),p8=Yr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),d8=Yr.div({fontSize:"10px",fontWeight:600,color:"#0891b2",backgroundColor:"#ecfeff",padding:"2px 8px",borderRadius:"10px",border:"1px solid #0891b2",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F9E0}"',fontSize:"9px"}}),g8=Yr.div({fontSize:"10px",fontWeight:600,color:"#7c3aed",backgroundColor:"#ede9fe",padding:"2px 8px",borderRadius:"10px",border:"1px solid #7c3aed",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F50D}"',fontSize:"9px"}}),f8=Yr.div({fontSize:"10px",fontWeight:600,color:"#d97706",backgroundColor:"#fef3c7",padding:"2px 8px",borderRadius:"10px",border:"1px solid #d97706",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u26A0\uFE0F"',fontSize:"9px"}}),m8=Yr.div(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:600,color:e.color.negative,backgroundColor:e.background.negative,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${e.color.negative}`})),h8=Yr.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),x8=e=>{if(!e)return{};let t={};if(e.includes("+")){let n=e.split("+");for(let r of n)r.startsWith("programmatic-")?t.programmatic=r.replace("programmatic-","").replace("-detection",""):r==="ai"||r==="ai-review"?t.ai="AI Review":r==="ai-validation"&&(t.ai="AI Validation");return t}return e.startsWith("programmatic-")?t.programmatic=e.replace("programmatic-","").replace("-detection",""):e==="ai-review"?t.ai="AI Review":e==="ai-validation"&&(t.ai="AI Validation"),t},zI=({issue:e,modelDisplayName:t,showModel:n=!1,showDetection:r=!1,dominantDetector:o,showFilePath:i=!0,enableFilePath:s=!1,unreliable:a=!1,validationErrorMessage:u})=>{let c=x8(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),g=e.generatedFix?.filePath||e.file;return qr.createElement(a8,null,qr.createElement(l8,{category:e.type},e.type),e.status!=="pending"&&qr.createElement(c8,{status:e.status},e.status),n&&t&&qr.createElement(u8,null,t),d&&qr.createElement(p8,null,c.ai&&!l&&qr.createElement(d8,null,c.ai),c.programmatic&&qr.createElement(g8,null,"Pre-filter: ",c.programmatic)),a&&qr.createElement(f8,{title:u},"Unreliable"),e.dismissed&&qr.createElement(m8,null,"Dismissed"),i&&s&&g&&qr.createElement(h8,null,g))};import Kn from"react";import{styled as Ho}from"storybook/theming";var y8=e=>{if(!e)return null;let n=(typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e)).match(/#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/);return n?n[0]:null},b8=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",S8=Ho.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"2px",fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"8px",padding:"8px 10px",backgroundColor:e.background.app,borderRadius:"4px"})),Fx=Ho.div({display:"flex",gap:"8px",alignItems:"baseline"}),Ex=Ho.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),Ax=Ho.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),w8=Ho(Ax)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),v8=Ho(Ax)(({theme:e})=>({color:e.color.positive,fontWeight:600})),k8=Ho.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
94
94
  linear-gradient(${e}, ${e}),
95
95
  linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.08) 75%),
96
96
  linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.08) 75%)
97
- `,backgroundSize:"100% 100%, 6px 6px, 6px 6px",backgroundPosition:"0 0, 0 0, 3px 3px",border:"1px solid rgba(0, 0, 0, 0.15)",marginRight:"6px",verticalAlign:"middle",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.15)"})),C8=Ho.span({display:"flex",alignItems:"center"}),zI=({value:e,isStrikethrough:t=!1})=>{let n=y8(e),r=b8(e),o=t?w8:v8;return n?Kn.createElement(C8,null,Kn.createElement(k8,{color:n,title:`Color: ${n}`}),Kn.createElement(o,null,r)):Kn.createElement(o,null,r)},NI=({property:e,currentValue:t,suggestedValue:n})=>Kn.createElement(S8,null,Kn.createElement(Fx,null,Kn.createElement(Ex,null,"Property"),Kn.createElement(Ax,{style:{fontWeight:600}},e)),t!=null&&t!==""&&Kn.createElement(Fx,null,Kn.createElement(Ex,null,"Current"),Kn.createElement(zI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&Kn.createElement(Fx,null,Kn.createElement(Ex,null,"Expected"),Kn.createElement(zI,{value:n,isStrikethrough:!1})));Te();var _I=new Set(["dimensions","width","height","minWidth","minHeight","maxWidth","maxHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","padding-top","padding-right","padding-bottom","padding-left","border","borderWidth","border-width","border / box-shadow","borderRadius","border-radius","gap","rowGap","columnGap"]);function F8(e){if(_I.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return _I.has(t)}var E8=Me.div(({theme:e,dismissed:t,fixApplied:n})=>({padding:"14px 16px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:t?e.background.negative:n?e.background.positive:"transparent",opacity:t?.7:n?.6:1,position:"relative",transition:"background-color 0.15s","&:hover":{backgroundColor:t||n?void 0:e.base==="dark"?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.02)"},"&:first-of-type":{borderTop:"none"}})),gfe=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),A8=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),P8=Me.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),L8=Me.input(({theme:e})=>({appearance:"none",WebkitAppearance:"none",marginTop:"2px",width:"14px",height:"14px",cursor:"pointer",flexShrink:0,border:`1.5px solid ${e.color.mediumdark||"#cbd5e1"}`,borderRadius:"3px",backgroundColor:e.background.content,position:"relative",transition:"all 0.15s","&:hover":{borderColor:se},"&:checked":{backgroundColor:se,borderColor:se},"&:checked::after":{content:'""',position:"absolute",left:"3px",top:"0px",width:"4px",height:"8px",border:"solid #fff",borderWidth:"0 2px 2px 0",transform:"rotate(45deg)"},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),M8=Me.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark,"& svg":{width:"16px",height:"16px"}})),B8=Me.span(({theme:e,severity:t})=>({flexShrink:0,fontSize:"10px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.04em",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark})),ffe=Me.div({flex:1,minWidth:0}),mfe=Me.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),D8=Me.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Lx=Me.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"0",fontSize:"11px",fontWeight:400,color:e.textMutedColor,backgroundColor:"transparent",border:"none",cursor:"pointer",transition:"color 0.15s","&:hover":{color:e.color.defaultText},"& svg":{width:"11px",height:"11px"}})),R8=Me(Lx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),hfe=Me.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),xfe=Me.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),z8=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),yfe=Me.pre(({theme:e})=>({fontSize:"13px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"12px",borderRadius:"4px",overflowX:"auto",margin:"8px 0 0 0",lineHeight:"1.5"})),bfe=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),N8=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginTop:"6px",fontStyle:"italic",display:"flex",alignItems:"baseline",gap:"4px","& strong":{fontStyle:"normal",fontWeight:600,color:"#7c3aed",fontSize:"10px"}})),O8=Me.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${se}`})),_8=Me.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:se,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),$8=Me.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr auto auto",gap:"8px",alignItems:"center",padding:"4px 0",fontSize:"11px",borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),U8=Me.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),$I=Me.span(({theme:e,type:t})=>({fontFamily:"monospace",fontSize:"10px",padding:"2px 6px",borderRadius:"3px",backgroundColor:t==="current"?e.background.negative:e.background.positive,color:t==="current"?e.color.negative:e.color.positive,textDecoration:t==="current"?"line-through":"none"})),Sfe=Me.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),j8=Me(En)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),wfe=Me(j8)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),H8=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontStyle:"italic",marginTop:"8px",padding:"8px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${e.color.negative}`})),UI=Me.div(({theme:e})=>({fontSize:"11px",color:e.color.negative,backgroundColor:e.background.negative,padding:"10px",borderRadius:"4px",marginTop:"10px",borderLeft:`3px solid ${e.color.negative}`,fontFamily:"monospace",lineHeight:"1.5"})),W8=Me.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),V8=Me.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),G8=Me.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),q8=Me.span(({theme:e,confidence:t})=>({padding:"4px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,backgroundColor:t>=.8?e.background.positive:t>=.6?e.background.warning:e.background.negative,color:t>=.8?e.color.positive:t>=.6?e.color.warning:e.color.negative})),jI=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),HI=Me.details({marginBottom:"8px"}),WI=Me.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),Y8=Me.pre(({theme:e})=>({fontSize:"11px",fontFamily:"monospace",backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"10px",borderRadius:"4px",overflowX:"auto",margin:0,lineHeight:"1.5",maxHeight:"300px",overflowY:"auto"})),K8=Me.div({display:"flex",gap:"8px",marginTop:"8px"}),X8=Me(Fn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),Q8=Me(Nr)({padding:"6px 12px",fontSize:"12px"}),vfe=Me(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),kfe=Me.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),J8=Me.div({display:"flex",alignItems:"center",gap:"12px"}),Z8=Me.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:se,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),eH=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Cfe=Me.div(({theme:e,width:t="100%"})=>({height:"10px",backgroundColor:e.background.app,borderRadius:"4px",width:t,animation:"pulse 1.5s ease-in-out infinite","@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}}})),tH=Me.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",fontSize:"11px",fontFamily:"monospace",lineHeight:"1.5",marginTop:"8px"})),VI=Me.div(({theme:e,side:t})=>({backgroundColor:t==="old"?e.background.negative:e.background.positive,borderRight:t==="old"?`1px solid ${e.appBorderColor}`:"none",minWidth:0,overflow:"hidden"})),GI=Me.div(({theme:e,side:t})=>({padding:"6px 8px",fontWeight:600,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="old"?e.background.negative:e.background.positive,color:t==="old"?e.color.negative:e.color.positive,borderBottom:`1px solid ${e.appBorderColor}`})),qI=Me.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),YI=Me.div(({theme:e,type:t})=>{let n="transparent",r=e.color.defaultText;return t==="removed"?(n=e.background.negative,r=e.color.negative):t==="added"?(n=e.background.positive,r=e.color.positive):t==="empty"&&(n=e.background.app,r=e.textMutedColor),{padding:"2px 8px",backgroundColor:n,color:r,whiteSpace:"pre",minHeight:"20px",borderBottom:"1px solid rgba(0, 0, 0, 0.05)"}}),KI=Me.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),XI=e=>{let t=e.split(`
98
- `),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(!o.startsWith("@@"))if(o.startsWith("-"))n.push({oldLine:{type:"removed",content:o.substring(1)},newLine:{type:"empty",content:""}});else if(o.startsWith("+"))n.push({oldLine:{type:"empty",content:""},newLine:{type:"added",content:o.substring(1)}});else{let i=o.startsWith(" ")?o.substring(1):o;n.push({oldLine:{type:"context",content:i},newLine:{type:"context",content:i}})}}return n},nH=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},rH=e=>({"claude-sonnet-4-6":"Sonnet 4.6","claude-sonnet-4-20250514":"Sonnet 4","claude-sonnet-3-5-20240620":"Sonnet 3.5","claude-3-opus-20240229":"Opus 3","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5.2-chat-latest":"GPT-5.2 Instant","gpt-4o":"GPT-4o"})[e]||e,QI=I8(({issue:e,modelId:t,dominantDetector:n,showFilePath:r=!0,onToggleSelection:o,onDismiss:i,onUndismiss:s,onApplyFix:a,onRegenerateFix:u})=>{let{featureFlags:c,userRole:l,setHoveredIssueId:d}=ce(),[g,p]=Px(!1),[m,k]=Px(!1),[I,A]=Px(!1),C=T8(null),D=OI(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{d(e.id),A(!0)},100)},[e.id,d]),R=OI(()=>{C.current&&clearTimeout(C.current),C.current=null,d(null),A(!1)},[d]),_=()=>{e.dismissed?s(e.id):p(!0)},P=(v,w)=>{let E=w?`${v}: ${w}`:v;i(e.id,E),p(!1)},N=async()=>{let v=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&v.push(`Property: ${e.property}`),e.currentValue&&v.push(`Current: ${e.currentValue}`),e.suggestedValue&&v.push(`Expected: ${e.suggestedValue}`),e.file&&v.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&v.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&v.push(`
97
+ `,backgroundSize:"100% 100%, 6px 6px, 6px 6px",backgroundPosition:"0 0, 0 0, 3px 3px",border:"1px solid rgba(0, 0, 0, 0.15)",marginRight:"6px",verticalAlign:"middle",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.15)"})),C8=Ho.span({display:"flex",alignItems:"center"}),NI=({value:e,isStrikethrough:t=!1})=>{let n=y8(e),r=b8(e),o=t?w8:v8;return n?Kn.createElement(C8,null,Kn.createElement(k8,{color:n,title:`Color: ${n}`}),Kn.createElement(o,null,r)):Kn.createElement(o,null,r)},OI=({property:e,currentValue:t,suggestedValue:n})=>Kn.createElement(S8,null,Kn.createElement(Fx,null,Kn.createElement(Ex,null,"Property"),Kn.createElement(Ax,{style:{fontWeight:600}},e)),t!=null&&t!==""&&Kn.createElement(Fx,null,Kn.createElement(Ex,null,"Current"),Kn.createElement(NI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&Kn.createElement(Fx,null,Kn.createElement(Ex,null,"Expected"),Kn.createElement(NI,{value:n,isStrikethrough:!1})));Te();var $I=new Set(["dimensions","width","height","minWidth","minHeight","maxWidth","maxHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","padding-top","padding-right","padding-bottom","padding-left","border","borderWidth","border-width","border / box-shadow","borderRadius","border-radius","gap","rowGap","columnGap"]);function F8(e){if($I.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return $I.has(t)}var E8=Me.div(({theme:e,dismissed:t,fixApplied:n})=>({padding:"14px 16px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:t?e.background.negative:n?e.background.positive:"transparent",opacity:t?.7:n?.6:1,position:"relative",transition:"background-color 0.15s","&:hover":{backgroundColor:t||n?void 0:e.base==="dark"?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.02)"},"&:first-of-type":{borderTop:"none"}})),gfe=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),A8=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),P8=Me.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),L8=Me.input(({theme:e})=>({appearance:"none",WebkitAppearance:"none",marginTop:"2px",width:"14px",height:"14px",cursor:"pointer",flexShrink:0,border:`1.5px solid ${e.color.mediumdark||"#cbd5e1"}`,borderRadius:"3px",backgroundColor:e.background.content,position:"relative",transition:"all 0.15s","&:hover":{borderColor:se},"&:checked":{backgroundColor:se,borderColor:se},"&:checked::after":{content:'""',position:"absolute",left:"3px",top:"0px",width:"4px",height:"8px",border:"solid #fff",borderWidth:"0 2px 2px 0",transform:"rotate(45deg)"},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),M8=Me.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark,"& svg":{width:"16px",height:"16px"}})),B8=Me.span(({theme:e,severity:t})=>({flexShrink:0,fontSize:"10px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.04em",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark})),ffe=Me.div({flex:1,minWidth:0}),mfe=Me.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),D8=Me.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Lx=Me.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"0",fontSize:"11px",fontWeight:400,color:e.textMutedColor,backgroundColor:"transparent",border:"none",cursor:"pointer",transition:"color 0.15s","&:hover":{color:e.color.defaultText},"& svg":{width:"11px",height:"11px"}})),R8=Me(Lx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),hfe=Me.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),xfe=Me.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),z8=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),yfe=Me.pre(({theme:e})=>({fontSize:"13px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"12px",borderRadius:"4px",overflowX:"auto",margin:"8px 0 0 0",lineHeight:"1.5"})),bfe=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),N8=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginTop:"6px",fontStyle:"italic",display:"flex",alignItems:"baseline",gap:"4px","& strong":{fontStyle:"normal",fontWeight:600,color:"#7c3aed",fontSize:"10px"}})),O8=Me.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${se}`})),_8=Me.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:se,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),$8=Me.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr auto auto",gap:"8px",alignItems:"center",padding:"4px 0",fontSize:"11px",borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),U8=Me.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),UI=Me.span(({theme:e,type:t})=>({fontFamily:"monospace",fontSize:"10px",padding:"2px 6px",borderRadius:"3px",backgroundColor:t==="current"?e.background.negative:e.background.positive,color:t==="current"?e.color.negative:e.color.positive,textDecoration:t==="current"?"line-through":"none"})),Sfe=Me.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),j8=Me(En)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),wfe=Me(j8)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),H8=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontStyle:"italic",marginTop:"8px",padding:"8px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${e.color.negative}`})),jI=Me.div(({theme:e})=>({fontSize:"11px",color:e.color.negative,backgroundColor:e.background.negative,padding:"10px",borderRadius:"4px",marginTop:"10px",borderLeft:`3px solid ${e.color.negative}`,fontFamily:"monospace",lineHeight:"1.5"})),W8=Me.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),V8=Me.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),G8=Me.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),q8=Me.span(({theme:e,confidence:t})=>({padding:"4px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,backgroundColor:t>=.8?e.background.positive:t>=.6?e.background.warning:e.background.negative,color:t>=.8?e.color.positive:t>=.6?e.color.warning:e.color.negative})),HI=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),WI=Me.details({marginBottom:"8px"}),VI=Me.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),Y8=Me.pre(({theme:e})=>({fontSize:"11px",fontFamily:"monospace",backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"10px",borderRadius:"4px",overflowX:"auto",margin:0,lineHeight:"1.5",maxHeight:"300px",overflowY:"auto"})),K8=Me.div({display:"flex",gap:"8px",marginTop:"8px"}),X8=Me(Fn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),Q8=Me(Nr)({padding:"6px 12px",fontSize:"12px"}),vfe=Me(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),kfe=Me.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),J8=Me.div({display:"flex",alignItems:"center",gap:"12px"}),Z8=Me.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:se,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),eH=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Cfe=Me.div(({theme:e,width:t="100%"})=>({height:"10px",backgroundColor:e.background.app,borderRadius:"4px",width:t,animation:"pulse 1.5s ease-in-out infinite","@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}}})),tH=Me.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",fontSize:"11px",fontFamily:"monospace",lineHeight:"1.5",marginTop:"8px"})),GI=Me.div(({theme:e,side:t})=>({backgroundColor:t==="old"?e.background.negative:e.background.positive,borderRight:t==="old"?`1px solid ${e.appBorderColor}`:"none",minWidth:0,overflow:"hidden"})),qI=Me.div(({theme:e,side:t})=>({padding:"6px 8px",fontWeight:600,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="old"?e.background.negative:e.background.positive,color:t==="old"?e.color.negative:e.color.positive,borderBottom:`1px solid ${e.appBorderColor}`})),YI=Me.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),KI=Me.div(({theme:e,type:t})=>{let n="transparent",r=e.color.defaultText;return t==="removed"?(n=e.background.negative,r=e.color.negative):t==="added"?(n=e.background.positive,r=e.color.positive):t==="empty"&&(n=e.background.app,r=e.textMutedColor),{padding:"2px 8px",backgroundColor:n,color:r,whiteSpace:"pre",minHeight:"20px",borderBottom:"1px solid rgba(0, 0, 0, 0.05)"}}),XI=Me.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),QI=e=>{let t=e.split(`
98
+ `),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(!o.startsWith("@@"))if(o.startsWith("-"))n.push({oldLine:{type:"removed",content:o.substring(1)},newLine:{type:"empty",content:""}});else if(o.startsWith("+"))n.push({oldLine:{type:"empty",content:""},newLine:{type:"added",content:o.substring(1)}});else{let i=o.startsWith(" ")?o.substring(1):o;n.push({oldLine:{type:"context",content:i},newLine:{type:"context",content:i}})}}return n},nH=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},rH=e=>({"claude-sonnet-4-6":"Sonnet 4.6","claude-sonnet-4-20250514":"Sonnet 4","claude-sonnet-3-5-20240620":"Sonnet 3.5","claude-3-opus-20240229":"Opus 3","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5.2-chat-latest":"GPT-5.2 Instant","gpt-4o":"GPT-4o"})[e]||e,JI=I8(({issue:e,modelId:t,dominantDetector:n,showFilePath:r=!0,onToggleSelection:o,onDismiss:i,onUndismiss:s,onApplyFix:a,onRegenerateFix:u})=>{let{featureFlags:c,userRole:l,setHoveredIssueId:d}=ce(),[g,p]=Px(!1),[m,v]=Px(!1),[I,A]=Px(!1),C=T8(null),D=_I(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{d(e.id),A(!0)},100)},[e.id,d]),R=_I(()=>{C.current&&clearTimeout(C.current),C.current=null,d(null),A(!1)},[d]),_=()=>{e.dismissed?s(e.id):p(!0)},P=(k,w)=>{let E=w?`${k}: ${w}`:k;i(e.id,E),p(!1)},N=async()=>{let k=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&k.push(`Property: ${e.property}`),e.currentValue&&k.push(`Current: ${e.currentValue}`),e.suggestedValue&&k.push(`Expected: ${e.suggestedValue}`),e.file&&k.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&k.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&k.push(`
99
99
  Suggested code:
100
100
  \`\`\`
101
101
  ${e.suggestedCode}
102
- \`\`\``),e.generatedFix){let E=e.generatedFix;if(v.push(`
103
- --- AI-Generated Fix ---`),v.push(`Status: ${E.status}`),E.confidence!==void 0){let f=E.confidence>1?E.confidence:Math.round(E.confidence*100);v.push(`Confidence: ${f}%`)}E.strategy&&v.push(`Strategy: ${E.strategy}`),E.filePath&&v.push(`Target file: ${E.filePath}`),E.code&&v.push(`
102
+ \`\`\``),e.generatedFix){let E=e.generatedFix;if(k.push(`
103
+ --- AI-Generated Fix ---`),k.push(`Status: ${E.status}`),E.confidence!==void 0){let f=E.confidence>1?E.confidence:Math.round(E.confidence*100);k.push(`Confidence: ${f}%`)}E.strategy&&k.push(`Strategy: ${E.strategy}`),E.filePath&&k.push(`Target file: ${E.filePath}`),E.code&&k.push(`
104
104
  Generated code:
105
105
  \`\`\`
106
106
  ${E.code}
107
- \`\`\``),E.diffPreview&&v.push(`
107
+ \`\`\``),E.diffPreview&&k.push(`
108
108
  Diff:
109
109
  \`\`\`diff
110
110
  ${E.diffPreview}
111
- \`\`\``),E.error&&v.push(`Error: ${E.error}`)}let w=v.filter(Boolean).join(`
112
- `);try{await navigator.clipboard.writeText(w),k(!0),setTimeout(()=>k(!1),2e3)}catch(E){console.error("Failed to copy:",E)}},x=e.generatedFix?.status==="applied";return Z.createElement(Z.Fragment,null,Z.createElement(E8,{dismissed:!!e.dismissed,fixApplied:x,onMouseEnter:D,onMouseLeave:R},Z.createElement(A8,null,Z.createElement(L8,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),Z.createElement(M8,{severity:e.severity},e.severity==="critical"?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("circle",{cx:"12",cy:"12",r:"10"}),Z.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),Z.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),Z.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),Z.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("circle",{cx:"12",cy:"12",r:"10"}),Z.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),Z.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),Z.createElement(B8,{severity:e.severity},e.severity),Z.createElement(P8,null,e.title),Z.createElement(D8,null,Z.createElement(Lx,{onClick:N,title:"Copy issue details"},m?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("polyline",{points:"20 6 9 17 4 12"})):Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),Z.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),"Copy"),e.dismissed?Z.createElement(Lx,{onClick:_,title:"Restore issue"},Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("polyline",{points:"1 4 1 10 7 10"}),Z.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):Z.createElement(R8,{onClick:_,title:"Dismiss issue"},Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Z.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),Z.createElement(RI,{issue:e,modelDisplayName:rH(t),showModel:c.enableModelSelection,showDetection:l==="admin",dominantDetector:n,showFilePath:r,enableFilePath:c.enableFixGeneration,unreliable:e._unreliable,validationErrorMessage:e._validationError?.message}),e.description&&e.description!==e.title&&Z.createElement(z8,null,e.description),e.property&&Z.createElement(NI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&I&&e.property&&e.currentValue&&e.suggestedValue&&F8(e.property)&&Z.createElement(DI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&Z.createElement(N8,null,Z.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&Z.createElement(O8,null,Z.createElement(_8,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((v,w)=>Z.createElement($8,{key:`${v.property}-${w}`},Z.createElement(U8,null,v.property),Z.createElement($I,{type:"current"},v.currentValue),Z.createElement($I,{type:"suggested"},v.suggestedValue)))),e.dismissed&&Z.createElement(H8,null,Z.createElement("strong",null,"Filtered by:")," ",nH(e.dismissedBy),e.dismissReason&&Z.createElement(Z.Fragment,null,Z.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&Z.createElement(UI,null,Z.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&Z.createElement(W8,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?Z.createElement(J8,{style:{margin:0}},Z.createElement(Z8,null),Z.createElement(eH,{style:{margin:0}},"Generating fix...")):Z.createElement(Z.Fragment,null,Z.createElement(V8,null,Z.createElement(G8,null,"AI-Generated Fix"),Z.createElement(q8,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&Z.createElement(jI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&Z.createElement(jI,{style:{fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?Z.createElement(HI,null,Z.createElement(WI,null,"View Diff"),Z.createElement(tH,null,Z.createElement(VI,{side:"old"},Z.createElement(GI,{side:"old"},"Old"),Z.createElement(qI,null,XI(e.generatedFix.diffPreview).map((v,w)=>Z.createElement(YI,{key:`old-${w}`,type:v.oldLine.type},v.oldLine.content||"\xA0")))),Z.createElement(VI,{side:"new"},Z.createElement(GI,{side:"new"},"New"),Z.createElement(qI,null,XI(e.generatedFix.diffPreview).map((v,w)=>Z.createElement(YI,{key:`new-${w}`,type:v.newLine.type},v.newLine.content||"\xA0")))))):e.generatedFix.code&&Z.createElement(HI,null,Z.createElement(WI,null,"View Generated Code"),Z.createElement(Y8,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&Z.createElement(UI,null,Z.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&Z.createElement(K8,null,Z.createElement(X8,{onClick:()=>a(e.id)},"Apply Fix"),u&&Z.createElement(Q8,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&Z.createElement(KI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&Z.createElement(KI,{status:"applied"},"\u2713 Fix applied successfully")))),Z.createElement(CI,{isOpen:g,issueTitle:e.title,onConfirm:P,onCancel:()=>p(!1)}))});import Mx from"react";import{styled as Bx,keyframes as oH}from"storybook/theming";var iH=oH`
111
+ \`\`\``),E.error&&k.push(`Error: ${E.error}`)}let w=k.filter(Boolean).join(`
112
+ `);try{await navigator.clipboard.writeText(w),v(!0),setTimeout(()=>v(!1),2e3)}catch(E){console.error("Failed to copy:",E)}},x=e.generatedFix?.status==="applied";return Z.createElement(Z.Fragment,null,Z.createElement(E8,{dismissed:!!e.dismissed,fixApplied:x,onMouseEnter:D,onMouseLeave:R},Z.createElement(A8,null,Z.createElement(L8,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),Z.createElement(M8,{severity:e.severity},e.severity==="critical"?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("circle",{cx:"12",cy:"12",r:"10"}),Z.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),Z.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),Z.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),Z.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("circle",{cx:"12",cy:"12",r:"10"}),Z.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),Z.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),Z.createElement(B8,{severity:e.severity},e.severity),Z.createElement(P8,null,e.title),Z.createElement(D8,null,Z.createElement(Lx,{onClick:N,title:"Copy issue details"},m?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("polyline",{points:"20 6 9 17 4 12"})):Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),Z.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),"Copy"),e.dismissed?Z.createElement(Lx,{onClick:_,title:"Restore issue"},Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("polyline",{points:"1 4 1 10 7 10"}),Z.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):Z.createElement(R8,{onClick:_,title:"Dismiss issue"},Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Z.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),Z.createElement(zI,{issue:e,modelDisplayName:rH(t),showModel:c.enableModelSelection,showDetection:l==="admin",dominantDetector:n,showFilePath:r,enableFilePath:c.enableFixGeneration,unreliable:e._unreliable,validationErrorMessage:e._validationError?.message}),e.description&&e.description!==e.title&&Z.createElement(z8,null,e.description),e.property&&Z.createElement(OI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&I&&e.property&&e.currentValue&&e.suggestedValue&&F8(e.property)&&Z.createElement(RI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&Z.createElement(N8,null,Z.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&Z.createElement(O8,null,Z.createElement(_8,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((k,w)=>Z.createElement($8,{key:`${k.property}-${w}`},Z.createElement(U8,null,k.property),Z.createElement(UI,{type:"current"},k.currentValue),Z.createElement(UI,{type:"suggested"},k.suggestedValue)))),e.dismissed&&Z.createElement(H8,null,Z.createElement("strong",null,"Filtered by:")," ",nH(e.dismissedBy),e.dismissReason&&Z.createElement(Z.Fragment,null,Z.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&Z.createElement(jI,null,Z.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&Z.createElement(W8,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?Z.createElement(J8,{style:{margin:0}},Z.createElement(Z8,null),Z.createElement(eH,{style:{margin:0}},"Generating fix...")):Z.createElement(Z.Fragment,null,Z.createElement(V8,null,Z.createElement(G8,null,"AI-Generated Fix"),Z.createElement(q8,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&Z.createElement(HI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&Z.createElement(HI,{style:{fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?Z.createElement(WI,null,Z.createElement(VI,null,"View Diff"),Z.createElement(tH,null,Z.createElement(GI,{side:"old"},Z.createElement(qI,{side:"old"},"Old"),Z.createElement(YI,null,QI(e.generatedFix.diffPreview).map((k,w)=>Z.createElement(KI,{key:`old-${w}`,type:k.oldLine.type},k.oldLine.content||"\xA0")))),Z.createElement(GI,{side:"new"},Z.createElement(qI,{side:"new"},"New"),Z.createElement(YI,null,QI(e.generatedFix.diffPreview).map((k,w)=>Z.createElement(KI,{key:`new-${w}`,type:k.newLine.type},k.newLine.content||"\xA0")))))):e.generatedFix.code&&Z.createElement(WI,null,Z.createElement(VI,null,"View Generated Code"),Z.createElement(Y8,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&Z.createElement(jI,null,Z.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&Z.createElement(K8,null,Z.createElement(X8,{onClick:()=>a(e.id)},"Apply Fix"),u&&Z.createElement(Q8,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&Z.createElement(XI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&Z.createElement(XI,{status:"applied"},"\u2713 Fix applied successfully")))),Z.createElement(TI,{isOpen:g,issueTitle:e.title,onConfirm:P,onCancel:()=>p(!1)}))});import Mx from"react";import{styled as Bx,keyframes as oH}from"storybook/theming";var iH=oH`
113
113
  0% { transform: rotate(0deg); }
114
114
  100% { transform: rotate(360deg); }
115
- `,sH=Bx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),aH=Bx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${iH} 0.8s linear infinite`})),lH=Bx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),eu=({label:e="Loading..."})=>Mx.createElement(sH,null,Mx.createElement(aH,null),Mx.createElement(lH,null,e));Te();import xt,{useState as cH,useEffect as uH,useRef as pH}from"react";import{styled as xn,keyframes as Ea}from"storybook/theming";var ls="#8b6cc1",dH="rgba(139, 108, 193, 0.2)",eF="rgba(139, 108, 193, 0.15)",gH="rgba(139, 108, 193, 0.1)",fH="rgba(139, 108, 193, 0.5)",tF=Ea`
115
+ `,sH=Bx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),aH=Bx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${iH} 0.8s linear infinite`})),lH=Bx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),eu=({label:e="Loading..."})=>Mx.createElement(sH,null,Mx.createElement(aH,null),Mx.createElement(lH,null,e));Te();import xt,{useState as cH,useEffect as uH,useRef as pH}from"react";import{styled as xn,keyframes as Ea}from"storybook/theming";var ls="#8b6cc1",dH="rgba(139, 108, 193, 0.2)",tF="rgba(139, 108, 193, 0.15)",gH="rgba(139, 108, 193, 0.1)",fH="rgba(139, 108, 193, 0.5)",nF=Ea`
116
116
  from { transform: rotate(0deg); }
117
117
  to { transform: rotate(360deg); }
118
118
  `,mH=Ea`
@@ -127,7 +127,7 @@ ${E.diffPreview}
127
127
  `,yH=Ea`
128
128
  0%, 100% { opacity: 1; }
129
129
  50% { opacity: 0.4; }
130
- `,bH=xn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${xH} 0.4s ease-out`}),SH=xn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),wH=xn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${eF} 0%, transparent 70%)`,animation:`${hH} 2s ease-in-out infinite`}),vH=xn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${dH}`}),kH=xn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:ls,borderRightColor:ls,animation:`${tF} 1.2s linear infinite`}),CH=xn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${eF}`}),TH=xn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:fH,animation:`${mH} 1.8s linear infinite`}),IH=xn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),FH=xn.div({position:"absolute",inset:0,animation:`${tF} 3s linear infinite`}),EH=xn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:ls}),AH=()=>xt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:ls,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},xt.createElement("path",{d:"M12 3l1.912 5.813a2 2 0 0 0 1.275 1.275L21 12l-5.813 1.912a2 2 0 0 0-1.275 1.275L12 21l-1.912-5.813a2 2 0 0 0-1.275-1.275L3 12l5.813-1.912a2 2 0 0 0 1.275-1.275L12 3z"}),xt.createElement("path",{d:"M5 3v4"}),xt.createElement("path",{d:"M3 5h4"}),xt.createElement("path",{d:"M19 17v4"}),xt.createElement("path",{d:"M17 19h4"})),PH=xn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),LH=xn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),MH=xn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),Dx=xn.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"999px",fontSize:"11px",fontWeight:500,...t==="done"&&{backgroundColor:e.color.positive?`${e.color.positive}1a`:"rgba(16, 185, 129, 0.1)",color:e.color.positive||"#10b981"},...t==="active"&&{backgroundColor:gH,color:ls},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),JI=xn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),ZI=xn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:ls,animation:`${yH} 1.5s ease-in-out infinite`}),BH=xn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),DH=()=>xt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},xt.createElement("polyline",{points:"20 6 9 17 4 12"})),nF=()=>{let{streamingProgress:e}=ce(),t=(e||0)>25,[n,r]=cH(0),o=pH();return uH(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),xt.createElement(bH,null,xt.createElement(SH,null,xt.createElement(wH,null),xt.createElement(vH,null),xt.createElement(kH,null),xt.createElement(CH,null),xt.createElement(TH,null),xt.createElement(IH,null,xt.createElement(AH,null)),xt.createElement(FH,null,xt.createElement(EH,null))),xt.createElement(PH,null,"Analyzing designs"),xt.createElement(LH,null,"AI is comparing screenshots and detecting issues"),xt.createElement(MH,null,xt.createElement(Dx,{variant:t?"done":"active"},t?xt.createElement(DH,null):xt.createElement(ZI,null),"Screenshots"),xt.createElement(JI,null),xt.createElement(Dx,{variant:t?"active":"pending"},t?xt.createElement(ZI,null):null,"Analysis"),xt.createElement(JI,null),xt.createElement(Dx,{variant:"pending"},"Report")),xt.createElement(BH,null,n,"s \xB7 Esc to stop"))};Te();var jfe=st.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",color:e.textMutedColor,cursor:"pointer",padding:"4px 8px",borderRadius:"4px",backgroundColor:e.background.app,"&:hover":{backgroundColor:e.background.hoverable}})),Hfe=st.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:se})),_H=st.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),$H=st.div({display:"flex",gap:"8px"}),rF=st(bn)({flex:1}),UH=st.div(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:t?"8px 8px 0 0":"8px",border:`1px solid ${e.appBorderColor}`,borderBottom:t?"none":`1px solid ${e.appBorderColor}`,cursor:"pointer",transition:"background-color 0.15s ease","&:hover":{backgroundColor:e.background.hoverable}})),jH=st.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),HH=st.span(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",color:e.textMutedColor,transition:"transform 0.15s ease",transform:t?"rotate(0deg)":"rotate(-90deg)","& svg":{width:"14px",height:"14px"}})),WH=st.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),VH=st.div({display:"flex",alignItems:"center",gap:"2px"}),tu=st(En)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Rx=st.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),GH=st.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Wfe=st.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Wo=st.div(({theme:e,variant:t})=>{let r=(()=>{switch(t){case"total":return{bg:e.background.app,text:e.color.defaultText};case"critical":return{bg:e.background.negative,text:e.color.negative};case"major":return{bg:e.background.warning,text:e.color.warning};case"minor":return{bg:e.color.tertiary,text:se};case"selected":return{bg:e.color.tertiary,text:se};case"score":return{bg:e.background.positive,text:e.color.positive};case"cost":return{bg:e.background.warning,text:e.color.warning};case"timing":return{bg:e.color.tertiary,text:se};case"tokens":return{bg:e.background.app,text:e.color.mediumdark};case"model":return{bg:e.background.app,text:e.color.mediumdark}}})();return{padding:"3px 8px",borderRadius:"10px",backgroundColor:r.bg,color:r.text,fontWeight:600,fontSize:"11px",whiteSpace:"nowrap"}}),qH=st.div({display:"flex",flexDirection:"column"}),YH=st.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),oF=st.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),iF=st.div({fontSize:"36px",marginBottom:"12px"}),sF=st.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),aF=st.div({fontSize:"12px"}),KH=OH`
130
+ `,bH=xn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${xH} 0.4s ease-out`}),SH=xn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),wH=xn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${tF} 0%, transparent 70%)`,animation:`${hH} 2s ease-in-out infinite`}),vH=xn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${dH}`}),kH=xn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:ls,borderRightColor:ls,animation:`${nF} 1.2s linear infinite`}),CH=xn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${tF}`}),TH=xn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:fH,animation:`${mH} 1.8s linear infinite`}),IH=xn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),FH=xn.div({position:"absolute",inset:0,animation:`${nF} 3s linear infinite`}),EH=xn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:ls}),AH=()=>xt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:ls,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},xt.createElement("path",{d:"M12 3l1.912 5.813a2 2 0 0 0 1.275 1.275L21 12l-5.813 1.912a2 2 0 0 0-1.275 1.275L12 21l-1.912-5.813a2 2 0 0 0-1.275-1.275L3 12l5.813-1.912a2 2 0 0 0 1.275-1.275L12 3z"}),xt.createElement("path",{d:"M5 3v4"}),xt.createElement("path",{d:"M3 5h4"}),xt.createElement("path",{d:"M19 17v4"}),xt.createElement("path",{d:"M17 19h4"})),PH=xn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),LH=xn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),MH=xn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),Dx=xn.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"999px",fontSize:"11px",fontWeight:500,...t==="done"&&{backgroundColor:e.color.positive?`${e.color.positive}1a`:"rgba(16, 185, 129, 0.1)",color:e.color.positive||"#10b981"},...t==="active"&&{backgroundColor:gH,color:ls},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),ZI=xn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),eF=xn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:ls,animation:`${yH} 1.5s ease-in-out infinite`}),BH=xn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),DH=()=>xt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},xt.createElement("polyline",{points:"20 6 9 17 4 12"})),rF=()=>{let{streamingProgress:e}=ce(),t=(e||0)>25,[n,r]=cH(0),o=pH();return uH(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),xt.createElement(bH,null,xt.createElement(SH,null,xt.createElement(wH,null),xt.createElement(vH,null),xt.createElement(kH,null),xt.createElement(CH,null),xt.createElement(TH,null),xt.createElement(IH,null,xt.createElement(AH,null)),xt.createElement(FH,null,xt.createElement(EH,null))),xt.createElement(PH,null,"Analyzing designs"),xt.createElement(LH,null,"AI is comparing screenshots and detecting issues"),xt.createElement(MH,null,xt.createElement(Dx,{variant:t?"done":"active"},t?xt.createElement(DH,null):xt.createElement(eF,null),"Screenshots"),xt.createElement(ZI,null),xt.createElement(Dx,{variant:t?"active":"pending"},t?xt.createElement(eF,null):null,"Analysis"),xt.createElement(ZI,null),xt.createElement(Dx,{variant:"pending"},"Report")),xt.createElement(BH,null,n,"s \xB7 Esc to stop"))};Te();var jfe=st.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",color:e.textMutedColor,cursor:"pointer",padding:"4px 8px",borderRadius:"4px",backgroundColor:e.background.app,"&:hover":{backgroundColor:e.background.hoverable}})),Hfe=st.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:se})),_H=st.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),$H=st.div({display:"flex",gap:"8px"}),oF=st(bn)({flex:1}),UH=st.div(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:t?"8px 8px 0 0":"8px",border:`1px solid ${e.appBorderColor}`,borderBottom:t?"none":`1px solid ${e.appBorderColor}`,cursor:"pointer",transition:"background-color 0.15s ease","&:hover":{backgroundColor:e.background.hoverable}})),jH=st.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),HH=st.span(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",color:e.textMutedColor,transition:"transform 0.15s ease",transform:t?"rotate(0deg)":"rotate(-90deg)","& svg":{width:"14px",height:"14px"}})),WH=st.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),VH=st.div({display:"flex",alignItems:"center",gap:"2px"}),tu=st(En)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Rx=st.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),GH=st.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Wfe=st.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Wo=st.div(({theme:e,variant:t})=>{let r=(()=>{switch(t){case"total":return{bg:e.background.app,text:e.color.defaultText};case"critical":return{bg:e.background.negative,text:e.color.negative};case"major":return{bg:e.background.warning,text:e.color.warning};case"minor":return{bg:e.color.tertiary,text:se};case"selected":return{bg:e.color.tertiary,text:se};case"score":return{bg:e.background.positive,text:e.color.positive};case"cost":return{bg:e.background.warning,text:e.color.warning};case"timing":return{bg:e.color.tertiary,text:se};case"tokens":return{bg:e.background.app,text:e.color.mediumdark};case"model":return{bg:e.background.app,text:e.color.mediumdark}}})();return{padding:"3px 8px",borderRadius:"10px",backgroundColor:r.bg,color:r.text,fontWeight:600,fontSize:"11px",whiteSpace:"nowrap"}}),qH=st.div({display:"flex",flexDirection:"column"}),YH=st.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),iF=st.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),sF=st.div({fontSize:"36px",marginBottom:"12px"}),aF=st.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),lF=st.div({fontSize:"12px"}),KH=OH`
131
131
  0% {
132
132
  transform: translateY(0) rotate(0deg) scale(1);
133
133
  opacity: 1;
@@ -139,7 +139,7 @@ ${E.diffPreview}
139
139
  transform: translateY(120px) rotate(720deg) scale(0.3);
140
140
  opacity: 0;
141
141
  }
142
- `;var Vfe=st.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Gfe=st.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"0",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>8?"50%":"2px",animation:`${KH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var XH=st.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderRadius:"6px",fontSize:"13px",fontWeight:600,backgroundColor:t==="success"?e.background.positive:e.background.warning,color:t==="success"?e.color.positive:e.color.warning,border:`2px solid ${t==="success"?e.color.positive:e.color.warning}`,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out","@keyframes slideIn":{"0%":{transform:"translateY(-10px)",opacity:0},"100%":{transform:"translateY(0)",opacity:1}}})),QH=st(En)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),lF=st.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),cF=st(Fn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),uF=st(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),pF=st(on)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),JH=st.div(({theme:e,confidence:t})=>{let n=t>=90?"#16a34a":t>=70?"#ca8a04":"#dc2626";return{padding:"10px 14px",borderRadius:"8px",border:`1px solid ${n}30`,backgroundColor:`${n}08`,marginTop:"8px",fontSize:"12px",lineHeight:1.5}}),ZH=st.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),eW=st.span(({confidence:e,theme:t})=>{let n=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:t.base==="dark"?e>=90?"rgba(22, 163, 74, 0.18)":e>=70?"rgba(202, 138, 4, 0.18)":"rgba(220, 38, 38, 0.18)":e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:n,fontSize:"11px",fontWeight:700}}),tW=st.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),nW=st.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),nu=st.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),ru=st.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),rW=e=>{if(["layout","content"].includes(e.type))return!0;if(e.type==="typography"){let n=(e.description||"").toLowerCase(),r=(e.property||"").toLowerCase();if(n.includes("text content")||n.includes("text differs")||r.includes("content")||r.includes("innerhtml")||r.includes("textcontent"))return!0}return!1},dF=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:d,onSelectNone:g,onSelectAllFixes:p,onApplyFixes:m,onApplyFix:k,onCopyAllFixes:I,onGenerateFixes:A,onDismiss:C,onUndismiss:D,isGenerating:R=!1,isApplying:_=!1,isCopying:P=!1,applyFixesResult:N,onDismissResult:x,generationTiming:v,generationUsage:w,generationProgress:E,autoApplySupported:f=!0,hasReviewBeenRun:T=!1,isLoadingReview:S=!1,isReviewing:y=!1,selfReview:F})=>{let[L,M]=Y.useState("all"),[z,h]=Y.useState("all"),[j,V]=Y.useState(!1),[B,G]=Y.useState(!0),{includeComponentIssues:te,setIncludeComponentIssues:le,featureFlags:xe}=ce(),ie=Y.useRef(null),[Ke,be]=zH(0);NH(()=>{if(!R){be(0);return}let re=setInterval(()=>be(K=>K+1),1e3);return()=>clearInterval(re)},[R]);let Ie=async()=>{let re=ve.map(H=>{let Ae=[`[${H.severity.toUpperCase()}] ${H.title||H.description}`,`Status: ${H.status}`,H.description&&H.description!==H.title?`Description: ${H.description}`:"",H.property?`Property: ${H.property}`:"",H.currentValue?`Current: ${H.currentValue}`:"",H.suggestedValue?`Expected: ${H.suggestedValue}`:"",H.file?`File: ${H.file}${H.lineNumber!==void 0?`:${H.lineNumber}`:""}`:"",H.suggestedCode?`Suggested code: ${H.suggestedCode}`:""];if(H.generatedFix){let Be=H.generatedFix;if(Ae.push(""),Ae.push("--- AI-Generated Fix ---"),Ae.push(`Fix Status: ${Be.status}`),Be.confidence!==void 0){let vt=Be.confidence>1?Be.confidence:Math.round(Be.confidence*100);Ae.push(`Confidence: ${vt}%`)}Be.strategy&&Ae.push(`Strategy: ${Be.strategy}`),Be.filePath&&Ae.push(`Target file: ${Be.filePath}`),Be.code&&Ae.push(`Generated code:
142
+ `;var Vfe=st.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Gfe=st.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"0",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>8?"50%":"2px",animation:`${KH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var XH=st.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderRadius:"6px",fontSize:"13px",fontWeight:600,backgroundColor:t==="success"?e.background.positive:e.background.warning,color:t==="success"?e.color.positive:e.color.warning,border:`2px solid ${t==="success"?e.color.positive:e.color.warning}`,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out","@keyframes slideIn":{"0%":{transform:"translateY(-10px)",opacity:0},"100%":{transform:"translateY(0)",opacity:1}}})),QH=st(En)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),cF=st.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),uF=st(Fn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),pF=st(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),dF=st(on)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),JH=st.div(({theme:e,confidence:t})=>{let n=t>=90?"#16a34a":t>=70?"#ca8a04":"#dc2626";return{padding:"10px 14px",borderRadius:"8px",border:`1px solid ${n}30`,backgroundColor:`${n}08`,marginTop:"8px",fontSize:"12px",lineHeight:1.5}}),ZH=st.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),eW=st.span(({confidence:e,theme:t})=>{let n=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:t.base==="dark"?e>=90?"rgba(22, 163, 74, 0.18)":e>=70?"rgba(202, 138, 4, 0.18)":"rgba(220, 38, 38, 0.18)":e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:n,fontSize:"11px",fontWeight:700}}),tW=st.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),nW=st.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),nu=st.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),ru=st.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),rW=e=>{if(["layout","content"].includes(e.type))return!0;if(e.type==="typography"){let n=(e.description||"").toLowerCase(),r=(e.property||"").toLowerCase();if(n.includes("text content")||n.includes("text differs")||r.includes("content")||r.includes("innerhtml")||r.includes("textcontent"))return!0}return!1},gF=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:d,onSelectNone:g,onSelectAllFixes:p,onApplyFixes:m,onApplyFix:v,onCopyAllFixes:I,onGenerateFixes:A,onDismiss:C,onUndismiss:D,isGenerating:R=!1,isApplying:_=!1,isCopying:P=!1,applyFixesResult:N,onDismissResult:x,generationTiming:k,generationUsage:w,generationProgress:E,autoApplySupported:f=!0,hasReviewBeenRun:T=!1,isLoadingReview:S=!1,isReviewing:y=!1,selfReview:F})=>{let[L,M]=Y.useState("all"),[z,h]=Y.useState("all"),[j,V]=Y.useState(!1),[B,G]=Y.useState(!0),{includeComponentIssues:te,setIncludeComponentIssues:le,featureFlags:xe}=ce(),ie=Y.useRef(null),[Ke,be]=zH(0);NH(()=>{if(!R){be(0);return}let re=setInterval(()=>be(K=>K+1),1e3);return()=>clearInterval(re)},[R]);let Ie=async()=>{let re=ve.map(H=>{let Ae=[`[${H.severity.toUpperCase()}] ${H.title||H.description}`,`Status: ${H.status}`,H.description&&H.description!==H.title?`Description: ${H.description}`:"",H.property?`Property: ${H.property}`:"",H.currentValue?`Current: ${H.currentValue}`:"",H.suggestedValue?`Expected: ${H.suggestedValue}`:"",H.file?`File: ${H.file}${H.lineNumber!==void 0?`:${H.lineNumber}`:""}`:"",H.suggestedCode?`Suggested code: ${H.suggestedCode}`:""];if(H.generatedFix){let Be=H.generatedFix;if(Ae.push(""),Ae.push("--- AI-Generated Fix ---"),Ae.push(`Fix Status: ${Be.status}`),Be.confidence!==void 0){let vt=Be.confidence>1?Be.confidence:Math.round(Be.confidence*100);Ae.push(`Confidence: ${vt}%`)}Be.strategy&&Ae.push(`Strategy: ${Be.strategy}`),Be.filePath&&Ae.push(`Target file: ${Be.filePath}`),Be.code&&Ae.push(`Generated code:
143
143
  ${Be.code}`),Be.diffPreview&&Ae.push(`Diff:
144
144
  ${Be.diffPreview}`),Be.error&&Ae.push(`Error: ${Be.error}`)}return Ae.push(""),Ae.filter(Boolean).join(`
145
145
  `)}).join(`
@@ -147,15 +147,15 @@ ${Be.diffPreview}`),Be.error&&Ae.push(`Error: ${Be.error}`)}return Ae.push(""),A
147
147
 
148
148
  `),K=ve.filter(H=>H.generatedFix?.status==="applied").length,me=ve.filter(H=>H.generatedFix?.status==="ready").length,oe=K>0||me>0?` | Fixes: ${K} applied, ${me} ready`:"",O=r!==void 0?` | Similarity: ${r}%`:"",U=`Score: ${n}/100${O} | ${ve.length} issues${oe}
149
149
 
150
- `;try{await navigator.clipboard.writeText(U+re),V(!0),setTimeout(()=>V(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};Y.useEffect(()=>{N&&ie.current&&ie.current.scrollIntoView({behavior:"smooth",block:"start"})},[N]);let ve=RH(()=>e.filter(re=>{let K=L==="all"||re.severity===L,me=z==="all"||re.status===z,oe=te||!rW(re);return K&&me&&oe}),[e,L,z,te]),ue=()=>{ve.forEach(re=>{re.selectedForFix||l(re.id)})},$e=()=>{ve.forEach(re=>{re.selectedForFix&&l(re.id)})},pe=()=>{ve.forEach(re=>{re.generatedFix&&re.generatedFix.status==="ready"&&!re.selectedForFix&&l(re.id)})},yt=ve.filter(re=>re.selectedForFix).length,$t=ve.filter(re=>re.severity==="critical").length,yn=ve.filter(re=>re.severity==="major").length,fe=ve.filter(re=>re.severity==="minor").length,tt=ve.filter(re=>re.generatedFix&&re.generatedFix.status==="ready").length,he=ve.filter(re=>re.selectedForFix&&re.generatedFix&&re.generatedFix.status==="ready").length;return e.length===0?S?Y.createElement(eu,{label:"Loading review..."}):y?Y.createElement(nF,null):Y.createElement(oF,null,Y.createElement(iF,null,T?"\u2728":"\u{1F441}\uFE0F"),Y.createElement(sF,null,T?"No issues found":"No review yet"),Y.createElement(aF,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):Y.createElement(_H,{"data-testid":"issues-panel"},Y.createElement($H,null,Y.createElement(rF,{value:L,onChange:re=>M(re.target.value)},Y.createElement("option",{value:"all"},"All Severities"),Y.createElement("option",{value:"critical"},"Critical Only"),Y.createElement("option",{value:"major"},"Major Only"),Y.createElement("option",{value:"minor"},"Minor Only")),Y.createElement(rF,{value:z,onChange:re=>h(re.target.value)},Y.createElement("option",{value:"all"},"All Statuses"),Y.createElement("option",{value:"pending"},"Pending"),Y.createElement("option",{value:"applied"},"Applied"),Y.createElement("option",{value:"verified"},"Verified"),Y.createElement("option",{value:"failed"},"Failed"))),Y.createElement("div",null,Y.createElement(UH,{isOpen:B,onClick:()=>G(!B)},Y.createElement(jH,null,Y.createElement(HH,{isOpen:B},Y.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Y.createElement("polyline",{points:"6 9 12 15 18 9"}))),Y.createElement(GH,null,ve.length," issues"),(()=>{if(ve.length===0)return null;let re=ve.map(oe=>oe.generatedFix?.filePath||oe.file).filter(Boolean);if(re.length===0)return null;let K=re[0];return re.every(oe=>oe===K)?Y.createElement(YH,null,"in ",K):null})(),Y.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},$t>0&&Y.createElement(Rx,{variant:"critical"},$t," critical"),yn>0&&Y.createElement(Rx,{variant:"major"},yn," major"),fe>0&&Y.createElement(Rx,{variant:"minor"},fe," minor"))),Y.createElement(VH,{onClick:re=>re.stopPropagation()},Y.createElement(tu,{onClick:ue},"All"),Y.createElement(tu,{onClick:$e},"None"),Y.createElement(tu,{onClick:Ie},j?"\u2713":"\u2398"," Copy"),tt>0&&Y.createElement(tu,{onClick:pe},"Fixes (",tt,")"))),N&&Y.createElement(XH,{ref:ie,variant:N.error||N.failed>0?"warning":"success"},N.error?Y.createElement(Y.Fragment,null,N.error):N.failed>0?Y.createElement(Y.Fragment,null,"Applied ",N.succeeded,"/",N.total," ","fixes. ",N.failed," failed. Run a new review to verify."):Y.createElement(Y.Fragment,null,"Applied ",N.total," fix",N.total!==1?"es":"","! Run a new review to verify changes."),x&&Y.createElement(QH,{onClick:x},"\u2715")),yt>0&&Y.createElement(lF,null,v&&Y.createElement(Wo,{variant:"timing"},v.durationSec,"s (",v.issueCount," ","fixes)"),w&&Y.createElement(Y.Fragment,null,Y.createElement(Wo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),Y.createElement(Wo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),Y.createElement(Wo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&A&&Y.createElement(pF,{disabled:R||_||P,onClick:A},Y.createElement("span",null,"\u{1F916}"),R&&E?`Generating ${E.completed}/${E.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${yt} Issue${yt>1?"s":""}`),xe.enableFixApply&&f&&m&&Y.createElement(cF,{disabled:R||_||he===0,onClick:m},_?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&I&&Y.createElement(uF,{disabled:R||P||he===0,copied:P,onClick:I},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")),F&&!R&&Y.createElement(JH,{confidence:F.overallConfidence},Y.createElement(ZH,null,Y.createElement(tW,null,"AI Self-Review"),Y.createElement(eW,{confidence:F.overallConfidence},F.wouldReachPerfect?"\u2713":"\u25B3"," ",F.overallConfidence,"% confidence")),Y.createElement(nW,null,F.variantSafety&&Y.createElement(nu,null,Y.createElement(ru,null,"Variant safety:"," "),F.variantSafety),F.gaps.length>0&&Y.createElement(nu,null,Y.createElement(ru,null,"Gaps: "),Y.createElement("ul",null,F.gaps.map((re,K)=>Y.createElement("li",{key:K},re)))),!F.wouldReachPerfect&&F.reasonsNotPerfect.length>0&&Y.createElement(nu,null,Y.createElement(ru,null,"Why not 100%:"," "),Y.createElement("ul",null,F.reasonsNotPerfect.map((re,K)=>Y.createElement("li",{key:K},re)))),F.suggestions&&F.suggestions.length>0&&Y.createElement(nu,null,Y.createElement(ru,null,"Suggestions: "),Y.createElement("ul",null,F.suggestions.map((re,K)=>Y.createElement("li",{key:K},re)))))),B&&Y.createElement(WH,null,ve.length===0?Y.createElement(oF,null,Y.createElement(iF,null,"\u{1F50D}"),Y.createElement(sF,null,"No issues match current filters"),Y.createElement(aF,null,"Try adjusting your severity or status filters")):Y.createElement(qH,null,(()=>{let re={};ve.forEach(U=>{let H=U.detectedBy;H&&(re[H]=(re[H]||0)+1)});let K=Object.entries(re).sort((U,H)=>H[1]-U[1])[0],me=K&&K[1]>ve.length/2?K[0]:void 0,oe=ve.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),O=oe.length>0&&oe.every(U=>U===oe[0]);return ve.map(U=>Y.createElement(QI,{key:U.id,issue:U,modelId:t,dominantDetector:me,showFilePath:!O,onToggleSelection:l,onDismiss:C,onUndismiss:D,onApplyFix:k}))})()))),yt>0&&Y.createElement(lF,null,v&&Y.createElement(Wo,{variant:"timing"},v.durationSec,"s (",v.issueCount," ","fixes)"),w&&Y.createElement(Y.Fragment,null,Y.createElement(Wo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),Y.createElement(Wo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),Y.createElement(Wo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&A&&Y.createElement(pF,{disabled:R||_||P,onClick:A},Y.createElement("span",null,"\u{1F916}"),R&&E?`Generating ${E.completed}/${E.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${yt} Issue${yt>1?"s":""}`),xe.enableFixApply&&f&&m&&Y.createElement(cF,{disabled:R||_||he===0,onClick:m},_?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&I&&Y.createElement(uF,{disabled:R||P||he===0,copied:P,onClick:I},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")))};_e();var oW=Ft.div({display:"flex",flexDirection:"column"}),iW=Ft.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),sW=Ft.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),zx=Ft.span(({theme:e,variant:t})=>{let n={resolved:{bg:e.background.positive,text:e.color.positive},remaining:{bg:e.background.warning,text:e.color.warning},new:{bg:e.color.tertiary,text:se}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),aW=Ft.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),ome=Ft.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),ime=Ft.div({fontSize:"48px",marginBottom:"16px"}),sme=Ft.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),ame=Ft.div({fontSize:"14px",opacity:.8}),lW=Ft.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),cW=Ft.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),uW=Ft(En)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),pW=Ft(Nr)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),dW=Ft.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),gW=Ft.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),fW=Ft.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),mW=Ft.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),hW=Ft.button(({theme:e})=>({background:"none",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"2px 8px",fontSize:"11px",color:e.color.mediumdark,cursor:"pointer","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.secondary}})),xW=Ft.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),yW=Ft.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),bW=Ft.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",padding:"12px 0 8px 0",marginTop:"8px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"8px","&:first-of-type":{marginTop:0}})),SW=Ft.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),ou={"false-positive":{icon:"\u2715",label:"False positive",group:"False Positive"},planned:{icon:"\u25F7",label:"Planned",group:"Planned"},"wont-fix":{icon:"\u2298",label:"Won't fix",group:"Won't Fix"},"no-figma-state":{icon:"\u25FB",label:"No Figma state",group:"No Figma State"},"design-pending":{icon:"\u2726",label:"Design pending",group:"Design Pending"}},mF=e=>{if(!e)return{categoryId:null,note:""};let t=e.indexOf(": "),n=t>-1?e.slice(0,t):e.trim();return ou[n]?{categoryId:n,note:t>-1?e.slice(t+2):""}:{categoryId:null,note:e}},wW=e=>{if(!e)return"Other";let{categoryId:t}=mF(e);if(t&&ou[t])return ou[t].group;let n=e.toLowerCase();return n.includes("hug")||n.includes("fill")||n.includes("content-driven")?"HUG/FILL Sizing":n.includes("sub-pixel")||n.includes("negligible")?"Sub-pixel Differences":n.includes("values match")||n.includes("values already match")||n.includes("identical")?"Values Match":n.includes("no fix needed")||n.includes("no changes needed")?"No Fix Needed":"Other"},gF=e=>{if(!e)return"";let t=e.replace(/^Auto-dismissed:\s*/i,"").replace(/^Programmatic:\s*/i,"").replace(/^Two-Pass:\s*/i,"");return t=t.replace(/Sub-pixel difference \([\d.]+px\) - within [\d.]+px tolerance/i,"Sub-pixel difference").replace(/Dimension issue with HUG\/FILL sizing - width is content-driven, not fixed/i,"Width is content-driven").replace(/Height issue with HUG sizing - dimension is content-driven, not actionable/i,"Height is content-driven").replace(/Width issue with HUG sizing - dimension is content-driven, not actionable/i,"Width is content-driven").replace(/no-changes-needed - values already match/i,"Values already match").replace(/Values are the same - no difference/i,"Values match"),t},vW=Ft.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#0369a1",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n["post-ai-validation"];return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),kW=Ft.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"8px",marginLeft:"8px",fontSize:"11px",color:e.textMutedColor,"& > span":{display:"inline-flex",alignItems:"center",gap:"3px"}})),Ox=e=>{if(!e)return;let t=e.toLowerCase();if(t.includes("no-changes-needed")||t.includes("values already match")||t.includes("sub-pixel")||t.includes("negligible")||t.includes("hug")||t.includes("fill")||t.includes("content-driven")||t.includes("equivalent")||t.includes("layout mechanism"))return"post-ai-validation"},CW=(e,t)=>{switch(e||Ox(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},fF=(e,t)=>{switch(e||Ox(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Auto";case"user":return"Manual";default:return"Auto"}},TW=Ft.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),IW=Ft.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),FW=Ft.pre(({theme:e})=>({fontSize:"12px",color:e.color.negative,backgroundColor:e.background.app,padding:"12px",borderRadius:"4px",overflow:"auto",maxHeight:"200px",fontFamily:"monospace",lineHeight:"1.5"})),EW=Ft(uy)({marginTop:"12px"}),Nx=class extends Oe.Component{constructor(n){super(n);this.handleReset=()=>{this.setState({hasError:!1,error:null})};this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){b.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?Oe.createElement(TW,null,Oe.createElement(IW,null,"\u26A0\uFE0F Issues Panel Error"),Oe.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),Oe.createElement(FW,null,this.state.error?.message||"Unknown error",`
150
+ `;try{await navigator.clipboard.writeText(U+re),V(!0),setTimeout(()=>V(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};Y.useEffect(()=>{N&&ie.current&&ie.current.scrollIntoView({behavior:"smooth",block:"start"})},[N]);let ve=RH(()=>e.filter(re=>{let K=L==="all"||re.severity===L,me=z==="all"||re.status===z,oe=te||!rW(re);return K&&me&&oe}),[e,L,z,te]),ue=()=>{ve.forEach(re=>{re.selectedForFix||l(re.id)})},$e=()=>{ve.forEach(re=>{re.selectedForFix&&l(re.id)})},pe=()=>{ve.forEach(re=>{re.generatedFix&&re.generatedFix.status==="ready"&&!re.selectedForFix&&l(re.id)})},yt=ve.filter(re=>re.selectedForFix).length,$t=ve.filter(re=>re.severity==="critical").length,yn=ve.filter(re=>re.severity==="major").length,fe=ve.filter(re=>re.severity==="minor").length,tt=ve.filter(re=>re.generatedFix&&re.generatedFix.status==="ready").length,he=ve.filter(re=>re.selectedForFix&&re.generatedFix&&re.generatedFix.status==="ready").length;return e.length===0?S?Y.createElement(eu,{label:"Loading review..."}):y?Y.createElement(rF,null):Y.createElement(iF,null,Y.createElement(sF,null,T?"\u2728":"\u{1F441}\uFE0F"),Y.createElement(aF,null,T?"No issues found":"No review yet"),Y.createElement(lF,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):Y.createElement(_H,{"data-testid":"issues-panel"},Y.createElement($H,null,Y.createElement(oF,{value:L,onChange:re=>M(re.target.value)},Y.createElement("option",{value:"all"},"All Severities"),Y.createElement("option",{value:"critical"},"Critical Only"),Y.createElement("option",{value:"major"},"Major Only"),Y.createElement("option",{value:"minor"},"Minor Only")),Y.createElement(oF,{value:z,onChange:re=>h(re.target.value)},Y.createElement("option",{value:"all"},"All Statuses"),Y.createElement("option",{value:"pending"},"Pending"),Y.createElement("option",{value:"applied"},"Applied"),Y.createElement("option",{value:"verified"},"Verified"),Y.createElement("option",{value:"failed"},"Failed"))),Y.createElement("div",null,Y.createElement(UH,{isOpen:B,onClick:()=>G(!B)},Y.createElement(jH,null,Y.createElement(HH,{isOpen:B},Y.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Y.createElement("polyline",{points:"6 9 12 15 18 9"}))),Y.createElement(GH,null,ve.length," issues"),(()=>{if(ve.length===0)return null;let re=ve.map(oe=>oe.generatedFix?.filePath||oe.file).filter(Boolean);if(re.length===0)return null;let K=re[0];return re.every(oe=>oe===K)?Y.createElement(YH,null,"in ",K):null})(),Y.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},$t>0&&Y.createElement(Rx,{variant:"critical"},$t," critical"),yn>0&&Y.createElement(Rx,{variant:"major"},yn," major"),fe>0&&Y.createElement(Rx,{variant:"minor"},fe," minor"))),Y.createElement(VH,{onClick:re=>re.stopPropagation()},Y.createElement(tu,{onClick:ue},"All"),Y.createElement(tu,{onClick:$e},"None"),Y.createElement(tu,{onClick:Ie},j?"\u2713":"\u2398"," Copy"),tt>0&&Y.createElement(tu,{onClick:pe},"Fixes (",tt,")"))),N&&Y.createElement(XH,{ref:ie,variant:N.error||N.failed>0?"warning":"success"},N.error?Y.createElement(Y.Fragment,null,N.error):N.failed>0?Y.createElement(Y.Fragment,null,"Applied ",N.succeeded,"/",N.total," ","fixes. ",N.failed," failed. Run a new review to verify."):Y.createElement(Y.Fragment,null,"Applied ",N.total," fix",N.total!==1?"es":"","! Run a new review to verify changes."),x&&Y.createElement(QH,{onClick:x},"\u2715")),yt>0&&Y.createElement(cF,null,k&&Y.createElement(Wo,{variant:"timing"},k.durationSec,"s (",k.issueCount," ","fixes)"),w&&Y.createElement(Y.Fragment,null,Y.createElement(Wo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),Y.createElement(Wo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),Y.createElement(Wo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&A&&Y.createElement(dF,{disabled:R||_||P,onClick:A},Y.createElement("span",null,"\u{1F916}"),R&&E?`Generating ${E.completed}/${E.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${yt} Issue${yt>1?"s":""}`),xe.enableFixApply&&f&&m&&Y.createElement(uF,{disabled:R||_||he===0,onClick:m},_?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&I&&Y.createElement(pF,{disabled:R||P||he===0,copied:P,onClick:I},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")),F&&!R&&Y.createElement(JH,{confidence:F.overallConfidence},Y.createElement(ZH,null,Y.createElement(tW,null,"AI Self-Review"),Y.createElement(eW,{confidence:F.overallConfidence},F.wouldReachPerfect?"\u2713":"\u25B3"," ",F.overallConfidence,"% confidence")),Y.createElement(nW,null,F.variantSafety&&Y.createElement(nu,null,Y.createElement(ru,null,"Variant safety:"," "),F.variantSafety),F.gaps.length>0&&Y.createElement(nu,null,Y.createElement(ru,null,"Gaps: "),Y.createElement("ul",null,F.gaps.map((re,K)=>Y.createElement("li",{key:K},re)))),!F.wouldReachPerfect&&F.reasonsNotPerfect.length>0&&Y.createElement(nu,null,Y.createElement(ru,null,"Why not 100%:"," "),Y.createElement("ul",null,F.reasonsNotPerfect.map((re,K)=>Y.createElement("li",{key:K},re)))),F.suggestions&&F.suggestions.length>0&&Y.createElement(nu,null,Y.createElement(ru,null,"Suggestions: "),Y.createElement("ul",null,F.suggestions.map((re,K)=>Y.createElement("li",{key:K},re)))))),B&&Y.createElement(WH,null,ve.length===0?Y.createElement(iF,null,Y.createElement(sF,null,"\u{1F50D}"),Y.createElement(aF,null,"No issues match current filters"),Y.createElement(lF,null,"Try adjusting your severity or status filters")):Y.createElement(qH,null,(()=>{let re={};ve.forEach(U=>{let H=U.detectedBy;H&&(re[H]=(re[H]||0)+1)});let K=Object.entries(re).sort((U,H)=>H[1]-U[1])[0],me=K&&K[1]>ve.length/2?K[0]:void 0,oe=ve.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),O=oe.length>0&&oe.every(U=>U===oe[0]);return ve.map(U=>Y.createElement(JI,{key:U.id,issue:U,modelId:t,dominantDetector:me,showFilePath:!O,onToggleSelection:l,onDismiss:C,onUndismiss:D,onApplyFix:v}))})()))),yt>0&&Y.createElement(cF,null,k&&Y.createElement(Wo,{variant:"timing"},k.durationSec,"s (",k.issueCount," ","fixes)"),w&&Y.createElement(Y.Fragment,null,Y.createElement(Wo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),Y.createElement(Wo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),Y.createElement(Wo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&A&&Y.createElement(dF,{disabled:R||_||P,onClick:A},Y.createElement("span",null,"\u{1F916}"),R&&E?`Generating ${E.completed}/${E.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${yt} Issue${yt>1?"s":""}`),xe.enableFixApply&&f&&m&&Y.createElement(uF,{disabled:R||_||he===0,onClick:m},_?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&I&&Y.createElement(pF,{disabled:R||P||he===0,copied:P,onClick:I},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")))};_e();var oW=Ft.div({display:"flex",flexDirection:"column"}),iW=Ft.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),sW=Ft.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),zx=Ft.span(({theme:e,variant:t})=>{let n={resolved:{bg:e.background.positive,text:e.color.positive},remaining:{bg:e.background.warning,text:e.color.warning},new:{bg:e.color.tertiary,text:se}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),aW=Ft.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),ome=Ft.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),ime=Ft.div({fontSize:"48px",marginBottom:"16px"}),sme=Ft.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),ame=Ft.div({fontSize:"14px",opacity:.8}),lW=Ft.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),cW=Ft.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),uW=Ft(En)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),pW=Ft(Nr)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),dW=Ft.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),gW=Ft.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),fW=Ft.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),mW=Ft.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),hW=Ft.button(({theme:e})=>({background:"none",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"2px 8px",fontSize:"11px",color:e.color.mediumdark,cursor:"pointer","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.secondary}})),xW=Ft.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),yW=Ft.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),bW=Ft.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",padding:"12px 0 8px 0",marginTop:"8px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"8px","&:first-of-type":{marginTop:0}})),SW=Ft.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),ou={"false-positive":{icon:"\u2715",label:"False positive",group:"False Positive"},planned:{icon:"\u25F7",label:"Planned",group:"Planned"},"wont-fix":{icon:"\u2298",label:"Won't fix",group:"Won't Fix"},"no-figma-state":{icon:"\u25FB",label:"No Figma state",group:"No Figma State"},"design-pending":{icon:"\u2726",label:"Design pending",group:"Design Pending"}},hF=e=>{if(!e)return{categoryId:null,note:""};let t=e.indexOf(": "),n=t>-1?e.slice(0,t):e.trim();return ou[n]?{categoryId:n,note:t>-1?e.slice(t+2):""}:{categoryId:null,note:e}},wW=e=>{if(!e)return"Other";let{categoryId:t}=hF(e);if(t&&ou[t])return ou[t].group;let n=e.toLowerCase();return n.includes("hug")||n.includes("fill")||n.includes("content-driven")?"HUG/FILL Sizing":n.includes("sub-pixel")||n.includes("negligible")?"Sub-pixel Differences":n.includes("values match")||n.includes("values already match")||n.includes("identical")?"Values Match":n.includes("no fix needed")||n.includes("no changes needed")?"No Fix Needed":"Other"},fF=e=>{if(!e)return"";let t=e.replace(/^Auto-dismissed:\s*/i,"").replace(/^Programmatic:\s*/i,"").replace(/^Two-Pass:\s*/i,"");return t=t.replace(/Sub-pixel difference \([\d.]+px\) - within [\d.]+px tolerance/i,"Sub-pixel difference").replace(/Dimension issue with HUG\/FILL sizing - width is content-driven, not fixed/i,"Width is content-driven").replace(/Height issue with HUG sizing - dimension is content-driven, not actionable/i,"Height is content-driven").replace(/Width issue with HUG sizing - dimension is content-driven, not actionable/i,"Width is content-driven").replace(/no-changes-needed - values already match/i,"Values already match").replace(/Values are the same - no difference/i,"Values match"),t},vW=Ft.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#0369a1",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n["post-ai-validation"];return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),kW=Ft.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"8px",marginLeft:"8px",fontSize:"11px",color:e.textMutedColor,"& > span":{display:"inline-flex",alignItems:"center",gap:"3px"}})),Ox=e=>{if(!e)return;let t=e.toLowerCase();if(t.includes("no-changes-needed")||t.includes("values already match")||t.includes("sub-pixel")||t.includes("negligible")||t.includes("hug")||t.includes("fill")||t.includes("content-driven")||t.includes("equivalent")||t.includes("layout mechanism"))return"post-ai-validation"},CW=(e,t)=>{switch(e||Ox(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},mF=(e,t)=>{switch(e||Ox(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Auto";case"user":return"Manual";default:return"Auto"}},TW=Ft.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),IW=Ft.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),FW=Ft.pre(({theme:e})=>({fontSize:"12px",color:e.color.negative,backgroundColor:e.background.app,padding:"12px",borderRadius:"4px",overflow:"auto",maxHeight:"200px",fontFamily:"monospace",lineHeight:"1.5"})),EW=Ft(uy)({marginTop:"12px"}),Nx=class extends Oe.Component{constructor(n){super(n);this.handleReset=()=>{this.setState({hasError:!1,error:null})};this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){b.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?Oe.createElement(TW,null,Oe.createElement(IW,null,"\u26A0\uFE0F Issues Panel Error"),Oe.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),Oe.createElement(FW,null,this.state.error?.message||"Unknown error",`
151
151
 
152
- `,this.state.error?.stack),Oe.createElement(EW,{onClick:this.handleReset},"Try Again")):this.props.children}},hF=()=>{let{currentStoryId:e}=nt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=ce(),{dismissAndSync:a,undismissAndSync:u}=wI(),{loadingMapping:c}=nt(),l=!!e&&!t&&!n&&c,[d,g]=Oe.useState(!1),[p,m]=Oe.useState(!1),[k,I]=Oe.useState(!1),{isSupported:A,isDetecting:C}=Tm(),{refreshStorybookOnly:D}=ti(),{generateBatchFixes:R,isGenerating:_,error:P,timing:N,progress:x,usage:v,selfReview:w,lastStorybookRoot:E}=wm(),{applyFixes:f,isApplying:T}=Sm({onComplete:D,storybookRoot:E}),S=r.find(K=>K.id===t),y=S?.issues||[],F=Oe.useMemo(()=>y.filter(K=>!K.dismissed),[y]),L=Oe.useMemo(()=>y.filter(K=>K.dismissed),[y]),M=Oe.useMemo(()=>{let K={postAiValidation:0,aiValidation:0,user:0};for(let me of L)switch(me.dismissedBy){case"post-ai-validation":K.postAiValidation++;break;case"ai-validation":K.aiValidation++;break;default:K.user++;break}return K},[L]),z=F,h=S?.modelId||"unknown",j=F.filter(K=>K.severity==="critical").length,V=F.filter(K=>K.severity==="major").length,B=F.filter(K=>K.severity==="minor").length,G=S?Io(j,V,B):void 0;Oe.useEffect(()=>{!e||G==null||Ur(e,{score:G,issueCount:F.length,criticalCount:j,majorCount:V,minorCount:B})},[G,e,F.length,j,V,B]);let te=S?.visualSimilarity,le=S?.costUsd,xe=S?.reviewDurationMs,ie=S?.inputTokens,Ke=S?.outputTokens,be=S?.cacheCreationTokens,Ie=S?.cacheReadTokens,ve=S?.parentReviewId?r.find(K=>K.id===S.parentReviewId):null,ue=Oe.useMemo(()=>{if(!ve||!S)return null;let K=new Set(ve.issues.map(H=>`${H.type}:${H.property||""}:${H.description}`)),me=new Set(z.map(H=>`${H.type}:${H.property||""}:${H.description}`)),oe=ve.issues.filter(H=>!me.has(`${H.type}:${H.property||""}:${H.description}`)).length,O=z.filter(H=>K.has(`${H.type}:${H.property||""}:${H.description}`)).length,U=z.filter(H=>!K.has(`${H.type}:${H.property||""}:${H.description}`)).length;return{resolved:oe,remaining:O,newIssues:U}},[ve,S,z]),$e=()=>{z.forEach(K=>{K.selectedForFix||o(K.id)})},pe=()=>{z.forEach(K=>{K.selectedForFix&&o(K.id)})},yt=()=>{z.forEach(K=>{K.generatedFix&&K.generatedFix.status==="ready"&&!K.selectedForFix&&o(K.id)})},{featureFlags:$t}=ce(),yn=()=>{if(!$t.enableFixGeneration){b.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let K=z.filter(me=>me.selectedForFix);if(K.length===0){b.warn("[IssuesPanel] No issues selected for fix generation");return}b.debug(`[IssuesPanel] Generating fixes for ${K.length} issue(s)`,K),R(K)},fe=()=>{if(!$t.enableFixApply){b.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let K=z.filter(oe=>oe.selectedForFix&&oe.generatedFix&&oe.generatedFix.status==="ready"&&oe.generatedFix.code&&oe.generatedFix.filePath);if(K.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let me=K.map(oe=>({id:oe.id,reviewId:oe.reviewId,type:oe.type,severity:oe.severity,title:oe.title,description:oe.description,generatedFix:oe.generatedFix,storyId:S?.storyId||""}));b.debug(`[IssuesPanel] Applying AI-generated fixes for ${me.length} issue(s)`,me),f(me)},tt=K=>{let me=z.find(O=>O.id===K);if(!me){b.warn("[IssuesPanel] Issue not found:",K);return}if(!me.generatedFix||me.generatedFix.status!=="ready"||!me.generatedFix.code||!me.generatedFix.filePath){b.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",K);return}let oe={id:me.id,reviewId:me.reviewId,type:me.type,severity:me.severity,title:me.title,description:me.description,generatedFix:me.generatedFix,storyId:S?.storyId||""};b.debug("[IssuesPanel] Applying single AI-generated fix for issue:",oe),f([oe])},he=async()=>{let K=z.filter(oe=>oe.selectedForFix&&oe.generatedFix&&oe.generatedFix.status==="ready"&&oe.generatedFix.code&&oe.generatedFix.filePath);if(K.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let me=K.map(oe=>{let O=oe.generatedFix,U=[];return U.push(`// File: ${O.filePath}`),U.push(`// Issue: ${oe.title||oe.description}`),oe.currentValue&&U.push(`// Actual: ${oe.currentValue}`),oe.suggestedValue&&U.push(`// Expected (Figma): ${oe.suggestedValue}`),O.diffPreview&&(U.push("//"),U.push("// Diff:"),O.diffPreview.split(`
152
+ `,this.state.error?.stack),Oe.createElement(EW,{onClick:this.handleReset},"Try Again")):this.props.children}},xF=()=>{let{currentStoryId:e}=nt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=ce(),{dismissAndSync:a,undismissAndSync:u}=vI(),{loadingMapping:c}=nt(),l=!!e&&!t&&!n&&c,[d,g]=Oe.useState(!1),[p,m]=Oe.useState(!1),[v,I]=Oe.useState(!1),{isSupported:A,isDetecting:C}=Tm(),{refreshStorybookOnly:D}=ti(),{generateBatchFixes:R,isGenerating:_,error:P,timing:N,progress:x,usage:k,selfReview:w,lastStorybookRoot:E}=wm(),{applyFixes:f,isApplying:T}=Sm({onComplete:D,storybookRoot:E}),S=r.find(K=>K.id===t),y=S?.issues||[],F=Oe.useMemo(()=>y.filter(K=>!K.dismissed),[y]),L=Oe.useMemo(()=>y.filter(K=>K.dismissed),[y]),M=Oe.useMemo(()=>{let K={postAiValidation:0,aiValidation:0,user:0};for(let me of L)switch(me.dismissedBy){case"post-ai-validation":K.postAiValidation++;break;case"ai-validation":K.aiValidation++;break;default:K.user++;break}return K},[L]),z=F,h=S?.modelId||"unknown",j=F.filter(K=>K.severity==="critical").length,V=F.filter(K=>K.severity==="major").length,B=F.filter(K=>K.severity==="minor").length,G=S?Io(j,V,B):void 0;Oe.useEffect(()=>{!e||G==null||Ur(e,{score:G,issueCount:F.length,criticalCount:j,majorCount:V,minorCount:B})},[G,e,F.length,j,V,B]);let te=S?.visualSimilarity,le=S?.costUsd,xe=S?.reviewDurationMs,ie=S?.inputTokens,Ke=S?.outputTokens,be=S?.cacheCreationTokens,Ie=S?.cacheReadTokens,ve=S?.parentReviewId?r.find(K=>K.id===S.parentReviewId):null,ue=Oe.useMemo(()=>{if(!ve||!S)return null;let K=new Set(ve.issues.map(H=>`${H.type}:${H.property||""}:${H.description}`)),me=new Set(z.map(H=>`${H.type}:${H.property||""}:${H.description}`)),oe=ve.issues.filter(H=>!me.has(`${H.type}:${H.property||""}:${H.description}`)).length,O=z.filter(H=>K.has(`${H.type}:${H.property||""}:${H.description}`)).length,U=z.filter(H=>!K.has(`${H.type}:${H.property||""}:${H.description}`)).length;return{resolved:oe,remaining:O,newIssues:U}},[ve,S,z]),$e=()=>{z.forEach(K=>{K.selectedForFix||o(K.id)})},pe=()=>{z.forEach(K=>{K.selectedForFix&&o(K.id)})},yt=()=>{z.forEach(K=>{K.generatedFix&&K.generatedFix.status==="ready"&&!K.selectedForFix&&o(K.id)})},{featureFlags:$t}=ce(),yn=()=>{if(!$t.enableFixGeneration){b.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let K=z.filter(me=>me.selectedForFix);if(K.length===0){b.warn("[IssuesPanel] No issues selected for fix generation");return}b.debug(`[IssuesPanel] Generating fixes for ${K.length} issue(s)`,K),R(K)},fe=()=>{if(!$t.enableFixApply){b.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let K=z.filter(oe=>oe.selectedForFix&&oe.generatedFix&&oe.generatedFix.status==="ready"&&oe.generatedFix.code&&oe.generatedFix.filePath);if(K.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let me=K.map(oe=>({id:oe.id,reviewId:oe.reviewId,type:oe.type,severity:oe.severity,title:oe.title,description:oe.description,generatedFix:oe.generatedFix,storyId:S?.storyId||""}));b.debug(`[IssuesPanel] Applying AI-generated fixes for ${me.length} issue(s)`,me),f(me)},tt=K=>{let me=z.find(O=>O.id===K);if(!me){b.warn("[IssuesPanel] Issue not found:",K);return}if(!me.generatedFix||me.generatedFix.status!=="ready"||!me.generatedFix.code||!me.generatedFix.filePath){b.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",K);return}let oe={id:me.id,reviewId:me.reviewId,type:me.type,severity:me.severity,title:me.title,description:me.description,generatedFix:me.generatedFix,storyId:S?.storyId||""};b.debug("[IssuesPanel] Applying single AI-generated fix for issue:",oe),f([oe])},he=async()=>{let K=z.filter(oe=>oe.selectedForFix&&oe.generatedFix&&oe.generatedFix.status==="ready"&&oe.generatedFix.code&&oe.generatedFix.filePath);if(K.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let me=K.map(oe=>{let O=oe.generatedFix,U=[];return U.push(`// File: ${O.filePath}`),U.push(`// Issue: ${oe.title||oe.description}`),oe.currentValue&&U.push(`// Actual: ${oe.currentValue}`),oe.suggestedValue&&U.push(`// Expected (Figma): ${oe.suggestedValue}`),O.diffPreview&&(U.push("//"),U.push("// Diff:"),O.diffPreview.split(`
153
153
  `).forEach(H=>{U.push(`// ${H}`)})),U.push("//"),U.push("// Full Fixed Code:"),U.push(O.code),U.join(`
154
154
  `)}).join(`
155
155
 
156
156
  `+"=".repeat(60)+`
157
157
 
158
- `);m(!0);try{await Im(me)?b.debug(`[IssuesPanel] Copied ${K.length} fix(es) to clipboard`):b.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>m(!1),1500)}catch(oe){b.error("[IssuesPanel] Error copying fixes:",oe),m(!1)}},re=async K=>{K.stopPropagation();let me=L.map(O=>[`[${O.severity.toUpperCase()}] ${O.title||O.description}`,`Phase: ${fF(O.dismissedBy,O.dismissReason)}`,O.dismissReason?`Reason: ${gF(O.dismissReason)}`:"",O.property?`Property: ${O.property}`:"",O.currentValue?`Current: ${O.currentValue}`:"",O.suggestedValue?`Expected: ${O.suggestedValue}`:""].filter(Boolean).join(`
158
+ `);m(!0);try{await Im(me)?b.debug(`[IssuesPanel] Copied ${K.length} fix(es) to clipboard`):b.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>m(!1),1500)}catch(oe){b.error("[IssuesPanel] Error copying fixes:",oe),m(!1)}},re=async K=>{K.stopPropagation();let me=L.map(O=>[`[${O.severity.toUpperCase()}] ${O.title||O.description}`,`Phase: ${mF(O.dismissedBy,O.dismissReason)}`,O.dismissReason?`Reason: ${fF(O.dismissReason)}`:"",O.property?`Property: ${O.property}`:"",O.currentValue?`Current: ${O.currentValue}`:"",O.suggestedValue?`Expected: ${O.suggestedValue}`:""].filter(Boolean).join(`
159
159
  `)).join(`
160
160
 
161
161
  ---
@@ -163,7 +163,7 @@ ${Be.diffPreview}`),Be.error&&Ae.push(`Error: ${Be.error}`)}return Ae.push(""),A
163
163
  `),oe=`Filtered Issues (${L.length})
164
164
  ${"=".repeat(40)}
165
165
 
166
- `;try{await navigator.clipboard.writeText(oe+me),I(!0),setTimeout(()=>I(!1),2e3)}catch(O){b.error("Failed to copy dismissed issues:",O)}};return Oe.createElement(oW,null,ue&&Oe.createElement(iW,null,Oe.createElement(sW,null,"\u{1F4CA} Progress:"),Oe.createElement(zx,{variant:"resolved"},"\u2705 ",ue.resolved," resolved"),Oe.createElement(zx,{variant:"remaining"},"\u23F3 ",ue.remaining," remaining"),ue.newIssues>0&&Oe.createElement(zx,{variant:"new"},"\u{1F195} ",ue.newIssues," new"),Oe.createElement(aW,null,"Iteration ",S?.iterationNumber||1)),Oe.createElement(Nx,null,Oe.createElement(dF,{issues:z,modelId:h,complianceScore:G,visualSimilarity:te,costUsd:le,reviewDurationMs:xe,inputTokens:ie,outputTokens:Ke,cacheCreationTokens:be,cacheReadTokens:Ie,onToggleSelection:o,onSelectAll:$e,onSelectNone:pe,onSelectAllFixes:yt,onGenerateFixes:yn,onApplyFixes:fe,onApplyFix:tt,onCopyAllFixes:he,onDismiss:a,onUndismiss:u,isGenerating:_,isApplying:T,isCopying:p,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:N,generationUsage:v,hasReviewBeenRun:!!S,isLoadingReview:l,isReviewing:n,generationProgress:x,autoApplySupported:A,selfReview:w})),L.length>0&&Oe.createElement(lW,null,Oe.createElement(cW,null,Oe.createElement(uW,{onClick:()=>g(!d)},Oe.createElement("span",null,d?"\u25BC":"\u25B6"),Oe.createElement("span",null,"Filtered out"),Oe.createElement(dW,null,L.length),Oe.createElement(kW,null,M.postAiValidation>0&&Oe.createElement("span",null,"\u2699\uFE0F ",M.postAiValidation),M.aiValidation>0&&Oe.createElement("span",null,"\u2726 ",M.aiValidation),M.user>0&&Oe.createElement("span",null,"\u{1F464} ",M.user))),Oe.createElement(pW,{onClick:re},k?"\u2713 Copied!":"Copy")),d&&Oe.createElement(gW,null,(()=>{let K=L.reduce((O,U)=>{let H=wW(U.dismissReason);return O[H]||(O[H]=[]),O[H].push(U),O},{}),me=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(K).sort((O,U)=>me.indexOf(O)-me.indexOf(U)).map(O=>Oe.createElement(Oe.Fragment,{key:O},Oe.createElement(bW,null,O,Oe.createElement(SW,null,K[O].length)),K[O].map(U=>Oe.createElement(fW,{key:U.id},Oe.createElement(mW,null,Oe.createElement(vW,{phase:U.dismissedBy||Ox(U.dismissReason)||"post-ai-validation"},CW(U.dismissedBy,U.dismissReason)," ",fF(U.dismissedBy,U.dismissReason)),Oe.createElement(hW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),Oe.createElement(xW,null,"[",U.severity.toUpperCase(),"]"," ",U.title||U.description),U.dismissReason&&(()=>{let{categoryId:H,note:Ae}=mF(U.dismissReason),Be=H?ou[H]:null;return Oe.createElement(yW,null,Be?Oe.createElement(Oe.Fragment,null,Be.icon," ",Be.label,Ae?` \u2014 ${Ae}`:""):gF(U.dismissReason))})()))))})())))};var PW=Aa.div({marginTop:"20px"}),LW=Aa.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),MW=Aa.div({display:"flex",alignItems:"center"}),_x=Aa(bo)({padding:"10px 16px"}),BW=Aa.div({minHeight:"200px"}),$x=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ce(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return AW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Dr.createElement(PW,null,Dr.createElement(LW,null,Dr.createElement(MW,null,a&&Dr.createElement(_x,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Dr.createElement(_x,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Dr.createElement(_x,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Dr.createElement(BW,null,a&&e==="chat"&&(u?Dr.createElement(SI,null):Dr.createElement(Cx,null)),e==="issues"&&Dr.createElement(hF,null),a&&e==="prompt"&&Dr.createElement(kx,null)))};Te();import W,{useState as fo,useRef as Vx,useEffect as NW,useMemo as OW}from"react";import{styled as Tt,useTheme as _W}from"storybook/theming";He();_e();var iu={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Pa="uicopilot_feature_flags";function Ux(){try{let e=localStorage.getItem(Pa);if(e){let t=JSON.parse(e);return{...iu,...t}}}catch(e){b.warn("[FeatureFlags] Failed to load from localStorage:",e)}return iu}function DW(e,t){try{let r={...Ux(),[e]:t},o={};for(let i in r){let s=i;r[s]!==iu[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Pa,JSON.stringify(o)):localStorage.removeItem(Pa),b.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){b.error("[FeatureFlags] Failed to set flag:",n)}}function RW(){try{localStorage.removeItem(Pa),b.debug("[FeatureFlags] Reset to defaults")}catch(e){b.error("[FeatureFlags] Failed to reset:",e)}}function jx(e){return Ux()[e]}function zW(){let e=Object.keys(iu).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Pa,JSON.stringify(e)),b.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){b.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:Ux,set:DW,reset:RW,enableAll:zW,isEnabled:jx}});_e();ct();import Mt from"react";var xF=()=>Mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Mt.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Mt.createElement("circle",{cx:"12",cy:"12",r:"3"}));var La={xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},Ma=()=>Mt.createElement("svg",{...La},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),yF=()=>Mt.createElement("svg",{...La},Mt.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Mt.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Mt.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Mt.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Mt.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Mt.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),bF=()=>Mt.createElement("svg",{...La},Mt.createElement("polyline",{points:"23 4 23 10 17 10"}),Mt.createElement("polyline",{points:"1 20 1 14 7 14"}),Mt.createElement("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})),Hx=()=>Mt.createElement("svg",{...La},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),Wx=()=>Mt.createElement("svg",{...La},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var Ba=Tt.div({marginTop:"20px"}),su=Tt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),au=Tt.div({display:"flex",alignItems:"center",gap:"12px"}),Da=Tt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Mme=Tt.div({display:"flex",gap:"8px"}),Bme=Tt.button(({active:e,theme:t})=>({padding:"4px 12px",backgroundColor:e?t.color.secondary:"transparent",color:e?"#fff":t.color.mediumdark,border:`1px solid ${e?t.color.secondary:t.appBorderColor}`,borderRadius:"4px",fontSize:"11px",fontWeight:500,cursor:"pointer",transition:"all 0.2s","&:hover":{opacity:.9}})),SF=Tt.div(({theme:e,layout:t})=>({display:t==="side-by-side"?"grid":"flex",gridTemplateColumns:t==="side-by-side"?"minmax(0, 1fr) minmax(0, 1fr)":void 0,gap:t==="side-by-side"?`${e.layoutMargin}px`:0,position:"relative",width:"100%",justifyContent:t==="overlay"?"center":void 0})),Ra=Tt.div(({theme:e,zoomed:t})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,overflow:"hidden",backgroundColor:e.background.app,minHeight:"60px",maxHeight:t?"400px":"150px",display:"flex",alignItems:"center",justifyContent:"center",transition:"max-height 0.2s ease, box-shadow 0.2s ease",boxShadow:t?"0 8px 30px rgba(0, 0, 0, 0.15)":"none","& img":t?{maxWidth:"100%",maxHeight:"400px"}:void 0})),za=Tt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.92)":"rgba(0, 0, 0, 0.7)",color:e.base==="dark"?"#0a0a0f":e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),Na=Tt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),Vo=Tt.button(({theme:e,accent:t})=>({width:"24px",height:"24px",padding:"0",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.12)":"rgba(255, 255, 255, 0.92)",border:`1px solid ${t}55`,borderRadius:e.appBorderRadius,color:t,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s",backdropFilter:"blur(4px)","&:hover:not(:disabled)":{backgroundColor:t,color:"#ffffff",borderColor:t},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),$W=Tt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),UW=Tt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),jW=Tt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),Dme=Tt.svg(({isVisible:e})=>({position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",opacity:e?1:0,transition:"opacity 150ms ease-in",...!e&&{transition:"opacity 100ms ease-out"}})),HW=Tt.div({position:"relative",display:"inline-block"}),Rme=Tt.div(({width:e,height:t,theme:n})=>({position:"relative",width:e?`${e}px`:"auto",height:t?`${t}px`:"auto",border:`1px solid ${n.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:n.background.app})),WW=Tt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),VW=Tt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),GW=Tt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),qW=Tt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),YW=Tt.input({flex:1}),Gx=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),zme=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),qx=Tt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),fi=Tt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center","&::before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:e.base==="dark"?"linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent)":"linear-gradient(90deg, transparent, rgba(0,0,0,0.04), transparent)",animation:"shimmer 1.5s ease-in-out infinite",pointerEvents:"none"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),mi=Tt.div({textAlign:"center",zIndex:1}),hi=Tt.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"12px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),xi=Tt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Yx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=_W(),{currentMapping:o,loadingMapping:i}=nt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:g}=ce(),{selectedProjectId:p}=Je(),{sessionToken:m}=ke(),{openComponentBrowser:k}=Gs(),{hasMapping:I,deleteMapping:A,setCurrentMapping:C}=ri(),D=jx("enableHoverHighlight"),[R,_]=fo("side-by-side"),[P,N]=fo(.5),[x,v]=fo(!1),[w,E]=fo(!1),[f,T]=fo(!1),[S,y]=fo(!1),[F,L]=fo(!1),M=async()=>{T(!1);try{let be=o?.id;be&&await A(be),C(null)}catch(be){b.error("[ScreenshotComparison] Failed to unlink:",be)}};NW(()=>{E(!1)},[s]);let[z,h]=fo(null),[j,V]=fo(null),B=Vx(null),G=Vx(null),te=Vx(null),le=OW(()=>{if(!D||!l||!g)return null;let be=d.find(Ie=>Ie.id===g);return be?.issues&&be.issues.find(Ie=>Ie.id===l)||null},[l,g,d]),xe=be=>{let Ie=be.currentTarget;E(!0),!mt.getState().figmaDimensions&&Ie.naturalWidth&&Ie.naturalHeight&&mt.getState().setFigmaDimensions({width:Ie.naturalWidth,height:Ie.naturalHeight}),requestAnimationFrame(()=>{if(G.current){let{clientWidth:ue,clientHeight:$e}=G.current;ue&&$e&&V({width:ue,height:$e})}})},ie=()=>{requestAnimationFrame(()=>{if(B.current){let{clientWidth:be,clientHeight:Ie}=B.current;be&&Ie&&h({width:be,height:Ie})}})},Ke=async()=>{if(!(!p||!m)){v(!0);try{let be=q();await ee(`${be}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},credentials:"include"}),c(null),b.debug("Figma cache cleared, image will reload on next review")}catch(be){b.error("Failed to refresh Figma:",be)}finally{v(!1)}}};return e?W.createElement(Ba,null,W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),W.createElement(qx,null,W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading Figma..."))),W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?W.createElement(Ba,null,W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),W.createElement(qx,null,W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading..."))))):W.createElement(Ba,null,W.createElement(Da,null,"Screenshot Comparison"),W.createElement(Ra,null,W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:k,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},W.createElement(Ma,null))),W.createElement(Gx,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},W.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),W.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the \u{1F50D} above to browse your Figma file and pick a matching frame. Once linked, run a Review to compare your code with the design.")))):!s&&!a?W.createElement(Ba,null,W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),W.createElement(qx,null,W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading..."))))):W.createElement(Ba,{ref:te},W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),R==="side-by-side"?W.createElement(SF,{layout:"side-by-side"},o&&s&&!t?W.createElement(Ra,{zoomed:S},W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:()=>y(be=>!be),title:S?"Shrink preview":"Enlarge preview","aria-label":S?"Shrink preview":"Enlarge preview"},S?W.createElement(Wx,null):W.createElement(Hx,null)),I&&W.createElement(Vo,{accent:r.color.secondary,onClick:k,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},W.createElement(Ma,null)),W.createElement(Vo,{accent:r.color.positive,onClick:Ke,disabled:x,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},W.createElement(bF,null)),I&&W.createElement(Vo,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},W.createElement(yF,null))),W.createElement(jW,null,W.createElement(UW,{ref:G,src:s,alt:"Figma design",onLoad:xe,style:{opacity:w?1:0,transition:"opacity 150ms ease-in"}}))):o&&!s&&!t?W.createElement(Ra,null,W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:k,disabled:!p,title:"Change Figma mapping","aria-label":"Change Figma mapping"},W.createElement(Ma,null))),W.createElement(Gx,{style:{border:"none",padding:"16px"}},"Figma image unavailable. Try mapping to a specific variant.")):!o&&!i?W.createElement(Ra,null,W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:k,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},W.createElement(Ma,null))),W.createElement(Gx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?W.createElement(Ra,{zoomed:F},W.createElement(za,null,"Storybook Component"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:()=>L(be=>!be),title:F?"Shrink preview":"Enlarge preview","aria-label":F?"Shrink preview":"Enlarge preview"},F?W.createElement(Wx,null):W.createElement(Hx,null))),W.createElement($W,{ref:B,src:a,alt:"Storybook component",onLoad:ie})):W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):W.createElement(W.Fragment,null,W.createElement(SF,{layout:"overlay"},W.createElement(HW,null,s&&a?W.createElement(W.Fragment,null,W.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},W.createElement(WW,{ref:B,src:a,alt:"Storybook component",onLoad:ie,style:{maxHeight:"150px"}}),z&&W.createElement(VW,{src:s,alt:"Figma design overlay",style:{opacity:P,width:z.width,height:z.height,objectFit:"fill"}})),W.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},W.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",W.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),z&&` \u2022 ${z.width}\xD7${z.height}px`)):W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading Images..."))))),a&&s&&W.createElement(GW,null,W.createElement(qW,null,"Figma Opacity:"),W.createElement(YW,{type:"range",min:"0",max:"1",step:"0.01",value:P,onChange:be=>N(parseFloat(be.target.value))}),W.createElement("span",null,Math.round(P*100),"%"))),W.createElement(jr,{isOpen:f,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:M,onCancel:()=>T(!1)}))};Te();ct();var KW=cs.div({height:"100%"}),Kx=cs.div({marginBottom:"20px"}),wF=cs.div(({theme:e})=>({padding:"12px",backgroundColor:e.background.negative||"#fee2e2",border:`1px solid ${e.color.negative||"#fca5a5"}`,borderRadius:"6px",color:e.color.negative||"#991b1b",fontSize:"13px",marginBottom:"16px",display:"flex",alignItems:"flex-start",gap:"8px"})),vF=cs.span({fontSize:"16px",flexShrink:0}),XW=cs.div(({theme:e})=>({padding:"10px 12px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}`,borderRadius:"6px",color:e.color.warning,fontSize:e.typography.size.s2,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px",lineHeight:1.4})),kF=cs.div({flex:1}),Xx=()=>{let{reviewError:e,getCurrentReview:t}=ce(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Gs(),{selectedProjectId:s}=io(),{setCurrentMapping:a}=ri(),{currentStoryId:u,currentStoryName:c}=nt(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:g,screenshotError:p,setFigmaImageDirect:m}=ti(),k=async I=>{b.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",I),b.debug("[ReviewPanel] frame.id:",I?.id);let A=mt.getState(),C=A.selectedProjectId,D=A.currentStoryId,R=A.currentStoryName,_=A.figmaFileUrl;b.debug("[ReviewPanel] selectedProjectId (from store):",C),b.debug("[ReviewPanel] currentStoryId (from store):",D),b.debug("[ReviewPanel] currentStoryName (from store):",R),I.thumbnail&&D&&(b.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),m(D,I.id,I.thumbnail));try{let P=q(),N=localStorage.getItem("uicopilot_session_token");if(b.debug("[ReviewPanel] sessionToken exists:",!!N),b.debug("[ReviewPanel] dashboardUrl:",P),!N||!C||!D){b.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!N,selectedProjectId:C,currentStoryId:D});return}let x=_?.match(/\/file\/([^\/]+)/)?.[1]||void 0;b.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:C,storyId:D,name:R,figmaNodeId:I.id,figmaFileKey:x});let v=await ee(`${P}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({projectId:C,storyId:D,name:R,figmaNodeId:I.id,figmaFileKey:x})});if(v.ok){let w=await v.json();w.mapping&&(a(w.mapping),I.thumbnail||(b.debug("[ReviewPanel] No thumbnail available, triggering fetch"),mt.getState().triggerScreenshotRefresh()),b.debug("[ReviewPanel] Mapping saved successfully:",w.mapping))}else{let w=await v.text();b.error("[ReviewPanel] Failed to save mapping:",w)}}catch(P){b.error("[ReviewPanel] Error saving mapping:",P)}};return Jt.createElement(KW,null,Jt.createElement(Kx,null,Jt.createElement(wh,null)),e&&Jt.createElement(wF,null,Jt.createElement(vF,null,"\u26A0\uFE0F"),Jt.createElement(kF,null,e)),p&&Jt.createElement(wF,null,Jt.createElement(vF,null,"\u26A0\uFE0F"),Jt.createElement(kF,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Jt.createElement(XW,null,Jt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Jt.createElement("span",null,Jt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Jt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Jt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Jt.createElement(Kx,null,Jt.createElement(Yx,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:g})),Jt.createElement(Kx,null,Jt.createElement($x,null)),Jt.createElement(Ki,{isOpen:r,onClose:o,onSelect:k,figmaFileUrl:i||"",projectId:s||void 0}))};Te();_e();He();ct();import{useEffect as CF,useState as QW,useRef as Qx,useCallback as JW}from"react";var ZW=q(),eV=2e3;function TF(){let{sessionToken:e,usageData:t,setUsageData:n}=ke(),[r,o]=QW(null),i=Qx(null),s=Qx(!1),a=Qx(0);CF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=JW(()=>{o(null)},[]);return CF(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<eV){b.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{b.debug("[useBalanceRefresh] Refreshing balance...");let g=await ee(`${ZW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let p=await g.json(),m=p.creditBalance,k=i.current;if(k!==null&&m>k){let I=m-k;o({message:`Credits added! +${Math.floor(I)} credit(s)`,previousBalance:k,newBalance:m}),b.debug("[useBalanceRefresh] Credits added:",I)}i.current=m,n(p),b.debug("[useBalanceRefresh] Balance updated:",m)}}catch(g){b.error("[useBalanceRefresh] Failed to refresh:",g)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}Te();Te();He();_e();ct();Df();import{useEffect as tV,useRef as nV}from"react";var rV=300*1e3,IF="uicopilot_feature_flags_fetched_at";function oV(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(IF);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<rV}catch{return!1}}var Jx=null,iV={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}};function FF(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ce(),{sessionToken:r,resetAuth:o}=ke(),i=nV(null);tV(()=>{if(!r||r===i.current)return;if(i.current=r,oV()){b.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Jx){b.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;Jx=ee(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw b.debug("[useFeatureFlags] Token rejected, resetting auth"),o(),new Error("session token invalid");if(!a.ok)throw new Error(`flags endpoint returned ${a.status}`);return a.json()}).then(a=>{b.debug("[useFeatureFlags] Received flags:",a);let u={enableFixGeneration:!!a.enableFixGeneration,enableFixApply:!!a.enableFixApply,enableAutoMap:!!a.enableAutoMap,enableReviewBadges:!!a.enableReviewBadges,showCosts:!!a.showCosts,enableParallelReview:!!a.enableParallelReview,enableModelSelection:!!a.enableModelSelection};a.role&&(t(a.role),a.role==="beta"&&Sw());let c=a.role==="admin"&&n?iV[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(IF,Date.now().toString())}catch{}}).catch(a=>{b.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Jx=null})},[r,e,t])}Te();He();_n();var lV={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},cV=Sr.div`
166
+ `;try{await navigator.clipboard.writeText(oe+me),I(!0),setTimeout(()=>I(!1),2e3)}catch(O){b.error("Failed to copy dismissed issues:",O)}};return Oe.createElement(oW,null,ue&&Oe.createElement(iW,null,Oe.createElement(sW,null,"\u{1F4CA} Progress:"),Oe.createElement(zx,{variant:"resolved"},"\u2705 ",ue.resolved," resolved"),Oe.createElement(zx,{variant:"remaining"},"\u23F3 ",ue.remaining," remaining"),ue.newIssues>0&&Oe.createElement(zx,{variant:"new"},"\u{1F195} ",ue.newIssues," new"),Oe.createElement(aW,null,"Iteration ",S?.iterationNumber||1)),Oe.createElement(Nx,null,Oe.createElement(gF,{issues:z,modelId:h,complianceScore:G,visualSimilarity:te,costUsd:le,reviewDurationMs:xe,inputTokens:ie,outputTokens:Ke,cacheCreationTokens:be,cacheReadTokens:Ie,onToggleSelection:o,onSelectAll:$e,onSelectNone:pe,onSelectAllFixes:yt,onGenerateFixes:yn,onApplyFixes:fe,onApplyFix:tt,onCopyAllFixes:he,onDismiss:a,onUndismiss:u,isGenerating:_,isApplying:T,isCopying:p,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:N,generationUsage:k,hasReviewBeenRun:!!S,isLoadingReview:l,isReviewing:n,generationProgress:x,autoApplySupported:A,selfReview:w})),L.length>0&&Oe.createElement(lW,null,Oe.createElement(cW,null,Oe.createElement(uW,{onClick:()=>g(!d)},Oe.createElement("span",null,d?"\u25BC":"\u25B6"),Oe.createElement("span",null,"Filtered out"),Oe.createElement(dW,null,L.length),Oe.createElement(kW,null,M.postAiValidation>0&&Oe.createElement("span",null,"\u2699\uFE0F ",M.postAiValidation),M.aiValidation>0&&Oe.createElement("span",null,"\u2726 ",M.aiValidation),M.user>0&&Oe.createElement("span",null,"\u{1F464} ",M.user))),Oe.createElement(pW,{onClick:re},v?"\u2713 Copied!":"Copy")),d&&Oe.createElement(gW,null,(()=>{let K=L.reduce((O,U)=>{let H=wW(U.dismissReason);return O[H]||(O[H]=[]),O[H].push(U),O},{}),me=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(K).sort((O,U)=>me.indexOf(O)-me.indexOf(U)).map(O=>Oe.createElement(Oe.Fragment,{key:O},Oe.createElement(bW,null,O,Oe.createElement(SW,null,K[O].length)),K[O].map(U=>Oe.createElement(fW,{key:U.id},Oe.createElement(mW,null,Oe.createElement(vW,{phase:U.dismissedBy||Ox(U.dismissReason)||"post-ai-validation"},CW(U.dismissedBy,U.dismissReason)," ",mF(U.dismissedBy,U.dismissReason)),Oe.createElement(hW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),Oe.createElement(xW,null,"[",U.severity.toUpperCase(),"]"," ",U.title||U.description),U.dismissReason&&(()=>{let{categoryId:H,note:Ae}=hF(U.dismissReason),Be=H?ou[H]:null;return Oe.createElement(yW,null,Be?Oe.createElement(Oe.Fragment,null,Be.icon," ",Be.label,Ae?` \u2014 ${Ae}`:""):fF(U.dismissReason))})()))))})())))};var PW=Aa.div({marginTop:"20px"}),LW=Aa.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),MW=Aa.div({display:"flex",alignItems:"center"}),_x=Aa(bo)({padding:"10px 16px"}),BW=Aa.div({minHeight:"200px"}),$x=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ce(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return AW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Dr.createElement(PW,null,Dr.createElement(LW,null,Dr.createElement(MW,null,a&&Dr.createElement(_x,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Dr.createElement(_x,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Dr.createElement(_x,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Dr.createElement(BW,null,a&&e==="chat"&&(u?Dr.createElement(wI,null):Dr.createElement(Cx,null)),e==="issues"&&Dr.createElement(xF,null),a&&e==="prompt"&&Dr.createElement(kx,null)))};Te();import W,{useState as fo,useRef as Vx,useEffect as NW,useMemo as OW}from"react";import{styled as Tt,useTheme as _W}from"storybook/theming";He();_e();var iu={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Pa="uicopilot_feature_flags";function Ux(){try{let e=localStorage.getItem(Pa);if(e){let t=JSON.parse(e);return{...iu,...t}}}catch(e){b.warn("[FeatureFlags] Failed to load from localStorage:",e)}return iu}function DW(e,t){try{let r={...Ux(),[e]:t},o={};for(let i in r){let s=i;r[s]!==iu[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Pa,JSON.stringify(o)):localStorage.removeItem(Pa),b.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){b.error("[FeatureFlags] Failed to set flag:",n)}}function RW(){try{localStorage.removeItem(Pa),b.debug("[FeatureFlags] Reset to defaults")}catch(e){b.error("[FeatureFlags] Failed to reset:",e)}}function jx(e){return Ux()[e]}function zW(){let e=Object.keys(iu).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Pa,JSON.stringify(e)),b.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){b.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:Ux,set:DW,reset:RW,enableAll:zW,isEnabled:jx}});_e();ct();import Mt from"react";var yF=()=>Mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Mt.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Mt.createElement("circle",{cx:"12",cy:"12",r:"3"}));var La={xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},Ma=()=>Mt.createElement("svg",{...La},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),bF=()=>Mt.createElement("svg",{...La},Mt.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Mt.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Mt.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Mt.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Mt.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Mt.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),SF=()=>Mt.createElement("svg",{...La},Mt.createElement("polyline",{points:"23 4 23 10 17 10"}),Mt.createElement("polyline",{points:"1 20 1 14 7 14"}),Mt.createElement("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})),Hx=()=>Mt.createElement("svg",{...La},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),Wx=()=>Mt.createElement("svg",{...La},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var Ba=Tt.div({marginTop:"20px"}),su=Tt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),au=Tt.div({display:"flex",alignItems:"center",gap:"12px"}),Da=Tt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Mme=Tt.div({display:"flex",gap:"8px"}),Bme=Tt.button(({active:e,theme:t})=>({padding:"4px 12px",backgroundColor:e?t.color.secondary:"transparent",color:e?"#fff":t.color.mediumdark,border:`1px solid ${e?t.color.secondary:t.appBorderColor}`,borderRadius:"4px",fontSize:"11px",fontWeight:500,cursor:"pointer",transition:"all 0.2s","&:hover":{opacity:.9}})),wF=Tt.div(({theme:e,layout:t})=>({display:t==="side-by-side"?"grid":"flex",gridTemplateColumns:t==="side-by-side"?"minmax(0, 1fr) minmax(0, 1fr)":void 0,gap:t==="side-by-side"?`${e.layoutMargin}px`:0,position:"relative",width:"100%",justifyContent:t==="overlay"?"center":void 0})),Ra=Tt.div(({theme:e,zoomed:t})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,overflow:"hidden",backgroundColor:e.background.app,minHeight:"60px",maxHeight:t?"400px":"150px",display:"flex",alignItems:"center",justifyContent:"center",transition:"max-height 0.2s ease, box-shadow 0.2s ease",boxShadow:t?"0 8px 30px rgba(0, 0, 0, 0.15)":"none","& img":t?{maxWidth:"100%",maxHeight:"400px"}:void 0})),za=Tt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.92)":"rgba(0, 0, 0, 0.7)",color:e.base==="dark"?"#0a0a0f":e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),Na=Tt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),Vo=Tt.button(({theme:e,accent:t})=>({width:"24px",height:"24px",padding:"0",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.12)":"rgba(255, 255, 255, 0.92)",border:`1px solid ${t}55`,borderRadius:e.appBorderRadius,color:t,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s",backdropFilter:"blur(4px)","&:hover:not(:disabled)":{backgroundColor:t,color:"#ffffff",borderColor:t},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),$W=Tt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),UW=Tt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),jW=Tt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),Dme=Tt.svg(({isVisible:e})=>({position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",opacity:e?1:0,transition:"opacity 150ms ease-in",...!e&&{transition:"opacity 100ms ease-out"}})),HW=Tt.div({position:"relative",display:"inline-block"}),Rme=Tt.div(({width:e,height:t,theme:n})=>({position:"relative",width:e?`${e}px`:"auto",height:t?`${t}px`:"auto",border:`1px solid ${n.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:n.background.app})),WW=Tt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),VW=Tt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),GW=Tt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),qW=Tt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),YW=Tt.input({flex:1}),Gx=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),zme=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),qx=Tt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),fi=Tt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center","&::before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:e.base==="dark"?"linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent)":"linear-gradient(90deg, transparent, rgba(0,0,0,0.04), transparent)",animation:"shimmer 1.5s ease-in-out infinite",pointerEvents:"none"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),mi=Tt.div({textAlign:"center",zIndex:1}),hi=Tt.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"12px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),xi=Tt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Yx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=_W(),{currentMapping:o,loadingMapping:i}=nt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:g}=ce(),{selectedProjectId:p}=Je(),{sessionToken:m}=ke(),{openComponentBrowser:v}=Gs(),{hasMapping:I,deleteMapping:A,setCurrentMapping:C}=ri(),D=jx("enableHoverHighlight"),[R,_]=fo("side-by-side"),[P,N]=fo(.5),[x,k]=fo(!1),[w,E]=fo(!1),[f,T]=fo(!1),[S,y]=fo(!1),[F,L]=fo(!1),M=async()=>{T(!1);try{let be=o?.id;be&&await A(be),C(null)}catch(be){b.error("[ScreenshotComparison] Failed to unlink:",be)}};NW(()=>{E(!1)},[s]);let[z,h]=fo(null),[j,V]=fo(null),B=Vx(null),G=Vx(null),te=Vx(null),le=OW(()=>{if(!D||!l||!g)return null;let be=d.find(Ie=>Ie.id===g);return be?.issues&&be.issues.find(Ie=>Ie.id===l)||null},[l,g,d]),xe=be=>{let Ie=be.currentTarget;E(!0),!mt.getState().figmaDimensions&&Ie.naturalWidth&&Ie.naturalHeight&&mt.getState().setFigmaDimensions({width:Ie.naturalWidth,height:Ie.naturalHeight}),requestAnimationFrame(()=>{if(G.current){let{clientWidth:ue,clientHeight:$e}=G.current;ue&&$e&&V({width:ue,height:$e})}})},ie=()=>{requestAnimationFrame(()=>{if(B.current){let{clientWidth:be,clientHeight:Ie}=B.current;be&&Ie&&h({width:be,height:Ie})}})},Ke=async()=>{if(!(!p||!m)){k(!0);try{let be=q();await ee(`${be}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},credentials:"include"}),c(null),b.debug("Figma cache cleared, image will reload on next review")}catch(be){b.error("Failed to refresh Figma:",be)}finally{k(!1)}}};return e?W.createElement(Ba,null,W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),W.createElement(qx,null,W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading Figma..."))),W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?W.createElement(Ba,null,W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),W.createElement(qx,null,W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading..."))))):W.createElement(Ba,null,W.createElement(Da,null,"Screenshot Comparison"),W.createElement(Ra,null,W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:v,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},W.createElement(Ma,null))),W.createElement(Gx,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},W.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),W.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the \u{1F50D} above to browse your Figma file and pick a matching frame. Once linked, run a Review to compare your code with the design.")))):!s&&!a?W.createElement(Ba,null,W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),W.createElement(qx,null,W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading..."))))):W.createElement(Ba,{ref:te},W.createElement(su,null,W.createElement(au,null,W.createElement(Da,null,"Screenshot Comparison"))),R==="side-by-side"?W.createElement(wF,{layout:"side-by-side"},o&&s&&!t?W.createElement(Ra,{zoomed:S},W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:()=>y(be=>!be),title:S?"Shrink preview":"Enlarge preview","aria-label":S?"Shrink preview":"Enlarge preview"},S?W.createElement(Wx,null):W.createElement(Hx,null)),I&&W.createElement(Vo,{accent:r.color.secondary,onClick:v,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},W.createElement(Ma,null)),W.createElement(Vo,{accent:r.color.positive,onClick:Ke,disabled:x,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},W.createElement(SF,null)),I&&W.createElement(Vo,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},W.createElement(bF,null))),W.createElement(jW,null,W.createElement(UW,{ref:G,src:s,alt:"Figma design",onLoad:xe,style:{opacity:w?1:0,transition:"opacity 150ms ease-in"}}))):o&&!s&&!t?W.createElement(Ra,null,W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:v,disabled:!p,title:"Change Figma mapping","aria-label":"Change Figma mapping"},W.createElement(Ma,null))),W.createElement(Gx,{style:{border:"none",padding:"16px"}},"Figma image unavailable. Try mapping to a specific variant.")):!o&&!i?W.createElement(Ra,null,W.createElement(za,null,"Figma Design"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:v,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},W.createElement(Ma,null))),W.createElement(Gx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?W.createElement(Ra,{zoomed:F},W.createElement(za,null,"Storybook Component"),W.createElement(Na,null,W.createElement(Vo,{accent:r.color.secondary,onClick:()=>L(be=>!be),title:F?"Shrink preview":"Enlarge preview","aria-label":F?"Shrink preview":"Enlarge preview"},F?W.createElement(Wx,null):W.createElement(Hx,null))),W.createElement($W,{ref:B,src:a,alt:"Storybook component",onLoad:ie})):W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):W.createElement(W.Fragment,null,W.createElement(wF,{layout:"overlay"},W.createElement(HW,null,s&&a?W.createElement(W.Fragment,null,W.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},W.createElement(WW,{ref:B,src:a,alt:"Storybook component",onLoad:ie,style:{maxHeight:"150px"}}),z&&W.createElement(VW,{src:s,alt:"Figma design overlay",style:{opacity:P,width:z.width,height:z.height,objectFit:"fill"}})),W.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},W.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",W.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),z&&` \u2022 ${z.width}\xD7${z.height}px`)):W.createElement(fi,null,W.createElement(mi,null,W.createElement(hi,null),W.createElement(xi,null,"Loading Images..."))))),a&&s&&W.createElement(GW,null,W.createElement(qW,null,"Figma Opacity:"),W.createElement(YW,{type:"range",min:"0",max:"1",step:"0.01",value:P,onChange:be=>N(parseFloat(be.target.value))}),W.createElement("span",null,Math.round(P*100),"%"))),W.createElement(jr,{isOpen:f,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:M,onCancel:()=>T(!1)}))};Te();ct();var KW=cs.div({height:"100%"}),Kx=cs.div({marginBottom:"20px"}),vF=cs.div(({theme:e})=>({padding:"12px",backgroundColor:e.background.negative||"#fee2e2",border:`1px solid ${e.color.negative||"#fca5a5"}`,borderRadius:"6px",color:e.color.negative||"#991b1b",fontSize:"13px",marginBottom:"16px",display:"flex",alignItems:"flex-start",gap:"8px"})),kF=cs.span({fontSize:"16px",flexShrink:0}),XW=cs.div(({theme:e})=>({padding:"10px 12px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}`,borderRadius:"6px",color:e.color.warning,fontSize:e.typography.size.s2,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px",lineHeight:1.4})),CF=cs.div({flex:1}),Xx=()=>{let{reviewError:e,getCurrentReview:t}=ce(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Gs(),{selectedProjectId:s}=io(),{setCurrentMapping:a}=ri(),{currentStoryId:u,currentStoryName:c}=nt(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:g,screenshotError:p,setFigmaImageDirect:m}=ti(),v=async I=>{b.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",I),b.debug("[ReviewPanel] frame.id:",I?.id);let A=mt.getState(),C=A.selectedProjectId,D=A.currentStoryId,R=A.currentStoryName,_=A.figmaFileUrl;b.debug("[ReviewPanel] selectedProjectId (from store):",C),b.debug("[ReviewPanel] currentStoryId (from store):",D),b.debug("[ReviewPanel] currentStoryName (from store):",R),I.thumbnail&&D&&(b.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),m(D,I.id,I.thumbnail));try{let P=q(),N=localStorage.getItem("uicopilot_session_token");if(b.debug("[ReviewPanel] sessionToken exists:",!!N),b.debug("[ReviewPanel] dashboardUrl:",P),!N||!C||!D){b.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!N,selectedProjectId:C,currentStoryId:D});return}let x=_?.match(/\/file\/([^\/]+)/)?.[1]||void 0;b.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:C,storyId:D,name:R,figmaNodeId:I.id,figmaFileKey:x});let k=await ee(`${P}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({projectId:C,storyId:D,name:R,figmaNodeId:I.id,figmaFileKey:x})});if(k.ok){let w=await k.json();w.mapping&&(a(w.mapping),I.thumbnail||(b.debug("[ReviewPanel] No thumbnail available, triggering fetch"),mt.getState().triggerScreenshotRefresh()),b.debug("[ReviewPanel] Mapping saved successfully:",w.mapping))}else{let w=await k.text();b.error("[ReviewPanel] Failed to save mapping:",w)}}catch(P){b.error("[ReviewPanel] Error saving mapping:",P)}};return Jt.createElement(KW,null,Jt.createElement(Kx,null,Jt.createElement(wh,null)),e&&Jt.createElement(vF,null,Jt.createElement(kF,null,"\u26A0\uFE0F"),Jt.createElement(CF,null,e)),p&&Jt.createElement(vF,null,Jt.createElement(kF,null,"\u26A0\uFE0F"),Jt.createElement(CF,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Jt.createElement(XW,null,Jt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Jt.createElement("span",null,Jt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Jt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Jt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Jt.createElement(Kx,null,Jt.createElement(Yx,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:g})),Jt.createElement(Kx,null,Jt.createElement($x,null)),Jt.createElement(Ki,{isOpen:r,onClose:o,onSelect:v,figmaFileUrl:i||"",projectId:s||void 0}))};Te();_e();He();ct();import{useEffect as TF,useState as QW,useRef as Qx,useCallback as JW}from"react";var ZW=q(),eV=2e3;function IF(){let{sessionToken:e,usageData:t,setUsageData:n}=ke(),[r,o]=QW(null),i=Qx(null),s=Qx(!1),a=Qx(0);TF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=JW(()=>{o(null)},[]);return TF(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<eV){b.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{b.debug("[useBalanceRefresh] Refreshing balance...");let g=await ee(`${ZW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let p=await g.json(),m=p.creditBalance,v=i.current;if(v!==null&&m>v){let I=m-v;o({message:`Credits added! +${Math.floor(I)} credit(s)`,previousBalance:v,newBalance:m}),b.debug("[useBalanceRefresh] Credits added:",I)}i.current=m,n(p),b.debug("[useBalanceRefresh] Balance updated:",m)}}catch(g){b.error("[useBalanceRefresh] Failed to refresh:",g)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}Te();Te();He();_e();ct();Df();import{useEffect as tV,useRef as nV}from"react";var rV=300*1e3,FF="uicopilot_feature_flags_fetched_at";function oV(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(FF);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<rV}catch{return!1}}var Jx=null,iV={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}};function EF(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ce(),{sessionToken:r,resetAuth:o}=ke(),i=nV(null);tV(()=>{if(!r||r===i.current)return;if(i.current=r,oV()){b.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Jx){b.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;Jx=ee(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw b.debug("[useFeatureFlags] Token rejected, resetting auth"),o(),new Error("session token invalid");if(!a.ok)throw new Error(`flags endpoint returned ${a.status}`);return a.json()}).then(a=>{b.debug("[useFeatureFlags] Received flags:",a);let u={enableFixGeneration:!!a.enableFixGeneration,enableFixApply:!!a.enableFixApply,enableAutoMap:!!a.enableAutoMap,enableReviewBadges:!!a.enableReviewBadges,showCosts:!!a.showCosts,enableParallelReview:!!a.enableParallelReview,enableModelSelection:!!a.enableModelSelection};a.role&&(t(a.role),a.role==="beta"&&Sw());let c=a.role==="admin"&&n?iV[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(FF,Date.now().toString())}catch{}}).catch(a=>{b.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Jx=null})},[r,e,t])}Te();He();_n();var lV={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},cV=Sr.div`
167
167
  position: fixed;
168
168
  top: 16px;
169
169
  right: 16px;
@@ -215,8 +215,8 @@ ${"=".repeat(40)}
215
215
  color: ${({theme:e})=>e.color.mediumdark};
216
216
  text-align: center;
217
217
  opacity: 0.7;
218
- `,fV=Sr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),mV=Sr.div({fontSize:"32px"}),hV=Sr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),xV=Sr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),EF=Sr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",margin:"8px 12px",backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}50`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s2,color:e.color.defaultText})),AF=Sr.span({flex:1}),PF=Sr.button(({theme:e})=>({padding:"4px 12px",fontSize:11,fontWeight:600,border:`1px solid ${e.color.warning}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.warning,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:`${e.color.warning}15`}})),LF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Je(),{isConnected:r,sessionToken:o,authError:i}=ke(),{currentStoryId:s}=nt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ce(),[g,p]=sV(!1),m=()=>{l(null),o&&fetch(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{d({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};ym(),Rm(),FF(),Fm(),Cm();let{notification:k,dismissNotification:I}=TF();aV(()=>{if(k){let P=setTimeout(I,5e3);return()=>clearTimeout(P)}},[k,I]);let A=t.find(P=>P.id===e),C=r&&!!e&&!!A,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=nt(),_=C&&!!s&&!a&&R;return zt.createElement(hu,{header:zt.createElement(xu,{toolbar:zt.createElement(jf,{onOpenSettings:()=>p(!0)})}),footer:zt.createElement(gV,null,Pt.NAME," v","0.5.26")},k&&zt.createElement(cV,{variant:k.variant||"success"},zt.createElement(uV,null,k.variant==="error"?"!":k.variant==="warning"?"\u26A0":"+"),zt.createElement(pV,null,k.message),zt.createElement(dV,{onClick:I},"x")),i&&zt.createElement(EF,null,zt.createElement("span",null,"\u26A0"),zt.createElement(AF,null,i),zt.createElement(PF,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&zt.createElement(EF,null,zt.createElement("span",null,"\u{1F441}"),zt.createElement(AF,null,"Previewing as ",c),zt.createElement(PF,{onClick:m},"Exit preview")),D||_?zt.createElement(eu,{label:D?"Loading...":"Loading review..."}):C?zt.createElement(Xx,null):zt.createElement(fV,null,zt.createElement(mV,null,"\u2699"),zt.createElement(hV,null,i?"Connection issue":`Set up ${Pt.NAME}`),zt.createElement(xV,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),zt.createElement(on,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),g&&zt.createElement(e1,{onClose:()=>p(!1)}))};import MF,{useCallback as yV}from"react";import{useStorybookApi as bV}from"storybook/manager-api";import{IconButton as SV}from"storybook/internal/components";var wV="uireview",vV=`${wV}/panel`,BF=()=>{let e=bV(),t=yV(()=>{e.togglePanel(!0),e.setSelectedPanel(vV)},[e]);return MF.createElement(SV,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},MF.createElement(xF,null))};Te();import Yt,{useState as Ua,useCallback as NF,useEffect as ny}from"react";import{styled as mo,useTheme as BV}from"storybook/theming";import{addons as uu}from"storybook/manager-api";He();_e();import{addons as EV,experimental_getStatusStore as cu}from"storybook/manager-api";async function DF(e,t,n,r){let o=new Array(e.length),i=0;async function s(){for(;i<e.length&&!r();){let a=i++;try{let u=await e[a]();o[a]=u,r()||n(a,u)}catch(u){o[a]=u,r()||n(a,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),o}He();_e();var kV=q(),CV="uireview/badge";async function TV(e,t,n=3){for(let r=0;r<=n;r++){let o=await fetch(e,t);if(o.status!==429||r===n)return o;let i=Math.pow(2,r)*1e3;b.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function IV(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:d,value:g}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let p=r.split(`
219
- `);r=p.pop()||"";for(let m of p)if(m.startsWith("data: "))try{let k=JSON.parse(m.slice(6));if(k.type==="complete"){o=k.complianceScore??k.validation?.complianceScore??null;let A=(k.issues||[]).filter(C=>!C.dismissed);i=A.filter(C=>C.severity==="critical").length,s=A.filter(C=>C.severity==="major").length,a=A.filter(C=>C.severity==="minor").length,u=k.costUsd||0,c=k.inputTokens||0,l=k.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function lu(e,t,n,r,o){e&&e.set([{value:n,typeId:CV,storyId:t,title:r,description:o}])}async function FV(e){let t=window.location.origin;try{let n=await fetch(`${t}/__uicopilot/capture?storyId=${encodeURIComponent(e)}`);if(n.ok){let r=await n.json();return{screenshot:r.screenshot||void 0,computedStyles:r.computedStyles||void 0,domTree:r.domTree||void 0}}}catch{}try{let n=await fetch(`${t}/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(n.ok)return{screenshot:(await n.json()).screenshot||void 0}}catch{}return{}}async function RF(e,t,n,r,o,i){lu(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await FV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await TV(`${kV}/api/review/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({projectId:n,storyId:e.storyId,storyName:e.storyName,storybookScreenshot:s.screenshot,computedStyles:s.computedStyles,domTree:s.domTree,aiModels:[r]})});if(console.warn(`[reviewAll] API response for ${e.storyName}: HTTP ${a.status}`),!a.ok)throw new Error(`HTTP ${a.status}`);let u=a.body?.getReader();if(!u)throw new Error("No response body");let c=await IV(u,i),{score:l,criticalCount:d,majorCount:g,minorCount:p,costUsd:m,inputTokens:k,outputTokens:I}=c;if(l!==null){let A=d>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",C=[`Score: ${l}`];d>0&&C.push(`${d} critical`),g>0&&C.push(`${g} major`),p>0&&C.push(`${p} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return lu(o,e.storyId,A,D,C.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:m,inputTokens:k,outputTokens:I}}return lu(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){b.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return lu(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var AV=q(),Oa="uireview/badge";function zF(){let e=!1,t=!1;try{let n=EV.getChannel();n.on(ey,async()=>{if(!t){t=!0,e=!1;try{await MV(n,()=>e)}finally{t=!1}}}),n.on(ty,()=>{e=!0})}catch{}}async function Zx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${AV}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(!n.ok)return[];let i=((await n.json()).mappings||[]).filter(s=>s.figmaNodeId).map(s=>{let a=s;return{storyId:a.storyId,storyName:a.name||a.storyId,figmaNodeId:a.figmaNodeId}});return PV(i),i}catch(e){return b.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function PV(e){try{if(typeof cu!="function")return;let t=cu(Oa);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Oa]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Oa];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Oa,storyId:s.storyId,title:"Mapped to Figma",description:"Ready for UI review \u2014 click Run to start"}));i.length>0&&t.set(i)}catch{}}function LV(){try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3}async function MV(e,t){let n=await Zx();if(n.length===0){e.emit($a,{total:0,passed:0,failed:0});return}let r=localStorage.getItem("uicopilot_session_token"),o=localStorage.getItem("uicopilot_selected_project_id");if(!r||!o)return;let i="claude-sonnet-4-6";try{let k=localStorage.getItem("uicopilot_selected_models");if(k){let I=JSON.parse(k);Array.isArray(I)&&I.length>0&&(i=I[0])}}catch{}let s=null;try{typeof cu=="function"&&(s=cu(Oa))}catch{}let a=LV(),u=0,c=0,l=0,d=0,g=0,p=0;e.emit(_a,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let m=n.map(k=>()=>RF(k,r,o,i,s,t));await DF(m,a,(k,I)=>{if(I&&typeof I=="object"&&"score"in I){let A=I;A.score!==null&&A.score>=90?u++:A.score!==null&&A.score>=70?c++:l++,d+=A.costUsd||0,g+=A.inputTokens||0,p+=A.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${k+1}/${n.length} done:`,n[k].storyName,I),e.emit(_a,{total:n.length,completed:u+c+l,currentStoryName:n[k].storyName})},t),e.emit($a,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:g,outputTokens:p})}var DV=mo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),RV=mo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),zV=mo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),OF=mo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),_F=mo.button(({theme:e,running:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",background:t?e.color.warning:e.color.secondary,border:"none",borderRadius:"6px",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,transition:"all 0.2s","&:disabled":{opacity:.4,cursor:"not-allowed"},"&:hover:not(:disabled)":{opacity:.9}})),NV=mo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),OV=mo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),$F=mo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),us=mo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),ey="uireview/review-all-start",ty="uireview/review-all-cancel",_a="uireview/review-all-progress",$a="uireview/review-all-complete";function UF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var jF=()=>{let[e,t]=Ua(!1),[n,r]=Ua(null),[o,i]=Ua(null),[s,a]=Ua(null),[u,c]=Ua(UF);ny(()=>{let m=()=>c(UF()),k=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(k),window.removeEventListener("storage",m)}},[]),ny(()=>{let m=()=>{Zx().then(C=>{a(C.length)}).catch(()=>{})},k=setTimeout(m,3e3),I=null;try{I=uu.getChannel(),I.on("storyChanged",m),I.on("uireview/mappings-changed",m)}catch{}let A=setInterval(m,6e4);return()=>{clearTimeout(k),clearInterval(A),I&&(I.off("storyChanged",m),I.off("uireview/mappings-changed",m))}},[]),ny(()=>{let m;try{m=uu.getChannel()}catch{return}let k=A=>{r(A),t(!0)},I=A=>{t(!1),r(null),i({total:A.total,passed:A.passed,failed:A.failed,warned:A.warnCount||0,costUsd:A.costUsd||0})};return m.on(_a,k),m.on($a,I),()=>{m.off(_a,k),m.off($a,I)}},[]);let l=NF(()=>{try{uu.getChannel().emit(ey),t(!0),i(null)}catch{}},[]),d=NF(()=>{try{uu.getChannel().emit(ty)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,p=BV();return u?Yt.createElement(DV,null,Yt.createElement(RV,null,Yt.createElement(zV,null,"UI Review"),e?Yt.createElement(_F,{running:!0,onClick:d},"Cancel"):Yt.createElement(_F,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Yt.createElement(Yt.Fragment,null,Yt.createElement($F,null,Yt.createElement(us,{dotColor:p.color.positive},"Pass (",o.passed,")"),Yt.createElement(us,{dotColor:p.color.warning},"Warn (",o.warned,")"),Yt.createElement(us,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Yt.createElement(OF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Yt.createElement($F,null,Yt.createElement(us,{dotColor:p.color.positive},"Pass"),Yt.createElement(us,{dotColor:p.color.warning},"Warn"),Yt.createElement(us,{dotColor:p.color.negative},"Fail")),e&&n&&Yt.createElement(Yt.Fragment,null,Yt.createElement(NV,null,Yt.createElement(OV,{percent:g})),Yt.createElement(OF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as WF from"@sentry/react";var _V="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",HF=!1;function $V(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function VF(){if(!HF){HF=!0;try{WF.init({dsn:_V,environment:$V(),release:`uicopilot-addon@${process.env.npm_package_version||"unknown"}`,tracesSampleRate:0,enabled:!0,beforeSend(e){return e.tags={...e.tags,component:"storybook-addon"},e}})}catch{}}}VF();var du="uireview",jV=`${du}/panel`,HV=`${du}/tool`,GF=`${du}/test-provider`;pu.register(du,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof oy=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=oy("uireview/badge");Nv(t);let n=oy("uireview/mapped");$v(n),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");pu.add(HV,{type:ry.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>ja.createElement(BF,null)}),zF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&pu.add(GF,{type:ry.experimental_TEST_PROVIDER,id:GF,render:()=>ja.createElement(jF,null)}),pu.add(jV,{type:ry.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>ja.createElement(UV,{active:t||!1},ja.createElement(_f,null,ja.createElement(LF,null)))})});
218
+ `,fV=Sr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),mV=Sr.div({fontSize:"32px"}),hV=Sr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),xV=Sr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),AF=Sr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",margin:"8px 12px",backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}50`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s2,color:e.color.defaultText})),PF=Sr.span({flex:1}),LF=Sr.button(({theme:e})=>({padding:"4px 12px",fontSize:11,fontWeight:600,border:`1px solid ${e.color.warning}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.warning,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:`${e.color.warning}15`}})),MF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Je(),{isConnected:r,sessionToken:o,authError:i}=ke(),{currentStoryId:s}=nt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ce(),[g,p]=sV(!1),m=()=>{l(null),o&&fetch(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{d({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};ym(),Rm(),EF(),Fm(),Cm();let{notification:v,dismissNotification:I}=IF();aV(()=>{if(v){let P=setTimeout(I,5e3);return()=>clearTimeout(P)}},[v,I]);let A=t.find(P=>P.id===e),C=r&&!!e&&!!A,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=nt(),_=C&&!!s&&!a&&R;return zt.createElement(hu,{header:zt.createElement(xu,{toolbar:zt.createElement(jf,{onOpenSettings:()=>p(!0)})}),footer:zt.createElement(gV,null,Pt.NAME," v","0.5.27")},v&&zt.createElement(cV,{variant:v.variant||"success"},zt.createElement(uV,null,v.variant==="error"?"!":v.variant==="warning"?"\u26A0":"+"),zt.createElement(pV,null,v.message),zt.createElement(dV,{onClick:I},"x")),i&&zt.createElement(AF,null,zt.createElement("span",null,"\u26A0"),zt.createElement(PF,null,i),zt.createElement(LF,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&zt.createElement(AF,null,zt.createElement("span",null,"\u{1F441}"),zt.createElement(PF,null,"Previewing as ",c),zt.createElement(LF,{onClick:m},"Exit preview")),D||_?zt.createElement(eu,{label:D?"Loading...":"Loading review..."}):C?zt.createElement(Xx,null):zt.createElement(fV,null,zt.createElement(mV,null,"\u2699"),zt.createElement(hV,null,i?"Connection issue":`Set up ${Pt.NAME}`),zt.createElement(xV,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),zt.createElement(on,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),g&&zt.createElement(t1,{onClose:()=>p(!1)}))};import BF,{useCallback as yV}from"react";import{useStorybookApi as bV}from"storybook/manager-api";import{IconButton as SV}from"storybook/internal/components";var wV="uireview",vV=`${wV}/panel`,DF=()=>{let e=bV(),t=yV(()=>{e.togglePanel(!0),e.setSelectedPanel(vV)},[e]);return BF.createElement(SV,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},BF.createElement(yF,null))};Te();import Yt,{useState as Ua,useCallback as OF,useEffect as ny}from"react";import{styled as mo,useTheme as BV}from"storybook/theming";import{addons as uu}from"storybook/manager-api";He();_e();import{addons as EV,experimental_getStatusStore as cu}from"storybook/manager-api";async function RF(e,t,n,r){let o=new Array(e.length),i=0;async function s(){for(;i<e.length&&!r();){let a=i++;try{let u=await e[a]();o[a]=u,r()||n(a,u)}catch(u){o[a]=u,r()||n(a,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),o}He();_e();var kV=q(),CV="uireview/badge";async function TV(e,t,n=3){for(let r=0;r<=n;r++){let o=await fetch(e,t);if(o.status!==429||r===n)return o;let i=Math.pow(2,r)*1e3;b.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function IV(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:d,value:g}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let p=r.split(`
219
+ `);r=p.pop()||"";for(let m of p)if(m.startsWith("data: "))try{let v=JSON.parse(m.slice(6));if(v.type==="complete"){o=v.complianceScore??v.validation?.complianceScore??null;let A=(v.issues||[]).filter(C=>!C.dismissed);i=A.filter(C=>C.severity==="critical").length,s=A.filter(C=>C.severity==="major").length,a=A.filter(C=>C.severity==="minor").length,u=v.costUsd||0,c=v.inputTokens||0,l=v.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function lu(e,t,n,r,o){e&&e.set([{value:n,typeId:CV,storyId:t,title:r,description:o}])}async function FV(e){let t=window.location.origin;try{let n=await fetch(`${t}/__uicopilot/capture?storyId=${encodeURIComponent(e)}`);if(n.ok){let r=await n.json();return{screenshot:r.screenshot||void 0,computedStyles:r.computedStyles||void 0,domTree:r.domTree||void 0}}}catch{}try{let n=await fetch(`${t}/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(n.ok)return{screenshot:(await n.json()).screenshot||void 0}}catch{}return{}}async function zF(e,t,n,r,o,i){lu(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await FV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await TV(`${kV}/api/review/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({projectId:n,storyId:e.storyId,storyName:e.storyName,storybookScreenshot:s.screenshot,computedStyles:s.computedStyles,domTree:s.domTree,aiModels:[r]})});if(console.warn(`[reviewAll] API response for ${e.storyName}: HTTP ${a.status}`),!a.ok)throw new Error(`HTTP ${a.status}`);let u=a.body?.getReader();if(!u)throw new Error("No response body");let c=await IV(u,i),{score:l,criticalCount:d,majorCount:g,minorCount:p,costUsd:m,inputTokens:v,outputTokens:I}=c;if(l!==null){let A=d>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",C=[`Score: ${l}`];d>0&&C.push(`${d} critical`),g>0&&C.push(`${g} major`),p>0&&C.push(`${p} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return lu(o,e.storyId,A,D,C.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:m,inputTokens:v,outputTokens:I}}return lu(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){b.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return lu(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var AV=q(),Oa="uireview/badge";function NF(){let e=!1,t=!1;try{let n=EV.getChannel();n.on(ey,async()=>{if(!t){t=!0,e=!1;try{await MV(n,()=>e)}finally{t=!1}}}),n.on(ty,()=>{e=!0})}catch{}}async function Zx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${AV}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(!n.ok)return[];let i=((await n.json()).mappings||[]).filter(s=>s.figmaNodeId).map(s=>{let a=s;return{storyId:a.storyId,storyName:a.name||a.storyId,figmaNodeId:a.figmaNodeId}});return PV(i),i}catch(e){return b.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function PV(e){try{if(typeof cu!="function")return;let t=cu(Oa);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Oa]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Oa];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Oa,storyId:s.storyId,title:"Mapped to Figma",description:"Ready for UI review \u2014 click Run to start"}));i.length>0&&t.set(i)}catch{}}function LV(){try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3}async function MV(e,t){let n=await Zx();if(n.length===0){e.emit($a,{total:0,passed:0,failed:0});return}let r=localStorage.getItem("uicopilot_session_token"),o=localStorage.getItem("uicopilot_selected_project_id");if(!r||!o)return;let i="claude-sonnet-4-6";try{let v=localStorage.getItem("uicopilot_selected_models");if(v){let I=JSON.parse(v);Array.isArray(I)&&I.length>0&&(i=I[0])}}catch{}let s=null;try{typeof cu=="function"&&(s=cu(Oa))}catch{}let a=LV(),u=0,c=0,l=0,d=0,g=0,p=0;e.emit(_a,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let m=n.map(v=>()=>zF(v,r,o,i,s,t));await RF(m,a,(v,I)=>{if(I&&typeof I=="object"&&"score"in I){let A=I;A.score!==null&&A.score>=90?u++:A.score!==null&&A.score>=70?c++:l++,d+=A.costUsd||0,g+=A.inputTokens||0,p+=A.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${v+1}/${n.length} done:`,n[v].storyName,I),e.emit(_a,{total:n.length,completed:u+c+l,currentStoryName:n[v].storyName})},t),e.emit($a,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:g,outputTokens:p})}var DV=mo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),RV=mo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),zV=mo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),_F=mo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),$F=mo.button(({theme:e,running:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",background:t?e.color.warning:e.color.secondary,border:"none",borderRadius:"6px",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,transition:"all 0.2s","&:disabled":{opacity:.4,cursor:"not-allowed"},"&:hover:not(:disabled)":{opacity:.9}})),NV=mo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),OV=mo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),UF=mo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),us=mo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),ey="uireview/review-all-start",ty="uireview/review-all-cancel",_a="uireview/review-all-progress",$a="uireview/review-all-complete";function jF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var HF=()=>{let[e,t]=Ua(!1),[n,r]=Ua(null),[o,i]=Ua(null),[s,a]=Ua(null),[u,c]=Ua(jF);ny(()=>{let m=()=>c(jF()),v=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(v),window.removeEventListener("storage",m)}},[]),ny(()=>{let m=()=>{Zx().then(C=>{a(C.length)}).catch(()=>{})},v=setTimeout(m,3e3),I=null;try{I=uu.getChannel(),I.on("storyChanged",m),I.on("uireview/mappings-changed",m)}catch{}let A=setInterval(m,6e4);return()=>{clearTimeout(v),clearInterval(A),I&&(I.off("storyChanged",m),I.off("uireview/mappings-changed",m))}},[]),ny(()=>{let m;try{m=uu.getChannel()}catch{return}let v=A=>{r(A),t(!0)},I=A=>{t(!1),r(null),i({total:A.total,passed:A.passed,failed:A.failed,warned:A.warnCount||0,costUsd:A.costUsd||0})};return m.on(_a,v),m.on($a,I),()=>{m.off(_a,v),m.off($a,I)}},[]);let l=OF(()=>{try{uu.getChannel().emit(ey),t(!0),i(null)}catch{}},[]),d=OF(()=>{try{uu.getChannel().emit(ty)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,p=BV();return u?Yt.createElement(DV,null,Yt.createElement(RV,null,Yt.createElement(zV,null,"UI Review"),e?Yt.createElement($F,{running:!0,onClick:d},"Cancel"):Yt.createElement($F,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Yt.createElement(Yt.Fragment,null,Yt.createElement(UF,null,Yt.createElement(us,{dotColor:p.color.positive},"Pass (",o.passed,")"),Yt.createElement(us,{dotColor:p.color.warning},"Warn (",o.warned,")"),Yt.createElement(us,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Yt.createElement(_F,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Yt.createElement(UF,null,Yt.createElement(us,{dotColor:p.color.positive},"Pass"),Yt.createElement(us,{dotColor:p.color.warning},"Warn"),Yt.createElement(us,{dotColor:p.color.negative},"Fail")),e&&n&&Yt.createElement(Yt.Fragment,null,Yt.createElement(NV,null,Yt.createElement(OV,{percent:g})),Yt.createElement(_F,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as VF from"@sentry/react";var _V="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",WF=!1;function $V(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function GF(){if(!WF){WF=!0;try{VF.init({dsn:_V,environment:$V(),release:`uicopilot-addon@${process.env.npm_package_version||"unknown"}`,tracesSampleRate:0,enabled:!0,beforeSend(e){return e.tags={...e.tags,component:"storybook-addon"},e}})}catch{}}}GF();var du="uireview",jV=`${du}/panel`,HV=`${du}/tool`,qF=`${du}/test-provider`;pu.register(du,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof oy=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=oy("uireview/badge");Nv(t);let n=oy("uireview/mapped");$v(n),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");pu.add(HV,{type:ry.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>ja.createElement(DF,null)}),NF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&pu.add(qF,{type:ry.experimental_TEST_PROVIDER,id:qF,render:()=>ja.createElement(HF,null)}),pu.add(jV,{type:ry.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>ja.createElement(UV,{active:t||!1},ja.createElement(_f,null,ja.createElement(MF,null)))})});
220
220
  /*! Bundled license information:
221
221
 
222
222
  @noble/hashes/utils.js: