@uicopilot/storybook-addon 0.5.22 → 0.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/manager.mjs +51 -51
- package/package.json +5 -3
package/dist/manager.mjs
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
var GF=Object.create;var $a=Object.defineProperty;var qF=Object.getOwnPropertyDescriptor;var YF=Object.getOwnPropertyNames;var KF=Object.getPrototypeOf,XF=Object.prototype.hasOwnProperty;var QF=(e,t,n)=>t in e?$a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t)=>()=>(e&&(t=e(e=0)),t);var ir=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Se=(e,t)=>{for(var n in t)$a(e,n,{get:t[n],enumerable:!0})},JF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of YF(t))!XF.call(e,o)&&o!==n&&$a(e,o,{get:()=>t[o],enumerable:!(r=qF(t,o))||r.enumerable});return e};var Ua=(e,t,n)=>(n=e!=null?GF(KF(e)):{},JF(t||!e||!e.__esModule?$a(n,"default",{value:e,enumerable:!0}):n,e));var sr=(e,t,n)=>QF(e,typeof t!="symbol"?t+"":t,n);function gy(){try{return typeof window<"u"&&localStorage.getItem(nE)==="true"}catch{return!1}}var nE,y,$e=_(()=>{"use strict";nE="uicopilot:debug";y={debug:(...e)=>{gy()&&console.log(...e)},info:(...e)=>{gy()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import rE,{createContext as oE,useContext as iE,useReducer as sE,useMemo as fy}from"react";function aE(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"),y.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 hu({children:e}){let[t,n]=sE(aE,pE),r=fy(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{y.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=fy(()=>({...t,...r}),[t,r]);return rE.createElement(hy.Provider,{value:o},e)}function we(){let e=iE(hy);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var lE,cE,uE,my,pE,hy,xu=_(()=>{"use strict";$e();lE=()=>{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"))};lE();cE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),uE=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",my=cE(),pE={isConnected:!!my,sessionToken:my,apiKey:uE(),authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},hy=oE(null)});import dE,{createContext as gE,useContext as fE,useReducer as mE,useMemo as xy,useRef as hE,useEffect as xE}from"react";function yE(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 yu({children:e}){let[t,n]=mE(yE,SE),r=hE(t);xE(()=>{r.current=t},[t]);let o=xy(()=>({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=xy(()=>({...t,...o}),[t,o]);return dE.createElement(yy.Provider,{value:i},e)}function Je(){let e=fE(yy);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var bE,SE,yy,bu=_(()=>{"use strict";bE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),SE={projects:[],selectedProjectId:bE(),loadingProjects:!1,currentStorybookPath:null},yy=gE(null)});import wE,{createContext as vE,useContext as kE,useReducer as CE,useMemo as by}from"react";function TE(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>Sy)for(let o of r.slice(0,r.length-Sy))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 Su({children:e}){let[t,n]=CE(TE,IE),r=by(()=>({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=by(()=>({...t,...r}),[t,r]);return wE.createElement(wy.Provider,{value:o},e)}function nt(){let e=kE(wy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var Sy,IE,wy,wu=_(()=>{"use strict";Sy=200;IE={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,mappingsByStoryId:{},reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},wy=vE(null)});var Ft,vu=_(()=>{"use strict";Ft={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 FE(){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 Va,ku,vy=_(()=>{"use strict";vu();Va=`[${Ft.NAME}]`,ku={debug:(...e)=>{FE()&&console.log(Va,...e)},info:(...e)=>{console.log(Va,...e)},warn:(...e)=>{console.warn(Va,...e)},error:(...e)=>{console.error(Va,...e)}}});var ky=_(()=>{"use strict"});var Cu=_(()=>{"use strict"});function Ut(e){return e>=48&&e<=57}function Mn(e){return Ut(e)||e>=65&&e<=70||e>=97&&e<=102}function qa(e){return e>=65&&e<=90}function AE(e){return e>=97&&e<=122}function PE(e){return qa(e)||AE(e)}function LE(e){return e>=128}function Ga(e){return PE(e)||LE(e)||e===95}function Ya(e){return Ga(e)||Ut(e)||e===45}function ME(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function gs(e){return e===10||e===13||e===12}function Or(e){return gs(e)||e===32||e===9}function Ln(e,t){return!(e!==92||gs(t)||t===0)}function fi(e,t,n){return e===45?Ga(t)||t===45||Ln(t,n):Ga(e)?!0:e===92?Ln(e,t):!1}function Ka(e,t,n){return e===43||e===45?Ut(t)?2:t===46&&Ut(n)?3:0:e===46?Ut(t)?2:0:Ut(e)?1:0}function Xa(e){return e===65279||e===65534?1:0}function Ja(e){return e<128?Tu[e]:Qa}var Tu,BE,fs,Iu,Qa,Fu,ms=_(()=>{"use strict";Tu=new Array(128),BE=128,fs=130,Iu=131,Qa=132,Fu=133;for(let e=0;e<Tu.length;e++)Tu[e]=Or(e)&&fs||Ut(e)&&Iu||Ga(e)&&Qa||ME(e)&&Fu||e||BE});function mi(e,t){return t<e.length?e.charCodeAt(t):0}function Za(e,t,n){return n===13&&mi(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 Cy(e,t){for(;t>=0&&Or(e.charCodeAt(t));t--);return t+1}function hs(e,t){for(;t<e.length&&Or(e.charCodeAt(t));t++);return t}function Eu(e,t){for(;t<e.length&&Ut(e.charCodeAt(t));t++);return t}function Qr(e,t){if(t+=2,Mn(mi(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Mn(mi(e,t));t++);let n=mi(e,t);Or(n)&&(t+=Za(e,t,n))}return t}function xs(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Ya(n)){if(Ln(n,mi(e,t+1))){t=Qr(e,t)-1;continue}break}}return t}function Go(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),Ut(n)&&(t=Eu(e,t+1),n=e.charCodeAt(t)),n===46&&Ut(e.charCodeAt(t+1))&&(t+=2,t=Eu(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)),Ut(n)&&(t=Eu(e,t+1+r+1))}return t}function el(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}Ln(n,mi(e,t+1))&&(t=Qr(e,t))}return t}function tl(e){if(e.length===1&&!Mn(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 nl=_(()=>{"use strict";ms()});var hi,Au=_(()=>{"use strict";hi=["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 xi(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Pu=_(()=>{"use strict"});function Fy(e){let t=e.source,n=t.length,r=t.length>0?Xa(t.charCodeAt(0)):0,o=xi(e.lines,n),i=xi(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===Ty||c===Iy||c===DE)&&(c===Iy&&u+1<n&&t.charCodeAt(u+1)===Ty&&(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 Ty,DE,Iy,rl,Ey=_(()=>{"use strict";Pu();ms();Ty=10,DE=12,Iy=13;rl=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||Fy(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||Fy(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 Ay(e,t,n){return e<t?t:e>n?n:e}var Sr,wr,ys,il,wo,vr,ol,Py=_(()=>{"use strict";Pu();nl();Au();Sr=16777215,wr=24,ys=1,il=2,wo=new Uint8Array(32);wo[2]=22;wo[21]=22;wo[19]=20;wo[23]=24;vr=new Uint8Array(32);vr[2]=ys;vr[21]=ys;vr[19]=ys;vr[23]=ys;vr[22]=il;vr[20]=il;vr[24]=il;ol=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=xi(this.offsetAndType,t.length+1),i=xi(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<<wr|g,a===-1&&(a=d),i[p]=c,l===u){let f=i[c];i[c]=p,c=f,u=wo[o[f]>>wr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=wo[l])}),o[s]=0<<wr|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]>>wr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>wr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&Sr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>wr;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]&Sr,this.offsetAndType[t]&Sr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&Sr:this.offsetAndType[this.tokenCount]&Sr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[Ay(t,0,this.tokenCount)]&Sr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[Ay(t,0,this.tokenCount)]>>wr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return vr[t]===ys}isBlockCloserTokenType(t){return vr[t]===il}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(vr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return wo[n]===o?r:-1}else if(vr[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]&Sr,n=this.offsetAndType[n],this.tokenType=n>>wr,this.tokenEnd=n&Sr):(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>>wr,this.tokenEnd=t&Sr):(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]&Sr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>wr)&&(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&Sr,a=i>>wr;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:hi[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=Go(e,c),fi(n(c),n(c+1),n(c+2))){l=12,c=xs(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=xs(e,c),Xr(e,d,c,"url")&&n(c)===40){if(c=hs(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(Ja(g)){case d:c++;return;case fs:if(gs(g)){c+=Za(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);gs(p)?c+=Za(e,c+1,p):Ln(g,p)&&(c=Qr(e,c)-1);break}}}function s(){for(l=7,c=hs(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch(Ja(d)){case 41:c++;return;case fs:if(c=hs(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=el(e,c),l=8;return;case 34:case 39:case 40:case Fu:c=el(e,c),l=8;return;case 92:if(Ln(d,n(c+1))){c=Qr(e,c)-1;break}c=el(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Xa(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch(Ja(d)){case fs:l=13,c=hs(e,c+1);break;case 34:i();break;case 35:Ya(n(c+1))||Ln(n(c+1),n(c+2))?(l=4,c=xs(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:Ka(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Ka(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):fi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Ka(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:fi(n(c+1),n(c+2),n(c+3))?(l=3,c=xs(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:Ln(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 Iu:r();break;case Qa:o();break;default:l=9,c++}t(l,u,u=c)}}var lr=_(()=>{"use strict";ms();nl();Cu();Cu();Au();ms();nl();Ey();Py()});var yi,Jn,Ss=_(()=>{"use strict";yi=null,Jn=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 yi!==null?(r=yi,yi=yi.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=yi,yi=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 Yo(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}
|
|
1
|
+
var qF=Object.create;var $a=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?$a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t)=>()=>(e&&(t=e(e=0)),t);var ir=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Se=(e,t)=>{for(var n in t)$a(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&&$a(e,o,{get:()=>t[o],enumerable:!(r=YF(t,o))||r.enumerable});return e};var Ua=(e,t,n)=>(n=e!=null?qF(XF(e)):{},ZF(t||!e||!e.__esModule?$a(n,"default",{value:e,enumerable:!0}):n,e));var sr=(e,t,n)=>JF(e,typeof t!="symbol"?t+"":t,n);function gy(){try{return typeof window<"u"&&localStorage.getItem(rE)==="true"}catch{return!1}}var rE,y,$e=_(()=>{"use strict";rE="uicopilot:debug";y={debug:(...e)=>{gy()&&console.log(...e)},info:(...e)=>{gy()&&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 fy}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"),y.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 hu({children:e}){let[t,n]=aE(lE,dE),r=fy(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{y.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=fy(()=>({...t,...r}),[t,r]);return oE.createElement(hy.Provider,{value:o},e)}function we(){let e=sE(hy);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var cE,uE,pE,my,dE,hy,xu=_(()=>{"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")||"",my=uE(),dE={isConnected:!!my,sessionToken:my,apiKey:pE(),authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},hy=iE(null)});import gE,{createContext as fE,useContext as mE,useReducer as hE,useMemo as xy,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 yu({children:e}){let[t,n]=hE(bE,wE),r=xE(t);yE(()=>{r.current=t},[t]);let o=xy(()=>({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=xy(()=>({...t,...o}),[t,o]);return gE.createElement(yy.Provider,{value:i},e)}function Je(){let e=mE(yy);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var SE,wE,yy,bu=_(()=>{"use strict";SE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),wE={projects:[],selectedProjectId:SE(),loadingProjects:!1,currentStorybookPath:null},yy=fE(null)});import vE,{createContext as kE,useContext as CE,useReducer as TE,useMemo as by}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>Sy)for(let o of r.slice(0,r.length-Sy))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 Su({children:e}){let[t,n]=TE(IE,FE),r=by(()=>({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=by(()=>({...t,...r}),[t,r]);return vE.createElement(wy.Provider,{value:o},e)}function nt(){let e=CE(wy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var Sy,FE,wy,wu=_(()=>{"use strict";Sy=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:{}},wy=kE(null)});var Et,vu=_(()=>{"use strict";Et={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 Va,ku,vy=_(()=>{"use strict";vu();Va=`[${Et.NAME}]`,ku={debug:(...e)=>{EE()&&console.log(Va,...e)},info:(...e)=>{console.log(Va,...e)},warn:(...e)=>{console.warn(Va,...e)},error:(...e)=>{console.error(Va,...e)}}});var ky=_(()=>{"use strict"});var Cu=_(()=>{"use strict"});function jt(e){return e>=48&&e<=57}function Bn(e){return jt(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 Ga(e){return LE(e)||ME(e)||e===95}function Ya(e){return Ga(e)||jt(e)||e===45}function BE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function gs(e){return e===10||e===13||e===12}function Or(e){return gs(e)||e===32||e===9}function Mn(e,t){return!(e!==92||gs(t)||t===0)}function fi(e,t,n){return e===45?Ga(t)||t===45||Mn(t,n):Ga(e)?!0:e===92?Mn(e,t):!1}function Ka(e,t,n){return e===43||e===45?jt(t)?2:t===46&&jt(n)?3:0:e===46?jt(t)?2:0:jt(e)?1:0}function Xa(e){return e===65279||e===65534?1:0}function Ja(e){return e<128?Tu[e]:Qa}var Tu,DE,fs,Iu,Qa,Fu,ms=_(()=>{"use strict";Tu=new Array(128),DE=128,fs=130,Iu=131,Qa=132,Fu=133;for(let e=0;e<Tu.length;e++)Tu[e]=Or(e)&&fs||jt(e)&&Iu||Ga(e)&&Qa||BE(e)&&Fu||e||DE});function mi(e,t){return t<e.length?e.charCodeAt(t):0}function Za(e,t,n){return n===13&&mi(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 Cy(e,t){for(;t>=0&&Or(e.charCodeAt(t));t--);return t+1}function hs(e,t){for(;t<e.length&&Or(e.charCodeAt(t));t++);return t}function Eu(e,t){for(;t<e.length&&jt(e.charCodeAt(t));t++);return t}function Qr(e,t){if(t+=2,Bn(mi(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Bn(mi(e,t));t++);let n=mi(e,t);Or(n)&&(t+=Za(e,t,n))}return t}function xs(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Ya(n)){if(Mn(n,mi(e,t+1))){t=Qr(e,t)-1;continue}break}}return t}function Go(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),jt(n)&&(t=Eu(e,t+1),n=e.charCodeAt(t)),n===46&&jt(e.charCodeAt(t+1))&&(t+=2,t=Eu(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)),jt(n)&&(t=Eu(e,t+1+r+1))}return t}function el(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}Mn(n,mi(e,t+1))&&(t=Qr(e,t))}return t}function tl(e){if(e.length===1&&!Bn(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 nl=_(()=>{"use strict";ms()});var hi,Au=_(()=>{"use strict";hi=["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 xi(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Pu=_(()=>{"use strict"});function Fy(e){let t=e.source,n=t.length,r=t.length>0?Xa(t.charCodeAt(0)):0,o=xi(e.lines,n),i=xi(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===Ty||c===Iy||c===RE)&&(c===Iy&&u+1<n&&t.charCodeAt(u+1)===Ty&&(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 Ty,RE,Iy,rl,Ey=_(()=>{"use strict";Pu();ms();Ty=10,RE=12,Iy=13;rl=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||Fy(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||Fy(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 Ay(e,t,n){return e<t?t:e>n?n:e}var Sr,wr,ys,il,wo,vr,ol,Py=_(()=>{"use strict";Pu();nl();Au();Sr=16777215,wr=24,ys=1,il=2,wo=new Uint8Array(32);wo[2]=22;wo[21]=22;wo[19]=20;wo[23]=24;vr=new Uint8Array(32);vr[2]=ys;vr[21]=ys;vr[19]=ys;vr[23]=ys;vr[22]=il;vr[20]=il;vr[24]=il;ol=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=xi(this.offsetAndType,t.length+1),i=xi(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,p,g)=>{let d=s++;if(o[d]=l<<wr|g,a===-1&&(a=p),i[d]=c,l===u){let f=i[c];i[c]=d,c=f,u=wo[o[f]>>wr]}else this.isBlockOpenerTokenType(l)&&(c=d,u=wo[l])}),o[s]=0<<wr|r,i[s]=s;for(let l=0;l<s;l++){let p=i[l];if(p<=l){let g=i[p];g!==l&&(i[l]=g)}else p>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]>>wr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>wr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&Sr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>wr;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]&Sr,this.offsetAndType[t]&Sr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&Sr:this.offsetAndType[this.tokenCount]&Sr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[Ay(t,0,this.tokenCount)]&Sr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[Ay(t,0,this.tokenCount)]>>wr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return vr[t]===ys}isBlockCloserTokenType(t){return vr[t]===il}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(vr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return wo[n]===o?r:-1}else if(vr[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]&Sr,n=this.offsetAndType[n],this.tokenType=n>>wr,this.tokenEnd=n&Sr):(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>>wr,this.tokenEnd=t&Sr):(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]&Sr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>wr)&&(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&Sr,a=i>>wr;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:hi[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function vo(e,t){function n(p){return p<a?e.charCodeAt(p):0}function r(){if(c=Go(e,c),fi(n(c),n(c+1),n(c+2))){l=12,c=xs(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let p=c;if(c=xs(e,c),Xr(e,p,c,"url")&&n(c)===40){if(c=hs(e,c+1),n(c)===34||n(c)===39){l=2,c=p+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(p){for(p||(p=n(c++)),l=5;c<e.length;c++){let g=e.charCodeAt(c);switch(Ja(g)){case p:c++;return;case fs:if(gs(g)){c+=Za(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let d=n(c+1);gs(d)?c+=Za(e,c+1,d):Mn(g,d)&&(c=Qr(e,c)-1);break}}}function s(){for(l=7,c=hs(e,c);c<e.length;c++){let p=e.charCodeAt(c);switch(Ja(p)){case 41:c++;return;case fs:if(c=hs(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=el(e,c),l=8;return;case 34:case 39:case 40:case Fu:c=el(e,c),l=8;return;case 92:if(Mn(p,n(c+1))){c=Qr(e,c)-1;break}c=el(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Xa(n(0)),c=u,l;for(;c<a;){let p=e.charCodeAt(c);switch(Ja(p)){case fs:l=13,c=hs(e,c+1);break;case 34:i();break;case 35:Ya(n(c+1))||Mn(n(c+1),n(c+2))?(l=4,c=xs(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:Ka(p,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Ka(p,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):fi(p,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Ka(p,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:fi(n(c+1),n(c+2),n(c+3))?(l=3,c=xs(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:Mn(p,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 Iu:r();break;case Qa:o();break;default:l=9,c++}t(l,u,u=c)}}var lr=_(()=>{"use strict";ms();nl();Cu();Cu();Au();ms();nl();Ey();Py()});var yi,Jn,Ss=_(()=>{"use strict";yi=null,Jn=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 yi!==null?(r=yi,yi=yi.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=yi,yi=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 Yo(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
2
|
`)}})}var al=_(()=>{"use strict"});function By({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(f,k){return c.slice(f,k).map((T,E)=>String(f+E+1).padStart(g)+" |"+T).join(`
|
|
3
3
|
`)}let a=`
|
|
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,
|
|
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,p=Math.min(t+i,c.length+1),g=Math.max(4,String(p).length)+1,d=0;n+=(My.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>Lu&&(d=n-Ly+3,n=Ly-2);for(let f=l;f<=p;f++)f>=0&&f<c.length&&(c[f]=c[f].replace(/\t/g,My),c[f]=(d>0&&c[f].length>d?"\u2026":"")+c[f].substr(d,Lu-2)+(c[f].length>d+Lu-1?"\u2026":""));return[s(l,t),new Array(n+g+2).join("-")+"^",s(t,p)].filter(Boolean).join(`
|
|
5
5
|
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Mu(e,t,n,r,o,i=1,s=1){return Object.assign(Yo("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return By({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
|
|
6
|
-
`+By({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Lu,Ly,My,Dy=_(()=>{"use strict";al();Lu=100,Ly=60,My=" "});function Ry(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 zy=_(()=>{"use strict"});function _E(e){return function(){return this[e]()}}function Du(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 $E(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:Du(e.atrule),pseudo:Du(e.pseudo),node:Du(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=bi,i=!1,s=new rl,a=Object.assign(new ol,$E(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Ry,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Ny?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Ny||l===Bu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===RE||l===Bu?1:0},consumeUntilSemicolonIncluded(l){return l===Bu?2:0},createList:bi,createSingleNodeList:bi,getFirstListNode:bi,getLastListNode:bi,parseWithFallback(l,d){let g=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(g-this.tokenIndex);let f=d.call(this);return i=!0,o(p,f),i=!1,f}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==Oy);return Oy},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,Go(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=hi[l].slice(0,-6).replace(/-/g," ").replace(/^./,f=>f.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(zE)&&(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(Cy(t,t.length-1)):s.getLocation(this.tokenStart);throw new Mu(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=>hi[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:bi,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:f,onToken:k}=d;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,p?OE:NE),Array.isArray(k)?a.forEachToken((E,I,D)=>{k.push({type:E,start:I,end:D})}):typeof k=="function"&&a.forEachToken(k.bind(u())),typeof f=="function"&&a.forEachToken((E,I,D)=>{if(E===25){let R=a.getLocation(I,D),$=Xr(t,D-2,D,"*/")?t.slice(I+2,D-2):t.slice(I+2,D);f($,R)}});let T=a.context[g].call(a,d);return a.eof||a.error(),T},{SyntaxError:Mu,config:a.config})}var bi,RE,zE,Bu,Ny,Oy,NE,OE,$y=_(()=>{"use strict";Ss();Dy();lr();zy();bi=()=>{},RE=33,zE=35,Bu=59,Ny=123,Oy=0,NE={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}},OE={createList(){return new Jn},createSingleNodeList(e){return new Jn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var jy=ir(Ru=>{"use strict";var Uy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Ru.encode=function(e){if(0<=e&&e<Uy.length)return Uy[e];throw new TypeError("Must be between 0 and 63: "+e)};Ru.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 qy=ir(Nu=>{"use strict";var Hy=jy(),zu=5,Wy=1<<zu,Vy=Wy-1,Gy=Wy;function UE(e){return e<0?(-e<<1)+1:(e<<1)+0}function jE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}Nu.encode=function(t){var n="",r,o=UE(t);do r=o&Vy,o>>>=zu,o>0&&(r|=Gy),n+=Hy.encode(r);while(o>0);return n};Nu.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=Hy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Gy),u&=Vy,i=i+(u<<s),s+=zu}while(a);r.value=jE(i),r.rest=n}});var ll=ir(sn=>{"use strict";function HE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}sn.getArg=HE;var Yy=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,WE=/^data:.+\,.+$/;function ws(e){var t=e.match(Yy);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}sn.urlParse=ws;function Si(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}sn.urlGenerate=Si;var VE=32;function GE(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>VE&&t.pop(),i}}var Ou=GE(function(t){var n=t,r=ws(t);if(r){if(!r.path)return t;n=r.path}for(var o=sn.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,Si(r)):n});sn.normalize=Ou;function Ky(e,t){e===""&&(e="."),t===""&&(t=".");var n=ws(t),r=ws(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),Si(n);if(n||t.match(WE))return t;if(r&&!r.host&&!r.path)return r.host=t,Si(r);var o=t.charAt(0)==="/"?t:Ou(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,Si(r)):o}sn.join=Ky;sn.isAbsolute=function(e){return e.charAt(0)==="/"||Yy.test(e)};function qE(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)}sn.relative=qE;var Xy=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Qy(e){return e}function YE(e){return Jy(e)?"$"+e:e}sn.toSetString=Xy?Qy:YE;function KE(e){return Jy(e)?e.slice(1):e}sn.fromSetString=Xy?Qy:KE;function Jy(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 XE(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)}sn.compareByOriginalPositions=XE;function QE(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)}sn.compareByOriginalPositionsNoSource=QE;function JE(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)}sn.compareByGeneratedPositionsDeflated=JE;function ZE(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)}sn.compareByGeneratedPositionsDeflatedNoLine=ZE;function Jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function eA(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)}sn.compareByGeneratedPositionsInflated=eA;function tA(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}sn.parseSourceMapInput=tA;function nA(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ws(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=Ky(Si(r),t)}return Ou(t)}sn.computeSourceURL=nA});var eb=ir(Zy=>{"use strict";var _u=ll(),$u=Object.prototype.hasOwnProperty,Ko=typeof Map<"u";function Zr(){this._array=[],this._set=Ko?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 Ko?this._set.size:Object.getOwnPropertyNames(this._set).length};Zr.prototype.add=function(t,n){var r=Ko?t:_u.toSetString(t),o=Ko?this.has(t):$u.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Ko?this._set.set(t,i):this._set[r]=i)};Zr.prototype.has=function(t){if(Ko)return this._set.has(t);var n=_u.toSetString(t);return $u.call(this._set,n)};Zr.prototype.indexOf=function(t){if(Ko){var n=this._set.get(t);if(n>=0)return n}else{var r=_u.toSetString(t);if($u.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()};Zy.ArraySet=Zr});var rb=ir(nb=>{"use strict";var tb=ll();function rA(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||tb.compareByGeneratedPositionsInflated(e,t)<=0}function cl(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}cl.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};cl.prototype.add=function(t){rA(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};cl.prototype.toArray=function(){return this._sorted||(this._array.sort(tb.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};nb.MappingList=cl});var ib=ir(ob=>{"use strict";var vs=qy(),jt=ll(),ul=eb().ArraySet,oA=rb().MappingList;function cr(e){e||(e={}),this._file=jt.getArg(e,"file",null),this._sourceRoot=jt.getArg(e,"sourceRoot",null),this._skipValidation=jt.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=jt.getArg(e,"ignoreInvalidMapping",!1),this._sources=new ul,this._names=new ul,this._mappings=new oA,this._sourcesContents=null}cr.prototype._version=3;cr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new cr(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=jt.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=jt.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};cr.prototype.addMapping=function(t){var n=jt.getArg(t,"generated"),r=jt.getArg(t,"original",null),o=jt.getArg(t,"source",null),i=jt.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}))};cr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=jt.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[jt.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[jt.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};cr.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=jt.relative(i,o));var s=new ul,a=new ul;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=jt.join(r,u.source)),i!=null&&(u.source=jt.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=jt.join(r,u)),i!=null&&(u=jt.relative(i,u)),this.setSourceContent(u,c))},this)};cr.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)}};cr.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,f=g.length;p<f;p++){if(c=g[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!jt.compareByGeneratedPositionsInflated(c,g[p-1]))continue;u+=","}u+=vs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=vs.encode(d-s),s=d,u+=vs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=vs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=vs.encode(l-i),i=l)),a+=u}return a};cr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=jt.relative(n,r));var o=jt.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};cr.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};cr.prototype.toString=function(){return JSON.stringify(this.toJSON())};ob.SourceMapGenerator=cr});function lb(e){let t=new ab.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&&sb.has(g.type)){let p=g.loc.start.line,f=g.loc.start.column-1;(r.line!==p||r.column!==f)&&(r.line=p,r.column=f,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&&sb.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,p,f){for(let k=0;k<g.length;k++)g.charCodeAt(k)===10?(s++,a=0):a++;l(g,p,f)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var ab,sb,cb=_(()=>{"use strict";ab=Ua(ib(),1),sb=new Set(["Atrule","Selector","Declaration"])});var pl={};Se(pl,{safe:()=>ju,spec:()=>lA});function pb(e){let t=new Set(e.map(([n,r])=>Uu(n)<<16|Uu(r)));return function(n,r,o){let i=Uu(r,o),s=o.charCodeAt(0),a=s===sA&&r!==1&&r!==2&&r!==15||s===iA?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var iA,sA,Uu,ub,aA,lA,ju,db=_(()=>{"use strict";iA=43,sA=45,Uu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),ub=[[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],["/","*"]],aA=ub.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,"-"]]);lA=pb(ub),ju=pb(aA)});function uA(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 gb(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:ju,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)===cA&&this.emit(`
|
|
7
|
-
`,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=lb(s)),r.mode in pl&&(s.tokenBefore=pl[r.mode]));let a={node:u=>s.node(u),children:
|
|
6
|
+
`+By({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Lu,Ly,My,Dy=_(()=>{"use strict";al();Lu=100,Ly=60,My=" "});function Ry(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 zy=_(()=>{"use strict"});function $E(e){return function(){return this[e]()}}function Du(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:Du(e.atrule),pseudo:Du(e.pseudo),node:Du(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=bi,i=!1,s=new rl,a=Object.assign(new ol,UE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Ry,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Ny?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Ny||l===Bu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===zE||l===Bu?1:0},consumeUntilSemicolonIncluded(l){return l===Bu?2:0},createList:bi,createSingleNodeList:bi,getFirstListNode:bi,getLastListNode:bi,parseWithFallback(l,p){let g=this.tokenIndex;try{return l.call(this)}catch(d){if(i)throw d;this.skip(g-this.tokenIndex);let f=p.call(this);return i=!0,o(d,f),i=!1,f}},lookupNonWSType(l){let p;do if(p=this.lookupType(l++),p!==13&&p!==25)return p;while(p!==Oy);return Oy},charCodeAt(l){return l>=0&&l<t.length?t.charCodeAt(l):0},substring(l,p){return t.substring(l,p)},substrToCursor(l){return this.source.substring(l,this.tokenStart)},cmpChar(l,p){return Kr(t,l,p)},cmpStr(l,p,g){return Xr(t,l,p,g)},consume(l){let p=this.tokenStart;return this.eat(l),this.substrToCursor(p)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let p=t.substring(this.tokenStart,Go(t,this.tokenStart));return this.eat(l),p},eat(l){if(this.tokenType!==l){let p=hi[l].slice(0,-6).replace(/-/g," ").replace(/^./,f=>f.toUpperCase()),g=`${/[[\](){}]/.test(p)?`"${p}"`:p} is expected`,d=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(d=this.tokenEnd-1,g="Identifier is expected but function found"):g="Identifier is expected";break;case 4:this.isDelim(NE)&&(this.next(),d++,g="Name is expected");break;case 11:this.tokenType===10&&(d=this.tokenEnd,g="Percent sign is expected");break}this.error(g,d)}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,p){return r?s.getLocationRange(l,p,n):null},getLocationFromList(l){if(r){let p=this.getFirstListNode(l),g=this.getLastListNode(l);return s.getLocationRange(p!==null?p.loc.start.offset-s.startOffset:this.tokenStart,g!==null?g.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,p){let g=typeof p<"u"&&p<t.length?s.getLocation(p):this.eof?s.getLocation(Cy(t,t.length-1)):s.getLocation(this.tokenStart);throw new Mu(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=>hi[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,p)=>a.source.substring(l,p),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,p)=>s.getLocationRange(l,p,n)});return Object.assign(function(l,p){t=l,p=p||{},a.setSource(t,vo),s.setSource(t,p.offset,p.line,p.column),n=p.filename||"<unknown>",r=!!p.positions,o=typeof p.onParseError=="function"?p.onParseError:bi,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in p?!!p.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in p?!!p.parseRulePrelude:!0,a.parseValue="parseValue"in p?!!p.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in p?!!p.parseCustomProperty:!1;let{context:g="default",list:d=!0,onComment:f,onToken:k}=p;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,d?_E:OE),Array.isArray(k)?a.forEachToken((E,I,D)=>{k.push({type:E,start:I,end:D})}):typeof k=="function"&&a.forEachToken(k.bind(u())),typeof f=="function"&&a.forEachToken((E,I,D)=>{if(E===25){let R=a.getLocation(I,D),$=Xr(t,D-2,D,"*/")?t.slice(I+2,D-2):t.slice(I+2,D);f($,R)}});let T=a.context[g].call(a,p);return a.eof||a.error(),T},{SyntaxError:Mu,config:a.config})}var bi,zE,NE,Bu,Ny,Oy,OE,_E,$y=_(()=>{"use strict";Ss();Dy();lr();zy();bi=()=>{},zE=33,NE=35,Bu=59,Ny=123,Oy=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 Jn},createSingleNodeList(e){return new Jn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var jy=ir(Ru=>{"use strict";var Uy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Ru.encode=function(e){if(0<=e&&e<Uy.length)return Uy[e];throw new TypeError("Must be between 0 and 63: "+e)};Ru.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 qy=ir(Nu=>{"use strict";var Hy=jy(),zu=5,Wy=1<<zu,Vy=Wy-1,Gy=Wy;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}Nu.encode=function(t){var n="",r,o=jE(t);do r=o&Vy,o>>>=zu,o>0&&(r|=Gy),n+=Hy.encode(r);while(o>0);return n};Nu.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=Hy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Gy),u&=Vy,i=i+(u<<s),s+=zu}while(a);r.value=HE(i),r.rest=n}});var ll=ir(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 Yy=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,VE=/^data:.+\,.+$/;function ws(e){var t=e.match(Yy);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}an.urlParse=ws;function Si(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=Si;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 Ou=qE(function(t){var n=t,r=ws(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,Si(r)):n});an.normalize=Ou;function Ky(e,t){e===""&&(e="."),t===""&&(t=".");var n=ws(t),r=ws(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),Si(n);if(n||t.match(VE))return t;if(r&&!r.host&&!r.path)return r.host=t,Si(r);var o=t.charAt(0)==="/"?t:Ou(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,Si(r)):o}an.join=Ky;an.isAbsolute=function(e){return e.charAt(0)==="/"||Yy.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 Xy=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Qy(e){return e}function KE(e){return Jy(e)?"$"+e:e}an.toSetString=Xy?Qy:KE;function XE(e){return Jy(e)?e.slice(1):e}an.fromSetString=Xy?Qy:XE;function Jy(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=ws(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=Ky(Si(r),t)}return Ou(t)}an.computeSourceURL=rA});var eb=ir(Zy=>{"use strict";var _u=ll(),$u=Object.prototype.hasOwnProperty,Ko=typeof Map<"u";function Zr(){this._array=[],this._set=Ko?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 Ko?this._set.size:Object.getOwnPropertyNames(this._set).length};Zr.prototype.add=function(t,n){var r=Ko?t:_u.toSetString(t),o=Ko?this.has(t):$u.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Ko?this._set.set(t,i):this._set[r]=i)};Zr.prototype.has=function(t){if(Ko)return this._set.has(t);var n=_u.toSetString(t);return $u.call(this._set,n)};Zr.prototype.indexOf=function(t){if(Ko){var n=this._set.get(t);if(n>=0)return n}else{var r=_u.toSetString(t);if($u.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()};Zy.ArraySet=Zr});var rb=ir(nb=>{"use strict";var tb=ll();function oA(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||tb.compareByGeneratedPositionsInflated(e,t)<=0}function cl(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}cl.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};cl.prototype.add=function(t){oA(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};cl.prototype.toArray=function(){return this._sorted||(this._array.sort(tb.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};nb.MappingList=cl});var ib=ir(ob=>{"use strict";var vs=qy(),Ht=ll(),ul=eb().ArraySet,iA=rb().MappingList;function cr(e){e||(e={}),this._file=Ht.getArg(e,"file",null),this._sourceRoot=Ht.getArg(e,"sourceRoot",null),this._skipValidation=Ht.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Ht.getArg(e,"ignoreInvalidMapping",!1),this._sources=new ul,this._names=new ul,this._mappings=new iA,this._sourcesContents=null}cr.prototype._version=3;cr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new cr(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=Ht.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=Ht.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};cr.prototype.addMapping=function(t){var n=Ht.getArg(t,"generated"),r=Ht.getArg(t,"original",null),o=Ht.getArg(t,"source",null),i=Ht.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}))};cr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Ht.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Ht.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Ht.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};cr.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=Ht.relative(i,o));var s=new ul,a=new ul;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=Ht.join(r,u.source)),i!=null&&(u.source=Ht.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 p=u.name;p!=null&&!a.has(p)&&a.add(p)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){var c=t.sourceContentFor(u);c!=null&&(r!=null&&(u=Ht.join(r,u)),i!=null&&(u=Ht.relative(i,u)),this.setSourceContent(u,c))},this)};cr.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)}};cr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,p,g=this._mappings.toArray(),d=0,f=g.length;d<f;d++){if(c=g[d],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(d>0){if(!Ht.compareByGeneratedPositionsInflated(c,g[d-1]))continue;u+=","}u+=vs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(p=this._sources.indexOf(c.source),u+=vs.encode(p-s),s=p,u+=vs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=vs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=vs.encode(l-i),i=l)),a+=u}return a};cr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Ht.relative(n,r));var o=Ht.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};cr.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};cr.prototype.toString=function(){return JSON.stringify(this.toJSON())};ob.SourceMapGenerator=cr});function lb(e){let t=new ab.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&&sb.has(g.type)){let d=g.loc.start.line,f=g.loc.start.column-1;(r.line!==d||r.column!==f)&&(r.line=d,r.column=f,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&&sb.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,d,f){for(let k=0;k<g.length;k++)g.charCodeAt(k)===10?(s++,a=0):a++;l(g,d,f)};let p=e.result;return e.result=function(){return u&&t.addMapping(i),{css:p(),map:t}},e}var ab,sb,cb=_(()=>{"use strict";ab=Ua(ib(),1),sb=new Set(["Atrule","Selector","Declaration"])});var pl={};Se(pl,{safe:()=>ju,spec:()=>cA});function pb(e){let t=new Set(e.map(([n,r])=>Uu(n)<<16|Uu(r)));return function(n,r,o){let i=Uu(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,Uu,ub,lA,cA,ju,db=_(()=>{"use strict";sA=43,aA=45,Uu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),ub=[[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=ub.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=pb(ub),ju=pb(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 gb(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:ju,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=lb(s)),r.mode in pl&&(s.tokenBefore=pl[r.mode]));let a={node:u=>s.node(u),children:pA,token:(u,c)=>s.token(u,c),tokenize:u=>vo(u,(c,l,p)=>{s.token(c,u.slice(l,p),l!==0)})};return s.node(n),s.result()}}var uA,fb=_(()=>{"use strict";lr();cb();db();uA=92});function mb(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Jn)&&(n.children=new Jn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Jn&&(n.children=n.children.toArray())}}),t}}}var hb=_(()=>{"use strict";Ss()});function xb(e){return typeof e=="function"?e:ks}function yb(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(Hu.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(Hu.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 bb(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 p=i[l.name];if(!l.nullable||p){if(l.type==="list"){if(t?p.reduceRight(u,!1):p.reduce(u,!1))return!0}else if(a(p))return!0}}o&&(s[r]=c)}}function Sb({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 wb(e){let t=gA(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Hu.call(t,c)&&t[c]!==null&&(n[c]=bb(t[c],!1),r[c]=bb(t[c],!0));let s=Sb(n),a=Sb(r),u=function(c,l){function p(E,I,D){let R=g.call(T,E,I,D);return R===o?!0:R===i?!1:!!(f.hasOwnProperty(E.type)&&f[E.type](E,T,p,k)||d.call(T,E,I,D)===o)}let g=ks,d=ks,f=n,k=(E,I,D,R)=>E||p(I,D,R),T={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=xb(l.enter),d=xb(l.leave),l.reverse&&(f=r),l.visit)){if(s.hasOwnProperty(l.visit))f=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=yb(g,l.visit),d=yb(d,l.visit)}if(g===ks&&d===ks)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");p(c)};return u.break=o,u.skip=i,u.find=function(c,l){let p=null;return u(c,function(g,d,f){if(l.call(this,g,d,f))return p=g,o}),p},u.findLast=function(c,l){let p=null;return u(c,{reverse:!0,enter(g,d,f){if(l.call(this,g,d,f))return p=g,o}}),p},u.findAll=function(c,l){let p=[];return u(c,function(g,d,f){l.call(this,g,d,f)&&p.push(g)}),p},u}var Hu,ks,vb=_(()=>{"use strict";({hasOwnProperty:Hu}=Object.prototype),ks=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=>dl(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function dl(e,t,n,r){let o;switch(e.type){case"Group":o=xA(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return dl(e.term,t,n,r)+t(mA(e),e);case"Boolean":o="<boolean-expr["+dl(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 wi(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)),dl(e,n,r,o)}var Wu=_(()=>{"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,p;for(let g=0;g<n.length;g++){let d=n[g].value;g===r&&(a=d.length,s=c.length),i!==null&&n[g].node===i&&(g<=r?u++:u=0),c+=d}return r===n.length||u>1?(l=gl(i||t,"end")||Cs(kb,c),p=Cs(l)):(l=gl(i,"start")||Cs(gl(t,"start")||kb,c.slice(0,s)),p=gl(i,"end")||Cs(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:p}}function gl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?Cs(n):n:null}function Cs({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 kb,vi,Cb,Tb=_(()=>{"use strict";al();Wu();kb={offset:0,line:1,column:1};vi=function(e,t){let n=Yo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Cb=function(e,t,n,r){let o=Yo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=yA(r,n);return o.rawMessage=e,o.syntax=t?wi(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 xl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===ml&&e.charCodeAt(t+1)===ml}function Ib(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===ml&&e.charCodeAt(t+1)!==ml){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function
|
|
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 xl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===ml&&e.charCodeAt(t+1)===ml}function Ib(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===ml&&e.charCodeAt(t+1)!==ml){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function bA(e){if(fl.has(e))return fl.get(e);let t=e.toLowerCase(),n=fl.get(t);if(n===void 0){let r=xl(t,0),o=r?"":Ib(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return fl.set(e,n),n}function SA(e){if(ki.has(e))return ki.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=xl(t,n.length);if(!r&&(t=t.toLowerCase(),ki.has(t))){let a=ki.get(t);return ki.set(e,a),a}let o=r?"":Ib(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 ki.set(e,s),s}var fl,ki,ml,hl,Vu,yl=_(()=>{"use strict";fl=new Map,ki=new Map,ml=45,hl=bA,Vu=SA});var Ci,bl=_(()=>{"use strict";Ci=["initial","inherit","unset","revert","revert-layer"]});function Yu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function Ts(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===Is||o===_r){if(n)return 0;t++}for(;t<e.value.length;t++)if(!jt(e.value.charCodeAt(t)))return 0;return r+1}function qu(e,t,n){let r=!1,o=Ts(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Yu(e,Is)||Yu(e,_r)){if(r=!0,o=Ts(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!==Is&&i!==_r)return 0}return ko(e,r?0:1,r,o)}function Ku(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,Gu))return 0;switch(e.value.length){case 2:return qu(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==_r?0:(n=Ts(t(++n),n,t),e=t(n),ko(e,0,Ti,n));default:return e.value.charCodeAt(2)!==_r?0:ko(e,3,Ti,n)}}else if(e.type===1||Yu(e,Is)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Kr(e.value,0,Gu))return 0;switch(e.value.length){case 1:return qu(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==_r?0:(n=Ts(t(++n),n,t),e=t(n),ko(e,0,Ti,n));default:return e.value.charCodeAt(1)!==_r?0:ko(e,2,Ti,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===Is||r===_r?1:0,i=o;for(;i<e.value.length&&jt(e.value.charCodeAt(i));i++);return i===o||!Kr(e.value,i,Gu)?0:i+1===e.value.length?qu(t(++n),n,t):e.value.charCodeAt(i+1)!==_r?0:i+2===e.value.length?(n=Ts(t(++n),n,t),e=t(n),ko(e,0,Ti,n)):ko(e,i+2,Ti,n)}return 0}var Is,_r,Gu,Ti,vA,Fb=_(()=>{"use strict";lr();Is=43,_r=45,Gu=110,Ti=!0,vA=!1});function Xu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function TA(e,t){return e.value.charCodeAt(0)===t}function Fs(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===Eb&&n&&r!==0)return Fs(e,t+r+1,!1),6;if(!Bn(i)||++r>6)return 0}return r}function Sl(e,t,n){if(!e)return 0;for(;Xu(n(t),Ab);){if(++e>6)return 0;t++}return t}function Qu(e,t){let n=0;if(e===null||e.type!==1||!Kr(e.value,0,CA)||(e=t(++n),e===null))return 0;if(Xu(e,kA))return e=t(++n),e===null?0:e.type===1?Sl(Fs(e,0,!0),++n,t):Xu(e,Ab)?Sl(1,++n,t):0;if(e.type===10){let r=Fs(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!TA(e,Eb)||!Fs(e,1,!1)?0:n+1:Sl(r,n,t))}return e.type===12?Sl(Fs(e,1,!0),++n,t):0}var kA,Eb,Ab,CA,Pb=_(()=>{"use strict";lr();kA=43,Eb=45,Ab=63,CA=117});function Cr(e,t){return t<e.length?e.charCodeAt(t):0}function Mb(e,t){return Xr(e,0,e.length,t)}function Bb(e,t){for(let n=0;n<t.length;n++)if(Mb(e,t[n]))return!0;return!1}function Db(e,t){return t!==e.length-2?!1:Cr(e,t)===92&&jt(Cr(e,t+1))}function wl(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=rp.get(e.type);break}o++}while(e=t(o));return o}function ur(e,t){return function(n,r,o){return n===null?0:n.type===2&&Bb(n.value,t)?PA(n,r):e(n,r,o)}}function At(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 Bb(t,Ci)||Mb(t,"default")?0:1}function Rb(e){return e===null||e.type!==1||Cr(e.value,0)!==45||Cr(e.value,1)!==45?0:1}function MA(e){return!Rb(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(!Bn(Cr(e.value,n)))return 0;return 1}function DA(e){return e===null||e.type!==4||!fi(Cr(e.value,1),Cr(e.value,2),Cr(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=rp.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=rp.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=Go(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Db(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return wl(r,t.value,o)?0:1}}function NA(e,t,n){return e===null||e.type!==11||wl(n,e.value,e.value.length-1)?0:1}function zb(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=Go(e.value,0);return!(r===e.value.length)&&!Db(e.value,r)||wl(n,e.value,r)?0:1}function _A(e,t,n){if(e===null||e.type!==10)return 0;let r=Cr(e.value,0)===43||Cr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!jt(Cr(e.value,r)))return 0;return wl(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:ur(to(null),eo),angle:ur(to(t),eo),decibel:ur(to(n),eo),frequency:ur(to(r),eo),flex:ur(to(o),eo),length:ur(zb(to(i)),eo),resolution:ur(to(s),eo),semitones:ur(to(a),eo),time:ur(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 Nb(e){return{...$A,...UA,...HA(e),"attr-unit":WA(e)}}var Ju,Zu,ep,IA,FA,EA,tp,np,Lb,AA,eo,rp,$A,UA,jA,Ob=_(()=>{"use strict";bl();Fb();Pb();lr();Ju=["calc(","-moz-calc(","-webkit-calc("],Zu=["min(","max(","clamp("],ep=["round(","mod(","rem("],IA=["sin(","cos(","tan("],FA=["asin(","acos(","atan(","atan2("],EA=["pow(","sqrt(","log(","exp(","sign("],tp=["hypot("],np=["abs("],Lb=[...Ju,...Zu,...ep,...IA,...EA,...tp,...np],AA=[...Ju,...Zu,...ep,...tp,...np],eo=[...Ju,...Zu,...ep,...FA,...tp,...np],rp=new Map([[2,22],[21,22],[19,20],[23,24]]);$A={"ident-token":At(1),"function-token":At(2),"at-keyword-token":At(3),"hash-token":At(4),"string-token":At(5),"bad-string-token":At(6),"url-token":At(7),"bad-url-token":At(8),"delim-token":At(9),"number-token":At(10),"percentage-token":At(11),"dimension-token":At(12),"whitespace-token":At(13),"CDO-token":At(14),"CDC-token":At(15),"colon-token":At(16),"semicolon-token":At(17),"comma-token":At(18),"[-token":At(19),"]-token":At(20),"(-token":At(21),")-token":At(22),"{-token":At(23),"}-token":At(24)},UA={string:At(5),ident:At(1),percentage:ur(NA,AA),zero:zb(),number:ur(OA,Lb),integer:ur(_A,Lb),"custom-ident":LA,"dashed-ident":Rb,"custom-property-name":MA,"hex-color":BA,"id-selector":DA,"an-plus-b":Ku,urange:Qu,"declaration-value":RA,"any-value":zA},jA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var vl={};Se(vl,{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 $b(e,t,n){return Object.assign(Yo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
|
|
11
11
|
`+t+`
|
|
12
|
-
--`+new Array((n||t.length)+1).join("-")+"^"})}var Ub=_(()=>{"use strict";al()});var JA,ZA,eP,tP,nP,jb,kl,Hb=_(()=>{"use strict";Ub();JA=9,ZA=10,eP=12,tP=13,nP=32,jb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),kl=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&&jb[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!==tP&&n!==ZA&&n!==eP&&n!==nP&&n!==JA)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 $b(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||jb[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 Kb(e){let t=null,n=null;return e.eat(Il),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===cp?(e.pos++,e.skipWs(),e.charCode()!==sp&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(sp),{min:Number(t),max:n?Number(n):0}}function cP(e){let t=null,n=!1;switch(e.charCode()){case Zb:e.pos++,t={min:0,max:0};break;case lp:e.pos++,t={min:1,max:0};break;case Tl:e.pos++,t={min:0,max:1};break;case ap:e.pos++,n=!0,e.charCode()===Il?t=Kb(e):e.charCode()===Tl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Il:t=Kb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function no(e,t){let n=cP(e);return n!==null?(n.term=t,e.charCode()===ap&&e.charCodeAt(e.pos-1)===lp||e.charCode()===Tl&&e.charCodeAt(e.pos-1)===sp?no(e,n):n):t}function op(e){let t=e.peek();return t===""?null:no(e,{type:"Token",value:t})}function uP(e){let t;return e.eat(up),e.eat(Cl),t=e.scanWord(),e.eat(Cl),e.eat(ip),no(e,{type:"Property",name:t})}function pP(e){let t=null,n=null,r=1;return e.eat(Es),e.charCode()===Vb&&(e.peek(),r=-1),r==-1&&e.charCode()===qb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(cp),e.skipWs(),e.charCode()===qb?e.peek():(r=1,e.charCode()===Vb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Ii),{type:"Range",min:t,max:n}}function dP(e){let t,n=null;if(e.eat(up),t=e.scanWord(),t==="boolean-expr"){e.eat(Es);let r=Fl(e,Ii);return e.eat(Ii),e.eat(ip),no(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Qb&&e.nextCharCode()===Jb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Es&&(e.skipWs(),n=pP(e)),e.eat(ip),no(e,{type:"Type",name:t,opts:n})}function gP(e){let t=e.scanWord();return e.charCode()===Qb?(e.pos++,{type:"Function",name:t}):no(e,{type:"Keyword",name:t})}function fP(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)=>Yb[o]-Yb[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 Fl(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?Fl(e,Jb):hP(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:fP(r,n)||" ",disallowEmpty:!1,explicit:!1}}function mP(e){let t;return e.eat(Es),t=Fl(e,Ii),e.eat(Ii),t.explicit=!0,e.charCode()===Xb&&(e.pos++,t.disallowEmpty=!0),t}function hP(e){let t=e.charCode();switch(t){case Ii:break;case Es:return no(e,mP(e));case up:return e.nextCharCode()===Cl?uP(e):dP(e);case Gb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Gb?2:1))};case Wb:return e.pos++,e.eat(Wb),{type:"Combinator",value:"&&"};case cp:return e.pos++,{type:"Comma"};case Cl:return no(e,{type:"String",value:e.scanString()});case aP:case rP:case oP:case sP:case iP:return{type:"Spaces",value:e.scanSpaces()};case lP:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):op(e);case Zb:case lp:case Tl:case ap:case Xb:break;case Il:if(t=e.nextCharCode(),t<48||t>57)return op(e);break;default:return e.isNameCharCode(t)?gP(e):op(e)}}function As(e){let t=new kl(e),n=Fl(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var rP,oP,iP,sP,aP,Xb,ap,Wb,Cl,Qb,Jb,Zb,lp,cp,Vb,up,ip,Tl,lP,Es,Ii,Il,Gb,sp,qb,Yb,pp=_(()=>{"use strict";Hb();rP=9,oP=10,iP=12,sP=13,aP=32,Xb=33,ap=35,Wb=38,Cl=39,Qb=40,Jb=41,Zb=42,lp=43,cp=44,Vb=45,up=60,ip=62,Tl=63,lP=64,Es=91,Ii=93,Il=123,Gb=124,sp=125,qb=8734,Yb={" ":1,"&&":2,"||":3,"|":4}});function e0(e){return typeof e=="function"?e:Ps}function dp(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=Ps,i=Ps;if(typeof t=="function"?o=t:t&&(o=e0(t.enter),i=e0(t.leave)),o===Ps&&i===Ps)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ps,t0=_(()=>{"use strict";Ps=function(){}});var gp=_(()=>{"use strict";Wu();pp();t0()});function bP(e){let t=[];return vo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function n0(e,t){return typeof e=="string"?bP(e):t.generate(e,yP)}var yP,r0=_(()=>{"use strict";lr();yP={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 bn(e,t,n){return t===pt&&n===St||e===pt&&t===pt&&n===pt?e:(e.type==="If"&&e.else===St&&t===pt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function i0(e){return e.length>2&&e.charCodeAt(e.length-2)===SP&&e.charCodeAt(e.length-1)===wP}function o0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&i0(e.name)}function Co(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Ls(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Ls(e.match,t,n),e.then=Ls(e.then,t,n),e.else=Ls(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function fp(e,t,n){switch(e){case" ":{let r=pt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=bn(i,r,St)}return r}case"|":{let r=St,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(o0(s)&&(o===null&&i>0&&o0(t[i-1])&&(o=Object.create(null),r=bn({type:"Enum",map:o},pt,r)),o!==null)){let a=(i0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=bn(s,pt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=St;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=fp(e,t.filter(function(a){return a!==i}),!1):s=pt,r=bn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?pt:St;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=fp(e,t.filter(function(a){return a!==i}),!0):s=pt,r=bn(i,s,r)}return r}}}function vP(e){let t=pt,n=Fi(e.term);if(e.max===0)n=bn(n,El,St),t=bn(n,null,St),t.then=bn(pt,pt,t),e.comma&&(t.then.else=bn({type:"Comma",syntax:e},t,St));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==pt&&(t=bn({type:"Comma",syntax:e},t,St)),t=bn(n,bn(pt,pt,t),St);if(e.min===0)t=bn(pt,pt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==pt&&(t=bn({type:"Comma",syntax:e},t,St)),t=bn(n,t,St);return t}function Fi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=fp(e.combinator,e.terms.map(Fi),!1);return e.disallowEmpty&&(t=bn(t,El,St)),t}case"Multiplier":return vP(e);case"Boolean":{let t=Fi(e.term),n=Fi(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=Fi(Co([{type:"Type",name:"!term"},Co([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Ls(r,{"!term":t,"!self":n}),Ls(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 Ms(e,t){return typeof e=="string"&&(e=As(e)),{type:"MatchGraph",match:Fi(e),syntax:t||null,source:e}}var pt,St,El,SP,wP,mp=_(()=>{"use strict";pp();pt={type:"Match"},St={type:"Mismatch"},El={type:"DisallowEmpty"},SP=40,wP=41});function EP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function hp(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 AP(e){return e.type!==9?!1:e.value!=="?"}function c0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||AP(e)}function u0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function PP(e,t,n){function r(){do I++,E=I<e.length?e[I]:null;while(E!==null&&(E.type===13||E.type===25))}function o($){let P=I+$;return P<e.length?e[P]:null}function i($,P){return{nextState:$,matchStack:R,syntaxStack:d,thenStack:g,tokenIndex:I,prev:P}}function s($){g={nextState:$,matchStack:R,syntaxStack:d,prev:g}}function a($){p=i($,p)}function u(){R={type:CP,syntax:t.syntax,token:E,prev:R},r(),f=null,I>D&&(D=I)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},R={type:xp,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===xp?R=R.prev:R={type:p0,syntax:d.syntax,token:R.token,prev:R},d=d.prev}let d=null,g=null,p=null,f=null,k=0,T=null,E=null,I=-1,D=0,R={type:kP,syntax:null,token:null,prev:null};for(r();T===null&&++k<l0;)switch(t.type){case"Match":if(g===null){if(E!==null&&(I!==e.length-1||E.value!=="\\0"&&E.value!=="\\9")){t=St;break}T=a0;break}if(t=g.nextState,t===El)if(g.matchStack===R){t=St;break}else t=pt;for(;g.syntaxStack!==d;)l();g=g.prev;break;case"Mismatch":if(f!==null&&f!==!1)(p===null||I>p.tokenIndex)&&(p=f,f=!1);else if(p===null){T=TP;break}t=p.nextState,g=p.thenStack,d=p.syntaxStack,R=p.matchStack,I=p.tokenIndex,E=I<e.length?e[I]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==St&&a(t.else),t.then!==pt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let z=t.syntax.terms;if(t.index===z.length){if(t.mask===0||t.syntax.all){t=St;break}t=pt;break}if(t.mask===(1<<z.length)-1){t=pt;break}for(;t.index<z.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=z[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(E!==null){let z=E.value.toLowerCase();if(z.indexOf("\\")!==-1&&(z=z.replace(/\\[09].*$/,"")),s0.call(t.map,z)){t=t.map[z];break}}t=St;break;case"Generic":{let z=d!==null?d.opts:null,x=I+Math.floor(t.fn(E,o,z));if(!isNaN(x)&&x>I){for(;I<x;)u();t=pt}else t=St;break}case"Type":case"Property":{let z=t.type==="Type"?"types":"properties",x=s0.call(n,z)?n[z][t.name]:null;if(!x||!x.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(f!==!1&&E!==null&&t.type==="Type"&&(t.name==="custom-ident"&&E.type===1||t.name==="length"&&E.value==="0")){f===null&&(f=i(t,p)),t=St;break}c(),t=x.matchRef||x.match;break}case"Keyword":{let z=t.name;if(E!==null){let x=E.value;if(x.indexOf("\\")!==-1&&(x=x.replace(/\\[09].*$/,"")),hp(x,z)){u(),t=pt;break}}t=St;break}case"AtKeyword":case"Function":if(E!==null&&hp(E.value,t.name)){u(),t=pt;break}t=St;break;case"Token":if(E!==null&&E.value===t.value){u(),t=pt;break}t=St;break;case"Comma":E!==null&&E.type===18?c0(R.token)?t=St:(u(),t=u0(E)?St:pt):t=c0(R.token)||u0(E)?pt:St;break;case"String":let $="",P=I;for(;P<e.length&&$.length<t.value.length;P++)$+=e[P].value;if(hp($,t.value)){for(;I<P;)u();t=pt}else t=St;break;default:throw new Error("Unknown node type: "+t.type)}switch(FP+=k,T){case null:console.warn("[csstree-match] BREAK after "+l0+" iterations"),T=IP,R=null;break;case a0:for(;d!==null;)l();break;default:R=null}return{tokens:e,reason:T,iterations:k,match:R,longestMatch:D}}function yp(e,t,n){let r=PP(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=EP(o).prev;o!==null;){switch(o.type){case xp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case p0: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 s0,kP,CP,xp,p0,a0,TP,IP,l0,FP,d0=_(()=>{"use strict";mp();({hasOwnProperty:s0}=Object.prototype),kP=0,CP=1,xp=2,p0=3,a0="Match",TP="Mismatch",IP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",l0=15e3,FP=0});var Sp={};Se(Sp,{getTrace:()=>g0,isKeyword:()=>BP,isProperty:()=>MP,isType:()=>LP});function g0(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 LP(e,t){return bp(this,e,n=>n.type==="Type"&&n.name===t)}function MP(e,t){return bp(this,e,n=>n.type==="Property"&&n.name===t)}function BP(e){return bp(this,e,t=>t.type==="Keyword")}function bp(e,t,n){let r=g0.call(e,t);return r===null?!1:r.some(n)}var f0=_(()=>{"use strict"});function m0(e){return"node"in e?e.node:m0(e.match[0])}function h0(e){return"node"in e?e.node:h0(e.match[e.match.length-1])}function wp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=m0(a),c=h0(a);e.syntax.walk(t,function(l,d,g){if(l===u){let p=new Jn;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 x0=_(()=>{"use strict";Ss()});function vp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function y0(e){return!!e&&vp(e.offset)&&vp(e.line)&&vp(e.column)}function DP(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(Bs.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(!y0(r.loc.start))i+=".start";else if(!y0(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 Jn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Bs.call(t,i)&&Bs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function b0(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<"+(b0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function RP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Bs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=b0(s,e+"."+i)}return{docs:o,check:DP(e,r)}}function S0(e){let t={};if(e.node){for(let n in e.node)if(Bs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=RP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Bs,w0=_(()=>{"use strict";Ss();({hasOwnProperty:Bs}=Object.prototype)});function kp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:wi(e[o].syntax,{compact:t}));return r}function zP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:wi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&kp(i.descriptors,t,n)};return r}function NP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function OP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function Tr(e,t,n){return{matched:e,iterations:n,error:t,...Sp}}function Ei(e,t,n,r){let o=n0(n,e.syntax),i;return NP(o)?Tr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=yp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=yp(o,t.match,e),!i.match)?Tr(null,new Cb(i.reason,t.syntax,n,i),i.iterations):Tr(i.match,null,i.iterations))}var Ds,v0=_(()=>{"use strict";Tb();yl();bl();Ob();_b();gp();r0();mp();d0();f0();x0();w0();Ds=class{constructor(t,n,r){if(this.cssWideKeywords=Ci,this.syntax=n,this.generic=!1,this.units={...vl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||S0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(vl))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(Nb(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=Ms(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=Ms(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:As(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Ms(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=OP(a)?Ms({...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 vi("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&&!Ei(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=hl(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 vi("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new vi("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Tr(null,r);let o=this.getAtrule(t);return o.prelude?Ei(this,o.prelude,n||"",!1):Tr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Tr(null,o);let i=this.getAtrule(t),s=hl(n);return Ei(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Tr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Vu(t).custom)return Tr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Tr(null,r):Ei(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Ei(this,r,n,!1):Tr(null,new vi("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Tr(null,new vi("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Ei(this,t,n,!1))}findValueFragments(t,n,r,o){return wp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return wp(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=hl(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=Vu(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&&dp(d.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let p=g.type==="Type"?u.types:u.properties,f=g.type==="Type"?o:i;hasOwnProperty.call(p,g.name)?n(u,g.name,f,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:kp(this.types,!n,t),properties:kp(this.properties,!n,t),atrules:zP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function Cp(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 Tp(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 Rs(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?Cp(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?Cp(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]=Cp(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Tp(e[r],o);break;case"atrule":case"pseudo":n[r]=Tp(e[r],o,["parse"]);break;case"node":n[r]=Tp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var k0=_(()=>{"use strict"});function C0(e){let t=_y(e),n=wb(e),r=gb(e),{fromPlainObject:o,toPlainObject:i}=mb(n),s={lexer:null,createLexer:a=>new Ds(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=Rs({},e);return C0(typeof a=="function"?a(u):Rs(u,a))}};return s.lexer=new Ds({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var T0,I0=_(()=>{"use strict";lr();$y();fb();hb();vb();v0();k0();T0=e=>C0(Rs({},e))});var F0,E0=_(()=>{"use strict";F0={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 Ep={};Se(Ep,{generate:()=>HP,name:()=>UP,parse:()=>Fp,structure:()=>jP});function Pl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===$r||r===Zn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Ut(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ai(e){return Pl.call(this,0,e)}function To(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Al:n="N is expected";break;case Zn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Ip(){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(Zn,e)){t=this.isDelim($r,e)?$r:Zn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ai.call(this,Xo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==$r&&n!==Zn&&this.error("Number sign is expected")),Ai.call(this,t!==0),t===Zn?"-"+this.consume(10):this.consume(10)}function Fp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ai.call(this,$P),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Zn))switch(t="-1",To.call(this,1,Al),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Ip.call(this);break;case 3:To.call(this,2,Zn),this.next(),this.skipSC(),Ai.call(this,Xo),n="-"+this.consume(10);break;default:To.call(this,2,Zn),Pl.call(this,3,Xo),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,Al),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Ip.call(this);break;case 2:To.call(this,1,Zn),this.next(),this.skipSC(),Ai.call(this,Xo),n="-"+this.consume(10);break;default:To.call(this,1,Zn),Pl.call(this,2,Xo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===$r||r===Zn,i=this.tokenStart+o;for(;i<this.tokenEnd&&Ut(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),To.call(this,i-this.tokenStart,Al),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Ip.call(this)):(To.call(this,i-this.tokenStart+1,Zn),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ai.call(this,Xo),n="-"+this.consume(10)):(Pl.call(this,i-this.tokenStart+2,Xo),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 HP(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,Zn,Al,Xo,$P,UP,jP,Ap=_(()=>{"use strict";lr();$r=43,Zn=45,Al=110,Xo=!0,$P=!1;UP="AnPlusB",jP={a:[String,null],b:[String,null]}});var Lp={};Se(Lp,{generate:()=>YP,name:()=>VP,parse:()=>Pp,structure:()=>qP,walkContext:()=>GP});function A0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function WP(){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 Pp(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),A0):o=A0.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(WP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function YP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var VP,GP,qP,Mp=_(()=>{"use strict";VP="Atrule",GP="atrule",qP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var Dp={};Se(Dp,{generate:()=>JP,name:()=>KP,parse:()=>Bp,structure:()=>QP,walkContext:()=>XP});function Bp(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 JP(e){this.children(e)}var KP,XP,QP,Rp=_(()=>{"use strict";KP="AtrulePrelude",XP="atrulePrelude",QP={children:[[]]}});var Op={};Se(Op,{generate:()=>s2,name:()=>o2,parse:()=>Np,structure:()=>i2});function n2(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(P0)?(t=!0,this.next()):this.isDelim(zp)||this.eat(1),this.isDelim(zp)?this.charCodeAt(this.tokenStart+1)!==Ll?(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 r2(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Ll&&t!==t2&&t!==e2&&t!==ZP&&t!==P0&&t!==zp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Ll&&(this.isDelim(Ll)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function Np(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=n2.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=r2.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 s2(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 ZP,P0,Ll,e2,zp,t2,o2,i2,_p=_(()=>{"use strict";ZP=36,P0=42,Ll=61,e2=94,zp=124,t2=126;o2="AttributeSelector",i2={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Up={};Se(Up,{generate:()=>d2,name:()=>c2,parse:()=>$p,structure:()=>p2,walkContext:()=>u2});function B0(){return this.Raw(null,!0)}function L0(){return this.parseWithFallback(this.Rule,B0)}function M0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function l2(){if(this.tokenType===17)return M0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,M0);return this.tokenType===17&&this.next(),e}function $p(e){let t=e?l2:L0,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),B0));break;default:e&&this.isDelim(a2)?r.push(L0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function d2(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var a2,c2,u2,p2,jp=_(()=>{"use strict";a2=38;c2="Block",u2="block",p2={children:[["Atrule","Rule","Declaration"]]}});var Wp={};Se(Wp,{generate:()=>m2,name:()=>g2,parse:()=>Hp,structure:()=>f2});function Hp(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 m2(e){this.token(9,"["),this.children(e),this.token(9,"]")}var g2,f2,Vp=_(()=>{"use strict";g2="Brackets",f2={children:[[]]}});var qp={};Se(qp,{generate:()=>y2,name:()=>h2,parse:()=>Gp,structure:()=>x2});function Gp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function y2(){this.token(15,"-->")}var h2,x2,Yp=_(()=>{"use strict";h2="CDC",x2=[]});var Xp={};Se(Xp,{generate:()=>w2,name:()=>b2,parse:()=>Kp,structure:()=>S2});function Kp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function w2(){this.token(14,"<!--")}var b2,S2,Qp=_(()=>{"use strict";b2="CDO",S2=[]});var Zp={};Se(Zp,{generate:()=>T2,name:()=>k2,parse:()=>Jp,structure:()=>C2});function Jp(){return this.eatDelim(v2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function T2(e){this.token(9,"."),this.token(1,e.name)}var v2,k2,C2,ed=_(()=>{"use strict";v2=46,k2="ClassSelector",C2={name:String}});var nd={};Se(nd,{generate:()=>L2,name:()=>A2,parse:()=>td,structure:()=>P2});function td(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case F2:case I2:case E2:this.next();break;case D0:this.next(),this.eatIdent("deep"),this.eatDelim(D0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function L2(e){this.tokenize(e.name)}var I2,D0,F2,E2,A2,P2,rd=_(()=>{"use strict";I2=43,D0=47,F2=62,E2=126,A2="Combinator",P2={name:String}});var id={};Se(id,{generate:()=>z2,name:()=>D2,parse:()=>od,structure:()=>R2});function od(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===M2&&this.charCodeAt(t-1)===B2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function z2(e){this.token(25,"/*"+e.value+"*/")}var M2,B2,D2,R2,sd=_(()=>{"use strict";M2=42,B2=47,D2="Comment",R2={value:String}});var ld={};Se(ld,{generate:()=>U2,name:()=>O2,parse:()=>ad,structure:()=>_2});function R0(e){return this.lookupTypeNonSC(1)===1&&N2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function ad(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(()=>$2[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 U2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var N2,O2,_2,$2,cd=_(()=>{"use strict";N2=new Set([16,22,0]),O2="Condition",_2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};$2={media:R0,container:R0,supports(){return this.SupportsDeclaration()}}});var pd={};Se(pd,{generate:()=>Z2,name:()=>X2,parse:()=>ud,structure:()=>J2,walkContext:()=>Q2});function q2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function Y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function K2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(N0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function ud(){let e=this.tokenStart,t=this.tokenIndex,n=eL.call(this),r=xl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?Y2:q2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(K2,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(N0)&&(s=tL.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 Z2(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 eL(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case V2:case H2:case G2:case j2:case W2:this.next();break;case z0:this.next(),this.isDelim(z0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function tL(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var N0,j2,H2,W2,V2,G2,z0,X2,Q2,J2,dd=_(()=>{"use strict";yl();N0=33,j2=35,H2=36,W2=38,V2=42,G2=43,z0=47;X2="Declaration",Q2="declaration",J2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var md={};Se(md,{generate:()=>iL,name:()=>rL,parse:()=>fd,structure:()=>oL});function gd(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function fd(){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),gd));break;default:this.isDelim(nL)?e.push(this.parseWithFallback(this.Rule,gd)):e.push(this.parseWithFallback(this.Declaration,gd))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function iL(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var nL,rL,oL,hd=_(()=>{"use strict";nL=38;rL="DeclarationList",oL={children:[["Declaration","Atrule","Rule"]]}});var yd={};Se(yd,{generate:()=>lL,name:()=>sL,parse:()=>xd,structure:()=>aL});function xd(){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 lL(e){this.token(12,e.value+e.unit)}var sL,aL,bd=_(()=>{"use strict";sL="Dimension",aL={value:String,unit:String}});var wd={};Se(wd,{generate:()=>dL,name:()=>uL,parse:()=>Sd,structure:()=>pL});function Sd(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(cL)&&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 dL(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var cL,uL,pL,vd=_(()=>{"use strict";cL=47,uL="Feature",pL={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var Cd={};Se(Cd,{generate:()=>hL,name:()=>gL,parse:()=>kd,structure:()=>fL});function mL(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function kd(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=mL.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 hL(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var gL,fL,Td=_(()=>{"use strict";gL="FeatureFunction",fL={kind:String,feature:String,value:["Declaration","Selector"]}});var Ed={};Se(Ed,{generate:()=>wL,name:()=>bL,parse:()=>Fd,structure:()=>SL});function Id(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(O0,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(O0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function $0(e){if(this.skipSC(),this.isDelim(xL)||this.isDelim(yL)){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 Fd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Id.call(this),r=$0.call(this,n.type==="Identifier"),o=Id.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=$0.call(this),s=Id.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 wL(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 O0,xL,_0,yL,bL,SL,Ad=_(()=>{"use strict";O0=47,xL=60,_0=61,yL=62,bL="FeatureRange",SL={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 Ld={};Se(Ld,{generate:()=>TL,name:()=>vL,parse:()=>Pd,structure:()=>CL,walkContext:()=>kL});function Pd(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 TL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var vL,kL,CL,Md=_(()=>{"use strict";vL="Function",kL="function",CL={name:String,children:[[]]}});var Dd={};Se(Dd,{generate:()=>EL,name:()=>IL,parse:()=>Bd,structure:()=>FL});function Bd(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 EL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var IL,FL,Rd=_(()=>{"use strict";IL="GeneralEnclosed",FL={kind:String,function:[String,null],children:[[]]}});var Nd={};Se(Nd,{generate:()=>ML,name:()=>PL,parse:()=>zd,structure:()=>LL,xxx:()=>AL});function zd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function ML(e){this.token(4,"#"+e.value)}var AL,PL,LL,Od=_(()=>{"use strict";AL="XXX",PL="Hash",LL={value:String}});var $d={};Se($d,{generate:()=>RL,name:()=>BL,parse:()=>_d,structure:()=>DL});function _d(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function RL(e){this.token(1,e.name)}var BL,DL,Ud=_(()=>{"use strict";BL="Identifier",DL={name:String}});var Hd={};Se(Hd,{generate:()=>OL,name:()=>zL,parse:()=>jd,structure:()=>NL});function jd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function OL(e){this.token(9,"#"+e.name)}var zL,NL,Wd=_(()=>{"use strict";zL="IdSelector",NL={name:String}});var Gd={};Se(Gd,{generate:()=>jL,name:()=>$L,parse:()=>Vd,structure:()=>UL});function Vd(){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 jL(e){this.tokenize(e.name)}var _L,$L,UL,qd=_(()=>{"use strict";_L=46,$L="Layer",UL={name:String}});var Kd={};Se(Kd,{generate:()=>VL,name:()=>HL,parse:()=>Yd,structure:()=>WL});function Yd(){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 VL(e){this.children(e,()=>this.token(18,","))}var HL,WL,Xd=_(()=>{"use strict";HL="LayerList",WL={children:[["Layer"]]}});var Jd={};Se(Jd,{generate:()=>YL,name:()=>GL,parse:()=>Qd,structure:()=>qL});function Qd(){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 YL(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 GL,qL,Zd=_(()=>{"use strict";GL="MediaQuery",qL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var tg={};Se(tg,{generate:()=>QL,name:()=>KL,parse:()=>eg,structure:()=>XL});function eg(){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 QL(e){this.children(e,()=>this.token(18,","))}var KL,XL,ng=_(()=>{"use strict";KL="MediaQueryList",XL={children:[["MediaQuery"]]}});var og={};Se(og,{generate:()=>tM,name:()=>ZL,parse:()=>rg,structure:()=>eM});function rg(){let e=this.tokenStart;return this.eatDelim(JL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function tM(){this.token(9,"&")}var JL,ZL,eM,ig=_(()=>{"use strict";JL=38,ZL="NestingSelector",eM={}});var ag={};Se(ag,{generate:()=>oM,name:()=>nM,parse:()=>sg,structure:()=>rM});function sg(){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 oM(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var nM,rM,lg=_(()=>{"use strict";nM="Nth",rM={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var ug={};Se(ug,{generate:()=>aM,name:()=>iM,parse:()=>cg,structure:()=>sM});function cg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function aM(e){this.token(10,e.value)}var iM,sM,pg=_(()=>{"use strict";iM="Number",sM={value:String}});var gg={};Se(gg,{generate:()=>uM,name:()=>lM,parse:()=>dg,structure:()=>cM});function dg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function uM(e){this.tokenize(e.value)}var lM,cM,fg=_(()=>{"use strict";lM="Operator",cM={value:String}});var hg={};Se(hg,{generate:()=>gM,name:()=>pM,parse:()=>mg,structure:()=>dM});function mg(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 gM(e){this.token(21,"("),this.children(e),this.token(22,")")}var pM,dM,xg=_(()=>{"use strict";pM="Parentheses",dM={children:[[]]}});var bg={};Se(bg,{generate:()=>hM,name:()=>fM,parse:()=>yg,structure:()=>mM});function yg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function hM(e){this.token(11,e.value+"%")}var fM,mM,Sg=_(()=>{"use strict";fM="Percentage",mM={value:String}});var vg={};Se(vg,{generate:()=>SM,name:()=>xM,parse:()=>wg,structure:()=>bM,walkContext:()=>yM});function wg(){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 SM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var xM,yM,bM,kg=_(()=>{"use strict";xM="PseudoClassSelector",yM="function",bM={name:String,children:[["Raw"],null]}});var Tg={};Se(Tg,{generate:()=>CM,name:()=>wM,parse:()=>Cg,structure:()=>kM,walkContext:()=>vM});function Cg(){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 CM(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 wM,vM,kM,Ig=_(()=>{"use strict";wM="PseudoElementSelector",vM="function",kM={name:String,children:[["Raw"],null]}});var Eg={};Se(Eg,{generate:()=>FM,name:()=>TM,parse:()=>Fg,structure:()=>IM});function j0(){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 Fg(){let e=this.tokenStart,t=j0.call(this),n=null;return this.skipSC(),this.isDelim(U0)&&(this.eatDelim(U0),n=j0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function FM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var U0,TM,IM,Ag=_(()=>{"use strict";U0=47;TM="Ratio",IM={left:["Number","Function"],right:["Number","Function",null]}});var Lg={};Se(Lg,{generate:()=>LM,name:()=>AM,parse:()=>Pg,structure:()=>PM});function EM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Pg(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=EM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function LM(e){this.tokenize(e.value)}var AM,PM,Mg=_(()=>{"use strict";AM="Raw",PM={value:String}});var Dg={};Se(Dg,{generate:()=>zM,name:()=>BM,parse:()=>Bg,structure:()=>RM,walkContext:()=>DM});function H0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function MM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Bg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(MM,H0):n=H0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function zM(e){this.node(e.prelude),this.node(e.block)}var BM,DM,RM,Rg=_(()=>{"use strict";BM="Rule",DM="rule",RM={prelude:["SelectorList","Raw"],block:["Block"]}});var Ng={};Se(Ng,{generate:()=>_M,name:()=>NM,parse:()=>zg,structure:()=>OM});function zg(){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 NM,OM,Og=_(()=>{"use strict";NM="Scope",OM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var $g={};Se($g,{generate:()=>jM,name:()=>$M,parse:()=>_g,structure:()=>UM});function _g(){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 jM(e){this.children(e)}var $M,UM,Ug=_(()=>{"use strict";$M="Selector",UM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Hg={};Se(Hg,{generate:()=>GM,name:()=>HM,parse:()=>jg,structure:()=>VM,walkContext:()=>WM});function jg(){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 GM(e){this.children(e,()=>this.token(18,","))}var HM,WM,VM,Wg=_(()=>{"use strict";HM="SelectorList",WM="selector",VM={children:[["Selector","Raw"]]}});function Ml(e){let t=e.length,n=e.charCodeAt(0),r=n===W0||n===V0?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===Vg){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Ln(Vg,a)){let u=s-1,c=Qr(e,u);s=c-1,i+=tl(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function G0(e,t){let n=t?"'":'"',r=t?V0:W0,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===Vg?(o+="\\"+e.charAt(s),i=!1):(i&&(Mn(a)||Or(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Vg,W0,V0,Bl=_(()=>{"use strict";lr();Vg=92,W0=34,V0=39});var qg={};Se(qg,{generate:()=>KM,name:()=>qM,parse:()=>Gg,structure:()=>YM});function Gg(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Ml(this.consume(5))}}function KM(e){this.token(5,G0(e.value))}var qM,YM,Yg=_(()=>{"use strict";Bl();qM="String",YM={value:String}});var Xg={};Se(Xg,{generate:()=>eB,name:()=>QM,parse:()=>Kg,structure:()=>ZM,walkContext:()=>JM});function Y0(){return this.Raw(null,!1)}function Kg(){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)!==XM){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,Y0);break;default:n=this.parseWithFallback(this.Rule,Y0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function eB(e){this.children(e)}var XM,QM,JM,ZM,Qg=_(()=>{"use strict";XM=33;QM="StyleSheet",JM="stylesheet",ZM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var Zg={};Se(Zg,{generate:()=>rB,name:()=>tB,parse:()=>Jg,structure:()=>nB});function Jg(){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 rB(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var tB,nB,ef=_(()=>{"use strict";tB="SupportsDeclaration",nB={declaration:"Declaration"}});var rf={};Se(rf,{generate:()=>aB,name:()=>iB,parse:()=>nf,structure:()=>sB});function tf(){this.tokenType!==1&&this.isDelim(oB)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function nf(){let e=this.tokenStart;return this.isDelim(K0)?(this.next(),tf.call(this)):(tf.call(this),this.isDelim(K0)&&(this.next(),tf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function aB(e){this.tokenize(e.name)}var oB,K0,iB,sB,of=_(()=>{"use strict";oB=42,K0=124;iB="TypeSelector",sB={name:String}});var lf={};Se(lf,{generate:()=>dB,name:()=>uB,parse:()=>af,structure:()=>pB});function zs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===Q0&&t&&n!==0)return zs.call(this,e+n+1,!1),-1;Mn(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 Dl(e){let t=0;for(;this.isDelim(sf);)++t>e&&this.error("Too many question marks"),this.next()}function lB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===X0?"Plus sign":"Hyphen minus")+" is expected")}function cB(){let e=0;switch(this.tokenType){case 10:if(e=zs.call(this,1,!0),this.isDelim(sf)){Dl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){lB.call(this,Q0),zs.call(this,1,!1);break}break;case 12:e=zs.call(this,1,!0),e>0&&Dl.call(this,6-e);break;default:if(this.eatDelim(X0),this.tokenType===1){e=zs.call(this,0,!0),e>0&&Dl.call(this,6-e);break}if(this.isDelim(sf)){this.next(),Dl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function af(){let e=this.tokenStart;return this.eatIdent("u"),cB.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function dB(e){this.tokenize(e.value)}var X0,Q0,sf,uB,pB,cf=_(()=>{"use strict";lr();X0=43,Q0=45,sf=63;uB="UnicodeRange",pB={value:String}});function Z0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===J0?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===uf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Ln(uf,s)){let a=i-1,u=Qr(e,a);i=u-1,o+=tl(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function eS(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===gB||o===uf||o===fB||o===mB||o===hB||o===J0?(t+="\\"+e.charAt(r),n=!1):(n&&Mn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var gB,uf,fB,mB,hB,J0,pf=_(()=>{"use strict";lr();gB=32,uf=92,fB=34,mB=39,hB=40,J0=41});var gf={};Se(gf,{generate:()=>bB,name:()=>xB,parse:()=>df,structure:()=>yB});function df(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=Z0(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=Ml(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 bB(e){this.token(7,eS(e.value))}var xB,yB,ff=_(()=>{"use strict";pf();Bl();xB="Url",yB={value:String}});var hf={};Se(hf,{generate:()=>vB,name:()=>SB,parse:()=>mf,structure:()=>wB});function mf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function vB(e){this.children(e)}var SB,wB,xf=_(()=>{"use strict";SB="Value",wB={children:[[]]}});var bf={};Se(bf,{generate:()=>IB,name:()=>CB,parse:()=>yf,structure:()=>TB});function yf(){return this.eat(13),kB}function IB(e){this.token(13,e.value)}var kB,CB,TB,Sf=_(()=>{"use strict";kB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),CB="WhiteSpace",TB={value:String}});var Ns={};Se(Ns,{AnPlusB:()=>Ep,Atrule:()=>Lp,AtrulePrelude:()=>Dp,AttributeSelector:()=>Op,Block:()=>Up,Brackets:()=>Wp,CDC:()=>qp,CDO:()=>Xp,ClassSelector:()=>Zp,Combinator:()=>nd,Comment:()=>id,Condition:()=>ld,Declaration:()=>pd,DeclarationList:()=>md,Dimension:()=>yd,Feature:()=>wd,FeatureFunction:()=>Cd,FeatureRange:()=>Ed,Function:()=>Ld,GeneralEnclosed:()=>Dd,Hash:()=>Nd,IdSelector:()=>Hd,Identifier:()=>$d,Layer:()=>Gd,LayerList:()=>Kd,MediaQuery:()=>Jd,MediaQueryList:()=>tg,NestingSelector:()=>og,Nth:()=>ag,Number:()=>ug,Operator:()=>gg,Parentheses:()=>hg,Percentage:()=>bg,PseudoClassSelector:()=>vg,PseudoElementSelector:()=>Tg,Ratio:()=>Eg,Raw:()=>Lg,Rule:()=>Dg,Scope:()=>Ng,Selector:()=>$g,SelectorList:()=>Hg,String:()=>qg,StyleSheet:()=>Xg,SupportsDeclaration:()=>Zg,TypeSelector:()=>rf,UnicodeRange:()=>lf,Url:()=>gf,Value:()=>hf,WhiteSpace:()=>bf});var wf=_(()=>{"use strict";Ap();Mp();Rp();_p();jp();Vp();Yp();Qp();ed();rd();sd();cd();dd();hd();bd();vd();Td();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();Yg();Qg();ef();of();cf();ff();xf();Sf()});var nS,rS=_(()=>{"use strict";bl();E0();wf();nS={generic:!0,cssWideKeywords:Ci,...F0,node:Ns}});function Os(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,LB)&&this.cmpChar(this.tokenStart+1,oS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===PB||t===EB||t===oS||t===AB)return this.Operator();t===FB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var FB,EB,oS,AB,PB,LB,vf=_(()=>{"use strict";FB=35,EB=42,oS=43,AB=45,PB=47,LB=117});var iS,sS=_(()=>{"use strict";vf();iS={getNode:Os}});function $B(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function UB(){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)===aS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case RB:case NB:case _B:case zB:return this.Combinator();case aS:return this.ClassSelector();case DB:case OB:return this.TypeSelector();case MB:return this.IdSelector();case BB:return this.NestingSelector()}break}}}var MB,BB,DB,RB,zB,aS,NB,OB,_B,lS,cS=_(()=>{"use strict";MB=35,BB=38,DB=42,RB=43,zB=47,aS=46,NB=62,OB=124,_B=126;lS={onWhiteSpace:$B,getNode:UB}});function uS(){return this.createSingleNodeList(this.Raw(null,!1))}var pS=_(()=>{"use strict"});function dS(){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 gS=_(()=>{"use strict"});function fS(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var mS,hS=_(()=>{"use strict";vf();pS();gS();mS={getNode:Os,onWhiteSpace(e,t){fS(e)&&(e.value=" "+e.value),fS(t.last)&&(t.last.value+=" ")},expression:uS,var:dS}});var kf={};Se(kf,{AtrulePrelude:()=>iS,Selector:()=>lS,Value:()=>mS});var xS=_(()=>{"use strict";sS();cS();hS()});var jB,yS,bS=_(()=>{"use strict";jB=new Set(["none","and","not","or"]),yS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);jB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var SS,wS=_(()=>{"use strict";SS={parse:{prelude:null,block(){return this.Block(!0)}}}});function Cf(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 vS,kS,CS=_(()=>{"use strict";vS={layer(){this.skipSC();let e=this.createList(),t=Cf.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=Cf.call(this,this.Declaration,()=>Cf.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},kS={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,vS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,vS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var TS,IS=_(()=>{"use strict";TS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var FS,ES=_(()=>{"use strict";FS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var AS,PS=_(()=>{"use strict";AS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var LS,MS=_(()=>{"use strict";LS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var BS,DS=_(()=>{"use strict";BS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var RS,zS=_(()=>{"use strict";RS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var NS,OS=_(()=>{"use strict";NS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var _S,$S=_(()=>{"use strict";bS();wS();CS();IS();ES();PS();MS();DS();zS();OS();_S={container:yS,"font-face":SS,import:kS,layer:TS,media:FS,nest:AS,page:LS,scope:BS,"starting-style":RS,supports:NS}});function US(){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 jS=_(()=>{"use strict"});var Qo,Tf,HB,WB,Rl,HS,WS=_(()=>{"use strict";jS();Qo={parse(){return this.createSingleNodeList(this.SelectorList())}},Tf={parse(){return this.createSingleNodeList(this.Selector())}},HB={parse(){return this.createSingleNodeList(this.Identifier())}},WB={parse:US},Rl={parse(){return this.createSingleNodeList(this.Nth())}},HS={dir:HB,has:Qo,lang:WB,matches:Qo,is:Qo,"-moz-any":Qo,"-webkit-any":Qo,where:Qo,not:Qo,"nth-child":Rl,"nth-last-child":Rl,"nth-last-of-type":Rl,"nth-of-type":Rl,slotted:Tf,host:Tf,"host-context":Tf}});var If={};Se(If,{AnPlusB:()=>Fp,Atrule:()=>Pp,AtrulePrelude:()=>Bp,AttributeSelector:()=>Np,Block:()=>$p,Brackets:()=>Hp,CDC:()=>Gp,CDO:()=>Kp,ClassSelector:()=>Jp,Combinator:()=>td,Comment:()=>od,Condition:()=>ad,Declaration:()=>ud,DeclarationList:()=>fd,Dimension:()=>xd,Feature:()=>Sd,FeatureFunction:()=>kd,FeatureRange:()=>Fd,Function:()=>Pd,GeneralEnclosed:()=>Bd,Hash:()=>zd,IdSelector:()=>jd,Identifier:()=>_d,Layer:()=>Vd,LayerList:()=>Yd,MediaQuery:()=>Qd,MediaQueryList:()=>eg,NestingSelector:()=>rg,Nth:()=>sg,Number:()=>cg,Operator:()=>dg,Parentheses:()=>mg,Percentage:()=>yg,PseudoClassSelector:()=>wg,PseudoElementSelector:()=>Cg,Ratio:()=>Fg,Raw:()=>Pg,Rule:()=>Bg,Scope:()=>zg,Selector:()=>_g,SelectorList:()=>jg,String:()=>Gg,StyleSheet:()=>Kg,SupportsDeclaration:()=>Jg,TypeSelector:()=>nf,UnicodeRange:()=>af,Url:()=>df,Value:()=>mf,WhiteSpace:()=>yf});var VS=_(()=>{"use strict";Ap();Mp();Rp();_p();jp();Vp();Yp();Qp();ed();rd();sd();cd();dd();hd();bd();vd();Td();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();Yg();Qg();ef();of();cf();ff();xf();Sf()});var GS,qS=_(()=>{"use strict";xS();$S();WS();VS();GS={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:kf,atrule:_S,pseudo:HS,node:If}});var YS,KS=_(()=>{"use strict";wf();YS={node:Ns}});var XS,QS=_(()=>{"use strict";I0();rS();qS();KS();XS=T0({...nS,...GS,...YS})});var JS=_(()=>{"use strict"});var ZS=_(()=>{"use strict"});var oY,ew,iY,sY,aY,tw,lY,cY,uY,pY,dY,gY,nw=_(()=>{"use strict";QS();JS();gp();yl();ZS();Bl();pf();({tokenize:oY,parse:ew,generate:iY,lexer:sY,createLexer:aY,walk:tw,find:lY,findLast:cY,findAll:uY,toPlainObject:pY,fromPlainObject:dY,fork:gY}=XS)});function YB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function ow(e){try{let t=ew(e.trim(),{context:"value"}),n=[];return tw(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 KB(e,t){let n=YB(e);if(!qB.has(n))return t;let r=ow(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 rw(e,t){let n=t.trim();if(!n)return"";let r=KB(e,n);return ow(r).map(i=>i==="0"?"0px":i).join(" ")}function iw(e,t,n){let r=rw(e,t),o=rw(e,n);return r!==""&&o!==""&&r===o}var qB,sw=_(()=>{"use strict";nw();qB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function XB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function QB(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 aw(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=QB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return XB(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 Jo(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=aw(r),p=aw(o);return!!(g===p||n&&iw(n,r,o))}var Ff=_(()=>{"use strict";sw()});function nD(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 lw(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 rD(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 oD(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&&nD(n)||lw(r)||lw(o)||n&&rD(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<uw:a<cw}return r.includes("%")||o.includes("%")?a<1:!1}function iD(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(tD.some(s=>t.includes(s))||!ZB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Jo(o,i,e.property))}function sD(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 aD(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)<pw}function lD(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(!eD.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]))>JB)}function cD(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 _s(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(Jo(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(aD(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${pw}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(oD(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")?uw:cw}px)`,dismissedBy:"post-ai-validation"}}return cD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:iD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:lD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:sD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var cw,uw,pw,JB,ZB,eD,tD,dw=_(()=>{"use strict";Ff();cw=.5,uw=2,pw=2,JB=5,ZB=["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"],eD=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],tD=["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 gw=_(()=>{"use strict"});var fw=_(()=>{"use strict"});var mw=_(()=>{"use strict"});var Ef=_(()=>{"use strict";Ff();dw();gw();fw();mw()});var yD,bD,PY,Af=_(()=>{"use strict";yD=["flex","inline-flex"],bD=["grid","inline-grid"],PY=[...yD,...bD]});var xw=_(()=>{"use strict";Ef();Af()});var yw=_(()=>{"use strict"});var zn=_(()=>{"use strict";vu();vy();ky();Ef();Af();xw();yw()});function wD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function er(e){try{let t=e.map(wD),n=JSON.stringify(t,vD);sessionStorage.setItem(Pf,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function Lf(){try{let e=sessionStorage.getItem(Pf);if(!e)return[];let t=JSON.parse(e,kD);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function bw(){try{let e=Lf();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&&(er(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function Sw(){try{sessionStorage.removeItem(Pf),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function vD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function kD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Pf,Mf=_(()=>{"use strict";$e();Pf="uicopilot_review_history"});import CD,{createContext as TD,useContext as ID,useReducer as FD,useMemo as ww,useRef as ED,useEffect as AD}from"react";function zl(e){let t=e.length>vw?e.slice(e.length-vw):e,n=Math.max(0,t.length-PD);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 LD(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=zl(i),er(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=zl([...e.reviewHistory,...r]);return er(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=zl([...e.reviewHistory,t.payload]);return er(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 er(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 er(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 er(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 er(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 er(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 er(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 y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return er(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 er(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return Sw(),{...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 Df({children:e}){let[t,n]=FD(LD,zD),r=ED(t);AD(()=>{r.current=t},[t]);let o=ww(()=>({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=ww(()=>({...t,...o}),[t,o]);return CD.createElement(kw.Provider,{value:i},e)}function ce(){let e=ID(kw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var vw,PD,MD,BD,Bf,DD,RD,zD,kw,Rf=_(()=>{"use strict";zn();Mf();$e();vw=20,PD=5;MD=()=>{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},BD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Bf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},DD=()=>{if(typeof localStorage>"u")return Bf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Bf;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 Bf},RD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},zD={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:zl(Lf()),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:RD(),roleOverride:BD(),featureFlags:DD(),reviewAllConcurrency:MD(),hoveredIssueId:null},kw=TD(null)});import $s,{useMemo as ND}from"react";function Nf({children:e}){return $s.createElement(hu,null,$s.createElement(yu,null,$s.createElement(Su,null,$s.createElement(Df,null,$s.createElement(OD,null),e))))}function Cw(e){let t=we(),n=Je(),r=nt(),o=ce(),i=ND(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function OD(){return zf=Cw(),null}var zf,gt,Tw=_(()=>{"use strict";xu();bu();wu();Rf();zf=null,gt=Object.assign(Cw,{getState:()=>{if(!zf)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return zf}})});var Ce=_(()=>{"use strict";Tw();xu();bu();wu();Rf()});function V(){return(process.env.STORYBOOK_UICOPILOT_URL||_D).replace(/\/$/,"")}var _D,Iw,He=_(()=>{"use strict";_D="https://app.uiparity.com";Iw=3.6});async function ne(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 Zo,useState as Ol,useRef as jw,useCallback as Uf}from"react";import{addons as jf}from"storybook/manager-api";async function UR(e,t,n){let r=`${e}:${t}`,o=Hf.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ne(`${qw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Hf.delete(r)});return Hf.set(r,i),i}function jR(e,t,n){try{sessionStorage.setItem(`${_l}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function HR(e,t){try{let n=sessionStorage.getItem(`${_l}${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(`${_l}${e}`)}catch{}return null}function WR(e){try{let t=sessionStorage.getItem(`${_l}${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 Hw,Ww,Vw,Gw,Bi,qw,Nn,Wf,Hf,_l,Yw,Kw,ei,Di=_(()=>{"use strict";Ce();Vf();$e();He();ct();Hw="storyArgsUpdated",Ww="storyRendered",Vw="forceRemount",Gw=null,Bi=()=>Gw,qw=V(),Nn=new Map,Wf=null,Hf=new Map;_l="uicopilot-figma-image-";Yw=(e,t,n)=>{let r=Nn.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):Nn.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),y.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},Kw=(e,t,n)=>{Wf=t;let r=Nn.get(e);r?r.figmaImageUrl=n:Nn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},ei=()=>{let[e,t]=Ol(!1),[n,r]=Ol(!1),[o,i]=Ol(!1),[s,a]=Ol(null),u=jw(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ce(),d=Uf(()=>{let P=gt.getState().currentStoryId;P&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",P),Nn.delete(P),u.current=null,i(!0),l())},[l]),g=Uf(()=>{let P=gt.getState().currentStoryId;if(P){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",P);let z=Nn.get(P);z&&(z.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=we(),{selectedProjectId:f}=Je(),{currentStoryId:k,currentMapping:T,loadingMapping:E}=nt(),{setStorybookImageUrl:I,setFigmaImageUrl:D}=ce(),R=jw(null);Zo(()=>{k&&R.current&&R.current!==k&&(y.debug("[useReviewScreenshots] Story switched, clearing images"),I(""),D("")),R.current=k},[k,I,D]),Zo(()=>{!k||E||T||D("")},[k,T,E,D]),Zo(()=>{if(!k)return;let P=WR(k);P&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",k),D(P))},[k,D]),Zo(()=>{let P=!1;return(async()=>{if(!p||!f||!k){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==k&&(y.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),I(""),D(""));let x=gt.getState();if(u.current===k&&x.storybookImageUrl&&x.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let w=T?.figmaNodeId??null;if(w!==Wf){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",k);let L=Nn.get(k);L&&(L.figmaImageUrl=null),Wf=w,u.current=null}let v=T?.figmaNodeId;if(v&&!Nn.get(k)?.figmaImageUrl){let L=HR(k,v);if(L){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",k),D(L);let B=Nn.get(k);B?B.figmaImageUrl=L:Nn.set(k,{storybookImageUrl:null,figmaImageUrl:L})}}let C=Nn.get(k),m=C&&C.storybookImageUrl&&C.figmaImageUrl,F=C&&C.storybookImageUrl&&!C.figmaImageUrl,S=C&&!C.storybookImageUrl&&C.figmaImageUrl;if(m){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",k),I(C.storybookImageUrl),D(C.figmaImageUrl),u.current=k;return}let b=F&&T?.figmaNodeId;b&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",k),I(C.storybookImageUrl));let A=S;if(A&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",k),D(C.figmaImageUrl)),u.current===k&&T?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),b?r(!0):(A||(t(!0),r(!0)),i(!0)),u.current=k,P)return;let L=A?C.figmaImageUrl:null,B;if(A)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(v){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",v);let h=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let U=await UR(f,v,p);h=U.imageUrl||null;let W=U.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${W}:`,h?"success":"not found")}catch(U){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",U)}if(h)try{y.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let U=`${qw}/api/proxy/image?url=${encodeURIComponent(h)}`,W=await ne(U);if(W.ok){let M=await W.blob(),Y=new FileReader,ee=await new Promise((xe,ae)=>{Y.onloadend=()=>xe(Y.result),Y.onerror=ae,Y.readAsDataURL(M)});L=ee,D(ee),y.debug("[useReviewScreenshots] Figma image loaded via proxy");let ge=new Image;await new Promise(xe=>{ge.onload=()=>{B={width:ge.naturalWidth,height:ge.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),xe()},ge.onerror=()=>xe(),ge.src=ee})}else L=h,D(h),y.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(U){y.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",U),L=h,D(h)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",v),D(null);L&&v&&jR(k,v,L),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let N=C?.storybookImageUrl||null;if(N)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",k);let h=await $l({storyId:k,sessionToken:p||void 0,...B&&{figmaWidth:B.width,figmaHeight:B.height}});h&&!P?(N=h,I(h),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",B||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}Nn.set(k,{storybookImageUrl:N,figmaImageUrl:L}),y.debug("[useReviewScreenshots] Screenshots cached for story:",k)}catch(L){y.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,f,k,T?.figmaNodeId,c]),Zo(()=>{let P=jf.getChannel(),z=null,x=w=>{Gw=w.args,y.debug("[useReviewScreenshots] Args updated for story:",w.storyId,"args:",w.args),z&&clearTimeout(z),z=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return P.on(Hw,x),()=>{P.off(Hw,x),z&&clearTimeout(z)}},[d]),Zo(()=>{let P=jf.getChannel(),z=!1,x=null,w=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),z=!0,i(!0)},v=()=>{z&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),x&&clearTimeout(x),x=setTimeout(()=>{z=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return P.on(Vw,w),P.on(Ww,v),()=>{P.off(Vw,w),P.off(Ww,v),x&&clearTimeout(x)}},[g]),Zo(()=>{let P=jf.getChannel(),z=async x=>{if(!x?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let w=gt.getState().currentStoryId,v=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x.snapshot,storyId:w})});if(v.ok){let C=await v.json();if(C.screenshot){I(C.screenshot);let m=gt.getState().currentStoryId;if(m){let F=Nn.get(m);F?F.storybookImageUrl=C.screenshot:Nn.set(m,{storybookImageUrl:C.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await v.text())}catch(w){y.error("[useReviewScreenshots] Snapshot screenshot error:",w)}finally{i(!1)}};return P.on("UICOPILOT/STORY_DOM_MUTATED",z),()=>{P.off("UICOPILOT/STORY_DOM_MUTATED",z)}},[]);let $=Uf((P,z,x)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Kw(P,z,x),D(x),r(!1),u.current=P},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:g,setFigmaImageDirect:$}}});function GR(){return!V().startsWith("http://localhost")}function qR(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 Xw(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=qR(o,t,n);return r.set(o,i),i})}async function YR(){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=Xw(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=Xw(d,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function KR(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 XR(e,t){y.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 ne(`${VR}/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 QR(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 JR(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),y.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=Bi();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=QR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=KR(s);i+=`&args=${a}`,y.debug("[Screenshot] Using URL with current args:",i)}else y.debug("[Screenshot] No current args, using default URL:",i);return i}async function ZR(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return y.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 y.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 $l(e){let t=e?.storyId||ez();if(t){let n=Gf.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Qw(t,e).finally(()=>{Gf.delete(t)});return Gf.set(t,r),r}return Qw(void 0,e)}async function Qw(e,t){try{if(e){let n=await ZR(e);if(n)return n}if(!GR()){let n=JR(t?.storyId);return await XR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await YR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function ez(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var VR,Gf,Vf=_(()=>{"use strict";He();Di();$e();ct();VR=V();Gf=new Map});function Tn(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 On(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 Vs(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Jw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let T=r.fontSize||"16px",E=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let I=t.fonts.check(`${E} ${T} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:I,fontWeight:E,fontSize:T,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),I)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(T=>T.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,f="unknown",k=new Map;for(let T of g){s.font=`${c} ${u} ${a} "${T}", monospace`;let E=s.measureText(o).width;if(k.set(T,E),E!==p){s.font=`${c} ${u} ${a} "${T}"`;let I=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(I-D)<.1){f=T;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:f,declaredFonts:l,fontWidths:Array.from(k.entries()),isIframe:t!==document}),f}var Gs=_(()=>{"use strict";$e()});function Ri(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 qf(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return y.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:Tn(n.color),backgroundColor:Tn(n.backgroundColor),borderColor:Tn(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:Jw(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 Yf(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){y.error("Error extracting declared styles:",r)}return n}var Ul=_(()=>{"use strict";$e();Gs()});function tz(e){let t=[],n=new Set,r=Zw.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(Zw.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function nz(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:Ri(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Vs(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:Tn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function rz(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 oz(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=Tn(n.borderColor),p=s?`${l} ${d} ${g}`:"none";return{selector:Ri(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:Tn(n.backgroundColor),gap:n.gap}}function qs(){y.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=rz(r,2),i=o.map(oz).filter(a=>a!==null);y.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=tz(r);s=a.map(nz),y.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){y.error("[computedStyles] Error extracting text elements:",a)}return{computed:qf(r),declared:Yf(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Zw,ev=_(()=>{"use strict";$e();Gs();Ul();Zw=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Kf(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 sz(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function az(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=Tn(n.backgroundColor);On("backgroundColor",o)||(r.backgroundColor=o);let i=sz(n.borderWidth,n.borderStyle,Tn(n.borderColor));i&&(r.border=i),On("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),On("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),On("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 T=0;T<e.attributes.length;T++){let E=e.attributes[T];if(["class","style","id","xmlns","xmlns:xlink"].includes(E.name))continue;let I=E.name.replace(/-([a-z])/g,(R,$)=>$.toUpperCase()),D=E.value.startsWith("rgb")?Tn(E.value):E.value;I==="d"&&D.length>100?r[I]=D.substring(0,100)+"...":r[I]=D}let p=n.getPropertyValue("fill"),f=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?Tn(p):p),f&&f!=="none"&&(r.stroke=f.startsWith("rgb")?Tn(f):f),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let T=e.getBoundingClientRect();T.width>0&&(r.width=`${Math.round(T.width*100)/100}px`),T.height>0&&(r.height=`${Math.round(T.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=iz.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Vs(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=Tn(n.color),On("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),On("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Kf(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);On("padding",d)||(r.padding=d);let g=Kf(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return On("margin",g)||(r.margin=g),On("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(On("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),On("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),On("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function tv(e){let t=1;for(let n of e.children)t+=tv(n);return t}function nv(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 T=k.textContent?.trim();if(T){d=T.length>50?T.substring(0,50)+"...":T;break}}let g=s;c?g=`${s}#${c}`:u&&(g=Ri(s,u));let p=az(o),f=[];if(i<t){let k=Array.from(o.children);for(let T of k){let E=T.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(E))continue;let D=(T.ownerDocument.defaultView||window).getComputedStyle(T);D.display==="none"||D.visibility==="hidden"||f.push(n(T,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:f}}y.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return y.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:tv(r)}),r}function Xf(e=4){y.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(y.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(y.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(y.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(y.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=nv(r,e);return y.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return y.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var iz,rv=_(()=>{"use strict";$e();Gs();Ul();iz=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Qf=_(()=>{"use strict";Gs();Ul();ev();rv()});var Av=ir((xQ,Ev)=>{"use strict";Ev.exports={compareTwoStrings:Fv,findBestMatch:Mz};function Fv(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 Mz(e,t){if(!Bz(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=Fv(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 Bz(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var T1=ir((Lse,C1)=>{"use strict";var S1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,L3=/\n/g,M3=/^\s*/,B3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,D3=/^:\s*/,R3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,z3=/^[;\s]*/,N3=/^\s+|\s+$/g,O3=`
|
|
14
|
-
`,w1="/",v1="*",ai="",_3="comment",$3="declaration";function U3(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(f){var k=f.match(L3);k&&(n+=k.length);var T=f.lastIndexOf(O3);r=~T?f.length-T:r+f.length}function i(){var f={line:n,column:r};return function(k){return k.position=new s(f),c(),k}}function s(f){this.start=f,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(f){var k=new Error(t.source+":"+n+":"+r+": "+f);if(k.reason=f,k.filename=t.source,k.line=n,k.column=r,k.source=e,!t.silent)throw k}function u(f){var k=f.exec(e);if(k){var T=k[0];return o(T),e=e.slice(T.length),k}}function c(){u(M3)}function l(f){var k;for(f=f||[];k=d();)k!==!1&&f.push(k);return f}function d(){var f=i();if(!(w1!=e.charAt(0)||v1!=e.charAt(1))){for(var k=2;ai!=e.charAt(k)&&(v1!=e.charAt(k)||w1!=e.charAt(k+1));)++k;if(k+=2,ai===e.charAt(k-1))return a("End of comment missing");var T=e.slice(2,k-2);return r+=2,o(T),e=e.slice(k),r+=2,f({type:_3,comment:T})}}function g(){var f=i(),k=u(B3);if(k){if(d(),!u(D3))return a("property missing ':'");var T=u(R3),E=f({type:$3,property:k1(k[0].replace(S1,ai)),value:T?k1(T[0].replace(S1,ai)):ai});return u(z3),E}}function p(){var f=[];l(f);for(var k;k=g();)k!==!1&&(f.push(k),l(f));return f}return c(),p()}function k1(e){return e?e.replace(N3,ai):ai}C1.exports=U3});var I1=ir(ma=>{"use strict";var j3=ma&&ma.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ma,"__esModule",{value:!0});ma.default=W3;var H3=j3(T1());function W3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,H3.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 E1=ir(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.camelCase=void 0;var V3=/^--[a-zA-Z0-9_-]+$/,G3=/-([a-z])/g,q3=/^[^-]+$/,Y3=/^-(webkit|moz|ms|o|khtml)-/,K3=/^-(ms)-/,X3=function(e){return!e||q3.test(e)||V3.test(e)},Q3=function(e,t){return t.toUpperCase()},F1=function(e,t){return"".concat(t,"-")},J3=function(e,t){return t===void 0&&(t={}),X3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(K3,F1):e=e.replace(Y3,F1),e.replace(G3,Q3))};kc.camelCase=J3});var P1=ir((Lh,A1)=>{"use strict";var Z3=Lh&&Lh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},eU=Z3(I1()),tU=E1();function Ph(e,t){var n={};return!e||typeof e!="string"||(0,eU.default)(e,function(r,o){r&&o&&(n[(0,tU.camelCase)(r,t)]=o)}),n}Ph.default=Ph;A1.exports=Ph});var rI=ir((sde,nI)=>{"use strict";var Gc=Object.prototype.hasOwnProperty,tI=Object.prototype.toString,KT=Object.defineProperty,XT=Object.getOwnPropertyDescriptor,QT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):tI.call(t)==="[object Array]"},JT=function(t){if(!t||tI.call(t)!=="[object Object]")return!1;var n=Gc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Gc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Gc.call(t,o)},ZT=function(t,n){KT&&n.name==="__proto__"?KT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},eI=function(t,n){if(n==="__proto__")if(Gc.call(t,n)){if(XT)return XT(t,n).value}else return;return t[n]};nI.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=eI(a,n),o=eI(t,n),a!==o&&(l&&o&&(JT(o)||(i=QT(o)))?(i?(i=!1,s=r&&QT(r)?r:[]):s=r&&JT(r)?r:{},ZT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&ZT(a,{name:n,newValue:o}));return a}});import Oa from"react";import{addons as cu,types as ny,experimental_getStatusStore as ry}from"storybook/manager-api";import{AddonPanel as IV}from"storybook/internal/components";import Dt,{useState as VW,useEffect as GW}from"react";import{styled as br}from"storybook/theming";import dy from"react";import{styled as Mt}from"storybook/theming";var oe="#ea580c",du="#c2410c",ja="#ff6b35";var sy=Mt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ay=Mt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),xo=Mt.div({marginBottom:"20px"}),yo=Mt.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})),ps=Mt.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`}})),hn=Mt.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"}})),ly=Mt(hn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),Ha=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"}}),kn=Mt.button(({theme:e})=>({...Ha(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),rn=Mt.button(({theme:e})=>({...Ha(e),backgroundColor:oe,color:e.color.inverseText,boxShadow:`0 2px 4px ${oe}4d`,"&:hover:not(:disabled)":{backgroundColor:du,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${oe}66`}})),Nr=Mt.button(({theme:e})=>({...Ha(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),cy=Mt.button(({theme:e})=>({...Ha(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Cn=Mt.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"}})),gu=Mt.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=Mt.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=Mt(ps)(({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"})),DV=Mt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),uy=Mt.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})),RV=Mt.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})),ds=Mt.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})),zV=Mt.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%)"}}})),py=Mt.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}}),NV=Mt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),OV=Mt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),_V=Mt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var fu=({header:e,children:t,footer:n})=>dy.createElement(sy,null,e,dy.createElement(ay,null,t),n);import ZF from"react";import{styled as eE}from"storybook/theming";var tE=eE.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})),mu=({toolbar:e})=>ZF.createElement(tE,null,e);import KV from"react";import{styled as Wa}from"storybook/theming";var JV=Wa.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})),ZV=Wa.div({display:"flex",flex:1}),e9=Wa(bo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),t9=Wa.div({display:"flex",gap:"8px",alignItems:"center"});import Jt,{useState as _f,useCallback as Ow,useEffect as _w}from"react";import{styled as ro}from"storybook/theming";import ve,{useEffect as Fw}from"react";import{styled as lt}from"storybook/theming";Ce();He();$e();ct();var Ew=lt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),Aw=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})),$D=lt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),UD=lt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:oe,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),jD=lt.div({display:"flex",flexDirection:"column",gap:"4px"}),HD=lt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),WD=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"}),VD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),GD=lt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),qD=lt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),YD=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"})),KD=lt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${oe} 100%)`,transition:"width 0.3s ease"})),XD=lt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),QD=lt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),JD=lt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:oe,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Pw=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}})),ZD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),eR=lt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),tR=lt.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:oe,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),nR=lt.div({display:"flex",gap:"8px"}),Lw=lt(Cn)({fontSize:"18px"}),rR=lt.div({padding:"20px 16px"}),oR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),iR=lt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),sR=lt.div({fontSize:"28px",fontWeight:700}),aR=lt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),lR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),cR=lt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),uR=lt.div({display:"flex",alignItems:"center",gap:"8px"}),pR=lt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),dR=lt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:oe,color:e.color.inverseText})),gR=lt.button(({theme:e})=>({background:"none",border:"none",color:oe,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),fR=lt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),mR=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"?oe:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),hR=30*1e3,Mw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(f=!1)=>{if(!t)return;let k=o&&Date.now()-o<hR;if(!(!f&&k&&r))try{let T=V(),E=await ne(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(E.ok){let I=await E.json();i(I)}}catch(T){y.error("Failed to fetch usage:",T)}};Fw(()=>{l()},[t]),Fw(()=>{let f=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let d=()=>{if(t){let f=V();fetch(`${f}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}).catch(()=>{})}n(),e()},g=()=>{let f=V();window.open(`${f}/pricing`,"_blank")},p=()=>{let f=V();window.open(`${f}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let f=Math.floor(u?.creditBalance??0),T=Math.max(f,10),E=Math.max(0,T-f),I=T>0?f/T*100:0;return ve.createElement(ve.Fragment,null,ve.createElement(Ew,{onClick:e}),ve.createElement(Aw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},ve.createElement($D,null,ve.createElement(UD,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement(jD,null,ve.createElement(HD,null,"UI Review"),ve.createElement(WD,null,(u?.plan||"BETA").toUpperCase())),ve.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},ve.createElement(Pw,{onClick:d,title:"Sign out",style:{position:"static"}},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Pw,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),ve.createElement(VD,null,ve.createElement(GD,null,"Credits"),ve.createElement(qD,null,f," left")),ve.createElement(YD,null,ve.createElement(KD,{percent:I})),ve.createElement(XD,null,E," used \xB7 ",f," remaining"),ve.createElement(QD,null),ve.createElement(JD,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return ve.createElement(ve.Fragment,null,ve.createElement(Ew,{onClick:e}),ve.createElement(Aw,{onClick:f=>f.stopPropagation()},ve.createElement(ZD,null,ve.createElement(eR,null,ve.createElement(tR,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement("span",null,u?.email||"Loading...")),ve.createElement(nR,null,ve.createElement(Lw,{onClick:d,title:"Sign out"},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Lw,{onClick:e,title:"Close"},"\xD7"))),ve.createElement(rR,null,c?ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?ve.createElement(ve.Fragment,null,ve.createElement(oR,null,ve.createElement(iR,null,"Credit Balance"),ve.createElement(sR,null,"$",(u?.creditBalance??0).toFixed(2)),ve.createElement(aR,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),ve.createElement(lR,null,ve.createElement(cR,null,ve.createElement(uR,null,ve.createElement(pR,null,"Current Plan"),ve.createElement(dR,null,u?.plan||"Free")),ve.createElement(gR,{onClick:g},"View detail >")),ve.createElement(fR,null,"~$0.02-0.05 per review depending on complexity"),ve.createElement(mR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Ce();import Pi from"react";import{styled as Bw}from"storybook/theming";He();Ce();ct();$e();var xR=Bw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),yR=Bw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),bR={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}},Dw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=we();return e!=="admin"?null:Pi.createElement(xR,null,Pi.createElement(yR,null,"View as:"),Pi.createElement(ly,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ne(`${V()}/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=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=bR[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Pi.createElement("option",{value:"admin"},"Admin"),Pi.createElement("option",{value:"beta"},"Beta Tester")),t&&Pi.createElement(py,{variant:"warning"},"Previewing as ",t))};He();Ce();ct();import ht,{useState as Us,useCallback as Of}from"react";import{styled as Ir}from"storybook/theming";var SR="0.5.7",wR=[{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"}],vR=Ir.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),kR=Ir.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)"})),CR=Ir.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),TR=Ir.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),IR=Ir.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}})),FR=Ir.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),ER=Ir.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:oe}})),Rw=Ir.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),zw=Ir.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),AR=Ir.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),PR=Ir.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 Nw({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=we(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=Us("other"),[u,c]=Us(""),[l,d]=Us(!1),[g,p]=Us(!1),[f,k]=Us(null),T=Of(()=>{c(""),a("other"),p(!1),k(null),d(!1)},[]),E=Of(()=>{T(),t()},[T,t]),I=Of(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 ne(`${V()}/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:SR})});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?ht.createElement(vR,{onClick:E},ht.createElement(kR,{onClick:D=>D.stopPropagation()},ht.createElement(CR,null,ht.createElement(TR,null,ht.createElement("span",null,"\u{1F4AC}"),"Send feedback"),ht.createElement(IR,{onClick:E,"aria-label":"Close"},"\xD7")),g?ht.createElement(ht.Fragment,null,ht.createElement(PR,null,ht.createElement("h4",null,"Thanks \u2014 got it."),ht.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),ht.createElement(Rw,null,ht.createElement("span",null),ht.createElement(kn,{onClick:E},"Close"))):ht.createElement("form",{onSubmit:I},ht.createElement(FR,null,ht.createElement(xo,null,ht.createElement(yo,{htmlFor:"feedback-severity"},"Type"),ht.createElement(hn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},wR.map(D=>ht.createElement("option",{key:D.value,value:D.value},D.label)))),ht.createElement(xo,null,ht.createElement(yo,{htmlFor:"feedback-message"},"What happened?"),ht.createElement(ER,{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})),ht.createElement(zw,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),f&&ht.createElement(AR,null,f)),ht.createElement(Rw,null,ht.createElement(zw,null,i?`Context: ${i}`:"No story selected"),ht.createElement("div",{style:{display:"flex",gap:"8px"}},ht.createElement(kn,{type:"button",onClick:E,disabled:l},"Cancel"),ht.createElement(rn,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}Ce();He();ct();var LR=ro.div({display:"flex",alignItems:"center"}),Li=ro.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),MR=ro.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),BR=ro.div({position:"relative"}),DR=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`}})),$w=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)"}})),RR=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)"}}}),zR=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}})),NR=ro.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:oe,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${oe}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 ${oe}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),OR=30*1e3,$f=({onOpenSettings:e})=>{let[t,n]=_f(!1),[r,o]=_f(!1),[i,s]=_f(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=we(),{userRole:d,roleOverride:g,featureFlags:p}=ce(),f=g??d;_w(()=>{(async()=>{if(!(!l||u&&Date.now()-u<OR&&a)){s(!0);try{let $=V(),P=await ne(`${$}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let z=await P.json();c(z)}}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=Ow(()=>{n(!0)},[]),T=Ow(()=>{n(!1)},[]),E=a?.creditBalance??0,I=E<2&&!i;return Jt.createElement(LR,null,e&&Jt.createElement(Li,null,Jt.createElement(zR,{onClick:e,title:"Settings"},Jt.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&f==="admin"&&Jt.createElement(Li,null,Jt.createElement(Dw,null)),Jt.createElement(Li,null,Jt.createElement(MR,null,"v","0.5.22")),l&&p.showCosts&&Jt.createElement(Li,null,Jt.createElement($w,{onClick:k,isLow:I,title:i?"Loading...":a?I?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?Jt.createElement(RR,null):a?`$${E.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&Jt.createElement(Li,null,Jt.createElement($w,{onClick:k,isLow:Math.floor(E)<=3,title:`${Math.floor(E)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(E))),Jt.createElement(Li,null,Jt.createElement(BR,null,Jt.createElement(DR,{title:"Account & Usage",onClick:k},a?.email?a.email[0].toUpperCase():"?"),t&&Jt.createElement(Mw,{onClose:T}))),l&&Jt.createElement(NR,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),Jt.createElement(Nw,{isOpen:r,onClose:()=>o(!1)}))};import Lt,{useEffect as C4,useRef as T4}from"react";import{styled as mr}from"storybook/theming";import rt from"react";Ce();$e();He();ct();zn();import{useState as _R,useCallback as Mi,useRef as Uw,useEffect as $R}from"react";var oo=V();y.debug("[useAuth] Module loaded, APP_URL:",oo);var js=()=>{let e=Uw(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:f,setPollingInterval:k,setAuthError:T,resetAuth:E}=we(),I=Uw(null),[D,R]=_R(!1),$=Mi(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let C;try{C=await ne(`${oo}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let B=A instanceof Error&&A.message.includes("timed out")?`Cannot reach ${Ft.NAME} server at ${oo}. Is the dashboard running?`:`Connection failed: ${oo} is not responding.`;T(B),y.error("[useAuth]",B);return}if(!C.ok){let A=`Cannot reach ${Ft.NAME} server. Is the dashboard running?`;T(A),y.error("[useAuth]",A);return}let{poll_code:m}=await C.json();y.debug("[useAuth] Got poll_code:",m.substring(0,15)+"...");let F=localStorage.getItem("uicopilot_force_sign_in")==="true";F&&localStorage.removeItem("uicopilot_force_sign_in");let S=`${oo}/addon/auth?poll_code=${m}${F?"&force_sign_in=true":""}`;R(!0),window.open(S,"uiparity-auth","width=520,height=620,left=300,top=150"),y.debug("[useAuth] Starting OAuth poll for token..."),I.current&&clearInterval(I.current);let b=async()=>{try{let L=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:m})})).json();L.status==="authorized"&&L.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),I.current&&(clearInterval(I.current),I.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token),R(!1)):L.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),I.current&&(clearInterval(I.current),I.current=null),R(!1))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};I.current=setInterval(b,2e3),setTimeout(b,1e3)}catch(C){y.error("[useAuth] OAuth flow error:",C),T(`Connection failed. Is the dashboard running at ${oo}?`),R(!1)}},[c,T]),P=Mi(async()=>{try{let C=await fetch(`${oo}/api/addon/auth/device`,{method:"POST"});if(!C.ok)throw new Error("Failed to start device code flow");let m=await C.json();g(m.device_code),p(m.user_code),f(m.verification_uri),window.open(m.verification_uri,"_blank"),z(m.device_code,m.interval*1e3)}catch(C){throw y.error("[useAuth] Device code flow error:",C),C}},[g,p,f]),z=Mi((C,m)=>{y.debug("[useAuth] Starting polling. Device code:",C,"Interval:",m),e.current&&clearInterval(e.current);let F=async()=>{try{let b=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:C})})).json();b.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null),localStorage.setItem("uicopilot_session_token",b.session_token),c(b.session_token),setOauthUrl(null)):(b.status==="expired"||b.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null))}catch(S){y.error("[useAuth] Polling error:",S)}};e.current=setInterval(F,m),k(m)},[g,p,f,c,k]),x=Mi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null),k(null)},[g,p,f,k]),w=Mi(C=>{l(C),c(C),localStorage.setItem("uicopilot_api_key",C)},[l,c]),v=Mi(()=>{E(),setOauthUrl(null),e.current&&(clearInterval(e.current),e.current=null),I.current&&(clearInterval(I.current),I.current=null)},[E]);return $R(()=>()=>{e.current&&clearInterval(e.current),I.current&&clearInterval(I.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:w,logout:v}};Ce();$e();He();ct();import{useCallback as Nl}from"react";var Hs=V(),io=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=we(),u=Nl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Hs}/api/projects`);let g=await ne(`${Hs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=Nl(async g=>{if(!a)throw new Error("Not authenticated");let p=await ne(`${Hs}/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 f=await p.json();return await u(),f.project},[a,u]),l=Nl(async(g,p)=>{if(!a)throw new Error("Not authenticated");let f={};if(p.name!==void 0&&(f.name=p.name),p.description!==void 0&&(f.description=p.description),p.figmaFileUrl!==void 0&&(f.figmaFileId=p.figmaFileUrl||void 0),!(await ne(`${Hs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=Nl(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ne(`${Hs}/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}};Ce();var Ws=()=>{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)}};Ce();Vf();Qf();import{useCallback as Js,useRef as Yl}from"react";$e();function jl(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){y.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();y.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{y.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),y.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{y.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var Hl=BigInt(4294967295),ov=BigInt(32);function lz(e,t=!1){return t?{h:Number(e&Hl),l:Number(e>>ov&Hl)}:{h:Number(e>>ov&Hl)|0,l:Number(e&Hl)|0}}function iv(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}=lz(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var sv=(e,t,n)=>e<<n|t>>>32-n,av=(e,t,n)=>t<<n|e>>>32-n,lv=(e,t,n)=>t<<n-32|e>>>64-n,cv=(e,t,n)=>e<<n-32|t>>>64-n;function cz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jf(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Wl(e,t,n=""){let r=cz(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 Zf(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 uv(e,t){Wl(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 pv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function em(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var uz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function pz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function dz(e){for(let t=0;t<e.length;t++)e[t]=pz(e[t]);return e}var tm=uz?e=>e:dz;function dv(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 gv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var gz=BigInt(0),Ys=BigInt(1),fz=BigInt(2),mz=BigInt(7),hz=BigInt(256),xz=BigInt(113),hv=[],xv=[],yv=[];for(let e=0,t=Ys,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],hv.push(2*(5*r+n)),xv.push((e+1)*(e+2)/2%64);let o=gz;for(let i=0;i<7;i++)t=(t<<Ys^(t>>mz)*xz)%hz,t&fz&&(o^=Ys<<(Ys<<BigInt(i))-Ys);yv.push(o)}var bv=iv(yv,!0),yz=bv[0],bz=bv[1],fv=(e,t,n)=>n>32?lv(e,t,n):sv(e,t,n),mv=(e,t,n)=>n>32?cv(e,t,n):av(e,t,n);function Sz(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=fv(c,l,1)^n[a],g=mv(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=xv[s],u=fv(o,i,a),c=mv(o,i,a),l=hv[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]^=yz[r],e[1]^=bz[r]}em(n)}var nm=class e{constructor(t,n,r,o=!1,i=24){sr(this,"state");sr(this,"pos",0);sr(this,"posOut",0);sr(this,"finished",!1);sr(this,"state32");sr(this,"destroyed",!1);sr(this,"blockLen");sr(this,"suffix");sr(this,"outputLen");sr(this,"enableXOF",!1);sr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Jf(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pv(this.state)}clone(){return this._cloneInto()}keccak(){tm(this.state32),Sz(this.state32,this.rounds),tm(this.state32),this.posOut=0,this.pos=0}update(t){Zf(this),Wl(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){Zf(this,!1),Wl(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 Jf(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(uv(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,em(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}},wz=(e,t,n,r={})=>dv(()=>new nm(t,e,n),r);var Sv=wz(6,72,64,gv(10));var vz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,rm=Math.ceil,dr=Math.floor,_n="[BigNumber Error] ",wv=_n+"Number primitive has more than 15 significant digits: ",Fr=1e14,Ve=14,om=9007199254740991,im=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Fo=1e7,an=1e9;function vv(e){var t,n,r,o=I.prototype={constructor:I,toString:null,valueOf:null},i=new I(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,f=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",E=!0;function I(x,w){var v,C,m,F,S,b,A,L,B=this;if(!(B instanceof I))return new I(x,w);if(w==null){if(x&&x._isBigNumber===!0){B.s=x.s,!x.c||x.e>d?B.c=B.e=null:x.e<l?B.c=[B.e=0]:(B.e=x.e,B.c=x.c.slice());return}if((b=typeof x=="number")&&x*0==0){if(B.s=1/x<0?(x=-x,-1):1,x===~~x){for(F=0,S=x;S>=10;S/=10,F++);F>d?B.c=B.e=null:(B.e=F,B.c=[x]);return}L=String(x)}else{if(!vz.test(L=String(x)))return r(B,L,b);B.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(F=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(F<0&&(F=S),F+=+L.slice(S+1),L=L.substring(0,S)):F<0&&(F=L.length)}else{if(zt(w,2,T.length,"Base"),w==10&&E)return B=new I(x),P(B,s+B.e+1,a);if(L=String(x),b=typeof x=="number"){if(x*0!=0)return r(B,L,b,w);if(B.s=1/x<0?(L=L.slice(1),-1):1,I.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(wv+x)}else B.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(v=T.slice(0,w),F=S=0,A=L.length;S<A;S++)if(v.indexOf(C=L.charAt(S))<0){if(C=="."){if(S>F){F=A;continue}}else if(!m&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){m=!0,S=-1,F=0;continue}return r(B,String(x),b,w)}b=!1,L=n(L,w,10,B.s),(F=L.indexOf("."))>-1?L=L.replace(".",""):F=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(A=L.length;L.charCodeAt(--A)===48;);if(L=L.slice(S,++A)){if(A-=S,b&&I.DEBUG&&A>15&&(x>om||x!==dr(x)))throw Error(wv+B.s*x);if((F=F-S-1)>d)B.c=B.e=null;else if(F<l)B.c=[B.e=0];else{if(B.e=F,B.c=[],S=(F+1)%Ve,F<0&&(S+=Ve),S<A){for(S&&B.c.push(+L.slice(0,S)),A-=Ve;S<A;)B.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=A;for(;S--;L+="0");B.c.push(+L)}}else B.c=[B.e=0]}I.clone=vv,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(x){var w,v;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(w="DECIMAL_PLACES")&&(v=x[w],zt(v,0,an,w),s=v),x.hasOwnProperty(w="ROUNDING_MODE")&&(v=x[w],zt(v,0,8,w),a=v),x.hasOwnProperty(w="EXPONENTIAL_AT")&&(v=x[w],v&&v.pop?(zt(v[0],-an,0,w),zt(v[1],0,an,w),u=v[0],c=v[1]):(zt(v,-an,an,w),u=-(c=v<0?-v:v))),x.hasOwnProperty(w="RANGE"))if(v=x[w],v&&v.pop)zt(v[0],-an,-1,w),zt(v[1],1,an,w),l=v[0],d=v[1];else if(zt(v,-an,an,w),v)l=-(d=v<0?-v:v);else throw Error(_n+w+" cannot be zero: "+v);if(x.hasOwnProperty(w="CRYPTO"))if(v=x[w],v===!!v)if(v)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=v;else throw g=!v,Error(_n+"crypto unavailable");else g=v;else throw Error(_n+w+" not true or false: "+v);if(x.hasOwnProperty(w="MODULO_MODE")&&(v=x[w],zt(v,0,9,w),p=v),x.hasOwnProperty(w="POW_PRECISION")&&(v=x[w],zt(v,0,an,w),f=v),x.hasOwnProperty(w="FORMAT"))if(v=x[w],typeof v=="object")k=v;else throw Error(_n+w+" not an object: "+v);if(x.hasOwnProperty(w="ALPHABET"))if(v=x[w],typeof v=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(v))E=v.slice(0,10)=="0123456789",T=v;else throw Error(_n+w+" invalid: "+v)}else throw Error(_n+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:f,FORMAT:k,ALPHABET:T}},I.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var w,v,C=x.c,m=x.e,F=x.s;e:if({}.toString.call(C)=="[object Array]"){if((F===1||F===-1)&&m>=-an&&m<=an&&m===dr(m)){if(C[0]===0){if(m===0&&C.length===1)return!0;break e}if(w=(m+1)%Ve,w<1&&(w+=Ve),String(C[0]).length==w){for(w=0;w<C.length;w++)if(v=C[w],v<0||v>=Fr||v!==dr(v))break e;if(v!==0)return!0}}}else if(C===null&&m===null&&(F===null||F===1||F===-1))return!0;throw Error(_n+"Invalid BigNumber: "+x)},I.maximum=I.max=function(){return R(arguments,-1)},I.minimum=I.min=function(){return R(arguments,1)},I.random=(function(){var x=9007199254740992,w=Math.random()*x&2097151?function(){return dr(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(v){var C,m,F,S,b,A=0,L=[],B=new I(i);if(v==null?v=s:zt(v,0,an),S=rm(v/Ve),g)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(S*=2));A<S;)b=C[A]*131072+(C[A+1]>>>11),b>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),C[A]=m[0],C[A+1]=m[1]):(L.push(b%1e14),A+=2);A=S/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(S*=7);A<S;)b=(C[A]&31)*281474976710656+C[A+1]*1099511627776+C[A+2]*4294967296+C[A+3]*16777216+(C[A+4]<<16)+(C[A+5]<<8)+C[A+6],b>=9e15?crypto.randomBytes(7).copy(C,A):(L.push(b%1e14),A+=7);A=S/7}else throw g=!1,Error(_n+"crypto unavailable");if(!g)for(;A<S;)b=w(),b<9e15&&(L[A++]=b%1e14);for(S=L[--A],v%=Ve,S&&v&&(b=im[Ve-v],L[A]=dr(S/b)*b);L[A]===0;L.pop(),A--);if(A<0)L=[F=0];else{for(F=-1;L[0]===0;L.splice(0,1),F-=Ve);for(A=1,b=L[0];b>=10;b/=10,A++);A<Ve&&(F-=Ve-A)}return B.e=F,B.c=L,B}})(),I.sum=function(){for(var x=1,w=arguments,v=new I(w[0]);x<w.length;)v=v.plus(w[x++]);return v},n=(function(){var x="0123456789";function w(v,C,m,F){for(var S,b=[0],A,L=0,B=v.length;L<B;){for(A=b.length;A--;b[A]*=C);for(b[0]+=F.indexOf(v.charAt(L++)),S=0;S<b.length;S++)b[S]>m-1&&(b[S+1]==null&&(b[S+1]=0),b[S+1]+=b[S]/m|0,b[S]%=m)}return b.reverse()}return function(v,C,m,F,S){var b,A,L,B,N,h,U,W,M=v.indexOf("."),Y=s,ee=a;for(M>=0&&(B=f,f=0,v=v.replace(".",""),W=new I(C),h=W.pow(v.length-M),f=B,W.c=w(so(pr(h.c),h.e,"0"),10,m,x),W.e=W.c.length),U=w(v,C,m,S?(b=T,x):(b=x,T)),L=B=U.length;U[--B]==0;U.pop());if(!U[0])return b.charAt(0);if(M<0?--L:(h.c=U,h.e=L,h.s=F,h=t(h,W,Y,ee,m),U=h.c,N=h.r,L=h.e),A=L+Y+1,M=U[A],B=m/2,N=N||A<0||U[A+1]!=null,N=ee<4?(M!=null||N)&&(ee==0||ee==(h.s<0?3:2)):M>B||M==B&&(ee==4||N||ee==6&&U[A-1]&1||ee==(h.s<0?8:7)),A<1||!U[0])v=N?so(b.charAt(1),-Y,b.charAt(0)):b.charAt(0);else{if(U.length=A,N)for(--m;++U[--A]>m;)U[A]=0,A||(++L,U=[1].concat(U));for(B=U.length;!U[--B];);for(M=0,v="";M<=B;v+=b.charAt(U[M++]));v=so(v,L,b.charAt(0))}return v}})(),t=(function(){function x(C,m,F){var S,b,A,L,B=0,N=C.length,h=m%Fo,U=m/Fo|0;for(C=C.slice();N--;)A=C[N]%Fo,L=C[N]/Fo|0,S=U*A+L*h,b=h*A+S%Fo*Fo+B,B=(b/F|0)+(S/Fo|0)+U*L,C[N]=b%F;return B&&(C=[B].concat(C)),C}function w(C,m,F,S){var b,A;if(F!=S)A=F>S?1:-1;else for(b=A=0;b<F;b++)if(C[b]!=m[b]){A=C[b]>m[b]?1:-1;break}return A}function v(C,m,F,S){for(var b=0;F--;)C[F]-=b,b=C[F]<m[F]?1:0,C[F]=b*S+C[F]-m[F];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,m,F,S,b){var A,L,B,N,h,U,W,M,Y,ee,ge,xe,ae,Ke,be,Te,te,Be=C.s==m.s?1:-1,Pe=C.c,pe=m.c;if(!Pe||!Pe[0]||!pe||!pe[0])return new I(!C.s||!m.s||(Pe?pe&&Pe[0]==pe[0]:!pe)?NaN:Pe&&Pe[0]==0||!pe?Be*0:Be/0);for(M=new I(Be),Y=M.c=[],L=C.e-m.e,Be=F+L+1,b||(b=Fr,L=gr(C.e/Ve)-gr(m.e/Ve),Be=Be/Ve|0),B=0;pe[B]==(Pe[B]||0);B++);if(pe[B]>(Pe[B]||0)&&L--,Be<0)Y.push(1),N=!0;else{for(Ke=Pe.length,Te=pe.length,B=0,Be+=2,h=dr(b/(pe[0]+1)),h>1&&(pe=x(pe,h,b),Pe=x(Pe,h,b),Te=pe.length,Ke=Pe.length),ae=Te,ee=Pe.slice(0,Te),ge=ee.length;ge<Te;ee[ge++]=0);te=pe.slice(),te=[0].concat(te),be=pe[0],pe[1]>=b/2&&be++;do{if(h=0,A=w(pe,ee,Te,ge),A<0){if(xe=ee[0],Te!=ge&&(xe=xe*b+(ee[1]||0)),h=dr(xe/be),h>1)for(h>=b&&(h=b-1),U=x(pe,h,b),W=U.length,ge=ee.length;w(U,ee,W,ge)==1;)h--,v(U,Te<W?te:pe,W,b),W=U.length,A=1;else h==0&&(A=h=1),U=pe.slice(),W=U.length;if(W<ge&&(U=[0].concat(U)),v(ee,U,ge,b),ge=ee.length,A==-1)for(;w(pe,ee,Te,ge)<1;)h++,v(ee,Te<ge?te:pe,ge,b),ge=ee.length}else A===0&&(h++,ee=[0]);Y[B++]=h,ee[0]?ee[ge++]=Pe[ae]||0:(ee=[Pe[ae]],ge=1)}while((ae++<Ke||ee[0]!=null)&&Be--);N=ee[0]!=null,Y[0]||Y.splice(0,1)}if(b==Fr){for(B=1,Be=Y[0];Be>=10;Be/=10,B++);P(M,F+(M.e=B+L*Ve-1)+1,S,N)}else M.e=L,M.r=+N;return M}})();function D(x,w,v,C){var m,F,S,b,A;if(v==null?v=a:zt(v,0,8),!x.c)return x.toString();if(m=x.c[0],S=x.e,w==null)A=pr(x.c),A=C==1||C==2&&(S<=u||S>=c)?Gl(A,S):so(A,S,"0");else if(x=P(new I(x),w,v),F=x.e,A=pr(x.c),b=A.length,C==1||C==2&&(w<=F||F<=u)){for(;b<w;A+="0",b++);A=Gl(A,F)}else if(w-=S+(C===2&&F>S),A=so(A,F,"0"),F+1>b){if(--w>0)for(A+=".";w--;A+="0");}else if(w+=F-b,w>0)for(F+1==b&&(A+=".");w--;A+="0");return x.s<0&&m?"-"+A:A}function R(x,w){for(var v,C,m=1,F=new I(x[0]);m<x.length;m++)C=new I(x[m]),(!C.s||(v=ti(F,C))===w||v===0&&F.s===w)&&(F=C);return F}function $(x,w,v){for(var C=1,m=w.length;!w[--m];w.pop());for(m=w[0];m>=10;m/=10,C++);return(v=C+v*Ve-1)>d?x.c=x.e=null:v<l?x.c=[x.e=0]:(x.e=v,x.c=w),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,w=/^([^.]+)\.$/,v=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(F,S,b,A){var L,B=b?S:S.replace(m,"");if(C.test(B))F.s=isNaN(B)?null:B<0?-1:1;else{if(!b&&(B=B.replace(x,function(N,h,U){return L=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!A||A==L?h:N}),A&&(L=A,B=B.replace(w,"$1").replace(v,"0.$1")),S!=B))return new I(B,L);if(I.DEBUG)throw Error(_n+"Not a"+(A?" base "+A:"")+" number: "+S);F.s=null}F.c=F.e=null}})();function P(x,w,v,C){var m,F,S,b,A,L,B,N=x.c,h=im;if(N){e:{for(m=1,b=N[0];b>=10;b/=10,m++);if(F=w-m,F<0)F+=Ve,S=w,A=N[L=0],B=dr(A/h[m-S-1]%10);else if(L=rm((F+1)/Ve),L>=N.length)if(C){for(;N.length<=L;N.push(0));A=B=0,m=1,F%=Ve,S=F-Ve+1}else break e;else{for(A=b=N[L],m=1;b>=10;b/=10,m++);F%=Ve,S=F-Ve+m,B=S<0?0:dr(A/h[m-S-1]%10)}if(C=C||w<0||N[L+1]!=null||(S<0?A:A%h[m-S-1]),C=v<4?(B||C)&&(v==0||v==(x.s<0?3:2)):B>5||B==5&&(v==4||C||v==6&&(F>0?S>0?A/h[m-S]:0:N[L-1])%10&1||v==(x.s<0?8:7)),w<1||!N[0])return N.length=0,C?(w-=x.e+1,N[0]=h[(Ve-w%Ve)%Ve],x.e=-w||0):N[0]=x.e=0,x;if(F==0?(N.length=L,b=1,L--):(N.length=L+1,b=h[Ve-F],N[L]=S>0?dr(A/h[m-S]%h[S])*b:0),C)for(;;)if(L==0){for(F=1,S=N[0];S>=10;S/=10,F++);for(S=N[0]+=b,b=1;S>=10;S/=10,b++);F!=b&&(x.e++,N[0]==Fr&&(N[0]=1));break}else{if(N[L]+=b,N[L]!=Fr)break;N[L--]=0,b=1}for(F=N.length;N[--F]===0;N.pop());}x.e>d?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function z(x){var w,v=x.e;return v===null?x.toString():(w=pr(x.c),w=v<=u||v>=c?Gl(w,v):so(w,v,"0"),x.s<0?"-"+w:w)}return o.absoluteValue=o.abs=function(){var x=new I(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,w){return ti(this,new I(x,w))},o.decimalPlaces=o.dp=function(x,w){var v,C,m,F=this;if(x!=null)return zt(x,0,an),w==null?w=a:zt(w,0,8),P(new I(F),x+F.e+1,w);if(!(v=F.c))return null;if(C=((m=v.length-1)-gr(this.e/Ve))*Ve,m=v[m])for(;m%10==0;m/=10,C--);return C<0&&(C=0),C},o.dividedBy=o.div=function(x,w){return t(this,new I(x,w),s,a)},o.dividedToIntegerBy=o.idiv=function(x,w){return t(this,new I(x,w),0,1)},o.exponentiatedBy=o.pow=function(x,w){var v,C,m,F,S,b,A,L,B,N=this;if(x=new I(x),x.c&&!x.isInteger())throw Error(_n+"Exponent not an integer: "+z(x));if(w!=null&&(w=new I(w)),b=x.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!x.c||!x.c[0])return B=new I(Math.pow(+z(N),b?x.s*(2-Vl(x)):+z(x))),w?B.mod(w):B;if(A=x.s<0,w){if(w.c?!w.c[0]:!w.s)return new I(NaN);C=!A&&N.isInteger()&&w.isInteger(),C&&(N=N.mod(w))}else{if(x.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||b&&N.c[1]>=24e7:N.c[0]<8e13||b&&N.c[0]<=9999975e7)))return F=N.s<0&&Vl(x)?-0:0,N.e>-1&&(F=1/F),new I(A?1/F:F);f&&(F=rm(f/Ve+2))}for(b?(v=new I(.5),A&&(x.s=1),L=Vl(x)):(m=Math.abs(+z(x)),L=m%2),B=new I(i);;){if(L){if(B=B.times(N),!B.c)break;F?B.c.length>F&&(B.c.length=F):C&&(B=B.mod(w))}if(m){if(m=dr(m/2),m===0)break;L=m%2}else if(x=x.times(v),P(x,x.e+1,1),x.e>14)L=Vl(x);else{if(m=+z(x),m===0)break;L=m%2}N=N.times(N),F?N.c&&N.c.length>F&&(N.c.length=F):C&&(N=N.mod(w))}return C?B:(A&&(B=i.div(B)),w?B.mod(w):F?P(B,f,a,S):B)},o.integerValue=function(x){var w=new I(this);return x==null?x=a:zt(x,0,8),P(w,w.e+1,x)},o.isEqualTo=o.eq=function(x,w){return ti(this,new I(x,w))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,w){return ti(this,new I(x,w))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,w){return(w=ti(this,new I(x,w)))===1||w===0},o.isInteger=function(){return!!this.c&&gr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,w){return ti(this,new I(x,w))<0},o.isLessThanOrEqualTo=o.lte=function(x,w){return(w=ti(this,new I(x,w)))===-1||w===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,w){var v,C,m,F,S=this,b=S.s;if(x=new I(x,w),w=x.s,!b||!w)return new I(NaN);if(b!=w)return x.s=-w,S.plus(x);var A=S.e/Ve,L=x.e/Ve,B=S.c,N=x.c;if(!A||!L){if(!B||!N)return B?(x.s=-w,x):new I(N?S:NaN);if(!B[0]||!N[0])return N[0]?(x.s=-w,x):new I(B[0]?S:a==3?-0:0)}if(A=gr(A),L=gr(L),B=B.slice(),b=A-L){for((F=b<0)?(b=-b,m=B):(L=A,m=N),m.reverse(),w=b;w--;m.push(0));m.reverse()}else for(C=(F=(b=B.length)<(w=N.length))?b:w,b=w=0;w<C;w++)if(B[w]!=N[w]){F=B[w]<N[w];break}if(F&&(m=B,B=N,N=m,x.s=-x.s),w=(C=N.length)-(v=B.length),w>0)for(;w--;B[v++]=0);for(w=Fr-1;C>b;){if(B[--C]<N[C]){for(v=C;v&&!B[--v];B[v]=w);--B[v],B[C]+=Fr}B[C]-=N[C]}for(;B[0]==0;B.splice(0,1),--L);return B[0]?$(x,B,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,w){var v,C,m=this;return x=new I(x,w),!m.c||!x.s||x.c&&!x.c[0]?new I(NaN):!x.c||m.c&&!m.c[0]?new I(m):(p==9?(C=x.s,x.s=1,v=t(m,x,0,3),x.s=C,v.s*=C):v=t(m,x,0,p),x=m.minus(v.times(x)),!x.c[0]&&p==1&&(x.s=m.s),x)},o.multipliedBy=o.times=function(x,w){var v,C,m,F,S,b,A,L,B,N,h,U,W,M,Y,ee=this,ge=ee.c,xe=(x=new I(x,w)).c;if(!ge||!xe||!ge[0]||!xe[0])return!ee.s||!x.s||ge&&!ge[0]&&!xe||xe&&!xe[0]&&!ge?x.c=x.e=x.s=null:(x.s*=ee.s,!ge||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(C=gr(ee.e/Ve)+gr(x.e/Ve),x.s*=ee.s,A=ge.length,N=xe.length,A<N&&(W=ge,ge=xe,xe=W,m=A,A=N,N=m),m=A+N,W=[];m--;W.push(0));for(M=Fr,Y=Fo,m=N;--m>=0;){for(v=0,h=xe[m]%Y,U=xe[m]/Y|0,S=A,F=m+S;F>m;)L=ge[--S]%Y,B=ge[S]/Y|0,b=U*L+B*h,L=h*L+b%Y*Y+W[F]+v,v=(L/M|0)+(b/Y|0)+U*B,W[F--]=L%M;W[F]=v}return v?++C:W.splice(0,1),$(x,W,C)},o.negated=function(){var x=new I(this);return x.s=-x.s||null,x},o.plus=function(x,w){var v,C=this,m=C.s;if(x=new I(x,w),w=x.s,!m||!w)return new I(NaN);if(m!=w)return x.s=-w,C.minus(x);var F=C.e/Ve,S=x.e/Ve,b=C.c,A=x.c;if(!F||!S){if(!b||!A)return new I(m/0);if(!b[0]||!A[0])return A[0]?x:new I(b[0]?C:m*0)}if(F=gr(F),S=gr(S),b=b.slice(),m=F-S){for(m>0?(S=F,v=A):(m=-m,v=b),v.reverse();m--;v.push(0));v.reverse()}for(m=b.length,w=A.length,m-w<0&&(v=A,A=b,b=v,w=m),m=0;w;)m=(b[--w]=b[w]+A[w]+m)/Fr|0,b[w]=Fr===b[w]?0:b[w]%Fr;return m&&(b=[m].concat(b),++S),$(x,b,S)},o.precision=o.sd=function(x,w){var v,C,m,F=this;if(x!=null&&x!==!!x)return zt(x,1,an),w==null?w=a:zt(w,0,8),P(new I(F),x,w);if(!(v=F.c))return null;if(m=v.length-1,C=m*Ve+1,m=v[m]){for(;m%10==0;m/=10,C--);for(m=v[0];m>=10;m/=10,C++);}return x&&F.e+1>C&&(C=F.e+1),C},o.shiftedBy=function(x){return zt(x,-om,om),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,w,v,C,m,F=this,S=F.c,b=F.s,A=F.e,L=s+4,B=new I("0.5");if(b!==1||!S||!S[0])return new I(!b||b<0&&(!S||S[0])?NaN:S?F:1/0);if(b=Math.sqrt(+z(F)),b==0||b==1/0?(w=pr(S),(w.length+A)%2==0&&(w+="0"),b=Math.sqrt(+w),A=gr((A+1)/2)-(A<0||A%2),b==1/0?w="5e"+A:(w=b.toExponential(),w=w.slice(0,w.indexOf("e")+1)+A),v=new I(w)):v=new I(b+""),v.c[0]){for(A=v.e,b=A+L,b<3&&(b=0);;)if(m=v,v=B.times(m.plus(t(F,m,L,1))),pr(m.c).slice(0,b)===(w=pr(v.c)).slice(0,b))if(v.e<A&&--b,w=w.slice(b-3,b+1),w=="9999"||!C&&w=="4999"){if(!C&&(P(m,m.e+s+2,0),m.times(m).eq(F))){v=m;break}L+=4,b+=4,C=1}else{(!+w||!+w.slice(1)&&w.charAt(0)=="5")&&(P(v,v.e+s+2,1),x=!v.times(v).eq(F));break}}return P(v,v.e+s+1,a,x)},o.toExponential=function(x,w){return x!=null&&(zt(x,0,an),x++),D(this,x,w,1)},o.toFixed=function(x,w){return x!=null&&(zt(x,0,an),x=x+this.e+1),D(this,x,w)},o.toFormat=function(x,w,v){var C,m=this;if(v==null)x!=null&&w&&typeof w=="object"?(v=w,w=null):x&&typeof x=="object"?(v=x,x=w=null):v=k;else if(typeof v!="object")throw Error(_n+"Argument not an object: "+v);if(C=m.toFixed(x,w),m.c){var F,S=C.split("."),b=+v.groupSize,A=+v.secondaryGroupSize,L=v.groupSeparator||"",B=S[0],N=S[1],h=m.s<0,U=h?B.slice(1):B,W=U.length;if(A&&(F=b,b=A,A=F,W-=F),b>0&&W>0){for(F=W%b||b,B=U.substr(0,F);F<W;F+=b)B+=L+U.substr(F,b);A>0&&(B+=L+U.slice(F)),h&&(B="-"+B)}C=N?B+(v.decimalSeparator||"")+((A=+v.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(v.fractionGroupSeparator||"")):N):B}return(v.prefix||"")+C+(v.suffix||"")},o.toFraction=function(x){var w,v,C,m,F,S,b,A,L,B,N,h,U=this,W=U.c;if(x!=null&&(b=new I(x),!b.isInteger()&&(b.c||b.s!==1)||b.lt(i)))throw Error(_n+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+z(b));if(!W)return new I(U);for(w=new I(i),L=v=new I(i),C=A=new I(i),h=pr(W),F=w.e=h.length-U.e-1,w.c[0]=im[(S=F%Ve)<0?Ve+S:S],x=!x||b.comparedTo(w)>0?F>0?w:L:b,S=d,d=1/0,b=new I(h),A.c[0]=0;B=t(b,w,0,1),m=v.plus(B.times(C)),m.comparedTo(x)!=1;)v=C,C=m,L=A.plus(B.times(m=L)),A=m,w=b.minus(B.times(m=w)),b=m;return m=t(x.minus(v),C,0,1),A=A.plus(m.times(L)),v=v.plus(m.times(C)),A.s=L.s=U.s,F=F*2,N=t(L,C,F,a).minus(U).abs().comparedTo(t(A,v,F,a).minus(U).abs())<1?[L,C]:[A,v],d=S,N},o.toNumber=function(){return+z(this)},o.toPrecision=function(x,w){return x!=null&&zt(x,1,an),D(this,x,w,2)},o.toString=function(x){var w,v=this,C=v.s,m=v.e;return m===null?C?(w="Infinity",C<0&&(w="-"+w)):w="NaN":(x==null?w=m<=u||m>=c?Gl(pr(v.c),m):so(pr(v.c),m,"0"):x===10&&E?(v=P(new I(v),s+m+1,a),w=so(pr(v.c),v.e,"0")):(zt(x,2,T.length,"Base"),w=n(so(pr(v.c),m,"0"),10,x,C,!0)),C<0&&v.c[0]&&(w="-"+w)),w},o.valueOf=o.toJSON=function(){return z(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&I.set(e),I}function gr(e){var t=e|0;return e>0||e===t?t:t-1}function pr(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 ti(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 zt(e,t,n,r){if(e<t||e>n||e!==dr(e))throw Error(_n+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Vl(e){var t=e.c.length-1;return gr(e.e/Ve)==t&&e.c[t]%2!=0}function Gl(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 kz=vv(),kv=kz;var Cz=24,Ks=32,Tz=()=>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,am=Tz(),sm=(e=4,t=am)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function Iz(e){let t=new kv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Tv=(e="")=>{let t=new TextEncoder;return Iz(Sv(t.encode(e))).toString(36).slice(1)},Cv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),Fz=e=>Cv[Math.floor(e()*Cv.length)],Ez=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=am}={})=>{let n=Object.keys(e).toString(),r=n.length?n+sm(Ks,t):sm(Ks,t);return Tv(r).substring(0,Ks)},Az=e=>()=>e++,Pz=476782367,Iv=({random:e=am,counter:t=Az(Math.floor(e()*Pz)),length:n=Cz,fingerprint:r=Ez({random:e})}={})=>{if(n>Ks)throw new Error(`Length must be between 2 and ${Ks}. Received: ${n}`);return function(){let i=Fz(e),s=Date.now().toString(36),a=t().toString(36),u=sm(n,e),c=`${s+u+a+r}`;return`${i+Tv(c).substring(1,n)}`}},Eo=Lz(Iv);function Lz(e){let t;return()=>(t||(t=e()),t())}var Dz=Ua(Av());zn();$e();var ql=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function Rz(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function lm(e,t){let n=[],r=e.split(`
|
|
15
|
-
`);for(let s=0;s<r.length;s++){let a=
|
|
16
|
-
`)}else r.push(i)}return n.description=r.join(" ").trim(),n}$e();var Xs=null,Pv=0,Oz=3e4;async function _z(){let e=Date.now();if(Xs&&e-Pv<Oz)return Xs;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 Xs=n.entries||n.stories||{},Pv=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Xs).length),Xs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Qs(e){try{let n=(await _z())[e];if(!n?.importPath)return y.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;y.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),y.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,y.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 y.debug("[storyFilePaths] Final paths:",u),u}catch(t){return y.error("[storyFilePaths] Error getting file paths:",t),null}}function cm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function $z(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 um(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?(y.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):$z(e.type,t)}$e();function Uz(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 jz(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 Hz(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 Wz(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 pm(e){if(!e||e.length===0)return[];let t=e.filter(i=>!Hz(i)),n=[],r=[];for(let i of t){let s=Uz(i),a=jz(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(Wz(n,"icon","dimensions"))),o.push(...r),y.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),y.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),y.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}$e();zn();var Vz=[/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],Gz=[/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 Lv(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return Gz.some(n=>n.test(t))?t:Vz.some(n=>n.test(t))?`Can't reach ${Ft.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)?`${Ft.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 Oi}from"storybook/manager-api";var dm="uireview/badge",zi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function qz(e){return e.score<70?"status-value:error":e.score<90?"status-value:warning":"status-value:success"}function Yz(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 Kz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Ni(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Dv(e){if(Ni())try{Oi.getChannel().emit(zi.REVIEW_START,{storyId:e})}catch{}}function Ur(e,t){if(Ni())try{Oi.getChannel().emit(zi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function Rv(e){if(Ni())try{Oi.getChannel().emit(zi.REVIEW_ERROR,{storyId:e})}catch{}}function Mv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Bv=null;function zv(e){if(Bv!==null)return;let t=Oi.getChannel(),n=o=>i=>{Ni()&&o(i)};t.on(zi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:dm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(zi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:qz(i),typeId:dm,storyId:o,title:Kz(i),description:Yz(i)}])})),t.on(zi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:dm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Ni();r||Mv(e),Bv=setInterval(()=>{let o=Ni();o!==r&&(r=o,o||Mv(e))},1500)}var Xz="uireview/mapped",Nv="uireview/mappings-updated";function Ov(e){try{Oi.getChannel().emit(Nv,{storyIds:e})}catch{}}function _v(e){Oi.getChannel().on(Nv,({storyIds:n})=>{n.length&&e.set(n.map(r=>({value:"status-value:success",typeId:Xz,storyId:r,title:"\u2713 Linked to Figma",description:"Story has a Figma mapping"})))})}var gm=V(),fm=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 mm=()=>{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:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,setFullPrompt:z,setFullResponse:x,setFigmaImageUrl:w,storybookImageUrl:v,setStorybookImageUrl:C,setFigmaDimensions:m,setMultiModelResults:F,updateMultiModelStreamingMessages:S,setModelCompleted:b,setActiveModelId:A,resetReview:L,addReview:B,setReviewDetailTab:N,includeTextComparison:h,usePromptCache:U,setApplyFixesResult:W,featureFlags:M}=ce(),{sessionToken:Y,usageData:ee,setUsageData:ge}=we(),{selectedProjectId:xe}=Je(),{currentStoryId:ae,currentStoryName:Ke}=nt(),be=Yl(ee);be.current=ee;let Te=Yl(null),te=Yl(null),Be=Yl({}),Pe=Js((fe,tt)=>{I({role:fe,content:tt})},[I]),pe=Js((fe,tt)=>{$(fe),P(tt)},[$,P]),Pt=Js(async fe=>{let{isIteration:tt=!1,parentReviewId:he=null}=fe||{};if(!Y)throw new Error("Not authenticated");if(!xe)throw new Error("No project selected");if(!ae||!Ke)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let ie=Date.now();try{d(!0),g(null),p(null),N("issues"),W(null),ae&&M.enableReviewBadges&&Dv(ae),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${fm}s timeout`),Te.current&&Te.current.abort(),I({role:"system",content:`Review auto-stopped after ${fm} seconds timeout.`})},fm*1e3),z(""),x(""),T(!0),E(!1),R(),pe(0,"Starting review..."),pe(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await jl(),y.debug("[Review] Iframe reloaded, styles should be fresh"),pe(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[K,me,se]=await Promise.all([$l({sessionToken:Y||void 0}),Promise.resolve(qs()),Promise.resolve(Xf())]);if(K&&K!==v&&(C(K),y.debug("[Review] Storybook screenshot captured and set")),!me)throw new Error("Failed to extract styles from component");let{computed:O,declared:j,markup:H,textElementStyles:Ee,nestedElementStyles:De}=me;se?y.debug("[Review] DOM tree extracted:",{selector:se.selector,childrenCount:se.children.length}):(y.error("[Review] DOM tree extraction FAILED - domTree is null"),y.error("[Review] This will cause AI to use comparison table instead of tree comparison")),pe(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:ae,name:Ke});let bt=gt.getState().currentMapping?.figmaNodeId??null,Yn=gt.getState().figmaImageUrl;if(bt&&(y.debug("[Review] Using Figma node ID from store:",bt),Yn&&(pe(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!bt)try{let Qe=await fetch(`${gm}/api/mappings?projectId=${xe}&storyId=${ae}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`}});if(Qe.ok){let Rt=await Qe.json();Rt.mapping?.figmaNodeId?(bt=Rt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",bt)):y.debug("[Review] No mapping found for story:",ae)}else y.debug("[Review] Failed to fetch mapping:",Qe.status)}catch(Qe){y.error("[Review] Error fetching mapping:",Qe)}if(bt&&!Yn){pe(65,"Fetching Figma design...");try{let Qe=await fetch(`${gm}/api/figma/frames?projectId=${xe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`}});if(Qe.ok){let $t=(await Qe.json()).thumbnails?.[bt];$t?(w($t),y.debug("[Review] Figma thumbnail fetched and displayed:",$t)):y.warn("[Review] No thumbnail found for node:",bt)}else y.warn("[Review] Failed to fetch Figma frames:",Qe.status)}catch(Qe){y.error("[Review] Error fetching Figma frames:",Qe)}}if(!bt)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..."),y.debug("[Review] Sending to streaming API...");let or={projectId:xe,storyId:ae,storyName:Ke,storybookScreenshot:K,computedStyles:O,declaredStyles:j,textElementStyles:Ee,nestedElementStyles:De,componentMarkup:H,domTree:se,figmaNodeId:bt,figmaImageUrl:Yn||void 0,aiModels:l,includeTextComparison:h,usePromptCache:U,parentReviewId:tt?he:void 0,isIteration:tt};y.debug("[Review] Request payload:",{...or,storybookScreenshot:K?`${K.substring(0,50)}...`:null,domTree:se?{selector:se.selector,childrenCount:se.children.length}:null}),Te.current=new AbortController;let An=await fetch(`${gm}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`},body:JSON.stringify(or),signal:Te.current.signal});if(y.debug("[Review] Response status:",An.status,An.statusText),!An.ok){let Qe=await An.json();if(y.error("[Review] API error response:",Qe),An.status===429){let Rt=Qe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Rt} seconds before trying again.`)}if(An.status===402){if(Qe.code==="INSUFFICIENT_CREDITS"){let Rt=Qe.details?.required??1,$t=Qe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Rt} credit(s) but you have ${$t}. 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 An.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=An.body?.getReader(),wn=new TextDecoder,Rr="",nn="",Ue=null,pu=null,oy=l.length>1,Vo={},cs={},AV={};if(!ho)throw new Error("Response body is not readable");let iy=gt.getState().streamingMessages.length;for(Pe("assistant","");;){let{done:Qe,value:Rt}=await ho.read();if(Qe)break;Rr+=wn.decode(Rt,{stream:!0});let $t=Rr.split(`
|
|
17
|
-
`);Rr
|
|
12
|
+
--`+new Array((n||t.length)+1).join("-")+"^"})}var Ub=_(()=>{"use strict";al()});var ZA,eP,tP,nP,rP,jb,kl,Hb=_(()=>{"use strict";Ub();ZA=9,eP=10,tP=12,nP=13,rP=32,jb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),kl=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&&jb[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 $b(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||jb[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 Kb(e){let t=null,n=null;return e.eat(Il),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===cp?(e.pos++,e.skipWs(),e.charCode()!==sp&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(sp),{min:Number(t),max:n?Number(n):0}}function uP(e){let t=null,n=!1;switch(e.charCode()){case Zb:e.pos++,t={min:0,max:0};break;case lp:e.pos++,t={min:1,max:0};break;case Tl:e.pos++,t={min:0,max:1};break;case ap:e.pos++,n=!0,e.charCode()===Il?t=Kb(e):e.charCode()===Tl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Il:t=Kb(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()===ap&&e.charCodeAt(e.pos-1)===lp||e.charCode()===Tl&&e.charCodeAt(e.pos-1)===sp?no(e,n):n):t}function op(e){let t=e.peek();return t===""?null:no(e,{type:"Token",value:t})}function pP(e){let t;return e.eat(up),e.eat(Cl),t=e.scanWord(),e.eat(Cl),e.eat(ip),no(e,{type:"Property",name:t})}function dP(e){let t=null,n=null,r=1;return e.eat(Es),e.charCode()===Vb&&(e.peek(),r=-1),r==-1&&e.charCode()===qb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(cp),e.skipWs(),e.charCode()===qb?e.peek():(r=1,e.charCode()===Vb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Ii),{type:"Range",min:t,max:n}}function gP(e){let t,n=null;if(e.eat(up),t=e.scanWord(),t==="boolean-expr"){e.eat(Es);let r=Fl(e,Ii);return e.eat(Ii),e.eat(ip),no(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Qb&&e.nextCharCode()===Jb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Es&&(e.skipWs(),n=dP(e)),e.eat(ip),no(e,{type:"Type",name:t,opts:n})}function fP(e){let t=e.scanWord();return e.charCode()===Qb?(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)=>Yb[o]-Yb[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 Fl(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?Fl(e,Jb):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(Es),t=Fl(e,Ii),e.eat(Ii),t.explicit=!0,e.charCode()===Xb&&(e.pos++,t.disallowEmpty=!0),t}function xP(e){let t=e.charCode();switch(t){case Ii:break;case Es:return no(e,hP(e));case up:return e.nextCharCode()===Cl?pP(e):gP(e);case Gb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Gb?2:1))};case Wb:return e.pos++,e.eat(Wb),{type:"Combinator",value:"&&"};case cp:return e.pos++,{type:"Comma"};case Cl: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()}):op(e);case Zb:case lp:case Tl:case ap:case Xb:break;case Il:if(t=e.nextCharCode(),t<48||t>57)return op(e);break;default:return e.isNameCharCode(t)?fP(e):op(e)}}function As(e){let t=new kl(e),n=Fl(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,Xb,ap,Wb,Cl,Qb,Jb,Zb,lp,cp,Vb,up,ip,Tl,cP,Es,Ii,Il,Gb,sp,qb,Yb,pp=_(()=>{"use strict";Hb();oP=9,iP=10,sP=12,aP=13,lP=32,Xb=33,ap=35,Wb=38,Cl=39,Qb=40,Jb=41,Zb=42,lp=43,cp=44,Vb=45,up=60,ip=62,Tl=63,cP=64,Es=91,Ii=93,Il=123,Gb=124,sp=125,qb=8734,Yb={" ":1,"&&":2,"||":3,"|":4}});function e0(e){return typeof e=="function"?e:Ps}function dp(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=Ps,i=Ps;if(typeof t=="function"?o=t:t&&(o=e0(t.enter),i=e0(t.leave)),o===Ps&&i===Ps)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ps,t0=_(()=>{"use strict";Ps=function(){}});var gp=_(()=>{"use strict";Wu();pp();t0()});function SP(e){let t=[];return vo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function n0(e,t){return typeof e=="string"?SP(e):t.generate(e,bP)}var bP,r0=_(()=>{"use strict";lr();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 Sn(e,t,n){return t===dt&&n===wt||e===dt&&t===dt&&n===dt?e:(e.type==="If"&&e.else===wt&&t===dt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function i0(e){return e.length>2&&e.charCodeAt(e.length-2)===wP&&e.charCodeAt(e.length-1)===vP}function o0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&i0(e.name)}function Co(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Ls(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Ls(e.match,t,n),e.then=Ls(e.then,t,n),e.else=Ls(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function fp(e,t,n){switch(e){case" ":{let r=dt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=Sn(i,r,wt)}return r}case"|":{let r=wt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(o0(s)&&(o===null&&i>0&&o0(t[i-1])&&(o=Object.create(null),r=Sn({type:"Enum",map:o},dt,r)),o!==null)){let a=(i0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=Sn(s,dt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=wt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=fp(e,t.filter(function(a){return a!==i}),!1):s=dt,r=Sn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?dt:wt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=fp(e,t.filter(function(a){return a!==i}),!0):s=dt,r=Sn(i,s,r)}return r}}}function kP(e){let t=dt,n=Fi(e.term);if(e.max===0)n=Sn(n,El,wt),t=Sn(n,null,wt),t.then=Sn(dt,dt,t),e.comma&&(t.then.else=Sn({type:"Comma",syntax:e},t,wt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==dt&&(t=Sn({type:"Comma",syntax:e},t,wt)),t=Sn(n,Sn(dt,dt,t),wt);if(e.min===0)t=Sn(dt,dt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==dt&&(t=Sn({type:"Comma",syntax:e},t,wt)),t=Sn(n,t,wt);return t}function Fi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=fp(e.combinator,e.terms.map(Fi),!1);return e.disallowEmpty&&(t=Sn(t,El,wt)),t}case"Multiplier":return kP(e);case"Boolean":{let t=Fi(e.term),n=Fi(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=Fi(Co([{type:"Type",name:"!term"},Co([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Ls(r,{"!term":t,"!self":n}),Ls(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 Ms(e,t){return typeof e=="string"&&(e=As(e)),{type:"MatchGraph",match:Fi(e),syntax:t||null,source:e}}var dt,wt,El,wP,vP,mp=_(()=>{"use strict";pp();dt={type:"Match"},wt={type:"Mismatch"},El={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 hp(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 c0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||PP(e)}function u0(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 I++,E=I<e.length?e[I]:null;while(E!==null&&(E.type===13||E.type===25))}function o($){let P=I+$;return P<e.length?e[P]:null}function i($,P){return{nextState:$,matchStack:R,syntaxStack:p,thenStack:g,tokenIndex:I,prev:P}}function s($){g={nextState:$,matchStack:R,syntaxStack:p,prev:g}}function a($){d=i($,d)}function u(){R={type:TP,syntax:t.syntax,token:E,prev:R},r(),f=null,I>D&&(D=I)}function c(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},R={type:xp,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===xp?R=R.prev:R={type:p0,syntax:p.syntax,token:R.token,prev:R},p=p.prev}let p=null,g=null,d=null,f=null,k=0,T=null,E=null,I=-1,D=0,R={type:CP,syntax:null,token:null,prev:null};for(r();T===null&&++k<l0;)switch(t.type){case"Match":if(g===null){if(E!==null&&(I!==e.length-1||E.value!=="\\0"&&E.value!=="\\9")){t=wt;break}T=a0;break}if(t=g.nextState,t===El)if(g.matchStack===R){t=wt;break}else t=dt;for(;g.syntaxStack!==p;)l();g=g.prev;break;case"Mismatch":if(f!==null&&f!==!1)(d===null||I>d.tokenIndex)&&(d=f,f=!1);else if(d===null){T=IP;break}t=d.nextState,g=d.thenStack,p=d.syntaxStack,R=d.matchStack,I=d.tokenIndex,E=I<e.length?e[I]:null,d=d.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==wt&&a(t.else),t.then!==dt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let z=t.syntax.terms;if(t.index===z.length){if(t.mask===0||t.syntax.all){t=wt;break}t=dt;break}if(t.mask===(1<<z.length)-1){t=dt;break}for(;t.index<z.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=z[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(E!==null){let z=E.value.toLowerCase();if(z.indexOf("\\")!==-1&&(z=z.replace(/\\[09].*$/,"")),s0.call(t.map,z)){t=t.map[z];break}}t=wt;break;case"Generic":{let z=p!==null?p.opts:null,x=I+Math.floor(t.fn(E,o,z));if(!isNaN(x)&&x>I){for(;I<x;)u();t=dt}else t=wt;break}case"Type":case"Property":{let z=t.type==="Type"?"types":"properties",x=s0.call(n,z)?n[z][t.name]:null;if(!x||!x.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(f!==!1&&E!==null&&t.type==="Type"&&(t.name==="custom-ident"&&E.type===1||t.name==="length"&&E.value==="0")){f===null&&(f=i(t,d)),t=wt;break}c(),t=x.matchRef||x.match;break}case"Keyword":{let z=t.name;if(E!==null){let x=E.value;if(x.indexOf("\\")!==-1&&(x=x.replace(/\\[09].*$/,"")),hp(x,z)){u(),t=dt;break}}t=wt;break}case"AtKeyword":case"Function":if(E!==null&&hp(E.value,t.name)){u(),t=dt;break}t=wt;break;case"Token":if(E!==null&&E.value===t.value){u(),t=dt;break}t=wt;break;case"Comma":E!==null&&E.type===18?c0(R.token)?t=wt:(u(),t=u0(E)?wt:dt):t=c0(R.token)||u0(E)?dt:wt;break;case"String":let $="",P=I;for(;P<e.length&&$.length<t.value.length;P++)$+=e[P].value;if(hp($,t.value)){for(;I<P;)u();t=dt}else t=wt;break;default:throw new Error("Unknown node type: "+t.type)}switch(EP+=k,T){case null:console.warn("[csstree-match] BREAK after "+l0+" iterations"),T=FP,R=null;break;case a0:for(;p!==null;)l();break;default:R=null}return{tokens:e,reason:T,iterations:k,match:R,longestMatch:D}}function yp(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 xp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case p0: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 s0,CP,TP,xp,p0,a0,IP,FP,l0,EP,d0=_(()=>{"use strict";mp();({hasOwnProperty:s0}=Object.prototype),CP=0,TP=1,xp=2,p0=3,a0="Match",IP="Mismatch",FP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",l0=15e3,EP=0});var Sp={};Se(Sp,{getTrace:()=>g0,isKeyword:()=>DP,isProperty:()=>BP,isType:()=>MP});function g0(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 bp(this,e,n=>n.type==="Type"&&n.name===t)}function BP(e,t){return bp(this,e,n=>n.type==="Property"&&n.name===t)}function DP(e){return bp(this,e,t=>t.type==="Keyword")}function bp(e,t,n){let r=g0.call(e,t);return r===null?!1:r.some(n)}var f0=_(()=>{"use strict"});function m0(e){return"node"in e?e.node:m0(e.match[0])}function h0(e){return"node"in e?e.node:h0(e.match[e.match.length-1])}function wp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=m0(a),c=h0(a);e.syntax.walk(t,function(l,p,g){if(l===u){let d=new Jn;do{if(d.appendData(p.data),p.data===c)break;p=p.next}while(p!==null);s.push({parent:g,nodes:d})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var x0=_(()=>{"use strict";Ss()});function vp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function y0(e){return!!e&&vp(e.offset)&&vp(e.line)&&vp(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(Bs.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(!y0(r.loc.start))i+=".start";else if(!y0(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 Jn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Bs.call(t,i)&&Bs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function b0(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<"+(b0(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(Bs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=b0(s,e+"."+i)}return{docs:o,check:RP(e,r)}}function S0(e){let t={};if(e.node){for(let n in e.node)if(Bs.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 Bs,w0=_(()=>{"use strict";Ss();({hasOwnProperty:Bs}=Object.prototype)});function kp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:wi(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:wi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&kp(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 Tr(e,t,n){return{matched:e,iterations:n,error:t,...Sp}}function Ei(e,t,n,r){let o=n0(n,e.syntax),i;return OP(o)?Tr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=yp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=yp(o,t.match,e),!i.match)?Tr(null,new Cb(i.reason,t.syntax,n,i),i.iterations):Tr(i.match,null,i.iterations))}var Ds,v0=_(()=>{"use strict";Tb();yl();bl();Ob();_b();gp();r0();mp();d0();f0();x0();w0();Ds=class{constructor(t,n,r){if(this.cssWideKeywords=Ci,this.syntax=n,this.generic=!1,this.units={...vl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||S0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(vl))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(Nb(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=Ms(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=Ms(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:As(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Ms(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=_P(a)?Ms({...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 vi("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&&!Ei(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=hl(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 vi("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new vi("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Tr(null,r);let o=this.getAtrule(t);return o.prelude?Ei(this,o.prelude,n||"",!1):Tr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Tr(null,o);let i=this.getAtrule(t),s=hl(n);return Ei(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Tr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Vu(t).custom)return Tr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Tr(null,r):Ei(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Ei(this,r,n,!1):Tr(null,new vi("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Tr(null,new vi("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Ei(this,t,n,!1))}findValueFragments(t,n,r,o){return wp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return wp(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=hl(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=Vu(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,p){if(l.has(c))return l.get(c);l.set(c,!1),p.syntax!==null&&dp(p.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let d=g.type==="Type"?u.types:u.properties,f=g.type==="Type"?o:i;hasOwnProperty.call(d,g.name)?n(u,g.name,f,d[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:kp(this.types,!n,t),properties:kp(this.properties,!n,t),atrules:NP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function Cp(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 Tp(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 Rs(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?Cp(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?Cp(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]=Cp(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Tp(e[r],o);break;case"atrule":case"pseudo":n[r]=Tp(e[r],o,["parse"]);break;case"node":n[r]=Tp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var k0=_(()=>{"use strict"});function C0(e){let t=_y(e),n=wb(e),r=gb(e),{fromPlainObject:o,toPlainObject:i}=mb(n),s={lexer:null,createLexer:a=>new Ds(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=Rs({},e);return C0(typeof a=="function"?a(u):Rs(u,a))}};return s.lexer=new Ds({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var T0,I0=_(()=>{"use strict";lr();$y();fb();hb();vb();v0();k0();T0=e=>C0(Rs({},e))});var F0,E0=_(()=>{"use strict";F0={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 Ep={};Se(Ep,{generate:()=>WP,name:()=>jP,parse:()=>Fp,structure:()=>HP});function Pl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===$r||r===Zn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)jt(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ai(e){return Pl.call(this,0,e)}function To(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Al:n="N is expected";break;case Zn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Ip(){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(Zn,e)){t=this.isDelim($r,e)?$r:Zn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ai.call(this,Xo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==$r&&n!==Zn&&this.error("Number sign is expected")),Ai.call(this,t!==0),t===Zn?"-"+this.consume(10):this.consume(10)}function Fp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ai.call(this,UP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Zn))switch(t="-1",To.call(this,1,Al),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Ip.call(this);break;case 3:To.call(this,2,Zn),this.next(),this.skipSC(),Ai.call(this,Xo),n="-"+this.consume(10);break;default:To.call(this,2,Zn),Pl.call(this,3,Xo),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,Al),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Ip.call(this);break;case 2:To.call(this,1,Zn),this.next(),this.skipSC(),Ai.call(this,Xo),n="-"+this.consume(10);break;default:To.call(this,1,Zn),Pl.call(this,2,Xo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===$r||r===Zn,i=this.tokenStart+o;for(;i<this.tokenEnd&&jt(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),To.call(this,i-this.tokenStart,Al),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Ip.call(this)):(To.call(this,i-this.tokenStart+1,Zn),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ai.call(this,Xo),n="-"+this.consume(10)):(Pl.call(this,i-this.tokenStart+2,Xo),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,Zn,Al,Xo,UP,jP,HP,Ap=_(()=>{"use strict";lr();$r=43,Zn=45,Al=110,Xo=!0,UP=!1;jP="AnPlusB",HP={a:[String,null],b:[String,null]}});var Lp={};Se(Lp,{generate:()=>KP,name:()=>GP,parse:()=>Pp,structure:()=>YP,walkContext:()=>qP});function A0(){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 Pp(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),A0):o=A0.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,Mp=_(()=>{"use strict";GP="Atrule",qP="atrule",YP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var Dp={};Se(Dp,{generate:()=>ZP,name:()=>XP,parse:()=>Bp,structure:()=>JP,walkContext:()=>QP});function Bp(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,Rp=_(()=>{"use strict";XP="AtrulePrelude",QP="atrulePrelude",JP={children:[[]]}});var Op={};Se(Op,{generate:()=>a2,name:()=>i2,parse:()=>Np,structure:()=>s2});function r2(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(P0)?(t=!0,this.next()):this.isDelim(zp)||this.eat(1),this.isDelim(zp)?this.charCodeAt(this.tokenStart+1)!==Ll?(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!==Ll&&t!==n2&&t!==t2&&t!==e2&&t!==P0&&t!==zp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Ll&&(this.isDelim(Ll)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function Np(){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,P0,Ll,t2,zp,n2,i2,s2,_p=_(()=>{"use strict";e2=36,P0=42,Ll=61,t2=94,zp=124,n2=126;i2="AttributeSelector",s2={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Up={};Se(Up,{generate:()=>g2,name:()=>u2,parse:()=>$p,structure:()=>d2,walkContext:()=>p2});function B0(){return this.Raw(null,!0)}function L0(){return this.parseWithFallback(this.Rule,B0)}function M0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function c2(){if(this.tokenType===17)return M0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,M0);return this.tokenType===17&&this.next(),e}function $p(e){let t=e?c2:L0,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),B0));break;default:e&&this.isDelim(l2)?r.push(L0.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,jp=_(()=>{"use strict";l2=38;u2="Block",p2="block",d2={children:[["Atrule","Rule","Declaration"]]}});var Wp={};Se(Wp,{generate:()=>h2,name:()=>f2,parse:()=>Hp,structure:()=>m2});function Hp(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,Vp=_(()=>{"use strict";f2="Brackets",m2={children:[[]]}});var qp={};Se(qp,{generate:()=>b2,name:()=>x2,parse:()=>Gp,structure:()=>y2});function Gp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function b2(){this.token(15,"-->")}var x2,y2,Yp=_(()=>{"use strict";x2="CDC",y2=[]});var Xp={};Se(Xp,{generate:()=>v2,name:()=>S2,parse:()=>Kp,structure:()=>w2});function Kp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function v2(){this.token(14,"<!--")}var S2,w2,Qp=_(()=>{"use strict";S2="CDO",w2=[]});var Zp={};Se(Zp,{generate:()=>I2,name:()=>C2,parse:()=>Jp,structure:()=>T2});function Jp(){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,ed=_(()=>{"use strict";k2=46,C2="ClassSelector",T2={name:String}});var nd={};Se(nd,{generate:()=>M2,name:()=>P2,parse:()=>td,structure:()=>L2});function td(){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 D0:this.next(),this.eatIdent("deep"),this.eatDelim(D0);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,D0,E2,A2,P2,L2,rd=_(()=>{"use strict";F2=43,D0=47,E2=62,A2=126,P2="Combinator",L2={name:String}});var id={};Se(id,{generate:()=>N2,name:()=>R2,parse:()=>od,structure:()=>z2});function od(){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,sd=_(()=>{"use strict";B2=42,D2=47,R2="Comment",z2={value:String}});var ld={};Se(ld,{generate:()=>j2,name:()=>_2,parse:()=>ad,structure:()=>$2});function R0(e){return this.lookupTypeNonSC(1)===1&&O2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function ad(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,cd=_(()=>{"use strict";O2=new Set([16,22,0]),_2="Condition",$2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};U2={media:R0,container:R0,supports(){return this.SupportsDeclaration()}}});var pd={};Se(pd,{generate:()=>eL,name:()=>Q2,parse:()=>ud,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(N0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function ud(){let e=this.tokenStart,t=this.tokenIndex,n=tL.call(this),r=xl(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(N0)&&(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 z0:this.next(),this.isDelim(z0)&&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 N0,H2,W2,V2,G2,q2,z0,Q2,J2,Z2,dd=_(()=>{"use strict";yl();N0=33,H2=35,W2=36,V2=38,G2=42,q2=43,z0=47;Q2="Declaration",J2="declaration",Z2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var md={};Se(md,{generate:()=>sL,name:()=>oL,parse:()=>fd,structure:()=>iL});function gd(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function fd(){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),gd));break;default:this.isDelim(rL)?e.push(this.parseWithFallback(this.Rule,gd)):e.push(this.parseWithFallback(this.Declaration,gd))}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,hd=_(()=>{"use strict";rL=38;oL="DeclarationList",iL={children:[["Declaration","Atrule","Rule"]]}});var yd={};Se(yd,{generate:()=>cL,name:()=>aL,parse:()=>xd,structure:()=>lL});function xd(){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,bd=_(()=>{"use strict";aL="Dimension",lL={value:String,unit:String}});var wd={};Se(wd,{generate:()=>gL,name:()=>pL,parse:()=>Sd,structure:()=>dL});function Sd(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,vd=_(()=>{"use strict";uL=47,pL="Feature",dL={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var Cd={};Se(Cd,{generate:()=>xL,name:()=>fL,parse:()=>kd,structure:()=>mL});function hL(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function kd(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,Td=_(()=>{"use strict";fL="FeatureFunction",mL={kind:String,feature:String,value:["Declaration","Selector"]}});var Ed={};Se(Ed,{generate:()=>vL,name:()=>SL,parse:()=>Fd,structure:()=>wL});function Id(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(O0,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(O0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function $0(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 Fd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Id.call(this),r=$0.call(this,n.type==="Identifier"),o=Id.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=$0.call(this),s=Id.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 O0,yL,_0,bL,SL,wL,Ad=_(()=>{"use strict";O0=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 Ld={};Se(Ld,{generate:()=>IL,name:()=>kL,parse:()=>Pd,structure:()=>TL,walkContext:()=>CL});function Pd(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,Md=_(()=>{"use strict";kL="Function",CL="function",TL={name:String,children:[[]]}});var Dd={};Se(Dd,{generate:()=>AL,name:()=>FL,parse:()=>Bd,structure:()=>EL});function Bd(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,Rd=_(()=>{"use strict";FL="GeneralEnclosed",EL={kind:String,function:[String,null],children:[[]]}});var Nd={};Se(Nd,{generate:()=>BL,name:()=>LL,parse:()=>zd,structure:()=>ML,xxx:()=>PL});function zd(){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,Od=_(()=>{"use strict";PL="XXX",LL="Hash",ML={value:String}});var $d={};Se($d,{generate:()=>zL,name:()=>DL,parse:()=>_d,structure:()=>RL});function _d(){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,Ud=_(()=>{"use strict";DL="Identifier",RL={name:String}});var Hd={};Se(Hd,{generate:()=>_L,name:()=>NL,parse:()=>jd,structure:()=>OL});function jd(){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,Wd=_(()=>{"use strict";NL="IdSelector",OL={name:String}});var Gd={};Se(Gd,{generate:()=>HL,name:()=>UL,parse:()=>Vd,structure:()=>jL});function Vd(){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,qd=_(()=>{"use strict";$L=46,UL="Layer",jL={name:String}});var Kd={};Se(Kd,{generate:()=>GL,name:()=>WL,parse:()=>Yd,structure:()=>VL});function Yd(){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,Xd=_(()=>{"use strict";WL="LayerList",VL={children:[["Layer"]]}});var Jd={};Se(Jd,{generate:()=>KL,name:()=>qL,parse:()=>Qd,structure:()=>YL});function Qd(){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,Zd=_(()=>{"use strict";qL="MediaQuery",YL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var tg={};Se(tg,{generate:()=>JL,name:()=>XL,parse:()=>eg,structure:()=>QL});function eg(){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,ng=_(()=>{"use strict";XL="MediaQueryList",QL={children:[["MediaQuery"]]}});var og={};Se(og,{generate:()=>nM,name:()=>eM,parse:()=>rg,structure:()=>tM});function rg(){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,ig=_(()=>{"use strict";ZL=38,eM="NestingSelector",tM={}});var ag={};Se(ag,{generate:()=>iM,name:()=>rM,parse:()=>sg,structure:()=>oM});function sg(){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,lg=_(()=>{"use strict";rM="Nth",oM={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var ug={};Se(ug,{generate:()=>lM,name:()=>sM,parse:()=>cg,structure:()=>aM});function cg(){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,pg=_(()=>{"use strict";sM="Number",aM={value:String}});var gg={};Se(gg,{generate:()=>pM,name:()=>cM,parse:()=>dg,structure:()=>uM});function dg(){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,fg=_(()=>{"use strict";cM="Operator",uM={value:String}});var hg={};Se(hg,{generate:()=>fM,name:()=>dM,parse:()=>mg,structure:()=>gM});function mg(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,xg=_(()=>{"use strict";dM="Parentheses",gM={children:[[]]}});var bg={};Se(bg,{generate:()=>xM,name:()=>mM,parse:()=>yg,structure:()=>hM});function yg(){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,Sg=_(()=>{"use strict";mM="Percentage",hM={value:String}});var vg={};Se(vg,{generate:()=>wM,name:()=>yM,parse:()=>wg,structure:()=>SM,walkContext:()=>bM});function wg(){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,kg=_(()=>{"use strict";yM="PseudoClassSelector",bM="function",SM={name:String,children:[["Raw"],null]}});var Tg={};Se(Tg,{generate:()=>TM,name:()=>vM,parse:()=>Cg,structure:()=>CM,walkContext:()=>kM});function Cg(){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,Ig=_(()=>{"use strict";vM="PseudoElementSelector",kM="function",CM={name:String,children:[["Raw"],null]}});var Eg={};Se(Eg,{generate:()=>EM,name:()=>IM,parse:()=>Fg,structure:()=>FM});function j0(){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 Fg(){let e=this.tokenStart,t=j0.call(this),n=null;return this.skipSC(),this.isDelim(U0)&&(this.eatDelim(U0),n=j0.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 U0,IM,FM,Ag=_(()=>{"use strict";U0=47;IM="Ratio",FM={left:["Number","Function"],right:["Number","Function",null]}});var Lg={};Se(Lg,{generate:()=>MM,name:()=>PM,parse:()=>Pg,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 Pg(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,Mg=_(()=>{"use strict";PM="Raw",LM={value:String}});var Dg={};Se(Dg,{generate:()=>NM,name:()=>DM,parse:()=>Bg,structure:()=>zM,walkContext:()=>RM});function H0(){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 Bg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(BM,H0):n=H0.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,Rg=_(()=>{"use strict";DM="Rule",RM="rule",zM={prelude:["SelectorList","Raw"],block:["Block"]}});var Ng={};Se(Ng,{generate:()=>$M,name:()=>OM,parse:()=>zg,structure:()=>_M});function zg(){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,Og=_(()=>{"use strict";OM="Scope",_M={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var $g={};Se($g,{generate:()=>HM,name:()=>UM,parse:()=>_g,structure:()=>jM});function _g(){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,Ug=_(()=>{"use strict";UM="Selector",jM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Hg={};Se(Hg,{generate:()=>qM,name:()=>WM,parse:()=>jg,structure:()=>GM,walkContext:()=>VM});function jg(){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,Wg=_(()=>{"use strict";WM="SelectorList",VM="selector",GM={children:[["Selector","Raw"]]}});function Ml(e){let t=e.length,n=e.charCodeAt(0),r=n===W0||n===V0?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===Vg){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Mn(Vg,a)){let u=s-1,c=Qr(e,u);s=c-1,i+=tl(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function G0(e,t){let n=t?"'":'"',r=t?V0:W0,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===Vg?(o+="\\"+e.charAt(s),i=!1):(i&&(Bn(a)||Or(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Vg,W0,V0,Bl=_(()=>{"use strict";lr();Vg=92,W0=34,V0=39});var qg={};Se(qg,{generate:()=>XM,name:()=>YM,parse:()=>Gg,structure:()=>KM});function Gg(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Ml(this.consume(5))}}function XM(e){this.token(5,G0(e.value))}var YM,KM,Yg=_(()=>{"use strict";Bl();YM="String",KM={value:String}});var Xg={};Se(Xg,{generate:()=>tB,name:()=>JM,parse:()=>Kg,structure:()=>eB,walkContext:()=>ZM});function Y0(){return this.Raw(null,!1)}function Kg(){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,Y0);break;default:n=this.parseWithFallback(this.Rule,Y0)}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,Qg=_(()=>{"use strict";QM=33;JM="StyleSheet",ZM="stylesheet",eB={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var Zg={};Se(Zg,{generate:()=>oB,name:()=>nB,parse:()=>Jg,structure:()=>rB});function Jg(){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,ef=_(()=>{"use strict";nB="SupportsDeclaration",rB={declaration:"Declaration"}});var rf={};Se(rf,{generate:()=>lB,name:()=>sB,parse:()=>nf,structure:()=>aB});function tf(){this.tokenType!==1&&this.isDelim(iB)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function nf(){let e=this.tokenStart;return this.isDelim(K0)?(this.next(),tf.call(this)):(tf.call(this),this.isDelim(K0)&&(this.next(),tf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function lB(e){this.tokenize(e.name)}var iB,K0,sB,aB,of=_(()=>{"use strict";iB=42,K0=124;sB="TypeSelector",aB={name:String}});var lf={};Se(lf,{generate:()=>gB,name:()=>pB,parse:()=>af,structure:()=>dB});function zs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===Q0&&t&&n!==0)return zs.call(this,e+n+1,!1),-1;Bn(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 Dl(e){let t=0;for(;this.isDelim(sf);)++t>e&&this.error("Too many question marks"),this.next()}function cB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===X0?"Plus sign":"Hyphen minus")+" is expected")}function uB(){let e=0;switch(this.tokenType){case 10:if(e=zs.call(this,1,!0),this.isDelim(sf)){Dl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){cB.call(this,Q0),zs.call(this,1,!1);break}break;case 12:e=zs.call(this,1,!0),e>0&&Dl.call(this,6-e);break;default:if(this.eatDelim(X0),this.tokenType===1){e=zs.call(this,0,!0),e>0&&Dl.call(this,6-e);break}if(this.isDelim(sf)){this.next(),Dl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function af(){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 X0,Q0,sf,pB,dB,cf=_(()=>{"use strict";lr();X0=43,Q0=45,sf=63;pB="UnicodeRange",dB={value:String}});function Z0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===J0?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===uf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Mn(uf,s)){let a=i-1,u=Qr(e,a);i=u-1,o+=tl(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function eS(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===uf||o===mB||o===hB||o===xB||o===J0?(t+="\\"+e.charAt(r),n=!1):(n&&Bn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var fB,uf,mB,hB,xB,J0,pf=_(()=>{"use strict";lr();fB=32,uf=92,mB=34,hB=39,xB=40,J0=41});var gf={};Se(gf,{generate:()=>SB,name:()=>yB,parse:()=>df,structure:()=>bB});function df(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=Z0(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=Ml(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,eS(e.value))}var yB,bB,ff=_(()=>{"use strict";pf();Bl();yB="Url",bB={value:String}});var hf={};Se(hf,{generate:()=>kB,name:()=>wB,parse:()=>mf,structure:()=>vB});function mf(){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,xf=_(()=>{"use strict";wB="Value",vB={children:[[]]}});var bf={};Se(bf,{generate:()=>FB,name:()=>TB,parse:()=>yf,structure:()=>IB});function yf(){return this.eat(13),CB}function FB(e){this.token(13,e.value)}var CB,TB,IB,Sf=_(()=>{"use strict";CB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),TB="WhiteSpace",IB={value:String}});var Ns={};Se(Ns,{AnPlusB:()=>Ep,Atrule:()=>Lp,AtrulePrelude:()=>Dp,AttributeSelector:()=>Op,Block:()=>Up,Brackets:()=>Wp,CDC:()=>qp,CDO:()=>Xp,ClassSelector:()=>Zp,Combinator:()=>nd,Comment:()=>id,Condition:()=>ld,Declaration:()=>pd,DeclarationList:()=>md,Dimension:()=>yd,Feature:()=>wd,FeatureFunction:()=>Cd,FeatureRange:()=>Ed,Function:()=>Ld,GeneralEnclosed:()=>Dd,Hash:()=>Nd,IdSelector:()=>Hd,Identifier:()=>$d,Layer:()=>Gd,LayerList:()=>Kd,MediaQuery:()=>Jd,MediaQueryList:()=>tg,NestingSelector:()=>og,Nth:()=>ag,Number:()=>ug,Operator:()=>gg,Parentheses:()=>hg,Percentage:()=>bg,PseudoClassSelector:()=>vg,PseudoElementSelector:()=>Tg,Ratio:()=>Eg,Raw:()=>Lg,Rule:()=>Dg,Scope:()=>Ng,Selector:()=>$g,SelectorList:()=>Hg,String:()=>qg,StyleSheet:()=>Xg,SupportsDeclaration:()=>Zg,TypeSelector:()=>rf,UnicodeRange:()=>lf,Url:()=>gf,Value:()=>hf,WhiteSpace:()=>bf});var wf=_(()=>{"use strict";Ap();Mp();Rp();_p();jp();Vp();Yp();Qp();ed();rd();sd();cd();dd();hd();bd();vd();Td();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();Yg();Qg();ef();of();cf();ff();xf();Sf()});var nS,rS=_(()=>{"use strict";bl();E0();wf();nS={generic:!0,cssWideKeywords:Ci,...F0,node:Ns}});function Os(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,oS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===LB||t===AB||t===oS||t===PB)return this.Operator();t===EB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var EB,AB,oS,PB,LB,MB,vf=_(()=>{"use strict";EB=35,AB=42,oS=43,PB=45,LB=47,MB=117});var iS,sS=_(()=>{"use strict";vf();iS={getNode:Os}});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)===aS&&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 aS: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,aS,OB,_B,$B,lS,cS=_(()=>{"use strict";BB=35,DB=38,RB=42,zB=43,NB=47,aS=46,OB=62,_B=124,$B=126;lS={onWhiteSpace:UB,getNode:jB}});function uS(){return this.createSingleNodeList(this.Raw(null,!1))}var pS=_(()=>{"use strict"});function dS(){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 gS=_(()=>{"use strict"});function fS(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var mS,hS=_(()=>{"use strict";vf();pS();gS();mS={getNode:Os,onWhiteSpace(e,t){fS(e)&&(e.value=" "+e.value),fS(t.last)&&(t.last.value+=" ")},expression:uS,var:dS}});var kf={};Se(kf,{AtrulePrelude:()=>iS,Selector:()=>lS,Value:()=>mS});var xS=_(()=>{"use strict";sS();cS();hS()});var HB,yS,bS=_(()=>{"use strict";HB=new Set(["none","and","not","or"]),yS={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 SS,wS=_(()=>{"use strict";SS={parse:{prelude:null,block(){return this.Block(!0)}}}});function Cf(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 vS,kS,CS=_(()=>{"use strict";vS={layer(){this.skipSC();let e=this.createList(),t=Cf.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=Cf.call(this,this.Declaration,()=>Cf.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},kS={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,vS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,vS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var TS,IS=_(()=>{"use strict";TS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var FS,ES=_(()=>{"use strict";FS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var AS,PS=_(()=>{"use strict";AS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var LS,MS=_(()=>{"use strict";LS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var BS,DS=_(()=>{"use strict";BS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var RS,zS=_(()=>{"use strict";RS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var NS,OS=_(()=>{"use strict";NS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var _S,$S=_(()=>{"use strict";bS();wS();CS();IS();ES();PS();MS();DS();zS();OS();_S={container:yS,"font-face":SS,import:kS,layer:TS,media:FS,nest:AS,page:LS,scope:BS,"starting-style":RS,supports:NS}});function US(){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 jS=_(()=>{"use strict"});var Qo,Tf,WB,VB,Rl,HS,WS=_(()=>{"use strict";jS();Qo={parse(){return this.createSingleNodeList(this.SelectorList())}},Tf={parse(){return this.createSingleNodeList(this.Selector())}},WB={parse(){return this.createSingleNodeList(this.Identifier())}},VB={parse:US},Rl={parse(){return this.createSingleNodeList(this.Nth())}},HS={dir:WB,has:Qo,lang:VB,matches:Qo,is:Qo,"-moz-any":Qo,"-webkit-any":Qo,where:Qo,not:Qo,"nth-child":Rl,"nth-last-child":Rl,"nth-last-of-type":Rl,"nth-of-type":Rl,slotted:Tf,host:Tf,"host-context":Tf}});var If={};Se(If,{AnPlusB:()=>Fp,Atrule:()=>Pp,AtrulePrelude:()=>Bp,AttributeSelector:()=>Np,Block:()=>$p,Brackets:()=>Hp,CDC:()=>Gp,CDO:()=>Kp,ClassSelector:()=>Jp,Combinator:()=>td,Comment:()=>od,Condition:()=>ad,Declaration:()=>ud,DeclarationList:()=>fd,Dimension:()=>xd,Feature:()=>Sd,FeatureFunction:()=>kd,FeatureRange:()=>Fd,Function:()=>Pd,GeneralEnclosed:()=>Bd,Hash:()=>zd,IdSelector:()=>jd,Identifier:()=>_d,Layer:()=>Vd,LayerList:()=>Yd,MediaQuery:()=>Qd,MediaQueryList:()=>eg,NestingSelector:()=>rg,Nth:()=>sg,Number:()=>cg,Operator:()=>dg,Parentheses:()=>mg,Percentage:()=>yg,PseudoClassSelector:()=>wg,PseudoElementSelector:()=>Cg,Ratio:()=>Fg,Raw:()=>Pg,Rule:()=>Bg,Scope:()=>zg,Selector:()=>_g,SelectorList:()=>jg,String:()=>Gg,StyleSheet:()=>Kg,SupportsDeclaration:()=>Jg,TypeSelector:()=>nf,UnicodeRange:()=>af,Url:()=>df,Value:()=>mf,WhiteSpace:()=>yf});var VS=_(()=>{"use strict";Ap();Mp();Rp();_p();jp();Vp();Yp();Qp();ed();rd();sd();cd();dd();hd();bd();vd();Td();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();Yg();Qg();ef();of();cf();ff();xf();Sf()});var GS,qS=_(()=>{"use strict";xS();$S();WS();VS();GS={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:kf,atrule:_S,pseudo:HS,node:If}});var YS,KS=_(()=>{"use strict";wf();YS={node:Ns}});var XS,QS=_(()=>{"use strict";I0();rS();qS();KS();XS=T0({...nS,...GS,...YS})});var JS=_(()=>{"use strict"});var ZS=_(()=>{"use strict"});var pY,ew,dY,gY,fY,tw,mY,hY,xY,yY,bY,SY,nw=_(()=>{"use strict";QS();JS();gp();yl();ZS();Bl();pf();({tokenize:pY,parse:ew,generate:dY,lexer:gY,createLexer:fY,walk:tw,find:mY,findLast:hY,findAll:xY,toPlainObject:yY,fromPlainObject:bY,fork:SY}=XS)});function KB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function ow(e){try{let t=ew(e.trim(),{context:"value"}),n=[];return tw(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=ow(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 rw(e,t){let n=t.trim();if(!n)return"";let r=XB(e,n);return ow(r).map(i=>i==="0"?"0px":i).join(" ")}function iw(e,t,n){let r=rw(e,t),o=rw(e,n);return r!==""&&o!==""&&r===o}var YB,sw=_(()=>{"use strict";nw();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 aw(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 Jo(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),p=c.test(o);if(l!==p)return!1;let g=aw(r),d=aw(o);return!!(g===d||n&&iw(n,r,o))}var Ff=_(()=>{"use strict";sw()});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 lw(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)||lw(r)||lw(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<uw:a<cw}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&&!Jo(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)<pw}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(p=>t.includes(p)||n.includes(p)))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 _s(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(Jo(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 (<${pw}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")?uw:cw}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 cw,uw,pw,ZB,eD,tD,nD,dw=_(()=>{"use strict";Ff();cw=.5,uw=2,pw=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 gw=_(()=>{"use strict"});var fw=_(()=>{"use strict"});var mw=_(()=>{"use strict"});var Ef=_(()=>{"use strict";Ff();dw();gw();fw();mw()});var bD,SD,NY,Af=_(()=>{"use strict";bD=["flex","inline-flex"],SD=["grid","inline-grid"],NY=[...bD,...SD]});var xw=_(()=>{"use strict";Ef();Af()});var yw=_(()=>{"use strict"});var Nn=_(()=>{"use strict";vu();vy();ky();Ef();Af();xw();yw()});function vD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function er(e){try{let t=e.map(vD),n=JSON.stringify(t,kD);sessionStorage.setItem(Pf,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function Lf(){try{let e=sessionStorage.getItem(Pf);if(!e)return[];let t=JSON.parse(e,CD);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function bw(){try{let e=Lf();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&&(er(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function Sw(){try{sessionStorage.removeItem(Pf),y.debug("[SessionStorage] Review history cleared")}catch(e){y.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 Pf,Mf=_(()=>{"use strict";$e();Pf="uicopilot_review_history"});import TD,{createContext as ID,useContext as FD,useReducer as ED,useMemo as ww,useRef as AD,useEffect as PD}from"react";function zl(e){let t=e.length>vw?e.slice(e.length-vw):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=zl(i),er(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=zl([...e.reviewHistory,...r]);return er(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=zl([...e.reviewHistory,t.payload]);return er(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 er(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 er(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 er(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 er(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 er(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 er(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 y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return er(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 er(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return Sw(),{...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 Df({children:e}){let[t,n]=ED(MD,ND),r=AD(t);PD(()=>{r.current=t},[t]);let o=ww(()=>({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=ww(()=>({...t,...o}),[t,o]);return TD.createElement(kw.Provider,{value:i},e)}function ce(){let e=FD(kw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var vw,LD,BD,DD,Bf,RD,zD,ND,kw,Rf=_(()=>{"use strict";Nn();Mf();$e();vw=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},Bf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},RD=()=>{if(typeof localStorage>"u")return Bf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Bf;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 Bf},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:zl(Lf()),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},kw=ID(null)});import $s,{useMemo as OD}from"react";function Nf({children:e}){return $s.createElement(hu,null,$s.createElement(yu,null,$s.createElement(Su,null,$s.createElement(Df,null,$s.createElement(_D,null),e))))}function Cw(e){let t=we(),n=Je(),r=nt(),o=ce(),i=OD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function _D(){return zf=Cw(),null}var zf,ft,Tw=_(()=>{"use strict";xu();bu();wu();Rf();zf=null,ft=Object.assign(Cw,{getState:()=>{if(!zf)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return zf}})});var Ce=_(()=>{"use strict";Tw();xu();bu();wu();Rf()});function V(){return(process.env.STORYBOOK_UICOPILOT_URL||$D).replace(/\/$/,"")}var $D,Iw,He=_(()=>{"use strict";$D="https://app.uiparity.com";Iw=3.6});async function ne(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 Zo,useState as Ol,useRef as jw,useCallback as Uf}from"react";import{addons as jf}from"storybook/manager-api";async function jR(e,t,n){let r=`${e}:${t}`,o=Hf.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ne(`${qw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Hf.delete(r)});return Hf.set(r,i),i}function HR(e,t,n){try{sessionStorage.setItem(`${_l}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function WR(e,t){try{let n=sessionStorage.getItem(`${_l}${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(`${_l}${e}`)}catch{}return null}function VR(e){try{let t=sessionStorage.getItem(`${_l}${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 Hw,Ww,Vw,Gw,Bi,qw,On,Wf,Hf,_l,Yw,Kw,ei,Di=_(()=>{"use strict";Ce();Vf();$e();He();ct();Hw="storyArgsUpdated",Ww="storyRendered",Vw="forceRemount",Gw=null,Bi=()=>Gw,qw=V(),On=new Map,Wf=null,Hf=new Map;_l="uicopilot-figma-image-";Yw=(e,t,n)=>{let r=On.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):On.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),y.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},Kw=(e,t,n)=>{Wf=t;let r=On.get(e);r?r.figmaImageUrl=n:On.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},ei=()=>{let[e,t]=Ol(!1),[n,r]=Ol(!1),[o,i]=Ol(!1),[s,a]=Ol(null),u=jw(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ce(),p=Uf(()=>{let P=ft.getState().currentStoryId;P&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",P),On.delete(P),u.current=null,i(!0),l())},[l]),g=Uf(()=>{let P=ft.getState().currentStoryId;if(P){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",P);let z=On.get(P);z&&(z.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:d}=we(),{selectedProjectId:f}=Je(),{currentStoryId:k,currentMapping:T,loadingMapping:E}=nt(),{setStorybookImageUrl:I,setFigmaImageUrl:D}=ce(),R=jw(null);Zo(()=>{k&&R.current&&R.current!==k&&(y.debug("[useReviewScreenshots] Story switched, clearing images"),I(""),D("")),R.current=k},[k,I,D]),Zo(()=>{!k||E||T||D("")},[k,T,E,D]),Zo(()=>{if(!k)return;let P=VR(k);P&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",k),D(P))},[k,D]),Zo(()=>{let P=!1;return(async()=>{if(!d||!f||!k){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==k&&(y.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),I(""),D(""));let x=ft.getState();if(u.current===k&&x.storybookImageUrl&&x.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let w=T?.figmaNodeId??null;if(w!==Wf){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",k);let L=On.get(k);L&&(L.figmaImageUrl=null),Wf=w,u.current=null}let v=T?.figmaNodeId;if(v&&!On.get(k)?.figmaImageUrl){let L=WR(k,v);if(L){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",k),D(L);let B=On.get(k);B?B.figmaImageUrl=L:On.set(k,{storybookImageUrl:null,figmaImageUrl:L})}}let C=On.get(k),m=C&&C.storybookImageUrl&&C.figmaImageUrl,F=C&&C.storybookImageUrl&&!C.figmaImageUrl,S=C&&!C.storybookImageUrl&&C.figmaImageUrl;if(m){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",k),I(C.storybookImageUrl),D(C.figmaImageUrl),u.current=k;return}let b=F&&T?.figmaNodeId;b&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",k),I(C.storybookImageUrl));let A=S;if(A&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",k),D(C.figmaImageUrl)),u.current===k&&T?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),b?r(!0):(A||(t(!0),r(!0)),i(!0)),u.current=k,P)return;let L=A?C.figmaImageUrl:null,B;if(A)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(v){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",v);let h=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let U=await jR(f,v,d);h=U.imageUrl||null;let W=U.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${W}:`,h?"success":"not found")}catch(U){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",U)}if(h)try{y.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let U=`${qw}/api/proxy/image?url=${encodeURIComponent(h)}`,W=await ne(U);if(W.ok){let M=await W.blob(),Y=new FileReader,ee=await new Promise((xe,se)=>{Y.onloadend=()=>xe(Y.result),Y.onerror=se,Y.readAsDataURL(M)});L=ee,D(ee),y.debug("[useReviewScreenshots] Figma image loaded via proxy");let ge=new Image;await new Promise(xe=>{ge.onload=()=>{B={width:ge.naturalWidth,height:ge.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),xe()},ge.onerror=()=>xe(),ge.src=ee})}else L=h,D(h),y.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(U){y.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",U),L=h,D(h)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",v),D(null);L&&v&&HR(k,v,L),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let N=C?.storybookImageUrl||null;if(N)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",k);let h=await $l({storyId:k,sessionToken:d||void 0,...B&&{figmaWidth:B.width,figmaHeight:B.height}});h&&!P?(N=h,I(h),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",B||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}On.set(k,{storybookImageUrl:N,figmaImageUrl:L}),y.debug("[useReviewScreenshots] Screenshots cached for story:",k)}catch(L){y.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}},[d,f,k,T?.figmaNodeId,c]),Zo(()=>{let P=jf.getChannel(),z=null,x=w=>{Gw=w.args,y.debug("[useReviewScreenshots] Args updated for story:",w.storyId,"args:",w.args),z&&clearTimeout(z),z=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return P.on(Hw,x),()=>{P.off(Hw,x),z&&clearTimeout(z)}},[p]),Zo(()=>{let P=jf.getChannel(),z=!1,x=null,w=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),z=!0,i(!0)},v=()=>{z&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),x&&clearTimeout(x),x=setTimeout(()=>{z=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return P.on(Vw,w),P.on(Ww,v),()=>{P.off(Vw,w),P.off(Ww,v),x&&clearTimeout(x)}},[g]),Zo(()=>{let P=jf.getChannel(),z=async x=>{if(!x?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let w=ft.getState().currentStoryId,v=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x.snapshot,storyId:w})});if(v.ok){let C=await v.json();if(C.screenshot){I(C.screenshot);let m=ft.getState().currentStoryId;if(m){let F=On.get(m);F?F.storybookImageUrl=C.screenshot:On.set(m,{storybookImageUrl:C.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await v.text())}catch(w){y.error("[useReviewScreenshots] Snapshot screenshot error:",w)}finally{i(!1)}};return P.on("UICOPILOT/STORY_DOM_MUTATED",z),()=>{P.off("UICOPILOT/STORY_DOM_MUTATED",z)}},[]);let $=Uf((P,z,x)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Kw(P,z,x),D(x),r(!1),u.current=P},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:p,refreshStorybookOnly:g,setFigmaImageDirect:$}}});function qR(){return!V().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 Xw(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=Xw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(p=>p.href===c);if(l)try{let p="";for(let g of Array.from(l.cssRules))p+=g.cssText+`
|
|
13
|
+
`;if(/(?:color|oklch|oklab|lab|lch)\(/.test(p)){let g=s.createElement("style");g.textContent=Xw(p,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){y.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 ne(`${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/",""),y.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=Bi();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=JR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=XR(s);i+=`&args=${a}`,y.debug("[Screenshot] Using URL with current args:",i)}else y.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 y.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 y.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 $l(e){let t=e?.storyId||tz();if(t){let n=Gf.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Qw(t,e).finally(()=>{Gf.delete(t)});return Gf.set(t,r),r}return Qw(void 0,e)}async function Qw(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 y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await KR()}catch(n){throw y.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,Gf,Vf=_(()=>{"use strict";He();Di();$e();ct();GR=V();Gf=new Map});function Fn(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 _n(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 Vs(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Jw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let T=r.fontSize||"16px",E=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let I=t.fonts.check(`${E} ${T} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:I,fontWeight:E,fontSize:T,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),I)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(T=>T.trim().replace(/['"]/g,"")),p=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...p])];s.font=`${c} ${u} ${a} monospace`;let d=s.measureText(o).width,f="unknown",k=new Map;for(let T of g){s.font=`${c} ${u} ${a} "${T}", monospace`;let E=s.measureText(o).width;if(k.set(T,E),E!==d){s.font=`${c} ${u} ${a} "${T}"`;let I=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(I-D)<.1){f=T;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:f,declaredFonts:l,fontWidths:Array.from(k.entries()),isIframe:t!==document}),f}var Gs=_(()=>{"use strict";$e()});function Ri(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 qf(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return y.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:Fn(n.color),backgroundColor:Fn(n.backgroundColor),borderColor:Fn(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:Jw(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 Yf(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){y.error("Error extracting declared styles:",r)}return n}var Ul=_(()=>{"use strict";$e();Gs()});function nz(e){let t=[],n=new Set,r=Zw.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(Zw.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:Ri(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Vs(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:Fn(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 p=`${c.tagName}.${o(c)}`;r.has(p)||(r.add(p),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,p=n.borderStyle,g=Fn(n.borderColor),d=s?`${l} ${p} ${g}`:"none";return{selector:Ri(r,i),className:i,border:d,borderRadius:n.borderRadius,backgroundColor:Fn(n.backgroundColor),gap:n.gap}}function qs(){y.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);y.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),y.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){y.error("[computedStyles] Error extracting text elements:",a)}return{computed:qf(r),declared:Yf(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Zw,ev=_(()=>{"use strict";$e();Gs();Ul();Zw=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Kf(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=Fn(n.backgroundColor);_n("backgroundColor",o)||(r.backgroundColor=o);let i=az(n.borderWidth,n.borderStyle,Fn(n.borderColor));i&&(r.border=i),_n("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),_n("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),_n("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 T=0;T<e.attributes.length;T++){let E=e.attributes[T];if(["class","style","id","xmlns","xmlns:xlink"].includes(E.name))continue;let I=E.name.replace(/-([a-z])/g,(R,$)=>$.toUpperCase()),D=E.value.startsWith("rgb")?Fn(E.value):E.value;I==="d"&&D.length>100?r[I]=D.substring(0,100)+"...":r[I]=D}let d=n.getPropertyValue("fill"),f=n.getPropertyValue("stroke");if(d&&d!=="none"&&(r.fill=d.startsWith("rgb")?Fn(d):d),f&&f!=="none"&&(r.stroke=f.startsWith("rgb")?Fn(f):f),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let T=e.getBoundingClientRect();T.width>0&&(r.width=`${Math.round(T.width*100)/100}px`),T.height>0&&(r.height=`${Math.round(T.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=Vs(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=Fn(n.color),_n("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),_n("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let p=Kf(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);_n("padding",p)||(r.padding=p);let g=Kf(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return _n("margin",g)||(r.margin=g),_n("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(_n("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),_n("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),_n("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function tv(e){let t=1;for(let n of e.children)t+=tv(n);return t}function nv(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,p;for(let k of Array.from(o.childNodes))if(k.nodeType===Node.TEXT_NODE){let T=k.textContent?.trim();if(T){p=T.length>50?T.substring(0,50)+"...":T;break}}let g=s;c?g=`${s}#${c}`:u&&(g=Ri(s,u));let d=lz(o),f=[];if(i<t){let k=Array.from(o.children);for(let T of k){let E=T.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(E))continue;let D=(T.ownerDocument.defaultView||window).getComputedStyle(T);D.display==="none"||D.visibility==="hidden"||f.push(n(T,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:p,styles:d,children:f}}y.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return y.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:tv(r)}),r}function Xf(e=4){y.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(y.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(y.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(y.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(y.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=nv(r,e);return y.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return y.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var sz,rv=_(()=>{"use strict";$e();Gs();Ul();sz=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Qf=_(()=>{"use strict";Gs();Ul();ev();rv()});var Av=ir((CQ,Ev)=>{"use strict";Ev.exports={compareTwoStrings:Fv,findBestMatch:Bz};function Fv(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=Fv(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 T1=ir((Ose,C1)=>{"use strict";var S1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,M3=/\n/g,B3=/^\s*/,D3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,R3=/^:\s*/,z3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,N3=/^[;\s]*/,O3=/^\s+|\s+$/g,_3=`
|
|
14
|
+
`,w1="/",v1="*",ai="",$3="comment",U3="declaration";function j3(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(f){var k=f.match(M3);k&&(n+=k.length);var T=f.lastIndexOf(_3);r=~T?f.length-T:r+f.length}function i(){var f={line:n,column:r};return function(k){return k.position=new s(f),c(),k}}function s(f){this.start=f,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(f){var k=new Error(t.source+":"+n+":"+r+": "+f);if(k.reason=f,k.filename=t.source,k.line=n,k.column=r,k.source=e,!t.silent)throw k}function u(f){var k=f.exec(e);if(k){var T=k[0];return o(T),e=e.slice(T.length),k}}function c(){u(B3)}function l(f){var k;for(f=f||[];k=p();)k!==!1&&f.push(k);return f}function p(){var f=i();if(!(w1!=e.charAt(0)||v1!=e.charAt(1))){for(var k=2;ai!=e.charAt(k)&&(v1!=e.charAt(k)||w1!=e.charAt(k+1));)++k;if(k+=2,ai===e.charAt(k-1))return a("End of comment missing");var T=e.slice(2,k-2);return r+=2,o(T),e=e.slice(k),r+=2,f({type:$3,comment:T})}}function g(){var f=i(),k=u(D3);if(k){if(p(),!u(R3))return a("property missing ':'");var T=u(z3),E=f({type:U3,property:k1(k[0].replace(S1,ai)),value:T?k1(T[0].replace(S1,ai)):ai});return u(N3),E}}function d(){var f=[];l(f);for(var k;k=g();)k!==!1&&(f.push(k),l(f));return f}return c(),d()}function k1(e){return e?e.replace(O3,ai):ai}C1.exports=j3});var I1=ir(ma=>{"use strict";var H3=ma&&ma.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ma,"__esModule",{value:!0});ma.default=V3;var W3=H3(T1());function V3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,W3.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 E1=ir(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.camelCase=void 0;var G3=/^--[a-zA-Z0-9_-]+$/,q3=/-([a-z])/g,Y3=/^[^-]+$/,K3=/^-(webkit|moz|ms|o|khtml)-/,X3=/^-(ms)-/,Q3=function(e){return!e||Y3.test(e)||G3.test(e)},J3=function(e,t){return t.toUpperCase()},F1=function(e,t){return"".concat(t,"-")},Z3=function(e,t){return t===void 0&&(t={}),Q3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(X3,F1):e=e.replace(K3,F1),e.replace(q3,J3))};kc.camelCase=Z3});var P1=ir((Lh,A1)=>{"use strict";var e5=Lh&&Lh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},t5=e5(I1()),n5=E1();function Ph(e,t){var n={};return!e||typeof e!="string"||(0,t5.default)(e,function(r,o){r&&o&&(n[(0,n5.camelCase)(r,t)]=o)}),n}Ph.default=Ph;A1.exports=Ph});var rI=ir((gde,nI)=>{"use strict";var Gc=Object.prototype.hasOwnProperty,tI=Object.prototype.toString,KT=Object.defineProperty,XT=Object.getOwnPropertyDescriptor,QT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):tI.call(t)==="[object Array]"},JT=function(t){if(!t||tI.call(t)!=="[object Object]")return!1;var n=Gc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Gc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Gc.call(t,o)},ZT=function(t,n){KT&&n.name==="__proto__"?KT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},eI=function(t,n){if(n==="__proto__")if(Gc.call(t,n)){if(XT)return XT(t,n).value}else return;return t[n]};nI.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=eI(a,n),o=eI(t,n),a!==o&&(l&&o&&(JT(o)||(i=QT(o)))?(i?(i=!1,s=r&&QT(r)?r:[]):s=r&&JT(r)?r:{},ZT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&ZT(a,{name:n,newValue:o}));return a}});import Oa from"react";import{addons as cu,types as ny,experimental_getStatusStore as ry}from"storybook/manager-api";import{AddonPanel as BV}from"storybook/internal/components";import Rt,{useState as JW,useEffect as ZW}from"react";import{styled as br}from"storybook/theming";import dy from"react";import{styled as Bt}from"storybook/theming";var ae="#ea580c",du="#c2410c",ja="#ff6b35";var sy=Bt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ay=Bt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),xo=Bt.div({marginBottom:"20px"}),yo=Bt.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})),ps=Bt.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`}})),xn=Bt.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"}})),ly=Bt(xn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),Ha=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"}}),Tn=Bt.button(({theme:e})=>({...Ha(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),on=Bt.button(({theme:e})=>({...Ha(e),backgroundColor:ae,color:e.color.inverseText,boxShadow:`0 2px 4px ${ae}4d`,"&:hover:not(:disabled)":{backgroundColor:du,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ae}66`}})),Nr=Bt.button(({theme:e})=>({...Ha(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),cy=Bt.button(({theme:e})=>({...Ha(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),In=Bt.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"}})),gu=Bt.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=Bt.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=Bt(ps)(({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"})),UV=Bt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),uy=Bt.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})),jV=Bt.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})),ds=Bt.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})),HV=Bt.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%)"}}})),py=Bt.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}}),WV=Bt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),VV=Bt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),GV=Bt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var fu=({header:e,children:t,footer:n})=>dy.createElement(sy,null,e,dy.createElement(ay,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})),mu=({toolbar:e})=>eE.createElement(nE,null,e);import n9 from"react";import{styled as Wa}from"storybook/theming";var i9=Wa.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})),s9=Wa.div({display:"flex",flex:1}),a9=Wa(bo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),l9=Wa.div({display:"flex",gap:"8px",alignItems:"center"});import Zt,{useState as _f,useCallback as Ow,useEffect as _w}from"react";import{styled as ro}from"storybook/theming";import ve,{useEffect as Fw}from"react";import{styled as lt}from"storybook/theming";Ce();He();$e();ct();var Ew=lt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),Aw=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:ae,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%, ${ae} 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:ae,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Pw=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:ae,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),rR=lt.div({display:"flex",gap:"8px"}),Lw=lt(In)({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:ae,color:e.color.inverseText})),fR=lt.button(({theme:e})=>({background:"none",border:"none",color:ae,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"?ae:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),xR=30*1e3,Mw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(f=!1)=>{if(!t)return;let k=o&&Date.now()-o<xR;if(!(!f&&k&&r))try{let T=V(),E=await ne(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(E.ok){let I=await E.json();i(I)}}catch(T){y.error("Failed to fetch usage:",T)}};Fw(()=>{l()},[t]),Fw(()=>{let f=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let p=()=>{if(t){let f=V();fetch(`${f}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}).catch(()=>{})}n(),e()},g=()=>{let f=V();window.open(`${f}/pricing`,"_blank")},d=()=>{let f=V();window.open(`${f}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let f=Math.floor(u?.creditBalance??0),T=Math.max(f,10),E=Math.max(0,T-f),I=T>0?f/T*100:0;return ve.createElement(ve.Fragment,null,ve.createElement(Ew,{onClick:e}),ve.createElement(Aw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},ve.createElement(UD,null,ve.createElement(jD,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement(HD,null,ve.createElement(WD,null,"UI Review"),ve.createElement(VD,null,(u?.plan||"BETA").toUpperCase())),ve.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},ve.createElement(Pw,{onClick:p,title:"Sign out",style:{position:"static"}},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Pw,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),ve.createElement(GD,null,ve.createElement(qD,null,"Credits"),ve.createElement(YD,null,f," left")),ve.createElement(KD,null,ve.createElement(XD,{percent:I})),ve.createElement(QD,null,E," used \xB7 ",f," remaining"),ve.createElement(JD,null),ve.createElement(ZD,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return ve.createElement(ve.Fragment,null,ve.createElement(Ew,{onClick:e}),ve.createElement(Aw,{onClick:f=>f.stopPropagation()},ve.createElement(eR,null,ve.createElement(tR,null,ve.createElement(nR,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement("span",null,u?.email||"Loading...")),ve.createElement(rR,null,ve.createElement(Lw,{onClick:p,title:"Sign out"},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Lw,{onClick:e,title:"Close"},"\xD7"))),ve.createElement(oR,null,c?ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?ve.createElement(ve.Fragment,null,ve.createElement(iR,null,ve.createElement(sR,null,"Credit Balance"),ve.createElement(aR,null,"$",(u?.creditBalance??0).toFixed(2)),ve.createElement(lR,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),ve.createElement(cR,null,ve.createElement(uR,null,ve.createElement(pR,null,ve.createElement(dR,null,"Current Plan"),ve.createElement(gR,null,u?.plan||"Free")),ve.createElement(fR,{onClick:g},"View detail >")),ve.createElement(mR,null,"~$0.02-0.05 per review depending on complexity"),ve.createElement(hR,{onClick:d,style:{marginTop:"16px"}},"Add Credits"))):ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Ce();import Pi from"react";import{styled as Bw}from"storybook/theming";He();Ce();ct();$e();var yR=Bw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),bR=Bw.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}},Dw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=we();return e!=="admin"?null:Pi.createElement(yR,null,Pi.createElement(bR,null,"View as:"),Pi.createElement(ly,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ne(`${V()}/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=>y.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"}},Pi.createElement("option",{value:"admin"},"Admin"),Pi.createElement("option",{value:"beta"},"Beta Tester")),t&&Pi.createElement(py,{variant:"warning"},"Previewing as ",t))};He();Ce();ct();import xt,{useState as Us,useCallback as Of}from"react";import{styled as Ir}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=Ir.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),CR=Ir.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=Ir.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),IR=Ir.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),FR=Ir.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=Ir.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),AR=Ir.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:ae}})),Rw=Ir.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),zw=Ir.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),PR=Ir.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),LR=Ir.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 Nw({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=we(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=Us("other"),[u,c]=Us(""),[l,p]=Us(!1),[g,d]=Us(!1),[f,k]=Us(null),T=Of(()=>{c(""),a("other"),d(!1),k(null),p(!1)},[]),E=Of(()=>{T(),t()},[T,t]),I=Of(async D=>{if(D.preventDefault(),!u.trim()){k("Please write a message.");return}if(!r||!n){k("Sign in to send feedback.");return}p(!0),k(null);try{let R=await ne(`${V()}/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})`)}d(!0)}catch(R){k(R instanceof Error?R.message:"Something went wrong")}finally{p(!1)}},[u,s,n,r,o,i]);return e?xt.createElement(kR,{onClick:E},xt.createElement(CR,{onClick:D=>D.stopPropagation()},xt.createElement(TR,null,xt.createElement(IR,null,xt.createElement("span",null,"\u{1F4AC}"),"Send feedback"),xt.createElement(FR,{onClick:E,"aria-label":"Close"},"\xD7")),g?xt.createElement(xt.Fragment,null,xt.createElement(LR,null,xt.createElement("h4",null,"Thanks \u2014 got it."),xt.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),xt.createElement(Rw,null,xt.createElement("span",null),xt.createElement(Tn,{onClick:E},"Close"))):xt.createElement("form",{onSubmit:I},xt.createElement(ER,null,xt.createElement(xo,null,xt.createElement(yo,{htmlFor:"feedback-severity"},"Type"),xt.createElement(xn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},vR.map(D=>xt.createElement("option",{key:D.value,value:D.value},D.label)))),xt.createElement(xo,null,xt.createElement(yo,{htmlFor:"feedback-message"},"What happened?"),xt.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})),xt.createElement(zw,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),f&&xt.createElement(PR,null,f)),xt.createElement(Rw,null,xt.createElement(zw,null,i?`Context: ${i}`:"No story selected"),xt.createElement("div",{style:{display:"flex",gap:"8px"}},xt.createElement(Tn,{type:"button",onClick:E,disabled:l},"Cancel"),xt.createElement(on,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}Ce();He();ct();var MR=ro.div({display:"flex",alignItems:"center"}),Li=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`}})),$w=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:ae,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${ae}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 ${ae}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),_R=30*1e3,$f=({onOpenSettings:e})=>{let[t,n]=_f(!1),[r,o]=_f(!1),[i,s]=_f(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=we(),{userRole:p,roleOverride:g,featureFlags:d}=ce(),f=g??p;_w(()=>{(async()=>{if(!(!l||u&&Date.now()-u<_R&&a)){s(!0);try{let $=V(),P=await ne(`${$}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let z=await P.json();c(z)}}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=Ow(()=>{n(!0)},[]),T=Ow(()=>{n(!1)},[]),E=a?.creditBalance??0,I=E<2&&!i;return Zt.createElement(MR,null,e&&Zt.createElement(Li,null,Zt.createElement(NR,{onClick:e,title:"Settings"},Zt.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&p==="admin"&&f==="admin"&&Zt.createElement(Li,null,Zt.createElement(Dw,null)),Zt.createElement(Li,null,Zt.createElement(BR,null,"v","0.5.23")),l&&d.showCosts&&Zt.createElement(Li,null,Zt.createElement($w,{onClick:k,isLow:I,title:i?"Loading...":a?I?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?Zt.createElement(zR,null):a?`$${E.toFixed(2)}`:"...")),l&&!d.showCosts&&a&&Zt.createElement(Li,null,Zt.createElement($w,{onClick:k,isLow:Math.floor(E)<=3,title:`${Math.floor(E)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(E))),Zt.createElement(Li,null,Zt.createElement(DR,null,Zt.createElement(RR,{title:"Account & Usage",onClick:k},a?.email?a.email[0].toUpperCase():"?"),t&&Zt.createElement(Mw,{onClose:T}))),l&&Zt.createElement(OR,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),Zt.createElement(Nw,{isOpen:r,onClose:()=>o(!1)}))};import Mt,{useEffect as T4,useRef as I4}from"react";import{styled as mr}from"storybook/theming";import rt from"react";Ce();$e();He();ct();Nn();import{useState as $R,useCallback as Mi,useRef as Uw,useEffect as UR}from"react";var oo=V();y.debug("[useAuth] Module loaded, APP_URL:",oo);var js=()=>{let e=Uw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:p,setDeviceCode:g,setUserCode:d,setVerificationUri:f,setPollingInterval:k,setAuthError:T,resetAuth:E}=we(),I=Uw(null),[D,R]=$R(!1),$=Mi(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let C;try{C=await ne(`${oo}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let B=A instanceof Error&&A.message.includes("timed out")?`Cannot reach ${Et.NAME} server at ${oo}. Is the dashboard running?`:`Connection failed: ${oo} is not responding.`;T(B),y.error("[useAuth]",B);return}if(!C.ok){let A=`Cannot reach ${Et.NAME} server. Is the dashboard running?`;T(A),y.error("[useAuth]",A);return}let{poll_code:m}=await C.json();y.debug("[useAuth] Got poll_code:",m.substring(0,15)+"...");let F=localStorage.getItem("uicopilot_force_sign_in")==="true";F&&localStorage.removeItem("uicopilot_force_sign_in");let S=`${oo}/addon/auth?poll_code=${m}${F?"&force_sign_in=true":""}`;R(!0),window.open(S,"uiparity-auth","width=520,height=620,left=300,top=150"),y.debug("[useAuth] Starting OAuth poll for token..."),I.current&&clearInterval(I.current);let b=async()=>{try{let L=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:m})})).json();L.status==="authorized"&&L.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),I.current&&(clearInterval(I.current),I.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token),R(!1)):L.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),I.current&&(clearInterval(I.current),I.current=null),R(!1))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};I.current=setInterval(b,2e3),setTimeout(b,1e3)}catch(C){y.error("[useAuth] OAuth flow error:",C),T(`Connection failed. Is the dashboard running at ${oo}?`),R(!1)}},[c,T]),P=Mi(async()=>{try{let C=await fetch(`${oo}/api/addon/auth/device`,{method:"POST"});if(!C.ok)throw new Error("Failed to start device code flow");let m=await C.json();g(m.device_code),d(m.user_code),f(m.verification_uri),window.open(m.verification_uri,"_blank"),z(m.device_code,m.interval*1e3)}catch(C){throw y.error("[useAuth] Device code flow error:",C),C}},[g,d,f]),z=Mi((C,m)=>{y.debug("[useAuth] Starting polling. Device code:",C,"Interval:",m),e.current&&clearInterval(e.current);let F=async()=>{try{let b=await(await fetch(`${oo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:C})})).json();b.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),d(null),f(null),localStorage.setItem("uicopilot_session_token",b.session_token),c(b.session_token),setOauthUrl(null)):(b.status==="expired"||b.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),d(null),f(null))}catch(S){y.error("[useAuth] Polling error:",S)}};e.current=setInterval(F,m),k(m)},[g,d,f,c,k]),x=Mi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),d(null),f(null),k(null)},[g,d,f,k]),w=Mi(C=>{l(C),c(C),localStorage.setItem("uicopilot_api_key",C)},[l,c]),v=Mi(()=>{E(),setOauthUrl(null),e.current&&(clearInterval(e.current),e.current=null),I.current&&(clearInterval(I.current),I.current=null)},[E]);return UR(()=>()=>{e.current&&clearInterval(e.current),I.current&&clearInterval(I.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:D,setAuthMethod:p,startOAuth:$,startDeviceCode:P,cancelDeviceCode:x,saveApiKey:w,logout:v}};Ce();$e();He();ct();import{useCallback as Nl}from"react";var Hs=V(),io=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=we(),u=Nl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Hs}/api/projects`);let g=await ne(`${Hs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let d=await g.json();y.debug("[useProjects] Projects:",d.projects),r(d.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=Nl(async g=>{if(!a)throw new Error("Not authenticated");let d=await ne(`${Hs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!d.ok)throw new Error("Failed to create project");let f=await d.json();return await u(),f.project},[a,u]),l=Nl(async(g,d)=>{if(!a)throw new Error("Not authenticated");let f={};if(d.name!==void 0&&(f.name=d.name),d.description!==void 0&&(f.description=d.description),d.figmaFileUrl!==void 0&&(f.figmaFileId=d.figmaFileUrl||void 0),!(await ne(`${Hs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)})).ok)throw new Error("Failed to update project");await u()},[a,u]),p=Nl(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ne(`${Hs}/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:p}};Ce();var Ws=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:p}=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:p,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};Ce();Vf();Qf();import{useCallback as Js,useRef as Yl}from"react";$e();function jl(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){y.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();y.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{y.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),y.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{y.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var Hl=BigInt(4294967295),ov=BigInt(32);function cz(e,t=!1){return t?{h:Number(e&Hl),l:Number(e>>ov&Hl)}:{h:Number(e>>ov&Hl)|0,l:Number(e&Hl)|0}}function iv(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 sv=(e,t,n)=>e<<n|t>>>32-n,av=(e,t,n)=>t<<n|e>>>32-n,lv=(e,t,n)=>t<<n-32|e>>>64-n,cv=(e,t,n)=>e<<n-32|t>>>64-n;function uz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jf(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Wl(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 Zf(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 uv(e,t){Wl(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 pv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function em(...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 tm=pz?e=>e:gz;function dv(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 gv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var fz=BigInt(0),Ys=BigInt(1),mz=BigInt(2),hz=BigInt(7),xz=BigInt(256),yz=BigInt(113),hv=[],xv=[],yv=[];for(let e=0,t=Ys,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],hv.push(2*(5*r+n)),xv.push((e+1)*(e+2)/2%64);let o=fz;for(let i=0;i<7;i++)t=(t<<Ys^(t>>hz)*yz)%xz,t&mz&&(o^=Ys<<(Ys<<BigInt(i))-Ys);yv.push(o)}var bv=iv(yv,!0),bz=bv[0],Sz=bv[1],fv=(e,t,n)=>n>32?lv(e,t,n):sv(e,t,n),mv=(e,t,n)=>n>32?cv(e,t,n):av(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],p=fv(c,l,1)^n[a],g=mv(c,l,1)^n[a+1];for(let d=0;d<50;d+=10)e[s+d]^=p,e[s+d+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=xv[s],u=fv(o,i,a),c=mv(o,i,a),l=hv[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]}em(n)}var nm=class e{constructor(t,n,r,o=!1,i=24){sr(this,"state");sr(this,"pos",0);sr(this,"posOut",0);sr(this,"finished",!1);sr(this,"state32");sr(this,"destroyed",!1);sr(this,"blockLen");sr(this,"suffix");sr(this,"outputLen");sr(this,"enableXOF",!1);sr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Jf(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pv(this.state)}clone(){return this._cloneInto()}keccak(){tm(this.state32),wz(this.state32,this.rounds),tm(this.state32),this.posOut=0,this.pos=0}update(t){Zf(this),Wl(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){Zf(this,!1),Wl(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 Jf(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(uv(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,em(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={})=>dv(()=>new nm(t,e,n),r);var Sv=vz(6,72,64,gv(10));var kz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,rm=Math.ceil,dr=Math.floor,$n="[BigNumber Error] ",wv=$n+"Number primitive has more than 15 significant digits: ",Fr=1e14,Ve=14,om=9007199254740991,im=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Fo=1e7,ln=1e9;function vv(e){var t,n,r,o=I.prototype={constructor:I,toString:null,valueOf:null},i=new I(1),s=20,a=4,u=-7,c=21,l=-1e7,p=1e7,g=!1,d=1,f=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",E=!0;function I(x,w){var v,C,m,F,S,b,A,L,B=this;if(!(B instanceof I))return new I(x,w);if(w==null){if(x&&x._isBigNumber===!0){B.s=x.s,!x.c||x.e>p?B.c=B.e=null:x.e<l?B.c=[B.e=0]:(B.e=x.e,B.c=x.c.slice());return}if((b=typeof x=="number")&&x*0==0){if(B.s=1/x<0?(x=-x,-1):1,x===~~x){for(F=0,S=x;S>=10;S/=10,F++);F>p?B.c=B.e=null:(B.e=F,B.c=[x]);return}L=String(x)}else{if(!kz.test(L=String(x)))return r(B,L,b);B.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(F=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(F<0&&(F=S),F+=+L.slice(S+1),L=L.substring(0,S)):F<0&&(F=L.length)}else{if(Nt(w,2,T.length,"Base"),w==10&&E)return B=new I(x),P(B,s+B.e+1,a);if(L=String(x),b=typeof x=="number"){if(x*0!=0)return r(B,L,b,w);if(B.s=1/x<0?(L=L.slice(1),-1):1,I.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(wv+x)}else B.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(v=T.slice(0,w),F=S=0,A=L.length;S<A;S++)if(v.indexOf(C=L.charAt(S))<0){if(C=="."){if(S>F){F=A;continue}}else if(!m&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){m=!0,S=-1,F=0;continue}return r(B,String(x),b,w)}b=!1,L=n(L,w,10,B.s),(F=L.indexOf("."))>-1?L=L.replace(".",""):F=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(A=L.length;L.charCodeAt(--A)===48;);if(L=L.slice(S,++A)){if(A-=S,b&&I.DEBUG&&A>15&&(x>om||x!==dr(x)))throw Error(wv+B.s*x);if((F=F-S-1)>p)B.c=B.e=null;else if(F<l)B.c=[B.e=0];else{if(B.e=F,B.c=[],S=(F+1)%Ve,F<0&&(S+=Ve),S<A){for(S&&B.c.push(+L.slice(0,S)),A-=Ve;S<A;)B.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=A;for(;S--;L+="0");B.c.push(+L)}}else B.c=[B.e=0]}I.clone=vv,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(x){var w,v;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(w="DECIMAL_PLACES")&&(v=x[w],Nt(v,0,ln,w),s=v),x.hasOwnProperty(w="ROUNDING_MODE")&&(v=x[w],Nt(v,0,8,w),a=v),x.hasOwnProperty(w="EXPONENTIAL_AT")&&(v=x[w],v&&v.pop?(Nt(v[0],-ln,0,w),Nt(v[1],0,ln,w),u=v[0],c=v[1]):(Nt(v,-ln,ln,w),u=-(c=v<0?-v:v))),x.hasOwnProperty(w="RANGE"))if(v=x[w],v&&v.pop)Nt(v[0],-ln,-1,w),Nt(v[1],1,ln,w),l=v[0],p=v[1];else if(Nt(v,-ln,ln,w),v)l=-(p=v<0?-v:v);else throw Error($n+w+" cannot be zero: "+v);if(x.hasOwnProperty(w="CRYPTO"))if(v=x[w],v===!!v)if(v)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=v;else throw g=!v,Error($n+"crypto unavailable");else g=v;else throw Error($n+w+" not true or false: "+v);if(x.hasOwnProperty(w="MODULO_MODE")&&(v=x[w],Nt(v,0,9,w),d=v),x.hasOwnProperty(w="POW_PRECISION")&&(v=x[w],Nt(v,0,ln,w),f=v),x.hasOwnProperty(w="FORMAT"))if(v=x[w],typeof v=="object")k=v;else throw Error($n+w+" not an object: "+v);if(x.hasOwnProperty(w="ALPHABET"))if(v=x[w],typeof v=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(v))E=v.slice(0,10)=="0123456789",T=v;else throw Error($n+w+" invalid: "+v)}else throw Error($n+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,p],CRYPTO:g,MODULO_MODE:d,POW_PRECISION:f,FORMAT:k,ALPHABET:T}},I.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var w,v,C=x.c,m=x.e,F=x.s;e:if({}.toString.call(C)=="[object Array]"){if((F===1||F===-1)&&m>=-ln&&m<=ln&&m===dr(m)){if(C[0]===0){if(m===0&&C.length===1)return!0;break e}if(w=(m+1)%Ve,w<1&&(w+=Ve),String(C[0]).length==w){for(w=0;w<C.length;w++)if(v=C[w],v<0||v>=Fr||v!==dr(v))break e;if(v!==0)return!0}}}else if(C===null&&m===null&&(F===null||F===1||F===-1))return!0;throw Error($n+"Invalid BigNumber: "+x)},I.maximum=I.max=function(){return R(arguments,-1)},I.minimum=I.min=function(){return R(arguments,1)},I.random=(function(){var x=9007199254740992,w=Math.random()*x&2097151?function(){return dr(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(v){var C,m,F,S,b,A=0,L=[],B=new I(i);if(v==null?v=s:Nt(v,0,ln),S=rm(v/Ve),g)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(S*=2));A<S;)b=C[A]*131072+(C[A+1]>>>11),b>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),C[A]=m[0],C[A+1]=m[1]):(L.push(b%1e14),A+=2);A=S/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(S*=7);A<S;)b=(C[A]&31)*281474976710656+C[A+1]*1099511627776+C[A+2]*4294967296+C[A+3]*16777216+(C[A+4]<<16)+(C[A+5]<<8)+C[A+6],b>=9e15?crypto.randomBytes(7).copy(C,A):(L.push(b%1e14),A+=7);A=S/7}else throw g=!1,Error($n+"crypto unavailable");if(!g)for(;A<S;)b=w(),b<9e15&&(L[A++]=b%1e14);for(S=L[--A],v%=Ve,S&&v&&(b=im[Ve-v],L[A]=dr(S/b)*b);L[A]===0;L.pop(),A--);if(A<0)L=[F=0];else{for(F=-1;L[0]===0;L.splice(0,1),F-=Ve);for(A=1,b=L[0];b>=10;b/=10,A++);A<Ve&&(F-=Ve-A)}return B.e=F,B.c=L,B}})(),I.sum=function(){for(var x=1,w=arguments,v=new I(w[0]);x<w.length;)v=v.plus(w[x++]);return v},n=(function(){var x="0123456789";function w(v,C,m,F){for(var S,b=[0],A,L=0,B=v.length;L<B;){for(A=b.length;A--;b[A]*=C);for(b[0]+=F.indexOf(v.charAt(L++)),S=0;S<b.length;S++)b[S]>m-1&&(b[S+1]==null&&(b[S+1]=0),b[S+1]+=b[S]/m|0,b[S]%=m)}return b.reverse()}return function(v,C,m,F,S){var b,A,L,B,N,h,U,W,M=v.indexOf("."),Y=s,ee=a;for(M>=0&&(B=f,f=0,v=v.replace(".",""),W=new I(C),h=W.pow(v.length-M),f=B,W.c=w(so(pr(h.c),h.e,"0"),10,m,x),W.e=W.c.length),U=w(v,C,m,S?(b=T,x):(b=x,T)),L=B=U.length;U[--B]==0;U.pop());if(!U[0])return b.charAt(0);if(M<0?--L:(h.c=U,h.e=L,h.s=F,h=t(h,W,Y,ee,m),U=h.c,N=h.r,L=h.e),A=L+Y+1,M=U[A],B=m/2,N=N||A<0||U[A+1]!=null,N=ee<4?(M!=null||N)&&(ee==0||ee==(h.s<0?3:2)):M>B||M==B&&(ee==4||N||ee==6&&U[A-1]&1||ee==(h.s<0?8:7)),A<1||!U[0])v=N?so(b.charAt(1),-Y,b.charAt(0)):b.charAt(0);else{if(U.length=A,N)for(--m;++U[--A]>m;)U[A]=0,A||(++L,U=[1].concat(U));for(B=U.length;!U[--B];);for(M=0,v="";M<=B;v+=b.charAt(U[M++]));v=so(v,L,b.charAt(0))}return v}})(),t=(function(){function x(C,m,F){var S,b,A,L,B=0,N=C.length,h=m%Fo,U=m/Fo|0;for(C=C.slice();N--;)A=C[N]%Fo,L=C[N]/Fo|0,S=U*A+L*h,b=h*A+S%Fo*Fo+B,B=(b/F|0)+(S/Fo|0)+U*L,C[N]=b%F;return B&&(C=[B].concat(C)),C}function w(C,m,F,S){var b,A;if(F!=S)A=F>S?1:-1;else for(b=A=0;b<F;b++)if(C[b]!=m[b]){A=C[b]>m[b]?1:-1;break}return A}function v(C,m,F,S){for(var b=0;F--;)C[F]-=b,b=C[F]<m[F]?1:0,C[F]=b*S+C[F]-m[F];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,m,F,S,b){var A,L,B,N,h,U,W,M,Y,ee,ge,xe,se,Ke,be,Te,te,Be=C.s==m.s?1:-1,Pe=C.c,pe=m.c;if(!Pe||!Pe[0]||!pe||!pe[0])return new I(!C.s||!m.s||(Pe?pe&&Pe[0]==pe[0]:!pe)?NaN:Pe&&Pe[0]==0||!pe?Be*0:Be/0);for(M=new I(Be),Y=M.c=[],L=C.e-m.e,Be=F+L+1,b||(b=Fr,L=gr(C.e/Ve)-gr(m.e/Ve),Be=Be/Ve|0),B=0;pe[B]==(Pe[B]||0);B++);if(pe[B]>(Pe[B]||0)&&L--,Be<0)Y.push(1),N=!0;else{for(Ke=Pe.length,Te=pe.length,B=0,Be+=2,h=dr(b/(pe[0]+1)),h>1&&(pe=x(pe,h,b),Pe=x(Pe,h,b),Te=pe.length,Ke=Pe.length),se=Te,ee=Pe.slice(0,Te),ge=ee.length;ge<Te;ee[ge++]=0);te=pe.slice(),te=[0].concat(te),be=pe[0],pe[1]>=b/2&&be++;do{if(h=0,A=w(pe,ee,Te,ge),A<0){if(xe=ee[0],Te!=ge&&(xe=xe*b+(ee[1]||0)),h=dr(xe/be),h>1)for(h>=b&&(h=b-1),U=x(pe,h,b),W=U.length,ge=ee.length;w(U,ee,W,ge)==1;)h--,v(U,Te<W?te:pe,W,b),W=U.length,A=1;else h==0&&(A=h=1),U=pe.slice(),W=U.length;if(W<ge&&(U=[0].concat(U)),v(ee,U,ge,b),ge=ee.length,A==-1)for(;w(pe,ee,Te,ge)<1;)h++,v(ee,Te<ge?te:pe,ge,b),ge=ee.length}else A===0&&(h++,ee=[0]);Y[B++]=h,ee[0]?ee[ge++]=Pe[se]||0:(ee=[Pe[se]],ge=1)}while((se++<Ke||ee[0]!=null)&&Be--);N=ee[0]!=null,Y[0]||Y.splice(0,1)}if(b==Fr){for(B=1,Be=Y[0];Be>=10;Be/=10,B++);P(M,F+(M.e=B+L*Ve-1)+1,S,N)}else M.e=L,M.r=+N;return M}})();function D(x,w,v,C){var m,F,S,b,A;if(v==null?v=a:Nt(v,0,8),!x.c)return x.toString();if(m=x.c[0],S=x.e,w==null)A=pr(x.c),A=C==1||C==2&&(S<=u||S>=c)?Gl(A,S):so(A,S,"0");else if(x=P(new I(x),w,v),F=x.e,A=pr(x.c),b=A.length,C==1||C==2&&(w<=F||F<=u)){for(;b<w;A+="0",b++);A=Gl(A,F)}else if(w-=S+(C===2&&F>S),A=so(A,F,"0"),F+1>b){if(--w>0)for(A+=".";w--;A+="0");}else if(w+=F-b,w>0)for(F+1==b&&(A+=".");w--;A+="0");return x.s<0&&m?"-"+A:A}function R(x,w){for(var v,C,m=1,F=new I(x[0]);m<x.length;m++)C=new I(x[m]),(!C.s||(v=ti(F,C))===w||v===0&&F.s===w)&&(F=C);return F}function $(x,w,v){for(var C=1,m=w.length;!w[--m];w.pop());for(m=w[0];m>=10;m/=10,C++);return(v=C+v*Ve-1)>p?x.c=x.e=null:v<l?x.c=[x.e=0]:(x.e=v,x.c=w),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,w=/^([^.]+)\.$/,v=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(F,S,b,A){var L,B=b?S:S.replace(m,"");if(C.test(B))F.s=isNaN(B)?null:B<0?-1:1;else{if(!b&&(B=B.replace(x,function(N,h,U){return L=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!A||A==L?h:N}),A&&(L=A,B=B.replace(w,"$1").replace(v,"0.$1")),S!=B))return new I(B,L);if(I.DEBUG)throw Error($n+"Not a"+(A?" base "+A:"")+" number: "+S);F.s=null}F.c=F.e=null}})();function P(x,w,v,C){var m,F,S,b,A,L,B,N=x.c,h=im;if(N){e:{for(m=1,b=N[0];b>=10;b/=10,m++);if(F=w-m,F<0)F+=Ve,S=w,A=N[L=0],B=dr(A/h[m-S-1]%10);else if(L=rm((F+1)/Ve),L>=N.length)if(C){for(;N.length<=L;N.push(0));A=B=0,m=1,F%=Ve,S=F-Ve+1}else break e;else{for(A=b=N[L],m=1;b>=10;b/=10,m++);F%=Ve,S=F-Ve+m,B=S<0?0:dr(A/h[m-S-1]%10)}if(C=C||w<0||N[L+1]!=null||(S<0?A:A%h[m-S-1]),C=v<4?(B||C)&&(v==0||v==(x.s<0?3:2)):B>5||B==5&&(v==4||C||v==6&&(F>0?S>0?A/h[m-S]:0:N[L-1])%10&1||v==(x.s<0?8:7)),w<1||!N[0])return N.length=0,C?(w-=x.e+1,N[0]=h[(Ve-w%Ve)%Ve],x.e=-w||0):N[0]=x.e=0,x;if(F==0?(N.length=L,b=1,L--):(N.length=L+1,b=h[Ve-F],N[L]=S>0?dr(A/h[m-S]%h[S])*b:0),C)for(;;)if(L==0){for(F=1,S=N[0];S>=10;S/=10,F++);for(S=N[0]+=b,b=1;S>=10;S/=10,b++);F!=b&&(x.e++,N[0]==Fr&&(N[0]=1));break}else{if(N[L]+=b,N[L]!=Fr)break;N[L--]=0,b=1}for(F=N.length;N[--F]===0;N.pop());}x.e>p?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function z(x){var w,v=x.e;return v===null?x.toString():(w=pr(x.c),w=v<=u||v>=c?Gl(w,v):so(w,v,"0"),x.s<0?"-"+w:w)}return o.absoluteValue=o.abs=function(){var x=new I(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,w){return ti(this,new I(x,w))},o.decimalPlaces=o.dp=function(x,w){var v,C,m,F=this;if(x!=null)return Nt(x,0,ln),w==null?w=a:Nt(w,0,8),P(new I(F),x+F.e+1,w);if(!(v=F.c))return null;if(C=((m=v.length-1)-gr(this.e/Ve))*Ve,m=v[m])for(;m%10==0;m/=10,C--);return C<0&&(C=0),C},o.dividedBy=o.div=function(x,w){return t(this,new I(x,w),s,a)},o.dividedToIntegerBy=o.idiv=function(x,w){return t(this,new I(x,w),0,1)},o.exponentiatedBy=o.pow=function(x,w){var v,C,m,F,S,b,A,L,B,N=this;if(x=new I(x),x.c&&!x.isInteger())throw Error($n+"Exponent not an integer: "+z(x));if(w!=null&&(w=new I(w)),b=x.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!x.c||!x.c[0])return B=new I(Math.pow(+z(N),b?x.s*(2-Vl(x)):+z(x))),w?B.mod(w):B;if(A=x.s<0,w){if(w.c?!w.c[0]:!w.s)return new I(NaN);C=!A&&N.isInteger()&&w.isInteger(),C&&(N=N.mod(w))}else{if(x.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||b&&N.c[1]>=24e7:N.c[0]<8e13||b&&N.c[0]<=9999975e7)))return F=N.s<0&&Vl(x)?-0:0,N.e>-1&&(F=1/F),new I(A?1/F:F);f&&(F=rm(f/Ve+2))}for(b?(v=new I(.5),A&&(x.s=1),L=Vl(x)):(m=Math.abs(+z(x)),L=m%2),B=new I(i);;){if(L){if(B=B.times(N),!B.c)break;F?B.c.length>F&&(B.c.length=F):C&&(B=B.mod(w))}if(m){if(m=dr(m/2),m===0)break;L=m%2}else if(x=x.times(v),P(x,x.e+1,1),x.e>14)L=Vl(x);else{if(m=+z(x),m===0)break;L=m%2}N=N.times(N),F?N.c&&N.c.length>F&&(N.c.length=F):C&&(N=N.mod(w))}return C?B:(A&&(B=i.div(B)),w?B.mod(w):F?P(B,f,a,S):B)},o.integerValue=function(x){var w=new I(this);return x==null?x=a:Nt(x,0,8),P(w,w.e+1,x)},o.isEqualTo=o.eq=function(x,w){return ti(this,new I(x,w))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,w){return ti(this,new I(x,w))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,w){return(w=ti(this,new I(x,w)))===1||w===0},o.isInteger=function(){return!!this.c&&gr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,w){return ti(this,new I(x,w))<0},o.isLessThanOrEqualTo=o.lte=function(x,w){return(w=ti(this,new I(x,w)))===-1||w===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,w){var v,C,m,F,S=this,b=S.s;if(x=new I(x,w),w=x.s,!b||!w)return new I(NaN);if(b!=w)return x.s=-w,S.plus(x);var A=S.e/Ve,L=x.e/Ve,B=S.c,N=x.c;if(!A||!L){if(!B||!N)return B?(x.s=-w,x):new I(N?S:NaN);if(!B[0]||!N[0])return N[0]?(x.s=-w,x):new I(B[0]?S:a==3?-0:0)}if(A=gr(A),L=gr(L),B=B.slice(),b=A-L){for((F=b<0)?(b=-b,m=B):(L=A,m=N),m.reverse(),w=b;w--;m.push(0));m.reverse()}else for(C=(F=(b=B.length)<(w=N.length))?b:w,b=w=0;w<C;w++)if(B[w]!=N[w]){F=B[w]<N[w];break}if(F&&(m=B,B=N,N=m,x.s=-x.s),w=(C=N.length)-(v=B.length),w>0)for(;w--;B[v++]=0);for(w=Fr-1;C>b;){if(B[--C]<N[C]){for(v=C;v&&!B[--v];B[v]=w);--B[v],B[C]+=Fr}B[C]-=N[C]}for(;B[0]==0;B.splice(0,1),--L);return B[0]?$(x,B,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,w){var v,C,m=this;return x=new I(x,w),!m.c||!x.s||x.c&&!x.c[0]?new I(NaN):!x.c||m.c&&!m.c[0]?new I(m):(d==9?(C=x.s,x.s=1,v=t(m,x,0,3),x.s=C,v.s*=C):v=t(m,x,0,d),x=m.minus(v.times(x)),!x.c[0]&&d==1&&(x.s=m.s),x)},o.multipliedBy=o.times=function(x,w){var v,C,m,F,S,b,A,L,B,N,h,U,W,M,Y,ee=this,ge=ee.c,xe=(x=new I(x,w)).c;if(!ge||!xe||!ge[0]||!xe[0])return!ee.s||!x.s||ge&&!ge[0]&&!xe||xe&&!xe[0]&&!ge?x.c=x.e=x.s=null:(x.s*=ee.s,!ge||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(C=gr(ee.e/Ve)+gr(x.e/Ve),x.s*=ee.s,A=ge.length,N=xe.length,A<N&&(W=ge,ge=xe,xe=W,m=A,A=N,N=m),m=A+N,W=[];m--;W.push(0));for(M=Fr,Y=Fo,m=N;--m>=0;){for(v=0,h=xe[m]%Y,U=xe[m]/Y|0,S=A,F=m+S;F>m;)L=ge[--S]%Y,B=ge[S]/Y|0,b=U*L+B*h,L=h*L+b%Y*Y+W[F]+v,v=(L/M|0)+(b/Y|0)+U*B,W[F--]=L%M;W[F]=v}return v?++C:W.splice(0,1),$(x,W,C)},o.negated=function(){var x=new I(this);return x.s=-x.s||null,x},o.plus=function(x,w){var v,C=this,m=C.s;if(x=new I(x,w),w=x.s,!m||!w)return new I(NaN);if(m!=w)return x.s=-w,C.minus(x);var F=C.e/Ve,S=x.e/Ve,b=C.c,A=x.c;if(!F||!S){if(!b||!A)return new I(m/0);if(!b[0]||!A[0])return A[0]?x:new I(b[0]?C:m*0)}if(F=gr(F),S=gr(S),b=b.slice(),m=F-S){for(m>0?(S=F,v=A):(m=-m,v=b),v.reverse();m--;v.push(0));v.reverse()}for(m=b.length,w=A.length,m-w<0&&(v=A,A=b,b=v,w=m),m=0;w;)m=(b[--w]=b[w]+A[w]+m)/Fr|0,b[w]=Fr===b[w]?0:b[w]%Fr;return m&&(b=[m].concat(b),++S),$(x,b,S)},o.precision=o.sd=function(x,w){var v,C,m,F=this;if(x!=null&&x!==!!x)return Nt(x,1,ln),w==null?w=a:Nt(w,0,8),P(new I(F),x,w);if(!(v=F.c))return null;if(m=v.length-1,C=m*Ve+1,m=v[m]){for(;m%10==0;m/=10,C--);for(m=v[0];m>=10;m/=10,C++);}return x&&F.e+1>C&&(C=F.e+1),C},o.shiftedBy=function(x){return Nt(x,-om,om),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,w,v,C,m,F=this,S=F.c,b=F.s,A=F.e,L=s+4,B=new I("0.5");if(b!==1||!S||!S[0])return new I(!b||b<0&&(!S||S[0])?NaN:S?F:1/0);if(b=Math.sqrt(+z(F)),b==0||b==1/0?(w=pr(S),(w.length+A)%2==0&&(w+="0"),b=Math.sqrt(+w),A=gr((A+1)/2)-(A<0||A%2),b==1/0?w="5e"+A:(w=b.toExponential(),w=w.slice(0,w.indexOf("e")+1)+A),v=new I(w)):v=new I(b+""),v.c[0]){for(A=v.e,b=A+L,b<3&&(b=0);;)if(m=v,v=B.times(m.plus(t(F,m,L,1))),pr(m.c).slice(0,b)===(w=pr(v.c)).slice(0,b))if(v.e<A&&--b,w=w.slice(b-3,b+1),w=="9999"||!C&&w=="4999"){if(!C&&(P(m,m.e+s+2,0),m.times(m).eq(F))){v=m;break}L+=4,b+=4,C=1}else{(!+w||!+w.slice(1)&&w.charAt(0)=="5")&&(P(v,v.e+s+2,1),x=!v.times(v).eq(F));break}}return P(v,v.e+s+1,a,x)},o.toExponential=function(x,w){return x!=null&&(Nt(x,0,ln),x++),D(this,x,w,1)},o.toFixed=function(x,w){return x!=null&&(Nt(x,0,ln),x=x+this.e+1),D(this,x,w)},o.toFormat=function(x,w,v){var C,m=this;if(v==null)x!=null&&w&&typeof w=="object"?(v=w,w=null):x&&typeof x=="object"?(v=x,x=w=null):v=k;else if(typeof v!="object")throw Error($n+"Argument not an object: "+v);if(C=m.toFixed(x,w),m.c){var F,S=C.split("."),b=+v.groupSize,A=+v.secondaryGroupSize,L=v.groupSeparator||"",B=S[0],N=S[1],h=m.s<0,U=h?B.slice(1):B,W=U.length;if(A&&(F=b,b=A,A=F,W-=F),b>0&&W>0){for(F=W%b||b,B=U.substr(0,F);F<W;F+=b)B+=L+U.substr(F,b);A>0&&(B+=L+U.slice(F)),h&&(B="-"+B)}C=N?B+(v.decimalSeparator||"")+((A=+v.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(v.fractionGroupSeparator||"")):N):B}return(v.prefix||"")+C+(v.suffix||"")},o.toFraction=function(x){var w,v,C,m,F,S,b,A,L,B,N,h,U=this,W=U.c;if(x!=null&&(b=new I(x),!b.isInteger()&&(b.c||b.s!==1)||b.lt(i)))throw Error($n+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+z(b));if(!W)return new I(U);for(w=new I(i),L=v=new I(i),C=A=new I(i),h=pr(W),F=w.e=h.length-U.e-1,w.c[0]=im[(S=F%Ve)<0?Ve+S:S],x=!x||b.comparedTo(w)>0?F>0?w:L:b,S=p,p=1/0,b=new I(h),A.c[0]=0;B=t(b,w,0,1),m=v.plus(B.times(C)),m.comparedTo(x)!=1;)v=C,C=m,L=A.plus(B.times(m=L)),A=m,w=b.minus(B.times(m=w)),b=m;return m=t(x.minus(v),C,0,1),A=A.plus(m.times(L)),v=v.plus(m.times(C)),A.s=L.s=U.s,F=F*2,N=t(L,C,F,a).minus(U).abs().comparedTo(t(A,v,F,a).minus(U).abs())<1?[L,C]:[A,v],p=S,N},o.toNumber=function(){return+z(this)},o.toPrecision=function(x,w){return x!=null&&Nt(x,1,ln),D(this,x,w,2)},o.toString=function(x){var w,v=this,C=v.s,m=v.e;return m===null?C?(w="Infinity",C<0&&(w="-"+w)):w="NaN":(x==null?w=m<=u||m>=c?Gl(pr(v.c),m):so(pr(v.c),m,"0"):x===10&&E?(v=P(new I(v),s+m+1,a),w=so(pr(v.c),v.e,"0")):(Nt(x,2,T.length,"Base"),w=n(so(pr(v.c),m,"0"),10,x,C,!0)),C<0&&v.c[0]&&(w="-"+w)),w},o.valueOf=o.toJSON=function(){return z(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&I.set(e),I}function gr(e){var t=e|0;return e>0||e===t?t:t-1}function pr(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 ti(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 Nt(e,t,n,r){if(e<t||e>n||e!==dr(e))throw Error($n+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Vl(e){var t=e.c.length-1;return gr(e.e/Ve)==t&&e.c[t]%2!=0}function Gl(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=vv(),kv=Cz;var Tz=24,Ks=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,am=Iz(),sm=(e=4,t=am)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function Fz(e){let t=new kv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Tv=(e="")=>{let t=new TextEncoder;return Fz(Sv(t.encode(e))).toString(36).slice(1)},Cv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),Ez=e=>Cv[Math.floor(e()*Cv.length)],Az=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=am}={})=>{let n=Object.keys(e).toString(),r=n.length?n+sm(Ks,t):sm(Ks,t);return Tv(r).substring(0,Ks)},Pz=e=>()=>e++,Lz=476782367,Iv=({random:e=am,counter:t=Pz(Math.floor(e()*Lz)),length:n=Tz,fingerprint:r=Az({random:e})}={})=>{if(n>Ks)throw new Error(`Length must be between 2 and ${Ks}. Received: ${n}`);return function(){let i=Ez(e),s=Date.now().toString(36),a=t().toString(36),u=sm(n,e),c=`${s+u+a+r}`;return`${i+Tv(c).substring(1,n)}`}},Eo=Mz(Iv);function Mz(e){let t;return()=>(t||(t=e()),t())}var Rz=Ua(Av());Nn();$e();var ql=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function zz(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function lm(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,,p]=u,g=Nz(l),d=Oz(r,s+1),f={id:Eo(),reviewId:t,type:c.trim(),severity:g,title:p.trim(),description:d.description,file:d.file,lineNumber:d.lineNumber,property:d.property,currentValue:d.currentValue,suggestedValue:d.suggestedValue,suggestedCode:d.suggestedCode,suggestedFix:d.suggestedFix,fixTarget:d.fixTarget,fixRequired:d.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(f)}ql.lastIndex=0}return n.map(s=>{let a=_s(s);return a.dismissed?(y.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 Xs=null,Pv=0,_z=3e4;async function $z(){let e=Date.now();if(Xs&&e-Pv<_z)return Xs;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 Xs=n.entries||n.stories||{},Pv=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Xs).length),Xs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Qs(e){try{let n=(await $z())[e];if(!n?.importPath)return y.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;y.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),y.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,y.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 y.debug("[storyFilePaths] Final paths:",u),u}catch(t){return y.error("[storyFilePaths] Error getting file paths:",t),null}}function cm(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 um(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?(y.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(p=>p.currentValue).filter(Boolean),l=e.map(p=>p.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 pm(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),y.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),y.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),y.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}$e();Nn();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 Lv(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 ${Et.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)?`${Et.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 Oi}from"storybook/manager-api";var dm="uireview/badge",zi={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 Ni(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Dv(e){if(Ni())try{Oi.getChannel().emit(zi.REVIEW_START,{storyId:e})}catch{}}function Ur(e,t){if(Ni())try{Oi.getChannel().emit(zi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function Rv(e){if(Ni())try{Oi.getChannel().emit(zi.REVIEW_ERROR,{storyId:e})}catch{}}function Mv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Bv=null;function zv(e){if(Bv!==null)return;let t=Oi.getChannel(),n=o=>i=>{Ni()&&o(i)};t.on(zi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:dm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(zi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:Yz(i),typeId:dm,storyId:o,title:Xz(i),description:Kz(i)}])})),t.on(zi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:dm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Ni();r||Mv(e),Bv=setInterval(()=>{let o=Ni();o!==r&&(r=o,o||Mv(e))},1500)}var Qz="uireview/mapped",Nv="uireview/mappings-updated";function Ov(e){try{Oi.getChannel().emit(Nv,{storyIds:e})}catch{}}function _v(e){Oi.getChannel().on(Nv,({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 gm=V(),fm=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 mm=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:p,setReviewError:g,setReviewResults:d,setShowReviewMenu:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,setFullPrompt:z,setFullResponse:x,setFigmaImageUrl:w,storybookImageUrl:v,setStorybookImageUrl:C,setFigmaDimensions:m,setMultiModelResults:F,updateMultiModelStreamingMessages:S,setModelCompleted:b,setActiveModelId:A,resetReview:L,addReview:B,setReviewDetailTab:N,includeTextComparison:h,usePromptCache:U,setApplyFixesResult:W,featureFlags:M}=ce(),{sessionToken:Y,usageData:ee,setUsageData:ge}=we(),{selectedProjectId:xe}=Je(),{currentStoryId:se,currentStoryName:Ke}=nt(),be=Yl(ee);be.current=ee;let Te=Yl(null),te=Yl(null),Be=Yl({}),Pe=Js((fe,tt)=>{I({role:fe,content:tt})},[I]),pe=Js((fe,tt)=>{$(fe),P(tt)},[$,P]),Lt=Js(async fe=>{let{isIteration:tt=!1,parentReviewId:he=null}=fe||{};if(!Y)throw new Error("Not authenticated");if(!xe)throw new Error("No project selected");if(!se||!Ke)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let oe=Date.now();try{p(!0),g(null),d(null),N("issues"),W(null),se&&M.enableReviewBadges&&Dv(se),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${fm}s timeout`),Te.current&&Te.current.abort(),I({role:"system",content:`Review auto-stopped after ${fm} seconds timeout.`})},fm*1e3),z(""),x(""),T(!0),E(!1),R(),pe(0,"Starting review..."),pe(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await jl(),y.debug("[Review] Iframe reloaded, styles should be fresh"),pe(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[K,me,ie]=await Promise.all([$l({sessionToken:Y||void 0}),Promise.resolve(qs()),Promise.resolve(Xf())]);if(K&&K!==v&&(C(K),y.debug("[Review] Storybook screenshot captured and set")),!me)throw new Error("Failed to extract styles from component");let{computed:O,declared:j,markup:H,textElementStyles:Ee,nestedElementStyles:De}=me;ie?y.debug("[Review] DOM tree extracted:",{selector:ie.selector,childrenCount:ie.children.length}):(y.error("[Review] DOM tree extraction FAILED - domTree is null"),y.error("[Review] This will cause AI to use comparison table instead of tree comparison")),pe(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:se,name:Ke});let St=ft.getState().currentMapping?.figmaNodeId??null,Yn=ft.getState().figmaImageUrl;if(St&&(y.debug("[Review] Using Figma node ID from store:",St),Yn&&(pe(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!St)try{let Qe=await fetch(`${gm}/api/mappings?projectId=${xe}&storyId=${se}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`}});if(Qe.ok){let zt=await Qe.json();zt.mapping?.figmaNodeId?(St=zt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",St)):y.debug("[Review] No mapping found for story:",se)}else y.debug("[Review] Failed to fetch mapping:",Qe.status)}catch(Qe){y.error("[Review] Error fetching mapping:",Qe)}if(St&&!Yn){pe(65,"Fetching Figma design...");try{let Qe=await fetch(`${gm}/api/figma/frames?projectId=${xe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`}});if(Qe.ok){let Ut=(await Qe.json()).thumbnails?.[St];Ut?(w(Ut),y.debug("[Review] Figma thumbnail fetched and displayed:",Ut)):y.warn("[Review] No thumbnail found for node:",St)}else y.warn("[Review] Failed to fetch Figma frames:",Qe.status)}catch(Qe){y.error("[Review] Error fetching Figma frames:",Qe)}}if(!St)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..."),y.debug("[Review] Sending to streaming API...");let or={projectId:xe,storyId:se,storyName:Ke,storybookScreenshot:K,computedStyles:O,declaredStyles:j,textElementStyles:Ee,nestedElementStyles:De,componentMarkup:H,domTree:ie,figmaNodeId:St,figmaImageUrl:Yn||void 0,aiModels:l,includeTextComparison:h,usePromptCache:U,parentReviewId:tt?he:void 0,isIteration:tt};y.debug("[Review] Request payload:",{...or,storybookScreenshot:K?`${K.substring(0,50)}...`:null,domTree:ie?{selector:ie.selector,childrenCount:ie.children.length}:null}),Te.current=new AbortController;let Pn=await fetch(`${gm}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`},body:JSON.stringify(or),signal:Te.current.signal});if(y.debug("[Review] Response status:",Pn.status,Pn.statusText),!Pn.ok){let Qe=await Pn.json();if(y.error("[Review] API error response:",Qe),Pn.status===429){let zt=Qe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${zt} seconds before trying again.`)}if(Pn.status===402){if(Qe.code==="INSUFFICIENT_CREDITS"){let zt=Qe.details?.required??1,Ut=Qe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${zt} credit(s) but you have ${Ut}. 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 Pn.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=Pn.body?.getReader(),kn=new TextDecoder,Rr="",rn="",Ue=null,pu=null,oy=l.length>1,Vo={},cs={},zV={};if(!ho)throw new Error("Response body is not readable");let iy=ft.getState().streamingMessages.length;for(Pe("assistant","");;){let{done:Qe,value:zt}=await ho.read();if(Qe)break;Rr+=kn.decode(zt,{stream:!0});let Ut=Rr.split(`
|
|
17
|
+
`);Rr=Ut.pop()||"";for(let Kn of Ut)if(Kn.startsWith("data: ")){let dn=Kn.slice(6);if(dn==="[DONE]")continue;try{let re=JSON.parse(dn);if(re.type!=="text"&&re.type!=="content"&&y.debug("[Review] SSE Event received:",re.type),re.type==="prompt")re.prompt&&(z(re.prompt),y.debug("[Review] Prompt received early"));else if(re.type==="model_started")y.debug("[Review] Model started:",re.modelId),Vo[re.modelId]||(Vo[re.modelId]="",cs[re.modelId]=[{role:"assistant",content:""}]);else if(re.type==="text"||re.type==="content")if(oy&&re.modelId){Vo[re.modelId]||(Vo[re.modelId]="",cs[re.modelId]=[{role:"assistant",content:""}]),Vo[re.modelId]+=re.content,cs[re.modelId][0].content=Vo[re.modelId],S(re.modelId,cs[re.modelId]);let Yt=Object.entries(Vo).map(([gn,at])=>`[${gn}]
|
|
18
18
|
${at}`).join(`
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
`);D(iy,
|
|
22
|
+
`);D(iy,Yt)}else rn+=re.content,D(iy,rn);else if(re.type==="model_completed")y.debug("[Review] Model completed:",re.modelId,re.complianceScore),b(re.modelId);else if(re.type==="figma_image")re.url&&(w(re.url),y.debug("[Review] Figma image URL received:",re.url));else if(re.type==="figma_dimensions")re.width&&re.height&&(m({width:re.width,height:re.height}),y.debug("[Review] Figma dimensions received:",re.width,"x",re.height));else if(re.type==="complete"||re.type==="result")Ue=re,y.debug("[Review] Final result received! Type:",re.type),y.debug("[Review] Final result issues count:",re.issues?.length||0),y.debug("[Review] Final result score:",re.validation?.complianceScore),re.remainingCredits!=null&&be.current&&ge({...be.current,creditBalance:re.remainingCredits,reviewCredits:Math.floor(re.remainingCredits)});else if(re.type==="all_complete")Ue=re,y.debug("[Review] Multi-model results received:",Object.keys(re.byModel)),re.remainingCredits!=null&&be.current&&ge({...be.current,creditBalance:re.remainingCredits,reviewCredits:Math.floor(re.remainingCredits)});else if(re.type==="error"||re.type==="model_error"){let Yt=new Error(re.message||re.error||"Streaming error");throw Yt.isServerError=!0,Yt}}catch(re){if(re.isServerError)throw re;let Yt=re instanceof Error?{message:re.message,name:re.name,stack:re.stack}:String(re);y.error("[Review] Error parsing SSE data:",Yt),y.error("[Review] Failed to parse data:",dn.substring(0,200)+(dn.length>200?"...":"")),pu=re instanceof Error?re:new Error(String(re))}}}if(pe(100,"Review complete!"),!Ue&&pu&&(y.error("[Review] No final result received. Last parse error:",pu),y.error("[Review] Streaming text available:",rn.length,"chars")),oy&&Ue?.type==="all_complete"){let Qe=Object.keys(Ue.byModel).reduce((Ut,Kn)=>{let dn=Ue.byModel[Kn];return Ut[Kn]={...dn,fullResponse:dn.response||dn.fullResponse||"",fullPrompt:dn.prompt||dn.fullPrompt||"",streamingMessages:cs[Kn]||[]},Ut},{}),zt=Object.keys(Ue.byModel)[0];F({byModel:Qe,activeModelId:zt}),Qe[zt]?.fullPrompt&&z(Qe[zt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys(Ue.byModel));try{let Ut=Eo(),Kn=Ue.byModel?.[zt]?.issues,dn=Kn&&Kn.length>0,re=dn?Kn.map(de=>({id:Eo(),reviewId:Ut,dbId:de.dbId,type:de.type,severity:de.severity,title:de.description,description:de.description,property:de.property,expected:Ao(de.expected),actual:Ao(de.actual),currentValue:Ao(de.actual),suggestedValue:Ao(de.expected),source:de.source||"computed-styles",suggestedFix:de.suggestedFix,file:de.file,domElement:de.domElement,figmaElement:de.figmaElement,fixTarget:de.fixTarget,fixRequired:de.fixRequired,detectedBy:de.detectedBy,dismissed:de.dismissed??!1,dismissReason:de.dismissReason,dismissedAt:de.dismissed?new Date:void 0,_unreliable:de._unreliable,_validationError:de._validationError,figmaContext:de.figmaContext,relatedTo:Array.isArray(de.relatedTo)?de.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):lm(Qe[zt]?.fullResponse||"",Ut);y.debug("[Review] Multi-model issues source:",dn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",re.length,"issues");let Yt=re.filter(de=>de.dismissed).length;Yt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Yt,"false positive issues"),Pe("system",`
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
\u2705 ${
|
|
26
|
+
\u2705 ${Yt} issue${Yt>1?"s were":" was"} auto-dismissed as false positive${Yt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let gn=Be.current[se];gn||(gn=await Qs(se)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},gn.storyFile&&(Be.current[se]=gn)),y.debug("[Review] Story file paths:",gn);let at=re.map(de=>({...de,file:de.file||cm(de.fixTarget,gn)||um(de,gn)}));if(at=pm(at),y.debug("[Review] After de-duplication:",at.length,"issues"),!h){let de=at.length;at=at.filter(Cn=>Cn.property?.toLowerCase()!=="textcontent"&&!Cn.description?.toLowerCase().includes("text content")),de!==at.length&&y.debug("[Review] Filtered out",de-at.length,"textContent issues (toggle OFF)")}let zr=Ue.validation?.complianceScore??Qe[zt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:zt,validationScore:Ue.validation?.complianceScore,modelScore:Qe[zt]?.complianceScore,multiModelScore:zr}),zr==null){let Cn=(Qe[zt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);zr=Cn?parseInt(Cn[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",zr)}let Ln;tt&&he&&(Ln=(ft.getState().reviewHistory.find(Cn=>Cn.id===he)?.iterationNumber||0)+1);let us={id:Ut,componentId:se,storyId:se,modelId:zt,parentReviewId:tt&&he||void 0,iterationNumber:Ln,figmaFileKey:void 0,figmaNodeId:St||void 0,figmaFileUrl:Yn||void 0,complianceScore:zr,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(de=>!de.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-oe,costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens};if(y.debug("[Review] Multi-model token data:",{costUsd:Ue.costUsd,inputTokens:Ue.inputTokens,outputTokens:Ue.outputTokens,cacheCreationTokens:Ue.cacheCreationTokens,cacheReadTokens:Ue.cacheReadTokens,reviewTokens:us.inputTokens}),B(us),se&&M.enableReviewBadges){let de=at.filter(Cn=>!Cn.dismissed);Ur(se,{score:zr??100,issueCount:de.length,criticalCount:de.filter(Cn=>Cn.severity==="critical").length,majorCount:de.filter(Cn=>Cn.severity==="major").length,minorCount:de.filter(Cn=>Cn.severity==="minor").length})}N("issues");let _a=at.filter(de=>!de.dismissed).length;y.debug("[Review] Created multi-model review with",_a,"active issues,",at.length-_a,"dismissed");let Ie=St||ft.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",at.filter(de=>!de.dismissed).length,"Dismissed:",at.filter(de=>de.dismissed).length)}catch(Ut){y.error("[Review] Failed to parse issues from multi-model response:",Ut)}}else if(Ue){Ue.prompt&&z(Ue.prompt),(Ue.response||rn)&&x(Ue.response||rn),Ue.figmaImageUrl&&w(Ue.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Qe=Eo(),zt=Ue.response||rn,Ut=Ue.issues,Kn=Ut&&Ut.length>0,dn=Kn?Ut.map(Ie=>({id:Eo(),reviewId:Qe,dbId:Ie.dbId,type:Ie.type,severity:Ie.severity,title:Ie.description,description:Ie.description,property:Ie.property,expected:Ao(Ie.expected),actual:Ao(Ie.actual),currentValue:Ao(Ie.actual),suggestedValue:Ao(Ie.expected),source:Ie.source||"computed-styles",suggestedFix:Ie.suggestedFix,file:Ie.file,domElement:Ie.domElement,figmaElement:Ie.figmaElement,fixTarget:Ie.fixTarget,fixRequired:Ie.fixRequired,detectedBy:Ie.detectedBy,dismissed:Ie.dismissed??!1,dismissReason:Ie.dismissReason,dismissedAt:Ie.dismissed?new Date:void 0,_unreliable:Ie._unreliable,_validationError:Ie._validationError,figmaContext:Ie.figmaContext,relatedTo:Array.isArray(Ie.relatedTo)?Ie.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):lm(zt,Qe);y.debug("[Review] Issues source:",Kn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",dn.length,"issues");let re=dn.filter(Ie=>Ie.dismissed).length;re>0&&(y.debug("[Review] Auto-dismissed:",re,"false positive issues"),Pe("system",`
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
\u2705 ${re} issue${re>1?"s were":" was"} auto-dismissed as false positive${re>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let qt=Ue.complianceScore??Ue.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Ue.complianceScore,validationScore:Ue.validation?.complianceScore,parsedScore:qt}),qt==null){let Ie=Rt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);qt=Ie?parseInt(Ie[1],10):void 0,y.debug("[Review] Parsed score from response:",qt)}let dn=Be.current[ae];dn||(dn=await Qs(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},dn.storyFile&&(Be.current[ae]=dn)),y.debug("[Review] Story file paths:",dn);let at=pn.map(Ie=>({...Ie,file:Ie.file||cm(Ie.fixTarget,dn)||um(Ie,dn)}));if(at=pm(at),y.debug("[Review] After de-duplication:",at.length,"issues"),!h){let Ie=at.length;at=at.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),Ie!==at.length&&y.debug("[Review] Filtered out",Ie-at.length,"textContent issues (toggle OFF)")}let zr;tt&&he&&(zr=(gt.getState().reviewHistory.find(de=>de.id===he)?.iterationNumber||0)+1);let Pn={id:Qe,componentId:ae,storyId:ae,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:zr,figmaFileKey:void 0,figmaNodeId:bt||void 0,figmaFileUrl:Yn||void 0,complianceScore:qt,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(Ie=>!Ie.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-ie,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(y.debug("[useAIReview] About to call addReview with review:",{id:Pn.id,storyId:Pn.storyId,issueCount:Pn.issues?.length,complianceScore:Pn.complianceScore,createdAt:Pn.createdAt?.toISOString(),inputTokens:Pn.inputTokens,outputTokens:Pn.outputTokens,costUsd:Pn.costUsd,cacheCreationTokens:Pn.cacheCreationTokens,cacheReadTokens:Pn.cacheReadTokens}),B(Pn),y.debug("[useAIReview] addReview called successfully"),ae&&M.enableReviewBadges){let Ie=at.filter(de=>!de.dismissed);Ur(ae,{score:qt??100,issueCount:Ie.length,criticalCount:Ie.filter(de=>de.severity==="critical").length,majorCount:Ie.filter(de=>de.severity==="major").length,minorCount:Ie.filter(de=>de.severity==="minor").length})}N("issues");let us=at.filter(Ie=>!Ie.dismissed).length;y.debug("[Review] Created review with",us,"active issues,",at.length-us,"dismissed");let _a=bt||gt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:bt,effectiveFigmaNodeIdSingle:_a,hasSessionToken:!!Y,selectedProjectId:xe,issueCount:at.length}),y.debug("[Review] Issue validation handled server-side. Active:",at.filter(Ie=>!Ie.dismissed).length,"Dismissed:",at.filter(Ie=>Ie.dismissed).length)}catch(Qe){y.error("[Review] Failed to parse issues:",Qe)}}else throw nn?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",nn.length),y.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"){y.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}y.error("[useAIReview] Review error:",K);let me=Lv(K);throw g(me),ae&&M.enableReviewBadges&&Rv(ae),pe(0,`Error: ${me}`),K}finally{d(!1),Te.current=null,te.current&&(clearTimeout(te.current),te.current=null),ge(null)}},[e,Y,xe,ae,Ke,l,d,g,p,F,S,b,A,T,E,R,Pe,pe,D,C,w,z,x,ge]),tn=Js(()=>n?.issues?o==="all"?n.issues:n.issues.filter(fe=>fe.severity===o):[],[n,o]),Dr=Js(()=>{Te.current&&(y.debug("[useAIReview] Cancelling review..."),Te.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Pt,cancelReview:Dr,setShowReviewMenu:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,resetReview:L,getFilteredIssues:tn}};Ce();$e();He();import{useCallback as qQ}from"react";var QQ=V();Ce();$e();import{useEffect as $v,useRef as Uv}from"react";import{useStorybookApi as Qz,useStorybookState as Jz,addons as Zz}from"storybook/manager-api";var jv="storyArgsUpdated",hm=()=>{let e=Qz(),t=Jz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=Uv(null),d=Uv(0);return $v(()=>{let g=t.storyId;if(g){l.current!==g&&(y.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),f=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(f),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:f})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),$v(()=>{let g=Zz.getChannel(),p=null,f=k=>{if(k.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:T,isValidating:E}=gt.getState();if(T||E){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(jv,f),()=>{g.off(jv,f),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Ce();He();ct();import{useCallback as Hv}from"react";import{addons as Wv}from"storybook/manager-api";var Vv=V(),ni=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=we(),{selectedProjectId:i}=Je(),s=Hv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ne(`${Vv}/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{Wv.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=Hv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ne(`${Vv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{Wv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Di();Ce();import{useCallback as xm,useEffect as Gv,useRef as eN}from"react";import{useChannel as tN,addons as qv}from"storybook/manager-api";$e();var nN=3e4,rN="forceRemount";function oN(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 iN(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 sN="UICOPILOT/APPLY_FIXES",aN="UICOPILOT/FIX_STARTED",lN="UICOPILOT/FIX_COMPLETED",cN="UICOPILOT/FIX_FAILED",uN="UICOPILOT/ALL_FIXES_APPLIED",ym=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=eN(null),l=xm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);Gv(()=>()=>l(),[l]),Gv(()=>{let f=qv.getChannel(),k=()=>{gt.getState().isApplying&&(y.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 f.on("channelWSDisconnect",k),()=>f.off("channelWSDisconnect",k)},[l,o,i]);let d=tN({[aN]:({issueId:f})=>{y.debug(`[useApplyFixes] Fix started for issue: ${f}`),a(f,{status:"applying"})},[lN]:({issueId:f,result:k})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${f}`,k),s(f,"applied"),a(f,{status:"applied"})},[cN]:({issueId:f,error:k})=>{y.error(`[useApplyFixes] Fix failed for issue: ${f}`,k),s(f,"failed",k),a(f,{status:"failed",error:k})},[uN]:async({summary:f})=>{if(y.debug("[useApplyFixes] All fixes applied:",f),l(),o(!1),i({succeeded:f.succeeded,failed:f.failed,total:f.total}),f.failed>0?y.warn(`Applied ${f.succeeded}/${f.total} fixes. ${f.failed} failed.`):y.debug(`Successfully applied all ${f.total} fixes!`),f.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{qv.getChannel().emit(rN,{storyId:gt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(k){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",k)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await jl(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=xm(f=>{let k=[],T=[],E=[];for(let I of f){let D=I.currentValue||I.actual||"",R=I.suggestedValue||I.expected||"";if(D&&R&&oN(D,R)){k.push(I);continue}if(iN(I)){T.push(I);continue}let $=I.generatedFix?.filePath||I.file||"";if(!$){y.warn(`[useApplyFixes] Skipping issue ${I.id} - no target file path`);continue}let P=$.toLowerCase().split(".").pop()||"",z=["tsx","jsx","ts","js"].includes(P)?"component":"css";E.push({...I,targetFilePath:$,targetFileType:z})}return{actionable:E,negligible:k,designTokens:T}},[]);return{applyFixes:xm(f=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(f.length===0){y.warn("[useApplyFixes] No issues to fix");return}let k=g(f);if(k.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${k.negligible.length} negligible issue(s)`),k.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${k.designTokens.length} design token suggestion(s)`),k.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let T=k.actionable.filter(D=>D.targetFileType==="css"),E=k.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),T.length>0){let D=[...new Set(T.map(R=>R.targetFilePath))];y.debug(` - ${T.length} CSS issue(s) in: ${D.join(", ")}`)}if(E.length>0){let D=[...new Set(E.map(R=>R.targetFilePath))];y.debug(` - ${E.length} component issue(s) in: ${D.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.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(()=>{gt.getState().isApplying&&(y.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."}))},nN),d(sN,{issues:k.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};Ce();He();import{useState as yJ}from"react";var wJ=V();Ce();import{useState as ri}from"react";He();$e();ct();var pN=V();async function Kl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ne(`${pN}/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 y.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return y.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return y.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Yv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return y.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Kl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return y.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}zn();Qf();Di();$e();He();var dN=["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"],gN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],fN=V();function bm(){let[e,t]=ri(!1),[n,r]=ri(null),[o,i]=ri(null),[s,a]=ri(null),[u,c]=ri(null),[l,d]=ri(null),[g,p]=ri(null),{sessionToken:f}=we(),{selectedProjectId:k}=Je(),{currentStoryId:T,currentStoryName:E}=nt(),{workspacePath:I,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:$,dismissIssue:P,recalculateScore:z,addStreamingMessage:x}=ce();return{generateBatchFixes:async v=>{if(!f){r("Not authenticated");return}if(!k){r("No project selected");return}if(!T){r("No story selected");return}if(v.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:v.length,completed:0});let C=v.map(m=>({issueId:m.id,generatedFix:{code:"",diffPreview:"",filePath:m.file||"",confidence:0,strategy:"",status:"generating"}}));R(C);try{y.debug("[useBatchGenerateFixes] Generating fixes for",v.length,"issues");let m=null;try{let h=qs();h?.computed&&(m=h.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let F=null;try{F=await Qs(T),F&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",F)}catch(h){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",h)}let S=await fetch(`${fN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({projectId:k,storyId:T,workspacePath:I,includeComponentIssues:$,computedStyles:m,storyFilePaths:F,reviewContext:{storyName:E||void 0,variantArgs:Bi()||void 0},issues:v.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 b=await S.json();if(!b.success)throw new Error(b.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",b.result.fixes.length,"fixes"),b.result.storybookRoot&&(p(b.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",b.result.storybookRoot)),b.result.selfReview&&(d(b.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",b.result.selfReview)),b.result.partialFailure){let{failedBatches:h,errors:U}=b.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",U),r(`Some fixes couldn't be generated (${h.join(", ")}): ${U[0]||"Unknown error"}`)}a({total:v.length,completed:b.result.fixes.length});let A=new Set(b.result.fixes.map(h=>h.issueId)),L=v.filter(h=>!A.has(h.id));L.length>0&&(y.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"})})),b.timing&&(i({durationSec:b.timing.durationSec,issueCount:b.timing.issueCount,avgPerIssueSec:b.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${b.timing.durationSec}s for ${b.timing.issueCount} issues`)),b.result?.usage&&(c({inputTokens:b.result.usage.inputTokens||0,outputTokens:b.result.usage.outputTokens||0,costUsd:b.result.usage.costUsd||0,modelId:b.result.usage.modelId||"unknown",provider:b.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${b.result.usage.inputTokens} in, ${b.result.usage.outputTokens} out, $${b.result.usage.costUsd?.toFixed(4)}`));let B=[],N=[];if(b.result.fixes.forEach(h=>{let U=h.noChangesNeeded===!0;if(!U){let Y=(h.fixStrategy||"").toLowerCase(),ee=(h.generatedCode||"").toLowerCase(),ge=(h.diffPreview||"").toLowerCase(),xe=dN.some(Ke=>Y.includes(Ke.toLowerCase())||Y.replace(/[-_]/g,"").includes(Ke.replace(/[-_]/g,""))),ae=gN.some(Ke=>ee.includes(Ke)||ge.includes(Ke));U=xe||ae}let W=v.find(Y=>Y.id===h.issueId);if(U&&W){let Y=W.suggestedValue,ee=W.currentValue;Y&&ee&&!Jo(Y,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${Y}", actual="${ee}"), NOT auto-dismissing issue ${h.issueId}`),U=!1)}let M=W?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:U,isProgrammaticIssue:M,detectedBy:W?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:W?.title?.substring(0,50)}),M&&U&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${W?.detectedBy})`),U=!1),U){let Y=`Auto-dismissed: ${h.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,Y),B.push({localId:h.issueId,dbId:W?.dbId,dismissReason:Y}),N.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 Y=h.error||h.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:Y,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),B.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${B.length} false positive(s), recalculating score`),z(),f){let U=B.filter(W=>W.dbId).map(W=>({dbId:W.dbId,dismissed:!0,dismissReason:W.dismissReason,dismissedBy:"system"}));U.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${U.length} dismissals to server`),Yv(U,f).then(W=>{W.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${W.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",W.error)}).catch(W=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",W)}))}let h=B.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${B.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;x({role:"system",content:h})}y.debug("[useBatchGenerateFixes] Updated",b.result.fixes.length,"issues with fixes")}catch(m){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",m),r(m?.message||"Failed to generate batch fixes");let F=v.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:m?.message||"Failed to generate fix"}}));R(F)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}Ce();$e();He();ct();import{useState as Sm,useCallback as wm}from"react";var mN=V();function vm(){let[e,t]=Sm([]),[n,r]=Sm(!1),[o,i]=Sm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=wm(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let f=await ne(`${mN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!f.ok){let T=await f.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let k=await f.json();if(!k.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",k.reviews.length,"reviews for:",u),t(k.reviews)}catch(p){y.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=wm(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let f=[];if(typeof p.models=="string")try{f=JSON.parse(p.models)}catch(I){y.error("[useReviewHistory] Failed to parse models:",I),f=["claude-sonnet-4-20250514"]}else f=p.models;let k=p.issues.map(I=>({id:I.id,reviewId:p.id,type:I.type,severity:I.severity,title:I.description,description:I.description,file:void 0,lineNumber:void 0,property:I.property,currentValue:I.actual,suggestedValue:I.expected,suggestedCode:I.suggestedFix||void 0,status:I.status,dismissed:I.dismissed||!1,dismissReason:I.dismissReason,dismissedBy:I.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(I.createdAt)})),T=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,E=p.storyId||"";if(c({id:p.id,componentId:"",storyId:E,modelId:f[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:T}),E){let I=p.issues.filter(P=>!P.dismissed),D=I.filter(P=>P.severity==="critical").length,R=I.filter(P=>P.severity==="major").length,$=I.filter(P=>P.severity==="minor").length;Ur(E,{score:p.complianceScore,issueCount:I.length,criticalCount:D,majorCount:R,minorCount:$})}},[c]),g=wm(p=>{let f=e.find(k=>k.id===p);if(!f){y.error("[useReviewHistory] Review not found:",p);return}d(f)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}Ce();$e();import{useEffect as hN,useState as xN,useRef as Xl}from"react";import{useChannel as yN}from"storybook/manager-api";var bN="UICOPILOT/WORKSPACE_PATH",Kv="UICOPILOT/REQUEST_WORKSPACE_PATH",SN=3e3,wN=500,vN=5,km=()=>{let[e,t]=xN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=Xl(!1),o=Xl(null),i=Xl(0),s=Xl(null),a=yN({[bN]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),y.debug("[useAutoApplySupport] Server responded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return hN(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Kv,{}),s.current=setInterval(()=>{!r.current&&i.current<vN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Kv,{}))},wN),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){y.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,y.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,y.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},SN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},Cm=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 y.error("[copyToClipboard] Failed to copy:",t),!1}};Ce();He();import{useEffect as kN,useRef as CN}from"react";var JJ=V(),TN=new Set;function Tm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Je(),n=CN(!1);kN(()=>{t&&TN.add(t)},[e,t])}Ce();zn();import{useCallback as tZ,useState as nZ}from"react";import{useState as oi,useMemo as sk,useCallback as $i}from"react";He();$e();ct();zn();import{useState as ao,useEffect as Ql,useRef as _i,useCallback as Im}from"react";var IN=300;function Xv({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([]),[f,k]=ao(new Set),[T,E]=ao(!1),[I,D]=ao(!1),[R,$]=ao(null),P=_i(1),z=_i(null),x=_i(null),[w,v]=ao(0),C=_i(!1),m=_i({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});m.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let F=Im(async(B,N,h=!1)=>{let{projectId:U,typeFilter:W,search:M,figmaPage:Y,limit:ee}=m.current;if(!U||!W)return;z.current&&z.current.abort();let ge=new AbortController;z.current=ge,N?D(!0):E(!0),$(null);try{let xe=V(),ae=localStorage.getItem("uicopilot_session_token");if(!ae)throw new Error(`Not authenticated. Please connect to ${Ft.NAME} first.`);let Ke=new URLSearchParams({projectId:U,page:String(B),limit:String(ee)});W&&Ke.append("type",W),Y&&Ke.append("figmaPage",Y),M.trim()&&Ke.append("search",M.trim()),h&&Ke.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ke.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`},signal:ge.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Te=await be.json(),te=Te.frames||[],Be=Te.thumbnails||{},Pe=be.headers.get("X-Cache-Status");if(te.length===0&&B===1&&!N&&!h&&!C.current&&Pe!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),C.current=!0,await F(1,!1,!0);return}N?(a(pe=>[...pe,...te]),c(pe=>({...pe,...Be}))):(a(te),c(Be)),d(Te.total||te.length),Te.pages&&p(Te.pages),Te.cacheDiff?.added&&k(new Set(Te.cacheDiff.added)),P.current=B}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let ae=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";$(ae),y.error("Error fetching frames:",xe)}finally{ge.signal.aborted||(E(!1),D(!1))}},[]);Ql(()=>{if(!i||!e||!t)return;C.current=!1,x.current&&clearTimeout(x.current);let B=n.trim()?IN:0;return x.current=setTimeout(()=>{P.current=1,F(1,!1)},B),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,w,F]);let S=_i(new Set);Ql(()=>{if(s.length===0)return;let B={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(B[N.id]=N.thumbnailCdnUrl);Object.keys(B).length>0&&c(N=>({...N,...B}))},[s]),Ql(()=>{if(s.length===0)return;let B=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(B.length===0)return;B.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=m.current,U=V(),W=localStorage.getItem("uicopilot_session_token");if(!W||!h)return;let M=await ne(`${U}/api/figma/frames?projectId=${h}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${W}`}});if(M.ok){let Y=await M.json();Y.thumbnails&&Object.keys(Y.thumbnails).length>0&&c(ee=>({...ee,...Y.thumbnails}))}}catch(h){B.forEach(U=>S.current.delete(U)),y.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),Ql(()=>()=>{z.current&&z.current.abort(),x.current&&clearTimeout(x.current)},[]);let b=Im(async()=>{let B=P.current+1;await F(B,!0)},[F]),A=Im(()=>{C.current=!1,P.current=1,a([]),c({}),v(B=>B+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:f,isLoading:T,loadingMore:I,hasMore:L,loadMore:b,refresh:A,error:R}}He();$e();ct();import{useState as Zs,useCallback as Jl,useRef as FN}from"react";function Qv({projectId:e}){let[t,n]=Zs({}),[r,o]=Zs({}),[i,s]=Zs(new Set),[a,u]=Zs(new Set),[c,l]=Zs({}),d=FN({}),g=Jl(async T=>{if(!(!e||i.has(T))){s(E=>new Set(E).add(T));try{let E=V(),I=localStorage.getItem("uicopilot_session_token"),D=await ne(`${E}/api/figma/variants?projectId=${e}&componentSetId=${T}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}});if(D.ok){let R=await D.json();if(R.variants){n(P=>({...P,[T]:R.variants}));let $={};for(let P of R.variants)P.thumbnailCdnUrl&&($[P.id]=P.thumbnailCdnUrl);o(P=>({...P,[T]:{...P[T]||{},...$}})),d.current[T]||(d.current[T]=new Set),Object.keys($).forEach(P=>d.current[T].add(P))}else o($=>({...$,[T]:$[T]||{}}))}else o(R=>({...R,[T]:{}}))}catch(E){y.error("Failed to fetch variant metadata:",E),o(I=>({...I,[T]:{}}))}finally{s(E=>{let I=new Set(E);return I.delete(T),I})}}},[e,i]),p=Jl(async(T,E)=>{if(!e||E.length===0)return;d.current[T]||(d.current[T]=new Set);let I=r[T]||{},D=E.filter(R=>!d.current[T].has(R)&&!I[R]);if(D.length!==0){D.forEach(R=>d.current[T].add(R)),u(R=>new Set(R).add(T));try{let R=V(),$=localStorage.getItem("uicopilot_session_token"),P=await ne(`${R}/api/figma/variants?projectId=${e}&componentSetId=${T}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${$}`}});if(P.ok){let z=await P.json();z.thumbnails&&Object.keys(z.thumbnails).length>0&&o(x=>({...x,[T]:{...x[T]||{},...z.thumbnails}})),Array.isArray(z.failed)&&z.failed.length>0&&l(x=>{let w=new Set(x[T]||[]);for(let v of z.failed)w.add(v);return{...x,[T]:w}})}}catch(R){y.error("Failed to fetch variant thumbnails:",R),D.forEach($=>d.current[T]?.delete($))}finally{u(R=>{let $=new Set(R);return $.delete(T),$})}}},[e]),f=Jl(T=>{o(E=>{let I={...E};return delete I[T],I}),n(E=>{let I={...E};return delete I[T],I}),l(E=>{let I={...E};return delete I[T],I}),delete d.current[T]},[]),k=Jl(()=>{o({}),n({}),l({}),d.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,fetchVariants:g,fetchVariantThumbnails:p,clearVariantsForSet:f,clearAllVariants:k}}He();Di();Ce();$e();ct();import{useState as Jv,useEffect as Zv,useRef as ek,useCallback as Fm}from"react";function tk({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Jv(null),[i,s]=Jv(!1),a=ek(null),u=ek(new Set),c=Fm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Bi();if(!g||Object.keys(g).length===0)return;let p=gt.getState().currentStoryId||"",f=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,k=>k.toUpperCase());a.current=e,s(!0),o(null);try{let k=V(),T=localStorage.getItem("uicopilot_session_token"),E=await ne(`${k}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:f,storyId:p,storyArgs:g,availableFilters:t.map(I=>({property:I.property,values:I.values}))})});if(E.ok){let I=await E.json();I.confidence>0&&Object.keys(I.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",I),o(I))}}catch(k){y.error("[useFilterSuggestion] Error:",k)}finally{s(!1)}},[e,t,n]);Zv(()=>{c()},[c]),Zv(()=>{e||(o(null),a.current=null)},[e]);let l=Fm(()=>{},[]),d=Fm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function nk(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function rk(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 ok(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 ik(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 ea({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=oi(!0),[i,s]=oi(!1),[a,u]=oi(!1),[c,l]=oi(""),[d,g]=oi(""),[p,f]=oi([]),[k,T]=oi(new Set),E=$i(te=>{l(te),p.length>0&&f([]),k.size>0&&T(new Set)},[p.length,k.size]),I=nk(r,i,a),{frames:D,thumbnails:R,totalFrames:$,availablePages:P,recentlyAdded:z,isLoading:x,loadingMore:w,hasMore:v,loadMore:C,refresh:m,error:F}=Xv({projectId:e,typeFilter:I,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!I}),{variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariants:N,fetchVariantThumbnails:h,clearVariantsForSet:U,clearAllVariants:W}=Qv({projectId:e}),M=sk(()=>{let te=rk(S),Be=ok(D),Pe={};for(let pe of[...te,...Be])Pe[pe.property]||(Pe[pe.property]=new Set),pe.values.forEach(Pt=>Pe[pe.property].add(Pt));return Object.entries(Pe).map(([pe,Pt])=>({property:pe,values:Array.from(Pt).sort()}))},[S,D]),Y=k.size===1?Array.from(k)[0]:null,ee=tk({expandedSetId:Y,availableFilters:M,filtersReady:M.length>0}),ge=$i(()=>{if(!ee.suggestion)return;let{suggestedFilters:te}=ee.suggestion,Be=Object.entries(te).map(([Pe,pe])=>({property:Pe,value:pe}));f(Be),ee.dismissSuggestion()},[ee.suggestion]),xe=sk(()=>p.some(te=>te.value)?D.filter(te=>ik(te,p,S[te.id])):D,[D,p,S]),ae=$i((te,Be)=>{Be.stopPropagation();let Pe=!k.has(te);T(pe=>{let Pt=new Set(pe);return Pt.has(te)?Pt.delete(te):Pt.add(te),Pt}),Pe&&!S[te]&&!L.has(te)?N(te):Pe||U(te)},[k,S,L,N,U]),Ke=$i((te,Be)=>{let Pe=Be===""?null:Be;f(pe=>pe.find(tn=>tn.property===te)?pe.map(tn=>tn.property===te?{...tn,value:Pe}:tn):[...pe,{property:te,value:Pe}])},[]),be=$i(()=>{f([])},[]),Te=$i(te=>{let Be=D.find(Pe=>Pe.id===te);if(Be?.thumbnailCdnUrl)return Be.thumbnailCdnUrl;if(R[te])return R[te];for(let Pe of Object.values(b))if(Pe[te])return Pe[te]},[R,b]);return{frames:D,filteredFrames:xe,thumbnails:R,totalFrames:$,isLoading:x,loadingMore:w,hasMore:v,error:F,loadMore:C,refresh:m,search:c,setSearch:E,figmaPage:d,setFigmaPage:g,availablePages:P,recentlyAdded:z,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:M,handleFilterChange:Ke,clearFilters:be,expandedSets:k,toggleExpanded:ae,variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariantThumbnails:h,resolveThumbnail:Te,filterSuggestion:ee.suggestion,filterSuggestionLoading:ee.isLoading,applySuggestedFilters:ge,dismissFilterSuggestion:ee.dismissSuggestion}}Ce();import{useEffect as Er,useCallback as MN,useState as BN,useRef as DN}from"react";import{useChannel as RN}from"storybook/manager-api";function Po(e){return e.status===401||e.status===403}var In=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};zn();function ak(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 ku.error("Error parsing Figma URL:",t),null}}$e();He();He();ct();var EN=V();async function Em(e){let t=await ne(`${EN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Po(t))throw new In(t.status);return t.ok?(await t.json()).projects||[]:[]}He();ct();var AN=V();async function Am(e,t){let n=await ne(`${AN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new In(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}He();ct();var PN=V();async function Pm(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 ne(`${PN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(s))throw new In(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}He();ct();var LN=V();async function Lm(e,t){let n=await ne(`${LN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new In(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Di();function zN(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 NN=V(),ON="UICOPILOT/WORKSPACE_PATH",_N="UICOPILOT/REQUEST_WORKSPACE_PATH",Mm=!1;function Bm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:f,setMappingsByStoryId:k,setMappingSource:T,setLoadingMapping:E}=nt(),{setReviewResults:I,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:$,setFullPrompt:P,setFullResponse:z,bulkAddReviews:x}=ce(),[w,v]=BN([]),C=DN(null);Er(()=>{let S=b=>{b.origin.startsWith(NN)&&b.data?.type==="UICOPILOT_AUTH_SUCCESS"&&b.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(b.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let m=RN({[ON]:S=>{y.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Er(()=>{m(_N)},[m]),Er(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let A=await Em(e);S||(s(A),n(null))}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch projects:",A)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Er(()=>{if(!i||r.length===0)return;let S=r.find(b=>b.storybookRoot===i);S&&o!==S.id&&(y.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id))},[i,r,o,a]),Er(()=>{if(!o||r.length===0)return;let S=r.find(A=>A.id===o),b=S?.figmaFileId;if(S&&typeof b=="string"&&b){let A=b,L=A.includes("figma.com")&&ak(A)?.fileKey||A;p(`https://www.figma.com/file/${L}`)}},[o,r,p]),Er(()=>!e||!o||Mm?void 0:(Mm=!0,(async()=>{try{let b=await Lm(e,o);for(let[A,L]of Object.entries(b))Ur(A,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(b).length,"stories")}catch(b){b instanceof In&&n(b.message),y.error("[useDataInit] Failed to fetch review statuses:",b)}})(),()=>{Mm=!1}),[e,o]),Er(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let A=await Am(e,o);if(S)return;let L={};for(let B of A)B.storyId&&(L[B.storyId]=B);k(L),Ov(Object.keys(L))}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch all mappings:",A)}})(),()=>{S=!0}},[e,o,d,k]),Er(()=>{if(!l){f(null),T(null);return}let S=g[l]||null;S?(f(S),T("database")):(f(null),T(null)),E(!1)},[l,g,f,T,E]),Er(()=>{v([]),C.current=null},[l]),Er(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let A=await Pm(e,o,l,10,!0);if(!S){v(A);let L=A.map(B=>zN(B)).filter(Boolean);L.length>0&&x(L)}}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch reviews:",A)}})(),()=>{S=!0}},[e,o,l]);let F=MN(S=>{y.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let b=[];if(typeof S.models=="string")try{b=JSON.parse(S.models)}catch{b=["claude-sonnet-4-20250514"]}else b=S.models;let A=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,B=S.storyId||"";I({id:S.id,componentId:"",storyId:B,modelId:b[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:A,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let N=gt.getState().currentStoryId;if(B&&B===N&&(S.storybookScreenshot&&(R(S.storybookScreenshot),Yw(B,S.storybookScreenshot,S.figmaScreenshot??void 0),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&($(S.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(z(S.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),B){let h=S.issues.filter(Y=>!Y.dismissed),U=h.filter(Y=>Y.severity==="critical").length,W=h.filter(Y=>Y.severity==="major").length,M=h.filter(Y=>Y.severity==="minor").length;Ur(B,{score:S.complianceScore,issueCount:h.length,criticalCount:U,majorCount:W,minorCount:M})}},[I,R,$,P,z]);Er(()=>{if(w.length>0&&l&&C.current!==l){let S=w[0];S&&S.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),C.current=l,F(S),D("issues"))}},[w,l,F,D])}zn();import{styled as ta}from"storybook/theming";var $N=ta.div({display:"flex",gap:"10px",marginTop:"8px"}),lk=ta.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),ck=ta.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"})),uk=ta.div({display:"flex",alignItems:"center",gap:"8px"}),pk=ta(kn)(({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"})),dk=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=js(),[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($N,null,rt.createElement(lk,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),rt.createElement(lk,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 ",Ft.NAME),t?rt.createElement(ck,null,rt.createElement(uk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Ft.NAME)),rt.createElement(pk,{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(ds,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),rt.createElement(ds,{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(ds,{style:{marginBottom:"12px"}},"Connect to ",Ft.NAME," to manage projects and integrations."),rt.createElement(kn,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Ft.NAME))),n==="apikey"&&rt.createElement(xo,null,rt.createElement(yo,null,"Session Token"),t?rt.createElement(ck,null,rt.createElement(uk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Ft.NAME)),rt.createElement(pk,{onClick:i},"Disconnect")):rt.createElement(rt.Fragment,null,rt.createElement(ds,{style:{marginBottom:"12px"}},"Paste the session token from your ",Ft.NAME," setup page."),rt.createElement(ps,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),rt.createElement(kn,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:d},"Save Token"))))};import Ot,{useState as na}from"react";Ce();import $n,{useState as UN,useEffect as jN,useCallback as HN}from"react";import{styled as lo,keyframes as gk}from"storybook/theming";var WN=gk({from:{opacity:0},to:{opacity:1}}),VN=gk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),GN=lo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${WN} 150ms ease-out`}),qN=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:`${VN} 150ms ease-out`})),YN=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})),KN=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})),XN=lo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),QN=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}})),JN=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})),ZN=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}})),eO=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]=UN(""),d=!!s&&c!==s,g=HN(p=>{p.key==="Escape"&&u()},[u]);return jN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?$n.createElement($n.Fragment,null,$n.createElement(GN,{onClick:u}),$n.createElement(qN,{role:"dialog","aria-modal":"true","aria-label":t},$n.createElement(YN,null,t),$n.createElement(KN,null,n),s&&$n.createElement($n.Fragment,null,$n.createElement(JN,null,"Type ",$n.createElement("strong",null,s)," to confirm:"),$n.createElement(QN,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),$n.createElement(XN,null,$n.createElement(ZN,{onClick:u},o),$n.createElement(eO,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as fr}from"storybook/theming";var tO=fr.div({marginBottom:"30px"}),nO=fr.div({display:"flex",gap:"8px",alignItems:"center"}),rO=fr(hn)({flex:1}),oO=fr(rn)({padding:"8px 12px",whiteSpace:"nowrap"}),iO=fr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Dm=fr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Rm=fr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),zm=fr(ps)({fontSize:"13px",padding:"6px 8px"}),sO=fr.div({display:"flex",gap:"8px",marginTop:"12px"}),fk=fr(rn)({fontSize:"12px",padding:"6px 12px"}),aO=fr(fk)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),lO=fr.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"}})),mk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=io(),{currentStorybookPath:s}=Je(),[a,u]=na(!1),[c,l]=na(!1),[d,g]=na(!1),[p,f]=na(!1),[k,T]=na({name:"",storybookRoot:"",figmaFileUrl:""}),E=e.find(z=>z.id===t),I=z=>{n(z||null),u(!1)},D=async()=>{if(t)try{f(!0),await i(t),g(!1)}catch(z){console.error("Failed to delete project:",z)}finally{f(!1)}},R=()=>{if(u(!0),s){let z=s.replace(/\/+$/,"").split("/").pop()||"";T({storybookRoot:s,name:z,figmaFileUrl:""})}},$=async()=>{if(k.name.trim())try{l(!0);let z;if(k.figmaFileUrl.trim()){let w=k.figmaFileUrl.trim(),v=w.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);z=v?v[1]:w}let x=await o({name:k.name.trim(),storybookRoot:k.storybookRoot.trim()||void 0,figmaFileId:z});n(x.id),u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}catch(z){console.error("Failed to create project:",z)}finally{l(!1)}},P=z=>{T(x=>{let w={...x,storybookRoot:z};if(!x.name&&z){let v=z.replace(/\/+$/,"").split("/").pop()||"";w.name=v}return w})};return Ot.createElement(tO,null,Ot.createElement(uy,null,"Project"),Ot.createElement(nO,null,Ot.createElement(rO,{value:t||"",onChange:z=>I(z.target.value),disabled:r||a},Ot.createElement("option",{value:""},"-- Select a project --"),e.map(z=>Ot.createElement("option",{key:z.id,value:z.id},z.name))),Ot.createElement(oO,{onClick:R,disabled:r,type:"button"},"+ New"),Ot.createElement(lO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),Ot.createElement(jr,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${E?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:E?.name,variant:"danger",onConfirm:D,onCancel:()=>g(!1)}),a&&Ot.createElement(iO,null,Ot.createElement(Dm,null,Ot.createElement(Rm,null,"Storybook Path (for fix generation)"),Ot.createElement(zm,{type:"text",placeholder:"/path/to/your/storybook",value:k.storybookRoot,onChange:z=>P(z.target.value)})),Ot.createElement(Dm,null,Ot.createElement(Rm,null,"Project Name *"),Ot.createElement(zm,{type:"text",placeholder:"my-storybook",value:k.name,onChange:z=>{let x=z.target.value;T(w=>({...w,name:x}))}})),Ot.createElement(Dm,null,Ot.createElement(Rm,null,"Figma File URL (for design comparison)"),Ot.createElement(zm,{type:"text",placeholder:"https://www.figma.com/file/...",value:k.figmaFileUrl,onChange:z=>{let x=z.target.value;T(w=>({...w,figmaFileUrl:x}))}})),Ot.createElement(sO,null,Ot.createElement(fk,{onClick:$,disabled:c||!k.name.trim()},c?"Creating...":"Create"),Ot.createElement(aO,{onClick:()=>{u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import yt,{useState as xc,useCallback as qC,useEffect as f4}from"react";import{styled as Pr}from"storybook/theming";import Hr,{useState as ra,useEffect as FO,useCallback as Om}from"react";import{styled as Lo}from"storybook/theming";Ce();He();ct();Ce();He();ct();import Ht,{useState as Nm}from"react";import{styled as Un,keyframes as cO}from"storybook/theming";var uO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},pO=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",dO=Un.div({position:"relative",display:"inline-flex"}),gO=cO`
|
|
30
|
+
\u2705 ${re} issue${re>1?"s were":" was"} auto-dismissed as false positive${re>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Yt=Ue.complianceScore??Ue.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Ue.complianceScore,validationScore:Ue.validation?.complianceScore,parsedScore:Yt}),Yt==null){let Ie=zt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Yt=Ie?parseInt(Ie[1],10):void 0,y.debug("[Review] Parsed score from response:",Yt)}let gn=Be.current[se];gn||(gn=await Qs(se)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},gn.storyFile&&(Be.current[se]=gn)),y.debug("[Review] Story file paths:",gn);let at=dn.map(Ie=>({...Ie,file:Ie.file||cm(Ie.fixTarget,gn)||um(Ie,gn)}));if(at=pm(at),y.debug("[Review] After de-duplication:",at.length,"issues"),!h){let Ie=at.length;at=at.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),Ie!==at.length&&y.debug("[Review] Filtered out",Ie-at.length,"textContent issues (toggle OFF)")}let zr;tt&&he&&(zr=(ft.getState().reviewHistory.find(de=>de.id===he)?.iterationNumber||0)+1);let Ln={id:Qe,componentId:se,storyId:se,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:zr,figmaFileKey:void 0,figmaNodeId:St||void 0,figmaFileUrl:Yn||void 0,complianceScore:Yt,visualSimilarity:Ue.visualSimilarity,issuesCount:at.filter(Ie=>!Ie.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-oe,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(y.debug("[useAIReview] About to call addReview with review:",{id:Ln.id,storyId:Ln.storyId,issueCount:Ln.issues?.length,complianceScore:Ln.complianceScore,createdAt:Ln.createdAt?.toISOString(),inputTokens:Ln.inputTokens,outputTokens:Ln.outputTokens,costUsd:Ln.costUsd,cacheCreationTokens:Ln.cacheCreationTokens,cacheReadTokens:Ln.cacheReadTokens}),B(Ln),y.debug("[useAIReview] addReview called successfully"),se&&M.enableReviewBadges){let Ie=at.filter(de=>!de.dismissed);Ur(se,{score:Yt??100,issueCount:Ie.length,criticalCount:Ie.filter(de=>de.severity==="critical").length,majorCount:Ie.filter(de=>de.severity==="major").length,minorCount:Ie.filter(de=>de.severity==="minor").length})}N("issues");let us=at.filter(Ie=>!Ie.dismissed).length;y.debug("[Review] Created review with",us,"active issues,",at.length-us,"dismissed");let _a=St||ft.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:St,effectiveFigmaNodeIdSingle:_a,hasSessionToken:!!Y,selectedProjectId:xe,issueCount:at.length}),y.debug("[Review] Issue validation handled server-side. Active:",at.filter(Ie=>!Ie.dismissed).length,"Dismissed:",at.filter(Ie=>Ie.dismissed).length)}catch(Qe){y.error("[Review] Failed to parse issues:",Qe)}}else throw rn?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",rn.length),y.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"){y.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}y.error("[useAIReview] Review error:",K);let me=Lv(K);throw g(me),se&&M.enableReviewBadges&&Rv(se),pe(0,`Error: ${me}`),K}finally{p(!1),Te.current=null,te.current&&(clearTimeout(te.current),te.current=null),ge(null)}},[e,Y,xe,se,Ke,l,p,g,d,F,S,b,A,T,E,R,Pe,pe,D,C,w,z,x,ge]),nn=Js(()=>n?.issues?o==="all"?n.issues:n.issues.filter(fe=>fe.severity===o):[],[n,o]),Dr=Js(()=>{Te.current&&(y.debug("[useAIReview] Cancelling review..."),Te.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Lt,cancelReview:Dr,setShowReviewMenu:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,resetReview:L,getFilteredIssues:nn}};Ce();$e();He();import{useCallback as eJ}from"react";var oJ=V();Ce();$e();import{useEffect as $v,useRef as Uv}from"react";import{useStorybookApi as Jz,useStorybookState as Zz,addons as eN}from"storybook/manager-api";var jv="storyArgsUpdated",hm=()=>{let e=Jz(),t=Zz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=Uv(null),p=Uv(0);return $v(()=>{let g=t.storyId;if(g){l.current!==g&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,p.current=Date.now()),o(g);let d=e.getData(g),f=d?.name&&d.name!=="default"?`${d.title} / ${d.name}`:d?.title||g;i(f),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:f})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),$v(()=>{let g=eN.getChannel(),d=null,f=k=>{if(k.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}d&&clearTimeout(d),d=setTimeout(()=>{let{isReviewing:T,isValidating:E}=ft.getState();if(T||E){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-p.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(jv,f),()=>{g.off(jv,f),d&&clearTimeout(d)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Ce();He();ct();import{useCallback as Hv}from"react";import{addons as Wv}from"storybook/manager-api";var Vv=V(),ni=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=we(),{selectedProjectId:i}=Je(),s=Hv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ne(`${Vv}/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 p=await l.json();r();try{Wv.getChannel().emit("uireview/mappings-changed")}catch{}return p.mapping},[o,i,r]),a=Hv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ne(`${Vv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{Wv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Di();Ce();import{useCallback as xm,useEffect as Gv,useRef as tN}from"react";import{useChannel as nN,addons as qv}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",ym=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=tN(null),l=xm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);Gv(()=>()=>l(),[l]),Gv(()=>{let f=qv.getChannel(),k=()=>{ft.getState().isApplying&&(y.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 f.on("channelWSDisconnect",k),()=>f.off("channelWSDisconnect",k)},[l,o,i]);let p=nN({[lN]:({issueId:f})=>{y.debug(`[useApplyFixes] Fix started for issue: ${f}`),a(f,{status:"applying"})},[cN]:({issueId:f,result:k})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${f}`,k),s(f,"applied"),a(f,{status:"applied"})},[uN]:({issueId:f,error:k})=>{y.error(`[useApplyFixes] Fix failed for issue: ${f}`,k),s(f,"failed",k),a(f,{status:"failed",error:k})},[pN]:async({summary:f})=>{if(y.debug("[useApplyFixes] All fixes applied:",f),l(),o(!1),i({succeeded:f.succeeded,failed:f.failed,total:f.total}),f.failed>0?y.warn(`Applied ${f.succeeded}/${f.total} fixes. ${f.failed} failed.`):y.debug(`Successfully applied all ${f.total} fixes!`),f.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{qv.getChannel().emit(oN,{storyId:ft.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(k){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",k)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await jl(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=xm(f=>{let k=[],T=[],E=[];for(let I of f){let D=I.currentValue||I.actual||"",R=I.suggestedValue||I.expected||"";if(D&&R&&iN(D,R)){k.push(I);continue}if(sN(I)){T.push(I);continue}let $=I.generatedFix?.filePath||I.file||"";if(!$){y.warn(`[useApplyFixes] Skipping issue ${I.id} - no target file path`);continue}let P=$.toLowerCase().split(".").pop()||"",z=["tsx","jsx","ts","js"].includes(P)?"component":"css";E.push({...I,targetFilePath:$,targetFileType:z})}return{actionable:E,negligible:k,designTokens:T}},[]);return{applyFixes:xm(f=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(f.length===0){y.warn("[useApplyFixes] No issues to fix");return}let k=g(f);if(k.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${k.negligible.length} negligible issue(s)`),k.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${k.designTokens.length} design token suggestion(s)`),k.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let T=k.actionable.filter(D=>D.targetFileType==="css"),E=k.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),T.length>0){let D=[...new Set(T.map(R=>R.targetFilePath))];y.debug(` - ${T.length} CSS issue(s) in: ${D.join(", ")}`)}if(E.length>0){let D=[...new Set(E.map(R=>R.targetFilePath))];y.debug(` - ${E.length} component issue(s) in: ${D.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.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(()=>{ft.getState().isApplying&&(y.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),p(aN,{issues:k.actionable,storybookRoot:n||void 0})},[p,r,o,i,g,n,l]),isApplying:r}};Ce();He();import{useState as TJ}from"react";var EJ=V();Ce();import{useState as ri}from"react";He();$e();ct();var dN=V();async function Kl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ne(`${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 y.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return y.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return y.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Yv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return y.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Kl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return y.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}Nn();Qf();Di();$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=V();function bm(){let[e,t]=ri(!1),[n,r]=ri(null),[o,i]=ri(null),[s,a]=ri(null),[u,c]=ri(null),[l,p]=ri(null),[g,d]=ri(null),{sessionToken:f}=we(),{selectedProjectId:k}=Je(),{currentStoryId:T,currentStoryName:E}=nt(),{workspacePath:I,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:$,dismissIssue:P,recalculateScore:z,addStreamingMessage:x}=ce();return{generateBatchFixes:async v=>{if(!f){r("Not authenticated");return}if(!k){r("No project selected");return}if(!T){r("No story selected");return}if(v.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),p(null),a({total:v.length,completed:0});let C=v.map(m=>({issueId:m.id,generatedFix:{code:"",diffPreview:"",filePath:m.file||"",confidence:0,strategy:"",status:"generating"}}));R(C);try{y.debug("[useBatchGenerateFixes] Generating fixes for",v.length,"issues");let m=null;try{let h=qs();h?.computed&&(m=h.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let F=null;try{F=await Qs(T),F&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",F)}catch(h){y.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 ${f}`},body:JSON.stringify({projectId:k,storyId:T,workspacePath:I,includeComponentIssues:$,computedStyles:m,storyFilePaths:F,reviewContext:{storyName:E||void 0,variantArgs:Bi()||void 0},issues:v.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 b=await S.json();if(!b.success)throw new Error(b.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",b.result.fixes.length,"fixes"),b.result.storybookRoot&&(d(b.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",b.result.storybookRoot)),b.result.selfReview&&(p(b.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",b.result.selfReview)),b.result.partialFailure){let{failedBatches:h,errors:U}=b.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",U),r(`Some fixes couldn't be generated (${h.join(", ")}): ${U[0]||"Unknown error"}`)}a({total:v.length,completed:b.result.fixes.length});let A=new Set(b.result.fixes.map(h=>h.issueId)),L=v.filter(h=>!A.has(h.id));L.length>0&&(y.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"})})),b.timing&&(i({durationSec:b.timing.durationSec,issueCount:b.timing.issueCount,avgPerIssueSec:b.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${b.timing.durationSec}s for ${b.timing.issueCount} issues`)),b.result?.usage&&(c({inputTokens:b.result.usage.inputTokens||0,outputTokens:b.result.usage.outputTokens||0,costUsd:b.result.usage.costUsd||0,modelId:b.result.usage.modelId||"unknown",provider:b.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${b.result.usage.inputTokens} in, ${b.result.usage.outputTokens} out, $${b.result.usage.costUsd?.toFixed(4)}`));let B=[],N=[];if(b.result.fixes.forEach(h=>{let U=h.noChangesNeeded===!0;if(!U){let Y=(h.fixStrategy||"").toLowerCase(),ee=(h.generatedCode||"").toLowerCase(),ge=(h.diffPreview||"").toLowerCase(),xe=gN.some(Ke=>Y.includes(Ke.toLowerCase())||Y.replace(/[-_]/g,"").includes(Ke.replace(/[-_]/g,""))),se=fN.some(Ke=>ee.includes(Ke)||ge.includes(Ke));U=xe||se}let W=v.find(Y=>Y.id===h.issueId);if(U&&W){let Y=W.suggestedValue,ee=W.currentValue;Y&&ee&&!Jo(Y,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${Y}", actual="${ee}"), NOT auto-dismissing issue ${h.issueId}`),U=!1)}let M=W?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:U,isProgrammaticIssue:M,detectedBy:W?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:W?.title?.substring(0,50)}),M&&U&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${W?.detectedBy})`),U=!1),U){let Y=`Auto-dismissed: ${h.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,Y),B.push({localId:h.issueId,dbId:W?.dbId,dismissReason:Y}),N.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 Y=h.error||h.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:Y,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),B.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${B.length} false positive(s), recalculating score`),z(),f){let U=B.filter(W=>W.dbId).map(W=>({dbId:W.dbId,dismissed:!0,dismissReason:W.dismissReason,dismissedBy:"system"}));U.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${U.length} dismissals to server`),Yv(U,f).then(W=>{W.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${W.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",W.error)}).catch(W=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",W)}))}let h=B.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${B.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;x({role:"system",content:h})}y.debug("[useBatchGenerateFixes] Updated",b.result.fixes.length,"issues with fixes")}catch(m){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",m),r(m?.message||"Failed to generate batch fixes");let F=v.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:m?.message||"Failed to generate fix"}}));R(F)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}Ce();$e();He();ct();import{useState as Sm,useCallback as wm}from"react";var hN=V();function vm(){let[e,t]=Sm([]),[n,r]=Sm(!1),[o,i]=Sm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=wm(async()=>{if(!(!s||!a)){r(!0),i(null);try{let d=new URLSearchParams({projectId:a,limit:"10"});u&&d.append("storyId",u);let f=await ne(`${hN}/api/reviews/list?${d.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!f.ok){let T=await f.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let k=await f.json();if(!k.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",k.reviews.length,"reviews for:",u),t(k.reviews)}catch(d){y.error("[useReviewHistory] Failed to fetch reviews:",d),i(d instanceof Error?d.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),p=wm(d=>{y.debug("[useReviewHistory] Applying review:",d.id,"with",d.issues.length,"issues");let f=[];if(typeof d.models=="string")try{f=JSON.parse(d.models)}catch(I){y.error("[useReviewHistory] Failed to parse models:",I),f=["claude-sonnet-4-20250514"]}else f=d.models;let k=d.issues.map(I=>({id:I.id,reviewId:d.id,type:I.type,severity:I.severity,title:I.description,description:I.description,file:void 0,lineNumber:void 0,property:I.property,currentValue:I.actual,suggestedValue:I.expected,suggestedCode:I.suggestedFix||void 0,status:I.status,dismissed:I.dismissed||!1,dismissReason:I.dismissReason,dismissedBy:I.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(I.createdAt)})),T=d.completedAt&&d.createdAt?new Date(d.completedAt).getTime()-new Date(d.createdAt).getTime():void 0,E=d.storyId||"";if(c({id:d.id,componentId:"",storyId:E,modelId:f[0]||"claude-sonnet-4-6",complianceScore:d.complianceScore,issuesCount:d.issuesCount,issues:k,createdAt:new Date(d.createdAt),timestamp:new Date(d.createdAt).toISOString(),costUsd:d.costUsd,inputTokens:d.inputTokens,outputTokens:d.outputTokens,reviewDurationMs:T}),E){let I=d.issues.filter(P=>!P.dismissed),D=I.filter(P=>P.severity==="critical").length,R=I.filter(P=>P.severity==="major").length,$=I.filter(P=>P.severity==="minor").length;Ur(E,{score:d.complianceScore,issueCount:I.length,criticalCount:D,majorCount:R,minorCount:$})}},[c]),g=wm(d=>{let f=e.find(k=>k.id===d);if(!f){y.error("[useReviewHistory] Review not found:",d);return}p(f)},[e,p]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}Ce();$e();import{useEffect as xN,useState as yN,useRef as Xl}from"react";import{useChannel as bN}from"storybook/manager-api";var SN="UICOPILOT/WORKSPACE_PATH",Kv="UICOPILOT/REQUEST_WORKSPACE_PATH",wN=3e3,vN=500,kN=5,km=()=>{let[e,t]=yN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=Xl(!1),o=Xl(null),i=Xl(0),s=Xl(null),a=bN({[SN]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),y.debug("[useAutoApplySupport] Server responded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return xN(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Kv,{}),s.current=setInterval(()=>{!r.current&&i.current<kN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Kv,{}))},vN),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){y.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,y.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,y.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},Cm=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 y.error("[copyToClipboard] Failed to copy:",t),!1}};Ce();He();import{useEffect as CN,useRef as TN}from"react";var iZ=V(),IN=new Set;function Tm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Je(),n=TN(!1);CN(()=>{t&&IN.add(t)},[e,t])}Ce();Nn();import{useCallback as lZ,useState as cZ}from"react";import{useState as oi,useMemo as sk,useCallback as $i}from"react";He();$e();ct();Nn();import{useState as ao,useEffect as Ql,useRef as _i,useCallback as Im}from"react";var FN=300;function Xv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=ao([]),[u,c]=ao({}),[l,p]=ao(0),[g,d]=ao([]),[f,k]=ao(new Set),[T,E]=ao(!1),[I,D]=ao(!1),[R,$]=ao(null),P=_i(1),z=_i(null),x=_i(null),[w,v]=ao(0),C=_i(!1),m=_i({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});m.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let F=Im(async(B,N,h=!1)=>{let{projectId:U,typeFilter:W,search:M,figmaPage:Y,limit:ee}=m.current;if(!U||!W)return;z.current&&z.current.abort();let ge=new AbortController;z.current=ge,N?D(!0):E(!0),$(null);try{let xe=V(),se=localStorage.getItem("uicopilot_session_token");if(!se)throw new Error(`Not authenticated. Please connect to ${Et.NAME} first.`);let Ke=new URLSearchParams({projectId:U,page:String(B),limit:String(ee)});W&&Ke.append("type",W),Y&&Ke.append("figmaPage",Y),M.trim()&&Ke.append("search",M.trim()),h&&Ke.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ke.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${se}`},signal:ge.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Te=await be.json(),te=Te.frames||[],Be=Te.thumbnails||{},Pe=be.headers.get("X-Cache-Status");if(te.length===0&&B===1&&!N&&!h&&!C.current&&Pe!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),C.current=!0,await F(1,!1,!0);return}N?(a(pe=>[...pe,...te]),c(pe=>({...pe,...Be}))):(a(te),c(Be)),p(Te.total||te.length),Te.pages&&d(Te.pages),Te.cacheDiff?.added&&k(new Set(Te.cacheDiff.added)),P.current=B}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let se=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";$(se),y.error("Error fetching frames:",xe)}finally{ge.signal.aborted||(E(!1),D(!1))}},[]);Ql(()=>{if(!i||!e||!t)return;C.current=!1,x.current&&clearTimeout(x.current);let B=n.trim()?FN:0;return x.current=setTimeout(()=>{P.current=1,F(1,!1)},B),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,w,F]);let S=_i(new Set);Ql(()=>{if(s.length===0)return;let B={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(B[N.id]=N.thumbnailCdnUrl);Object.keys(B).length>0&&c(N=>({...N,...B}))},[s]),Ql(()=>{if(s.length===0)return;let B=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(B.length===0)return;B.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=m.current,U=V(),W=localStorage.getItem("uicopilot_session_token");if(!W||!h)return;let M=await ne(`${U}/api/figma/frames?projectId=${h}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${W}`}});if(M.ok){let Y=await M.json();Y.thumbnails&&Object.keys(Y.thumbnails).length>0&&c(ee=>({...ee,...Y.thumbnails}))}}catch(h){B.forEach(U=>S.current.delete(U)),y.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),Ql(()=>()=>{z.current&&z.current.abort(),x.current&&clearTimeout(x.current)},[]);let b=Im(async()=>{let B=P.current+1;await F(B,!0)},[F]),A=Im(()=>{C.current=!1,P.current=1,a([]),c({}),v(B=>B+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:f,isLoading:T,loadingMore:I,hasMore:L,loadMore:b,refresh:A,error:R}}He();$e();ct();import{useState as Zs,useCallback as Jl,useRef as EN}from"react";function Qv({projectId:e}){let[t,n]=Zs({}),[r,o]=Zs({}),[i,s]=Zs(new Set),[a,u]=Zs(new Set),[c,l]=Zs({}),p=EN({}),g=Jl(async T=>{if(!(!e||i.has(T))){s(E=>new Set(E).add(T));try{let E=V(),I=localStorage.getItem("uicopilot_session_token"),D=await ne(`${E}/api/figma/variants?projectId=${e}&componentSetId=${T}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}});if(D.ok){let R=await D.json();if(R.variants){n(P=>({...P,[T]:R.variants}));let $={};for(let P of R.variants)P.thumbnailCdnUrl&&($[P.id]=P.thumbnailCdnUrl);o(P=>({...P,[T]:{...P[T]||{},...$}})),p.current[T]||(p.current[T]=new Set),Object.keys($).forEach(P=>p.current[T].add(P))}else o($=>({...$,[T]:$[T]||{}}))}else o(R=>({...R,[T]:{}}))}catch(E){y.error("Failed to fetch variant metadata:",E),o(I=>({...I,[T]:{}}))}finally{s(E=>{let I=new Set(E);return I.delete(T),I})}}},[e,i]),d=Jl(async(T,E)=>{if(!e||E.length===0)return;p.current[T]||(p.current[T]=new Set);let I=r[T]||{},D=E.filter(R=>!p.current[T].has(R)&&!I[R]);if(D.length!==0){D.forEach(R=>p.current[T].add(R)),u(R=>new Set(R).add(T));try{let R=V(),$=localStorage.getItem("uicopilot_session_token"),P=await ne(`${R}/api/figma/variants?projectId=${e}&componentSetId=${T}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${$}`}});if(P.ok){let z=await P.json();z.thumbnails&&Object.keys(z.thumbnails).length>0&&o(x=>({...x,[T]:{...x[T]||{},...z.thumbnails}})),Array.isArray(z.failed)&&z.failed.length>0&&l(x=>{let w=new Set(x[T]||[]);for(let v of z.failed)w.add(v);return{...x,[T]:w}})}}catch(R){y.error("Failed to fetch variant thumbnails:",R),D.forEach($=>p.current[T]?.delete($))}finally{u(R=>{let $=new Set(R);return $.delete(T),$})}}},[e]),f=Jl(T=>{o(E=>{let I={...E};return delete I[T],I}),n(E=>{let I={...E};return delete I[T],I}),l(E=>{let I={...E};return delete I[T],I}),delete p.current[T]},[]),k=Jl(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,fetchVariants:g,fetchVariantThumbnails:d,clearVariantsForSet:f,clearAllVariants:k}}He();Di();Ce();$e();ct();import{useState as Jv,useEffect as Zv,useRef as ek,useCallback as Fm}from"react";function tk({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Jv(null),[i,s]=Jv(!1),a=ek(null),u=ek(new Set),c=Fm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Bi();if(!g||Object.keys(g).length===0)return;let d=ft.getState().currentStoryId||"",f=d.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,k=>k.toUpperCase());a.current=e,s(!0),o(null);try{let k=V(),T=localStorage.getItem("uicopilot_session_token"),E=await ne(`${k}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:f,storyId:d,storyArgs:g,availableFilters:t.map(I=>({property:I.property,values:I.values}))})});if(E.ok){let I=await E.json();I.confidence>0&&Object.keys(I.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",I),o(I))}}catch(k){y.error("[useFilterSuggestion] Error:",k)}finally{s(!1)}},[e,t,n]);Zv(()=>{c()},[c]),Zv(()=>{e||(o(null),a.current=null)},[e]);let l=Fm(()=>{},[]),p=Fm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:p}}function nk(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function rk(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 ok(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 ik(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 ea({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=oi(!0),[i,s]=oi(!1),[a,u]=oi(!1),[c,l]=oi(""),[p,g]=oi(""),[d,f]=oi([]),[k,T]=oi(new Set),E=$i(te=>{l(te),d.length>0&&f([]),k.size>0&&T(new Set)},[d.length,k.size]),I=nk(r,i,a),{frames:D,thumbnails:R,totalFrames:$,availablePages:P,recentlyAdded:z,isLoading:x,loadingMore:w,hasMore:v,loadMore:C,refresh:m,error:F}=Xv({projectId:e,typeFilter:I,search:c,figmaPage:p||void 0,limit:t,enabled:n&&!!I}),{variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariants:N,fetchVariantThumbnails:h,clearVariantsForSet:U,clearAllVariants:W}=Qv({projectId:e}),M=sk(()=>{let te=rk(S),Be=ok(D),Pe={};for(let pe of[...te,...Be])Pe[pe.property]||(Pe[pe.property]=new Set),pe.values.forEach(Lt=>Pe[pe.property].add(Lt));return Object.entries(Pe).map(([pe,Lt])=>({property:pe,values:Array.from(Lt).sort()}))},[S,D]),Y=k.size===1?Array.from(k)[0]:null,ee=tk({expandedSetId:Y,availableFilters:M,filtersReady:M.length>0}),ge=$i(()=>{if(!ee.suggestion)return;let{suggestedFilters:te}=ee.suggestion,Be=Object.entries(te).map(([Pe,pe])=>({property:Pe,value:pe}));f(Be),ee.dismissSuggestion()},[ee.suggestion]),xe=sk(()=>d.some(te=>te.value)?D.filter(te=>ik(te,d,S[te.id])):D,[D,d,S]),se=$i((te,Be)=>{Be.stopPropagation();let Pe=!k.has(te);T(pe=>{let Lt=new Set(pe);return Lt.has(te)?Lt.delete(te):Lt.add(te),Lt}),Pe&&!S[te]&&!L.has(te)?N(te):Pe||U(te)},[k,S,L,N,U]),Ke=$i((te,Be)=>{let Pe=Be===""?null:Be;f(pe=>pe.find(nn=>nn.property===te)?pe.map(nn=>nn.property===te?{...nn,value:Pe}:nn):[...pe,{property:te,value:Pe}])},[]),be=$i(()=>{f([])},[]),Te=$i(te=>{let Be=D.find(Pe=>Pe.id===te);if(Be?.thumbnailCdnUrl)return Be.thumbnailCdnUrl;if(R[te])return R[te];for(let Pe of Object.values(b))if(Pe[te])return Pe[te]},[R,b]);return{frames:D,filteredFrames:xe,thumbnails:R,totalFrames:$,isLoading:x,loadingMore:w,hasMore:v,error:F,loadMore:C,refresh:m,search:c,setSearch:E,figmaPage:p,setFigmaPage:g,availablePages:P,recentlyAdded:z,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:d,availableFilters:M,handleFilterChange:Ke,clearFilters:be,expandedSets:k,toggleExpanded:se,variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariantThumbnails:h,resolveThumbnail:Te,filterSuggestion:ee.suggestion,filterSuggestionLoading:ee.isLoading,applySuggestedFilters:ge,dismissFilterSuggestion:ee.dismissSuggestion}}Ce();import{useEffect as Er,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 En=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};Nn();function ak(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 ku.error("Error parsing Figma URL:",t),null}}$e();He();He();ct();var AN=V();async function Em(e){let t=await ne(`${AN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Po(t))throw new En(t.status);return t.ok?(await t.json()).projects||[]:[]}He();ct();var PN=V();async function Am(e,t){let n=await ne(`${PN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new En(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}He();ct();var LN=V();async function Pm(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 ne(`${LN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(s))throw new En(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}He();ct();var MN=V();async function Lm(e,t){let n=await ne(`${MN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Po(n))throw new En(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Di();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=V(),_N="UICOPILOT/WORKSPACE_PATH",$N="UICOPILOT/REQUEST_WORKSPACE_PATH",Mm=!1;function Bm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:p,mappingsByStoryId:g,setFigmaFileUrl:d,setCurrentMapping:f,setMappingsByStoryId:k,setMappingSource:T,setLoadingMapping:E}=nt(),{setReviewResults:I,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:$,setFullPrompt:P,setFullResponse:z,bulkAddReviews:x}=ce(),[w,v]=DN([]),C=RN(null);Er(()=>{let S=b=>{b.origin.startsWith(ON)&&b.data?.type==="UICOPILOT_AUTH_SUCCESS"&&b.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(b.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let m=zN({[_N]:S=>{y.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Er(()=>{m($N)},[m]),Er(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let A=await Em(e);S||(s(A),n(null))}catch(A){A instanceof En&&n(A.message),y.error("[useDataInit] Failed to fetch projects:",A)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Er(()=>{if(!i||r.length===0)return;let S=r.find(b=>b.storybookRoot===i);S&&o!==S.id&&(y.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id))},[i,r,o,a]),Er(()=>{if(!o||r.length===0)return;let S=r.find(A=>A.id===o),b=S?.figmaFileId;if(S&&typeof b=="string"&&b){let A=b,L=A.includes("figma.com")&&ak(A)?.fileKey||A;d(`https://www.figma.com/file/${L}`)}},[o,r,d]),Er(()=>!e||!o||Mm?void 0:(Mm=!0,(async()=>{try{let b=await Lm(e,o);for(let[A,L]of Object.entries(b))Ur(A,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(b).length,"stories")}catch(b){b instanceof En&&n(b.message),y.error("[useDataInit] Failed to fetch review statuses:",b)}})(),()=>{Mm=!1}),[e,o]),Er(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let A=await Am(e,o);if(S)return;let L={};for(let B of A)B.storyId&&(L[B.storyId]=B);k(L),Ov(Object.keys(L))}catch(A){A instanceof En&&n(A.message),y.error("[useDataInit] Failed to fetch all mappings:",A)}})(),()=>{S=!0}},[e,o,p,k]),Er(()=>{if(!l){f(null),T(null);return}let S=g[l]||null;S?(f(S),T("database")):(f(null),T(null)),E(!1)},[l,g,f,T,E]),Er(()=>{v([]),C.current=null},[l]),Er(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let A=await Pm(e,o,l,10,!0);if(!S){v(A);let L=A.map(B=>NN(B)).filter(Boolean);L.length>0&&x(L)}}catch(A){A instanceof En&&n(A.message),y.error("[useDataInit] Failed to fetch reviews:",A)}})(),()=>{S=!0}},[e,o,l]);let F=BN(S=>{y.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let b=[];if(typeof S.models=="string")try{b=JSON.parse(S.models)}catch{b=["claude-sonnet-4-20250514"]}else b=S.models;let A=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,B=S.storyId||"";I({id:S.id,componentId:"",storyId:B,modelId:b[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:A,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let N=ft.getState().currentStoryId;if(B&&B===N&&(S.storybookScreenshot&&(R(S.storybookScreenshot),Yw(B,S.storybookScreenshot,S.figmaScreenshot??void 0),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&($(S.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(z(S.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),B){let h=S.issues.filter(Y=>!Y.dismissed),U=h.filter(Y=>Y.severity==="critical").length,W=h.filter(Y=>Y.severity==="major").length,M=h.filter(Y=>Y.severity==="minor").length;Ur(B,{score:S.complianceScore,issueCount:h.length,criticalCount:U,majorCount:W,minorCount:M})}},[I,R,$,P,z]);Er(()=>{if(w.length>0&&l&&C.current!==l){let S=w[0];S&&S.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),C.current=l,F(S),D("issues"))}},[w,l,F,D])}Nn();import{styled as ta}from"storybook/theming";var UN=ta.div({display:"flex",gap:"10px",marginTop:"8px"}),lk=ta.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),ck=ta.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"})),uk=ta.div({display:"flex",alignItems:"center",gap:"8px"}),pk=ta(Tn)(({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"})),dk=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=js(),[c,l]=rt.useState(""),p=()=>{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(lk,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),rt.createElement(lk,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 ",Et.NAME),t?rt.createElement(ck,null,rt.createElement(uk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Et.NAME)),rt.createElement(pk,{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(ds,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),rt.createElement(ds,{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(ds,{style:{marginBottom:"12px"}},"Connect to ",Et.NAME," to manage projects and integrations."),rt.createElement(Tn,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Et.NAME))),n==="apikey"&&rt.createElement(xo,null,rt.createElement(yo,null,"Session Token"),t?rt.createElement(ck,null,rt.createElement(uk,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Et.NAME)),rt.createElement(pk,{onClick:i},"Disconnect")):rt.createElement(rt.Fragment,null,rt.createElement(ds,{style:{marginBottom:"12px"}},"Paste the session token from your ",Et.NAME," setup page."),rt.createElement(ps,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),rt.createElement(Tn,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:p},"Save Token"))))};import _t,{useState as na}from"react";Ce();import Un,{useState as jN,useEffect as HN,useCallback as WN}from"react";import{styled as lo,keyframes as gk}from"storybook/theming";var VN=gk({from:{opacity:0},to:{opacity:1}}),GN=gk({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(""),p=!!s&&c!==s,g=WN(d=>{d.key==="Escape"&&u()},[u]);return HN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?Un.createElement(Un.Fragment,null,Un.createElement(qN,{onClick:u}),Un.createElement(YN,{role:"dialog","aria-modal":"true","aria-label":t},Un.createElement(KN,null,t),Un.createElement(XN,null,n),s&&Un.createElement(Un.Fragment,null,Un.createElement(ZN,null,"Type ",Un.createElement("strong",null,s)," to confirm:"),Un.createElement(JN,{type:"text",value:c,onChange:d=>l(d.target.value),placeholder:s,autoFocus:!0})),Un.createElement(QN,null,Un.createElement(eO,{onClick:u},o),Un.createElement(tO,{variant:i,onClick:a,disabled:p},r)))):null};import{styled as fr}from"storybook/theming";var nO=fr.div({marginBottom:"30px"}),rO=fr.div({display:"flex",gap:"8px",alignItems:"center"}),oO=fr(xn)({flex:1}),iO=fr(on)({padding:"8px 12px",whiteSpace:"nowrap"}),sO=fr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Dm=fr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Rm=fr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),zm=fr(ps)({fontSize:"13px",padding:"6px 8px"}),aO=fr.div({display:"flex",gap:"8px",marginTop:"12px"}),fk=fr(on)({fontSize:"12px",padding:"6px 12px"}),lO=fr(fk)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),cO=fr.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"}})),mk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=io(),{currentStorybookPath:s}=Je(),[a,u]=na(!1),[c,l]=na(!1),[p,g]=na(!1),[d,f]=na(!1),[k,T]=na({name:"",storybookRoot:"",figmaFileUrl:""}),E=e.find(z=>z.id===t),I=z=>{n(z||null),u(!1)},D=async()=>{if(t)try{f(!0),await i(t),g(!1)}catch(z){console.error("Failed to delete project:",z)}finally{f(!1)}},R=()=>{if(u(!0),s){let z=s.replace(/\/+$/,"").split("/").pop()||"";T({storybookRoot:s,name:z,figmaFileUrl:""})}},$=async()=>{if(k.name.trim())try{l(!0);let z;if(k.figmaFileUrl.trim()){let w=k.figmaFileUrl.trim(),v=w.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);z=v?v[1]:w}let x=await o({name:k.name.trim(),storybookRoot:k.storybookRoot.trim()||void 0,figmaFileId:z});n(x.id),u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}catch(z){console.error("Failed to create project:",z)}finally{l(!1)}},P=z=>{T(x=>{let w={...x,storybookRoot:z};if(!x.name&&z){let v=z.replace(/\/+$/,"").split("/").pop()||"";w.name=v}return w})};return _t.createElement(nO,null,_t.createElement(uy,null,"Project"),_t.createElement(rO,null,_t.createElement(oO,{value:t||"",onChange:z=>I(z.target.value),disabled:r||a},_t.createElement("option",{value:""},"-- Select a project --"),e.map(z=>_t.createElement("option",{key:z.id,value:z.id},z.name))),_t.createElement(iO,{onClick:R,disabled:r,type:"button"},"+ New"),_t.createElement(cO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),_t.createElement(jr,{isOpen:p,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${E?.name||"this project"}". This cannot be undone.`,confirmLabel:d?"Deleting...":"Delete",confirmText:E?.name,variant:"danger",onConfirm:D,onCancel:()=>g(!1)}),a&&_t.createElement(sO,null,_t.createElement(Dm,null,_t.createElement(Rm,null,"Storybook Path (for fix generation)"),_t.createElement(zm,{type:"text",placeholder:"/path/to/your/storybook",value:k.storybookRoot,onChange:z=>P(z.target.value)})),_t.createElement(Dm,null,_t.createElement(Rm,null,"Project Name *"),_t.createElement(zm,{type:"text",placeholder:"my-storybook",value:k.name,onChange:z=>{let x=z.target.value;T(w=>({...w,name:x}))}})),_t.createElement(Dm,null,_t.createElement(Rm,null,"Figma File URL (for design comparison)"),_t.createElement(zm,{type:"text",placeholder:"https://www.figma.com/file/...",value:k.figmaFileUrl,onChange:z=>{let x=z.target.value;T(w=>({...w,figmaFileUrl:x}))}})),_t.createElement(aO,null,_t.createElement(fk,{onClick:$,disabled:c||!k.name.trim()},c?"Creating...":"Create"),_t.createElement(lO,{onClick:()=>{u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import bt,{useState as xc,useCallback as qC,useEffect as m4}from"react";import{styled as Pr}from"storybook/theming";import Hr,{useState as ra,useEffect as EO,useCallback as Om}from"react";import{styled as Lo}from"storybook/theming";Ce();He();ct();Ce();He();ct();import Wt,{useState as Nm}from"react";import{styled as jn,keyframes as uO}from"storybook/theming";var pO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},dO=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",gO=jn.div({position:"relative",display:"inline-flex"}),fO=uO`
|
|
31
31
|
0% { transform: rotate(0deg); }
|
|
32
32
|
100% { transform: rotate(360deg); }
|
|
33
|
-
`,
|
|
33
|
+
`,mO=jn.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}}}),hO=jn.span`
|
|
34
34
|
display: inline-block;
|
|
35
35
|
width: 10px;
|
|
36
36
|
height: 10px;
|
|
37
37
|
border: 2px solid rgba(255,255,255,0.3);
|
|
38
38
|
border-top-color: #fff;
|
|
39
39
|
border-radius: 50%;
|
|
40
|
-
animation: ${
|
|
41
|
-
`,hO=Un.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})),xO=Un.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),yO=Un.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),bO=Un.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()}}),SO=Un.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),wO=Un.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),vO=Un.span({display:"flex",alignItems:"center",gap:"4px"}),kO=Un.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),CO=Un.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),TO=Un.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),IO=Un.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"}})),hk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Je(),[n,r]=Nm(!1),[o,i]=Nm(!1),[s,a]=Nm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=V(),l=localStorage.getItem("uicopilot_session_token"),d=await ne(`${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?Ht.createElement(dO,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Ht.createElement(fO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Ht.createElement(Ht.Fragment,null,Ht.createElement(mO,null)," Checking..."):s?Ht.createElement(Ht.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Ht.createElement(Ht.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Ht.createElement(hO,null,Ht.createElement(xO,null,Ht.createElement(yO,null,"Figma Design Quality"),Ht.createElement(bO,{score:s.score},Math.round(s.score),"%")),Ht.createElement(SO,null,Object.entries(s.categories).map(([c,l])=>Ht.createElement(wO,{key:c},Ht.createElement(vO,null,Ht.createElement(kO,{status:l.status},pO(l.status)),uO[c]||c),Ht.createElement(CO,null,l.score)))),s.summary&&Ht.createElement(TO,null,s.summary),s.recommendations?.length>0&&Ht.createElement(IO,null,s.recommendations.slice(0,2).map((c,l)=>Ht.createElement("li",{key:l},c))))):null};var EO=Lo.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),AO=Lo.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),PO=Lo.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),LO=Lo.div({display:"flex",gap:"8px",alignItems:"center"}),MO=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:oe,boxShadow:`0 0 0 1px ${oe}`},"&::placeholder":{color:e.color.mediumlight}})),BO=Lo(rn)({whiteSpace:"nowrap"}),DO=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"}})),RO=Lo.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),xk=()=>{let{selectedProjectId:e,projects:t}=Je(),{sessionToken:n}=we(),{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||"";FO(()=>{s(d),l(null)},[o?.id,d]);let g=i!==d,p=Om(async()=>{if(!(!e||!g))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let R=V();try{await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}ne(`${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]),f=Om(R=>{R.key==="Enter"&&g&&!a&&p()},[g,a,p]),[k,T]=ra(!1),[E,I]=ra(!1),D=Om(async()=>{if(!(!e||!n))try{I(!0),await r(e,{figmaFileUrl:""});let R=V();await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),await ne(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),s(""),T(!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{I(!1)}},[e,n,r]);return e?Hr.createElement(EO,null,Hr.createElement(AO,null,Hr.createElement(PO,null,"Figma File URL"),Hr.createElement(hk,{figmaFileUrl:d})),Hr.createElement(LO,null,Hr.createElement(MO,{type:"text",value:i,onChange:R=>s(R.target.value),onKeyDown:f,placeholder:"https://www.figma.com/file/..."}),Hr.createElement(BO,{onClick:p,disabled:!g||a},a?"Saving...":"Save"),d&&Hr.createElement(DO,{onClick:()=>T(!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:E?"Removing...":"Remove",variant:"danger",onConfirm:D,onCancel:()=>T(!1)}),c&&Hr.createElement(RO,{variant:c.type},c.message)):null};import kt,{useState as dc,useEffect as G$}from"react";import{styled as tr}from"storybook/theming";Ce();He();import et,{useState as Wi,useEffect as E$,useCallback as Ro}from"react";import{styled as Zt}from"storybook/theming";He();He();$e();import Q,{useState as ji,useEffect as oC,useMemo as Qm,useCallback as iC}from"react";import{styled as Ye}from"storybook/theming";ct();import ze,{useState as rC,useEffect as zO,memo as NO}from"react";import{styled as ye}from"storybook/theming";var yk=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}),bk=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}`})),Sk=ye.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),wk=ye.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),vk=ye(Cn)({fontSize:"20px",padding:"4px 8px"}),kk=ye.div({flex:1,overflow:"auto",padding:"20px"}),Ck=ye(So)({fontSize:"14px",marginBottom:"16px"}),_m=ye.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Tk=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:oe,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),$m=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"})),Ik=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.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})),Um=ye.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:oe,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"})),jm=ye.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Hm=ye.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Wm=ye.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Vm=ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Ek=ye.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Zl=ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Ak=ye.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Pk=ye.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),Lk=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:oe}})),Mk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${oe}`,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:oe,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Bk=ye.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:oe,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),Dk=ye.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),yte=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"})),Rk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${oe}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),zk=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%"}}})),Gm=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"}})),Nk=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})),Ok=ye.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),_k=ye.span(({theme:e})=>({color:e.color.defaultText})),ec=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%"}}})),$k=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),Uk=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}`})),jk=ye.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),Hk=ye(hn)({flex:1,width:"auto"}),Wk=ye.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),Vk=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"})),Gk=ye.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),qk=ye.span(({theme:e})=>({color:e.color.defaultText})),Yk=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}})),Kk=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}})),Xk=ye.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),tc=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})),Ui=ye(hn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),nc=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`}})),Qk=ye.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),Jk=ye.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:oe,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),Zk=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),qm=ye.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?oe: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:oe,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Ym=ye.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?oe:e.appBorderColor}`,backgroundColor:t?oe:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),eC=ye.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),tC=ye.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:oe,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:oe,opacity:t?.6:.9}})),nC=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 OO}from"storybook/theming";var _O=OO.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}})),Km=NO(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=rC(!1),[a,u]=rC(!1);return zO(()=>{s(!1),u(!1)},[e]),i?ze.createElement(oa,null,ze.createElement(jm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),ze.createElement(ia,null,"Failed to load")):e?ze.createElement(ze.Fragment,null,!a&&ze.createElement(oa,{style:{position:"absolute",inset:0}},ze.createElement(Um,null),ze.createElement(ia,null,"Loading...")),ze.createElement(Fk,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?ze.createElement(oa,null,ze.createElement(jm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),ze.createElement(ia,null,o?"Render failed":"No preview")):ze.createElement(oa,null,ze.createElement(Um,null),ze.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:f=1,onShowMore:k})=>{let E=e.type==="COMPONENT_SET",I=E&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],R=ze.useMemo(()=>D.length===0?[]:p.some(z=>z.value)?D.filter(z=>z.variantProperties?p.every(x=>x.value?z.variantProperties?.[x.property]===x.value:!0):!1):D,[D,p]),$=z=>{if(E){c(e.id,z);return}l(e)},P=d?qm:Tk;return ze.createElement(ze.Fragment,null,ze.createElement(P,{onClick:$,title:e.name,isSelected:d?g.has(e.id):void 0,style:{cursor:"pointer"}},d&&!I&&ze.createElement(Ym,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),E?ze.createElement(Ik,null,I&&ze.createElement(Lk,{onClick:z=>c(e.id,z),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),I&&ze.createElement(Bk,null,R.length>0&&R.length!==D.length?`${R.length} / ${D.length}`:e.childCount??D.length," ","variants"),ze.createElement(Km,{src:t,alt:e.name,isComponentSet:!0})):ze.createElement($m,null,ze.createElement(Km,{src:t,alt:e.name,isComponentSet:!1})),ze.createElement(Hm,null,ze.createElement(Wm,null,e.name,u&&ze.createElement(nC,null,"New")),ze.createElement(Vm,null,e.type))),I&&a&&s&&ze.createElement(ze.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((z,x)=>ze.createElement(Rk,{key:`skeleton-${x}`},ze.createElement(zk,null),ze.createElement(Gm,{width:"80%"}),ze.createElement(Gm,{width:"50%"})))),I&&a&&!s&&R.slice(0,f*50).map(z=>ze.createElement(Xm,{key:z.id,variant:z,thumbnail:r?.[z.id]||n[z.id],onSelect:l,multiSelect:d,isSelected:g.has(z.id),loadingDone:!!t||r!==void 0&&z.id in(r||{}),failed:i?.has(z.id)})),I&&a&&!s&&R.length>f*50&&ze.createElement(_O,{onClick:()=>k?.(e.id)},"Show more (",R.length-f*50," ","remaining)"))},Xm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>ze.createElement(r?qm:Mk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&ze.createElement(Ym,{isSelected:o},o?"\u2713":""),ze.createElement($m,null,ze.createElement(Km,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),ze.createElement(Hm,null,ze.createElement(Wm,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&ze.createElement(Dk,null,Object.entries(e.variantProperties).map(([c,l])=>ze.createElement(Nk,{key:c},ze.createElement(Ok,null,c,":")," ",ze.createElement(_k,null,l)))),ze.createElement(Vm,{style:{marginTop:"6px"}},"VARIANT")));var $O=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),UO=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),jO=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),sC=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),aC=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),rc=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),HO=Ye(hn)({flex:1,width:"auto"}),lC=Ye(So)({flex:1,fontSize:"13px"}),WO=Ye.div({flex:1,overflow:"auto",padding:"8px"}),VO=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}})),GO=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),qO=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),YO=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})),KO=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),XO=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"})),QO=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),JO=Ye.div({flex:1,overflow:"hidden"}),ZO=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),e_=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)"}}})),t_=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),n_=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),r_=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),o_=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Jm=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),i_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Zm=20,s_=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"})),a_=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`}})),l_=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),c_=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`}})),u_=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),eh=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),th=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),p_=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),d_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),cC=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),uC=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"}}})),pC=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"}}})),g_=()=>Q.createElement(d_,null,Array.from({length:8}).map((e,t)=>Q.createElement(cC,{key:t},Q.createElement(uC,null),Q.createElement(pC,{width:`${60+t%3*15}%`})))),f_=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"})),m_=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"}),h_=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)"}}})),x_=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),dC=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=ea({projectId:i,limit:Zm,enabled:!!i}),[a,u]=ji("all"),[c,l]=ji(""),[d,g]=ji(null),[p,f]=ji(1),[k,T]=ji(null),[E,I]=ji(!1),D=Qm(()=>{let m=new Set;return e.forEach(F=>{F.componentTitle&&m.add(F.componentTitle)}),Array.from(m).sort()},[e]),R=Qm(()=>e.filter(m=>{if(a!=="all"&&m.componentTitle!==a)return!1;if(c){let F=c.toLowerCase();return m.name.toLowerCase().includes(F)||m.title.toLowerCase().includes(F)}return!0}),[e,a,c]),$=d?s.frames.find(m=>m.id===d):null,P=Qm(()=>{if(!d)return[];let m=s.variantChildren[d]||[];return m.length===0?[]:s.variantFilters.some(F=>F.value)?m.filter(F=>F.variantProperties?s.variantFilters.every(S=>S.value?F.variantProperties?.[S.property]===S.value:!0):!1):m},[d,s.variantChildren,s.variantFilters]),z=P.slice(0,p*Zm),x=P.length>p*Zm;oC(()=>{if(!d||z.length===0)return;let m=z.map(F=>F.id);s.fetchVariantThumbnails(d,m)},[d,z.length,p]),oC(()=>{I(!1)},[]);let w=iC(async m=>{if(n)try{let F=V(),S=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${F}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:m.id,name:m.name})})).ok)throw new Error("Failed to save mapping");o(n,m.id,m.name)}catch(F){y.error("[MapStoriesTab] Error saving mapping:",F)}},[n,i,o]),v=iC((m,F)=>{if(F.stopPropagation(),d===m){g(null),f(1);return}g(m),f(1),!s.variantThumbnails[m]&&!s.loadingVariants.has(m)&&s.toggleExpanded(m,F)},[d,s]),C=e.find(m=>m.id===n);return t?Q.createElement(p_,null,"Loading stories..."):Q.createElement($O,null,Q.createElement(UO,null,Q.createElement(sC,null,Q.createElement(aC,null,"Storybook Stories"),Q.createElement(rc,null,Q.createElement(HO,{value:a,onChange:m=>u(m.target.value)},Q.createElement("option",{value:"all"},"All Components"),D.map(m=>Q.createElement("option",{key:m,value:m},m)))),Q.createElement(rc,null,Q.createElement(lC,{type:"text",placeholder:"Search stories...",value:c,onChange:m=>l(m.target.value)}))),Q.createElement(WO,null,R.length===0?Q.createElement(th,null,"No stories found"):R.map(m=>Q.createElement(VO,{key:m.id,selected:m.id===n,mapped:!!m.figmaMapping,onClick:()=>r(m.id)},Q.createElement(GO,null,Q.createElement(qO,null,m.name),Q.createElement(YO,{mapped:!!m.figmaMapping},m.figmaMapping?"Mapped":"Unmapped")),Q.createElement(KO,null,m.title),m.figmaMapping&&Q.createElement(XO,{onMouseEnter:()=>T(m.id),onMouseLeave:()=>T(null)},(()=>{let F=m.figmaMapping?.figmaNodeId,S=F?s.resolveThumbnail(F):void 0;return Q.createElement(Q.Fragment,null,S?Q.createElement(QO,{src:S,alt:m.figmaMapping?.figmaFrameName||""}):Q.createElement("span",null,"\u{1F517}"),k===m.id&&S&&Q.createElement(e_,null,Q.createElement(t_,{src:S,alt:m.figmaMapping?.figmaFrameName||""}),Q.createElement(n_,null,m.figmaMapping?.figmaFrameName)))})(),Q.createElement(JO,null,Q.createElement(ZO,null,m.figmaMapping.figmaFrameName))))))),Q.createElement(jO,null,n?Q.createElement(Q.Fragment,null,Q.createElement(f_,null,Q.createElement("span",null,"Click a Figma component below to link it to"," ",Q.createElement("strong",null,C?.name))),Q.createElement(sC,null,Q.createElement(aC,null,"Figma Components"),Q.createElement(rc,null,Q.createElement(o_,null,Q.createElement(Jm,null,Q.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:m=>s.setShowComponentSets(m.target.checked)}),"Component Sets"),Q.createElement(Jm,null,Q.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:m=>s.setShowFrames(m.target.checked)}),"Frames"),Q.createElement(Jm,null,Q.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:m=>s.setShowComponents(m.target.checked)}),"Components")),s.availablePages.length>1&&Q.createElement(Ui,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:m=>s.setFigmaPage(m.target.value)},Q.createElement("option",{value:""},"All pages"),s.availablePages.map(m=>Q.createElement("option",{key:m,value:m},m)))),s.availableFilters.length>0&&Q.createElement(tc,null,Q.createElement(sa,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:m,values:F})=>{let S=s.variantFilters.find(b=>b.property===m);return Q.createElement(Ui,{key:m,isActive:!!S?.value,value:S?.value||"",onChange:b=>s.handleFilterChange(m,b.target.value)},Q.createElement("option",{value:""},m),F.map(b=>Q.createElement("option",{key:b,value:b},m,"=",b)))}),s.availableFilters.length>5&&Q.createElement(sa,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(m=>m.value)&&Q.createElement(nc,{onClick:s.clearFilters},"Clear All")),Q.createElement(rc,null,Q.createElement(lC,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:m=>s.setSearch(m.target.value)}))),Q.createElement(r_,null,E&&Q.createElement(m_,null,Q.createElement(h_,null),Q.createElement(x_,null,"Loading thumbnails...")),s.isLoading?Q.createElement(g_,null):s.filteredFrames.length===0?Q.createElement(th,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(i_,null,d&&$?Q.createElement(Q.Fragment,null,Q.createElement(l_,null,Q.createElement(c_,{onClick:()=>{g(null),f(1)}},"Back"),Q.createElement(u_,null,$.name)),s.loadingVariants.has(d)?Q.createElement(Q.Fragment,null,Q.createElement(eh,null,"Loading ",$.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,$.childCount??8)}).map((m,F)=>Q.createElement(cC,{key:`variant-skeleton-${F}`},Q.createElement(uC,null),Q.createElement(pC,{width:`${60+F%3*15}%`})))):Q.createElement(Q.Fragment,null,Q.createElement(eh,null,"Showing ",z.length," of"," ",P.length," variants"),z.map(m=>Q.createElement(Xm,{key:m.id,variant:m,thumbnail:s.variantThumbnails[d]?.[m.id]||s.thumbnails[m.id],onSelect:w,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d),failed:s.variantFailed[d]?.has(m.id)})))):Q.createElement(Q.Fragment,null,Q.createElement(eh,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(m=>Q.createElement(aa,{key:m.id,frame:m,thumbnail:s.thumbnails[m.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[m.id],variantChildren:s.variantChildren[m.id],variantFailed:s.variantFailed[m.id],isLoadingVariants:s.loadingVariants.has(m.id),isExpanded:!1,onToggleExpand:v,onSelect:w,variantFilters:s.variantFilters}))),(d?x:s.hasMore)&&Q.createElement(s_,null,Q.createElement(a_,{disabled:s.loadingMore,onClick:async()=>{d?f(m=>m+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Q.createElement(th,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 nh,useMemo as gC,useCallback as fC}from"react";import{styled as Nt}from"storybook/theming";ct();var y_=Nt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),b_=Nt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),S_=Nt(hn)({width:"auto",minWidth:"200px"}),w_=Nt(So)({fontSize:"13px",minWidth:"250px"}),v_=Nt.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}})),k_=Nt.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}})),C_=Nt.div({flex:1,overflow:"auto"}),T_=Nt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),I_=Nt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),oc=Nt.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}`})),F_=Nt.tbody({}),E_=Nt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),ic=Nt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),A_=Nt.div({display:"flex",flexDirection:"column",gap:"2px"}),P_=Nt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),L_=Nt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),M_=Nt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),B_=Nt.div({display:"flex",alignItems:"center",gap:"8px"}),D_=Nt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),R_=Nt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),mC=Nt.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`}})),z_=Nt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),N_=Nt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),hC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=nh("all"),[a,u]=nh(""),[c,l]=nh(!0),d=gC(()=>{let T=new Set;return e.forEach(E=>{E.componentTitle&&T.add(E.componentTitle)}),Array.from(T).sort()},[e]),g=gC(()=>e.filter(T=>{if(i!=="all"&&T.componentTitle!==i||!c&&!T.figmaMapping)return!1;if(a){let E=a.toLowerCase();return T.name.toLowerCase().includes(E)||T.title.toLowerCase().includes(E)||(T.figmaMapping?.figmaFrameName?.toLowerCase().includes(E)??!1)}return!0}),[e,i,a,c]),p=fC(async T=>{try{let E=V(),I=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${E}/api/mappings?projectId=${o}&storyId=${T}`,{method:"DELETE",headers:{Authorization:`Bearer ${I}`}})).ok)throw new Error("Failed to delete mapping");r(T)}catch(E){console.error("[ViewAllMappingsTab] Error unlinking:",E)}},[o,r]),f=fC(()=>{let T=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),E=new Blob([JSON.stringify(T,null,2)],{type:"application/json"}),I=URL.createObjectURL(E),D=document.createElement("a");D.href=I,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(I)},[e]);if(t)return ot.createElement(N_,null,"Loading mappings...");let k=e.filter(T=>T.figmaMapping).length;return ot.createElement(y_,null,ot.createElement(b_,null,ot.createElement(S_,{value:i,onChange:T=>s(T.target.value)},ot.createElement("option",{value:"all"},"All Components"),d.map(T=>ot.createElement("option",{key:T,value:T},T))),ot.createElement(w_,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:T=>u(T.target.value)}),ot.createElement(v_,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),ot.createElement(k_,{onClick:f,disabled:k===0},"\u{1F4E5} Export JSON")),g.length===0?ot.createElement(z_,null,ot.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):ot.createElement(C_,null,ot.createElement(T_,null,ot.createElement(I_,null,ot.createElement("tr",null,ot.createElement(oc,{style:{width:"35%"}},"Story"),ot.createElement(oc,{style:{width:"35%"}},"Figma Component"),ot.createElement(oc,{style:{width:"15%"}},"Status"),ot.createElement(oc,{style:{width:"15%"}},"Actions"))),ot.createElement(F_,null,g.map(T=>ot.createElement(E_,{key:T.id,mapped:!!T.figmaMapping},ot.createElement(ic,null,ot.createElement(A_,null,ot.createElement(P_,null,T.name),ot.createElement(L_,null,T.title))),ot.createElement(ic,null,ot.createElement(M_,{mapped:!!T.figmaMapping},T.figmaMapping?ot.createElement(ot.Fragment,null,ot.createElement("span",null,"\u{1F3A8}"),T.figmaMapping.figmaFrameName):"\u2014")),ot.createElement(ic,null,ot.createElement(B_,null,ot.createElement(D_,{mapped:!!T.figmaMapping}),ot.createElement(R_,{mapped:!!T.figmaMapping},T.figmaMapping?"Mapped":"Unmapped"))),ot.createElement(ic,null,T.figmaMapping?ot.createElement(mC,{variant:"unlink",onClick:()=>p(T.id)},"Unlink"):ot.createElement(mC,{variant:"link",onClick:()=>n(T.id)},"Link"))))))))};import Fe,{useState as pc,useMemo as kC}from"react";import{styled as dt}from"storybook/theming";import xC from"react";import{styled as yC,keyframes as O_}from"storybook/theming";var __=O_`
|
|
40
|
+
animation: ${fO} 0.8s linear infinite;
|
|
41
|
+
`,xO=jn.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})),yO=jn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),bO=jn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),SO=jn.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()}}),wO=jn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),vO=jn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),kO=jn.span({display:"flex",alignItems:"center",gap:"4px"}),CO=jn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),TO=jn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),IO=jn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),FO=jn.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"}})),hk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Je(),[n,r]=Nm(!1),[o,i]=Nm(!1),[s,a]=Nm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=V(),l=localStorage.getItem("uicopilot_session_token"),p=await ne(`${c}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({projectId:t,figmaFileUrl:e,figmaMetadata:{}})});if(!p.ok)throw new Error("Failed to check quality");let g=await p.json();a(g),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Wt.createElement(gO,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Wt.createElement(mO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Wt.createElement(Wt.Fragment,null,Wt.createElement(hO,null)," Checking..."):s?Wt.createElement(Wt.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Wt.createElement(Wt.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Wt.createElement(xO,null,Wt.createElement(yO,null,Wt.createElement(bO,null,"Figma Design Quality"),Wt.createElement(SO,{score:s.score},Math.round(s.score),"%")),Wt.createElement(wO,null,Object.entries(s.categories).map(([c,l])=>Wt.createElement(vO,{key:c},Wt.createElement(kO,null,Wt.createElement(CO,{status:l.status},dO(l.status)),pO[c]||c),Wt.createElement(TO,null,l.score)))),s.summary&&Wt.createElement(IO,null,s.summary),s.recommendations?.length>0&&Wt.createElement(FO,null,s.recommendations.slice(0,2).map((c,l)=>Wt.createElement("li",{key:l},c))))):null};var AO=Lo.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),PO=Lo.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),LO=Lo.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),MO=Lo.div({display:"flex",gap:"8px",alignItems:"center"}),BO=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:ae,boxShadow:`0 0 0 1px ${ae}`},"&::placeholder":{color:e.color.mediumlight}})),DO=Lo(on)({whiteSpace:"nowrap"}),RO=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"}})),zO=Lo.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),xk=()=>{let{selectedProjectId:e,projects:t}=Je(),{sessionToken:n}=we(),{updateProject:r}=io(),o=t.find(R=>R.id===e),[i,s]=ra(""),[a,u]=ra(!1),[c,l]=ra(null),p=o?.figmaFileUrl||o?.figmaFileId||"";EO(()=>{s(p),l(null)},[o?.id,p]);let g=i!==p,d=Om(async()=>{if(!(!e||!g))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let R=V();try{await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}ne(`${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]),f=Om(R=>{R.key==="Enter"&&g&&!a&&d()},[g,a,d]),[k,T]=ra(!1),[E,I]=ra(!1),D=Om(async()=>{if(!(!e||!n))try{I(!0),await r(e,{figmaFileUrl:""});let R=V();await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),await ne(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),s(""),T(!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{I(!1)}},[e,n,r]);return e?Hr.createElement(AO,null,Hr.createElement(PO,null,Hr.createElement(LO,null,"Figma File URL"),Hr.createElement(hk,{figmaFileUrl:p})),Hr.createElement(MO,null,Hr.createElement(BO,{type:"text",value:i,onChange:R=>s(R.target.value),onKeyDown:f,placeholder:"https://www.figma.com/file/..."}),Hr.createElement(DO,{onClick:d,disabled:!g||a},a?"Saving...":"Save"),p&&Hr.createElement(RO,{onClick:()=>T(!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:E?"Removing...":"Remove",variant:"danger",onConfirm:D,onCancel:()=>T(!1)}),c&&Hr.createElement(zO,{variant:c.type},c.message)):null};import Ct,{useState as dc,useEffect as q$}from"react";import{styled as tr}from"storybook/theming";Ce();He();import et,{useState as Wi,useEffect as A$,useCallback as Ro}from"react";import{styled as en}from"storybook/theming";He();He();$e();import Q,{useState as ji,useEffect as oC,useMemo as Qm,useCallback as iC}from"react";import{styled as Ye}from"storybook/theming";ct();import ze,{useState as rC,useEffect as NO,memo as OO}from"react";import{styled as ye}from"storybook/theming";var yk=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}),bk=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}`})),Sk=ye.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),wk=ye.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),vk=ye(In)({fontSize:"20px",padding:"4px 8px"}),kk=ye.div({flex:1,overflow:"auto",padding:"20px"}),Ck=ye(So)({fontSize:"14px",marginBottom:"16px"}),_m=ye.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Tk=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:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),$m=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"})),Ik=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.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})),Um=ye.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:ae,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"})),jm=ye.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Hm=ye.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Wm=ye.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Vm=ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Ek=ye.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Zl=ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Ak=ye.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Pk=ye.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),Lk=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:ae}})),Mk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ae}`,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:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Bk=ye.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:ae,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),Dk=ye.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),Tte=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"})),Rk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ae}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),zk=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%"}}})),Gm=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"}})),Nk=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})),Ok=ye.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),_k=ye.span(({theme:e})=>({color:e.color.defaultText})),ec=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%"}}})),$k=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),Uk=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}`})),jk=ye.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),Hk=ye(xn)({flex:1,width:"auto"}),Wk=ye.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),Vk=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"})),Gk=ye.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),qk=ye.span(({theme:e})=>({color:e.color.defaultText})),Yk=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}})),Kk=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}})),Xk=ye.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),tc=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})),Ui=ye(xn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),nc=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`}})),Qk=ye.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),Jk=ye.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),Zk=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),qm=ye.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?ae: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:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Ym=ye.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?ae:e.appBorderColor}`,backgroundColor:t?ae:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),eC=ye.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),tC=ye.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:ae,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:ae,opacity:t?.6:.9}})),nC=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 _O}from"storybook/theming";var $O=_O.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}})),Km=OO(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=rC(!1),[a,u]=rC(!1);return NO(()=>{s(!1),u(!1)},[e]),i?ze.createElement(oa,null,ze.createElement(jm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),ze.createElement(ia,null,"Failed to load")):e?ze.createElement(ze.Fragment,null,!a&&ze.createElement(oa,{style:{position:"absolute",inset:0}},ze.createElement(Um,null),ze.createElement(ia,null,"Loading...")),ze.createElement(Fk,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?ze.createElement(oa,null,ze.createElement(jm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),ze.createElement(ia,null,o?"Render failed":"No preview")):ze.createElement(oa,null,ze.createElement(Um,null),ze.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:p=!1,selectedFrames:g=new Set,variantFilters:d=[],variantPage:f=1,onShowMore:k})=>{let E=e.type==="COMPONENT_SET",I=E&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],R=ze.useMemo(()=>D.length===0?[]:d.some(z=>z.value)?D.filter(z=>z.variantProperties?d.every(x=>x.value?z.variantProperties?.[x.property]===x.value:!0):!1):D,[D,d]),$=z=>{if(E){c(e.id,z);return}l(e)},P=p?qm:Tk;return ze.createElement(ze.Fragment,null,ze.createElement(P,{onClick:$,title:e.name,isSelected:p?g.has(e.id):void 0,style:{cursor:"pointer"}},p&&!I&&ze.createElement(Ym,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),E?ze.createElement(Ik,null,I&&ze.createElement(Lk,{onClick:z=>c(e.id,z),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),I&&ze.createElement(Bk,null,R.length>0&&R.length!==D.length?`${R.length} / ${D.length}`:e.childCount??D.length," ","variants"),ze.createElement(Km,{src:t,alt:e.name,isComponentSet:!0})):ze.createElement($m,null,ze.createElement(Km,{src:t,alt:e.name,isComponentSet:!1})),ze.createElement(Hm,null,ze.createElement(Wm,null,e.name,u&&ze.createElement(nC,null,"New")),ze.createElement(Vm,null,e.type))),I&&a&&s&&ze.createElement(ze.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((z,x)=>ze.createElement(Rk,{key:`skeleton-${x}`},ze.createElement(zk,null),ze.createElement(Gm,{width:"80%"}),ze.createElement(Gm,{width:"50%"})))),I&&a&&!s&&R.slice(0,f*50).map(z=>ze.createElement(Xm,{key:z.id,variant:z,thumbnail:r?.[z.id]||n[z.id],onSelect:l,multiSelect:p,isSelected:g.has(z.id),loadingDone:!!t||r!==void 0&&z.id in(r||{}),failed:i?.has(z.id)})),I&&a&&!s&&R.length>f*50&&ze.createElement($O,{onClick:()=>k?.(e.id)},"Show more (",R.length-f*50," ","remaining)"))},Xm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>ze.createElement(r?qm:Mk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&ze.createElement(Ym,{isSelected:o},o?"\u2713":""),ze.createElement($m,null,ze.createElement(Km,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),ze.createElement(Hm,null,ze.createElement(Wm,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&ze.createElement(Dk,null,Object.entries(e.variantProperties).map(([c,l])=>ze.createElement(Nk,{key:c},ze.createElement(Ok,null,c,":")," ",ze.createElement(_k,null,l)))),ze.createElement(Vm,{style:{marginTop:"6px"}},"VARIANT")));var UO=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),jO=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),HO=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),sC=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),aC=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),rc=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),WO=Ye(xn)({flex:1,width:"auto"}),lC=Ye(So)({flex:1,fontSize:"13px"}),VO=Ye.div({flex:1,overflow:"auto",padding:"8px"}),GO=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}})),qO=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),YO=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),KO=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})),XO=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),QO=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"})),JO=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),ZO=Ye.div({flex:1,overflow:"hidden"}),e_=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),t_=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)"}}})),n_=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),r_=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),o_=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),i_=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Jm=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),s_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Zm=20,a_=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"})),l_=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`}})),c_=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),u_=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`}})),p_=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),eh=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),th=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),d_=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),g_=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),cC=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),uC=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"}}})),pC=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"}}})),f_=()=>Q.createElement(g_,null,Array.from({length:8}).map((e,t)=>Q.createElement(cC,{key:t},Q.createElement(uC,null),Q.createElement(pC,{width:`${60+t%3*15}%`})))),m_=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"})),h_=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"}),x_=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)"}}})),y_=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),dC=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=ea({projectId:i,limit:Zm,enabled:!!i}),[a,u]=ji("all"),[c,l]=ji(""),[p,g]=ji(null),[d,f]=ji(1),[k,T]=ji(null),[E,I]=ji(!1),D=Qm(()=>{let m=new Set;return e.forEach(F=>{F.componentTitle&&m.add(F.componentTitle)}),Array.from(m).sort()},[e]),R=Qm(()=>e.filter(m=>{if(a!=="all"&&m.componentTitle!==a)return!1;if(c){let F=c.toLowerCase();return m.name.toLowerCase().includes(F)||m.title.toLowerCase().includes(F)}return!0}),[e,a,c]),$=p?s.frames.find(m=>m.id===p):null,P=Qm(()=>{if(!p)return[];let m=s.variantChildren[p]||[];return m.length===0?[]:s.variantFilters.some(F=>F.value)?m.filter(F=>F.variantProperties?s.variantFilters.every(S=>S.value?F.variantProperties?.[S.property]===S.value:!0):!1):m},[p,s.variantChildren,s.variantFilters]),z=P.slice(0,d*Zm),x=P.length>d*Zm;oC(()=>{if(!p||z.length===0)return;let m=z.map(F=>F.id);s.fetchVariantThumbnails(p,m)},[p,z.length,d]),oC(()=>{I(!1)},[]);let w=iC(async m=>{if(n)try{let F=V(),S=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${F}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:m.id,name:m.name})})).ok)throw new Error("Failed to save mapping");o(n,m.id,m.name)}catch(F){y.error("[MapStoriesTab] Error saving mapping:",F)}},[n,i,o]),v=iC((m,F)=>{if(F.stopPropagation(),p===m){g(null),f(1);return}g(m),f(1),!s.variantThumbnails[m]&&!s.loadingVariants.has(m)&&s.toggleExpanded(m,F)},[p,s]),C=e.find(m=>m.id===n);return t?Q.createElement(d_,null,"Loading stories..."):Q.createElement(UO,null,Q.createElement(jO,null,Q.createElement(sC,null,Q.createElement(aC,null,"Storybook Stories"),Q.createElement(rc,null,Q.createElement(WO,{value:a,onChange:m=>u(m.target.value)},Q.createElement("option",{value:"all"},"All Components"),D.map(m=>Q.createElement("option",{key:m,value:m},m)))),Q.createElement(rc,null,Q.createElement(lC,{type:"text",placeholder:"Search stories...",value:c,onChange:m=>l(m.target.value)}))),Q.createElement(VO,null,R.length===0?Q.createElement(th,null,"No stories found"):R.map(m=>Q.createElement(GO,{key:m.id,selected:m.id===n,mapped:!!m.figmaMapping,onClick:()=>r(m.id)},Q.createElement(qO,null,Q.createElement(YO,null,m.name),Q.createElement(KO,{mapped:!!m.figmaMapping},m.figmaMapping?"Mapped":"Unmapped")),Q.createElement(XO,null,m.title),m.figmaMapping&&Q.createElement(QO,{onMouseEnter:()=>T(m.id),onMouseLeave:()=>T(null)},(()=>{let F=m.figmaMapping?.figmaNodeId,S=F?s.resolveThumbnail(F):void 0;return Q.createElement(Q.Fragment,null,S?Q.createElement(JO,{src:S,alt:m.figmaMapping?.figmaFrameName||""}):Q.createElement("span",null,"\u{1F517}"),k===m.id&&S&&Q.createElement(t_,null,Q.createElement(n_,{src:S,alt:m.figmaMapping?.figmaFrameName||""}),Q.createElement(r_,null,m.figmaMapping?.figmaFrameName)))})(),Q.createElement(ZO,null,Q.createElement(e_,null,m.figmaMapping.figmaFrameName))))))),Q.createElement(HO,null,n?Q.createElement(Q.Fragment,null,Q.createElement(m_,null,Q.createElement("span",null,"Click a Figma component below to link it to"," ",Q.createElement("strong",null,C?.name))),Q.createElement(sC,null,Q.createElement(aC,null,"Figma Components"),Q.createElement(rc,null,Q.createElement(i_,null,Q.createElement(Jm,null,Q.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:m=>s.setShowComponentSets(m.target.checked)}),"Component Sets"),Q.createElement(Jm,null,Q.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:m=>s.setShowFrames(m.target.checked)}),"Frames"),Q.createElement(Jm,null,Q.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:m=>s.setShowComponents(m.target.checked)}),"Components")),s.availablePages.length>1&&Q.createElement(Ui,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:m=>s.setFigmaPage(m.target.value)},Q.createElement("option",{value:""},"All pages"),s.availablePages.map(m=>Q.createElement("option",{key:m,value:m},m)))),s.availableFilters.length>0&&Q.createElement(tc,null,Q.createElement(sa,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:m,values:F})=>{let S=s.variantFilters.find(b=>b.property===m);return Q.createElement(Ui,{key:m,isActive:!!S?.value,value:S?.value||"",onChange:b=>s.handleFilterChange(m,b.target.value)},Q.createElement("option",{value:""},m),F.map(b=>Q.createElement("option",{key:b,value:b},m,"=",b)))}),s.availableFilters.length>5&&Q.createElement(sa,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(m=>m.value)&&Q.createElement(nc,{onClick:s.clearFilters},"Clear All")),Q.createElement(rc,null,Q.createElement(lC,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:m=>s.setSearch(m.target.value)}))),Q.createElement(o_,null,E&&Q.createElement(h_,null,Q.createElement(x_,null),Q.createElement(y_,null,"Loading thumbnails...")),s.isLoading?Q.createElement(f_,null):s.filteredFrames.length===0?Q.createElement(th,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(s_,null,p&&$?Q.createElement(Q.Fragment,null,Q.createElement(c_,null,Q.createElement(u_,{onClick:()=>{g(null),f(1)}},"Back"),Q.createElement(p_,null,$.name)),s.loadingVariants.has(p)?Q.createElement(Q.Fragment,null,Q.createElement(eh,null,"Loading ",$.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,$.childCount??8)}).map((m,F)=>Q.createElement(cC,{key:`variant-skeleton-${F}`},Q.createElement(uC,null),Q.createElement(pC,{width:`${60+F%3*15}%`})))):Q.createElement(Q.Fragment,null,Q.createElement(eh,null,"Showing ",z.length," of"," ",P.length," variants"),z.map(m=>Q.createElement(Xm,{key:m.id,variant:m,thumbnail:s.variantThumbnails[p]?.[m.id]||s.thumbnails[m.id],onSelect:w,loadingDone:s.variantThumbnails[p]!==void 0&&!s.loadingVariants.has(p),failed:s.variantFailed[p]?.has(m.id)})))):Q.createElement(Q.Fragment,null,Q.createElement(eh,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(m=>Q.createElement(aa,{key:m.id,frame:m,thumbnail:s.thumbnails[m.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[m.id],variantChildren:s.variantChildren[m.id],variantFailed:s.variantFailed[m.id],isLoadingVariants:s.loadingVariants.has(m.id),isExpanded:!1,onToggleExpand:v,onSelect:w,variantFilters:s.variantFilters}))),(p?x:s.hasMore)&&Q.createElement(a_,null,Q.createElement(l_,{disabled:s.loadingMore,onClick:async()=>{p?f(m=>m+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Q.createElement(th,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 nh,useMemo as gC,useCallback as fC}from"react";import{styled as Ot}from"storybook/theming";ct();var b_=Ot.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),S_=Ot.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),w_=Ot(xn)({width:"auto",minWidth:"200px"}),v_=Ot(So)({fontSize:"13px",minWidth:"250px"}),k_=Ot.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}})),C_=Ot.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}})),T_=Ot.div({flex:1,overflow:"auto"}),I_=Ot.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),F_=Ot.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),oc=Ot.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}`})),E_=Ot.tbody({}),A_=Ot.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),ic=Ot.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),P_=Ot.div({display:"flex",flexDirection:"column",gap:"2px"}),L_=Ot.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),M_=Ot.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),B_=Ot.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),D_=Ot.div({display:"flex",alignItems:"center",gap:"8px"}),R_=Ot.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),z_=Ot.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),mC=Ot.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`}})),N_=Ot.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),O_=Ot.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),hC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=nh("all"),[a,u]=nh(""),[c,l]=nh(!0),p=gC(()=>{let T=new Set;return e.forEach(E=>{E.componentTitle&&T.add(E.componentTitle)}),Array.from(T).sort()},[e]),g=gC(()=>e.filter(T=>{if(i!=="all"&&T.componentTitle!==i||!c&&!T.figmaMapping)return!1;if(a){let E=a.toLowerCase();return T.name.toLowerCase().includes(E)||T.title.toLowerCase().includes(E)||(T.figmaMapping?.figmaFrameName?.toLowerCase().includes(E)??!1)}return!0}),[e,i,a,c]),d=fC(async T=>{try{let E=V(),I=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${E}/api/mappings?projectId=${o}&storyId=${T}`,{method:"DELETE",headers:{Authorization:`Bearer ${I}`}})).ok)throw new Error("Failed to delete mapping");r(T)}catch(E){console.error("[ViewAllMappingsTab] Error unlinking:",E)}},[o,r]),f=fC(()=>{let T=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),E=new Blob([JSON.stringify(T,null,2)],{type:"application/json"}),I=URL.createObjectURL(E),D=document.createElement("a");D.href=I,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(I)},[e]);if(t)return ot.createElement(O_,null,"Loading mappings...");let k=e.filter(T=>T.figmaMapping).length;return ot.createElement(b_,null,ot.createElement(S_,null,ot.createElement(w_,{value:i,onChange:T=>s(T.target.value)},ot.createElement("option",{value:"all"},"All Components"),p.map(T=>ot.createElement("option",{key:T,value:T},T))),ot.createElement(v_,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:T=>u(T.target.value)}),ot.createElement(k_,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),ot.createElement(C_,{onClick:f,disabled:k===0},"\u{1F4E5} Export JSON")),g.length===0?ot.createElement(N_,null,ot.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):ot.createElement(T_,null,ot.createElement(I_,null,ot.createElement(F_,null,ot.createElement("tr",null,ot.createElement(oc,{style:{width:"35%"}},"Story"),ot.createElement(oc,{style:{width:"35%"}},"Figma Component"),ot.createElement(oc,{style:{width:"15%"}},"Status"),ot.createElement(oc,{style:{width:"15%"}},"Actions"))),ot.createElement(E_,null,g.map(T=>ot.createElement(A_,{key:T.id,mapped:!!T.figmaMapping},ot.createElement(ic,null,ot.createElement(P_,null,ot.createElement(L_,null,T.name),ot.createElement(M_,null,T.title))),ot.createElement(ic,null,ot.createElement(B_,{mapped:!!T.figmaMapping},T.figmaMapping?ot.createElement(ot.Fragment,null,ot.createElement("span",null,"\u{1F3A8}"),T.figmaMapping.figmaFrameName):"\u2014")),ot.createElement(ic,null,ot.createElement(D_,null,ot.createElement(R_,{mapped:!!T.figmaMapping}),ot.createElement(z_,{mapped:!!T.figmaMapping},T.figmaMapping?"Mapped":"Unmapped"))),ot.createElement(ic,null,T.figmaMapping?ot.createElement(mC,{variant:"unlink",onClick:()=>d(T.id)},"Unlink"):ot.createElement(mC,{variant:"link",onClick:()=>n(T.id)},"Link"))))))))};import Fe,{useState as pc,useMemo as kC}from"react";import{styled as gt}from"storybook/theming";import xC from"react";import{styled as yC,keyframes as __}from"storybook/theming";var $_=__`
|
|
42
42
|
0% { transform: rotate(0deg); }
|
|
43
43
|
100% { transform: rotate(360deg); }
|
|
44
|
-
`,$_=yC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${__} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),U_=yC.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}}})),Ar=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>xC.createElement(U_,{variant:r,disabled:t||e,onClick:n},e&&xC.createElement($_,null),e&&i?i:o);He();import ln from"react";import{styled as la}from"storybook/theming";var bC=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"})),j_=la.div({display:"flex",alignItems:"center",gap:"12px"}),sc=la.span({whiteSpace:"nowrap"}),SC=la.div({display:"flex",alignItems:"center",gap:"8px"}),ac=la.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),lc=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Iw;return r?ln.createElement(bC,null,ln.createElement(sc,null,o.toLocaleString()," tokens"),ln.createElement(SC,null,ln.createElement(ac,null,"$",n.toFixed(4)),ln.createElement("span",null,"\xB7"),ln.createElement(ac,null,"\u20AA",i.toFixed(2)))):ln.createElement(bC,null,ln.createElement(j_,null,ln.createElement(sc,null,e.toLocaleString()," input"),ln.createElement("span",null,"+"),ln.createElement(sc,null,t.toLocaleString()," output"),ln.createElement("span",null,"="),ln.createElement(sc,null,ln.createElement("strong",null,o.toLocaleString())," tokens")),ln.createElement(SC,null,ln.createElement(ac,null,"$",n.toFixed(4)),ln.createElement("span",null,"\xB7"),ln.createElement(ac,null,"\u20AA",i.toFixed(2))))};import jn from"react";import{styled as Mo}from"storybook/theming";function rh(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var H_=Mo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),wC=Mo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),W_=Mo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),V_=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})),G_=Mo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),q_=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),Y_=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),K_=Mo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),vC=({data:e,color:t,compact:n})=>n?jn.createElement(wC,{color:t},e.summary):jn.createElement(H_,null,jn.createElement(wC,{color:t},e.summary),e.mappings&&e.mappings.length>0&&jn.createElement(W_,null,e.mappings.map((r,o)=>jn.createElement(jn.Fragment,{key:o},jn.createElement(V_,null,r.from," ",jn.createElement(G_,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&jn.createElement(q_,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&jn.createElement(jn.Fragment,null,e.defaults.map((r,o)=>jn.createElement(Y_,{key:o},jn.createElement(K_,null,r.choice),jn.createElement("span",null,"\u2014 ",r.why)))));var X_=dt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),Q_=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),J_=dt.div({display:"flex",flexDirection:"column",gap:"4px"}),Z_=dt.div({display:"flex",alignItems:"center",gap:"10px"}),e$=dt.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"})),CC=dt.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})),t$=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),n$=dt.div({display:"flex",gap:"8px"}),r$=dt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),o$=dt(So)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),i$=dt.div({display:"flex",gap:"4px"}),cc=dt.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}})),s$=dt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),a$=dt.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}})),l$=dt.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}`}})),c$=dt.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"})),uc=dt.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}`})),u$=dt.img({width:"100%",height:"100%",objectFit:"contain"}),AC=dt.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)"}}})),TC=dt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),IC=dt.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"})),oh=dt.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"})),sne=dt.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"})),p$=dt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),d$=dt.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})),g$=dt.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}})),f$=dt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),m$=dt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),h$=dt.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})),x$=dt.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})),y$=dt.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"}})),ane=dt.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})),FC=({src:e,alt:t})=>{let[n,r]=pc(!1);return Fe.createElement(Fe.Fragment,null,!n&&Fe.createElement(AC,null),Fe.createElement(u$,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function EC(e){return e>=90?"high":e>=70?"medium":"low"}function b$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var PC=({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]=pc(()=>{let v=new Set;for(let C of e.mappings)C.confidence>=90&&v.add(C.storyId);return v}),[f,k]=pc(""),[T,E]=pc("all"),I=kC(()=>{let v=new Map;for(let C of t)v.set(C.id,{name:C.name,title:C.title});return v},[t]),D=kC(()=>{let v=e.mappings;if(T!=="all"&&(v=v.filter(C=>EC(C.confidence)===T)),f.trim()){let C=f.toLowerCase();v=v.filter(m=>{let F=I.get(m.storyId);return F?.name.toLowerCase().includes(C)||F?.title.toLowerCase().includes(C)||m.componentSetName.toLowerCase().includes(C)||m.figmaFrameName.toLowerCase().includes(C)})}return v},[e.mappings,T,f,I]),R=v=>{p(C=>{let m=new Set(C);return m.has(v)?m.delete(v):m.add(v),m})},$=()=>{let v=e.mappings.filter(C=>g.has(C.storyId));n(v)},P=e.mappings.filter(v=>v.confidence>=90).length,z=e.mappings.filter(v=>v.confidence>=70&&v.confidence<90).length,x=e.mappings.filter(v=>v.confidence<70).length,w=e.usage;return Fe.createElement(X_,null,Fe.createElement(Q_,null,Fe.createElement(J_,null,Fe.createElement(Z_,null,Fe.createElement(e$,null,"Auto-Map Results"),Fe.createElement(CC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Fe.createElement(CC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Fe.createElement(x$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Fe.createElement(t$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Fe.createElement(n$,null,a==="cache"&&o&&Fe.createElement(y$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Fe.createElement(Ar,{onClick:r,variant:"ghost"},"Cancel"),Fe.createElement(Ar,{loading:i,onClick:$,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Fe.createElement(r$,null,Fe.createElement(o$,{type:"text",placeholder:"Filter stories...",value:f,onChange:v=>k(v.target.value)}),Fe.createElement(i$,null,Fe.createElement(cc,{active:T==="all",onClick:()=>E("all")},"All ",e.mappings.length),P>0&&Fe.createElement(cc,{active:T==="high",onClick:()=>E("high")},"\u226590% (",P,")"),z>0&&Fe.createElement(cc,{active:T==="medium",onClick:()=>E("medium")},"70-89% (",z,")"),x>0&&Fe.createElement(cc,{active:T==="low",onClick:()=>E("low")},"<70% (",x,")"))),Fe.createElement(s$,null,D.map(v=>{let C=I.get(v.storyId),m=EC(v.confidence),F=g.has(v.storyId),S=m==="low";return Fe.createElement(a$,{key:v.storyId,dimmed:S&&!F},Fe.createElement(l$,{checked:F,onClick:()=>R(v.storyId)},F?"\u2713":""),(()=>{let b=c?.(v.storyId);return b?Fe.createElement(uc,null,Fe.createElement(FC,{src:b,alt:C?.name||v.storyId})):l?Fe.createElement(uc,null,Fe.createElement(AC,null)):Fe.createElement(c$,{bgColor:S?"#f1f5f9":"#eff6ff"},Fe.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:S?"#94a3b8":"#3b82f6"}},(C?.name||"?").substring(0,4)))})(),Fe.createElement(TC,null,Fe.createElement(IC,null,C?.name||v.storyId),Fe.createElement(oh,null,C?.title||"")),Fe.createElement(p$,null,"\u2192"),(()=>{let b=u?.(v.figmaNodeId),A=rh(v.reason),L=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return b?Fe.createElement(uc,{title:L},Fe.createElement(FC,{src:b,alt:v.figmaFrameName})):Fe.createElement(uc,{title:L},Fe.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Fe.createElement(TC,null,Fe.createElement(IC,null,v.componentSetName),Fe.createElement(oh,null,v.figmaFrameName),Fe.createElement(vC,{data:rh(v.reason),color:b$(m)})),Fe.createElement(d$,{level:m},v.confidence,"%"),d&&Fe.createElement(g$,{onClick:()=>d(v.componentSetName)},"Browse"))}),e.unmatched.length>0&&Fe.createElement(f$,null,Fe.createElement(oh,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Fe.createElement(m$,null,e.unmatched.map(v=>{let C=I.get(v);return Fe.createElement(h$,{key:v},Fe.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),C?`${C.name} (${C.title})`:v)})))),w&&a!=="cache"&&Fe.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Fe.createElement(lc,{inputTokens:w.inputTokens||0,outputTokens:w.outputTokens||0,costUsd:w.costUsd||0})))};He();$e();import{useState as Bo,useCallback as Do,useRef as S$}from"react";import{useStorybookApi as w$}from"storybook/manager-api";function LC({projectId:e}){let t=w$(),n=S$(null),[r,o]=Bo(!1),[i,s]=Bo(!1),[a,u]=Bo(!1),[c,l]=Bo(null),[d,g]=Bo(null),[p,f]=Bo(null),[k,T]=Bo(""),[E,I]=Bo(null),D=Do(async()=>{let C=await fetch("/index.json");if(!C.ok)throw new Error("Failed to fetch Storybook index");let m=await C.json(),F=m.entries||m.stories||{},S=Object.keys(F).filter(L=>F[L].type==="story");y.debug(`[useAutoMap] Found ${S.length} stories in index.json`);let b=[];for(let L of S){let B=F[L],N=t.getData(L),h={...N?.initialArgs||{}},U=N?.argTypes||{};for(let[W,M]of Object.entries(U))if(!(W in h)){let Y=M;if(Y.defaultValue!==void 0)h[W]=Y.defaultValue;else if(Y.table?.defaultValue?.summary!==void 0){let ee=Y.table.defaultValue.summary;ee==="false"?h[W]=!1:ee==="true"?h[W]=!0:h[W]=ee}}b.push({id:L,name:B.name||L.split("--").pop()||L,title:B.title||"",initialArgs:h,argTypes:U})}let A=b.filter(L=>Object.keys(L.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${b.length} stories, ${A.length} with args`),b},[t]),R=Do(async()=>{if(!e)return!1;try{let C=V(),m=localStorage.getItem("uicopilot_session_token");if(!m)return!1;let F=await fetch(`${C}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${m}`}});if(!F.ok)return!1;let S=await F.json();return S.hasSuggestions&&S.mappings?.length>0?(g(S),I("cache"),T(`Loaded ${S.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${S.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),$=Do(async C=>{o(!0),T("Collecting story information...");let m;try{if(m=await D(),C?.length&&(m=m.filter(S=>!C.includes(S.id)),y.debug(`[useAutoMap] After excluding mapped: ${m.length} stories`)),m.length===0){l("No unmapped stories found"),o(!1);return}f(m)}catch(S){l(S instanceof Error?S.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),T(`Analyzing ${m.length} stories against Figma components...`);let F=new AbortController;n.current=F;try{let S=V(),b=localStorage.getItem("uicopilot_session_token");if(!b)throw new Error("Not authenticated");let A=await fetch(`${S}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b}`},body:JSON.stringify({projectId:e,stories:m.map(B=>({id:B.id,name:B.name,title:B.title,initialArgs:B.initialArgs,argTypes:B.argTypes}))}),signal:F.signal});if(!A.ok){let B=await A.json();throw new Error(B.error||"Auto-map failed")}let L=await A.json();g(L),I("llm"),T(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(S){if(S instanceof DOMException&&S.name==="AbortError"){T("Cancelled");return}l(S instanceof Error?S.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),P=Do(async C=>{if(!e)return;if(l(null),g(null),I(null),o(!0),T("Checking for existing suggestions..."),await R()){o(!1);return}await $(C)},[e,R,$]),z=Do(async C=>{e&&(l(null),g(null),I(null),await $(C))},[e,$]),x=Do(async C=>{if(!(!e||C.length===0)){u(!0),T(`Applying ${C.length} mappings...`);try{let m=V(),F=localStorage.getItem("uicopilot_session_token");if(!F)throw new Error("Not authenticated");let S=0;for(let b of C)try{(await fetch(`${m}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F}`},body:JSON.stringify({projectId:e,storyId:b.storyId,figmaNodeId:b.figmaNodeId,name:b.figmaFrameName||b.componentSetName})})).ok?S++:y.warn(`[useAutoMap] Failed to apply mapping for ${b.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${b.storyId}:`,A)}T(`Applied ${S}/${C.length} mappings`),y.debug(`[useAutoMap] Applied ${S}/${C.length} mappings`)}catch(m){l(m instanceof Error?m.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),w=Do(()=>{n.current?.abort()},[]),v=Do(()=>{g(null),f(null),l(null),T(""),I(null)},[]);return{collectAndMap:P,rerun:z,loadExisting:R,applyMappings:x,cancel:w,reset:v,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:k,source:E}}$e();import{useState as ih,useEffect as v$,useRef as MC}from"react";var BC=2;async function k$(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 DC(e){let[t,n]=ih({}),[r,o]=ih(0),[i,s]=ih(!1),a=MC(null),u=MC(""),c=e.join(",");return v$(()=>{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+=BC){let f=e.slice(p,p+BC),k=await Promise.all(f.map(E=>k$(E,l.signal).then(I=>({id:E,img:I}))));if(l.signal.aborted)break;let T={};for(let{id:E,img:I}of k)d++,I&&(T[E]=I);Object.keys(T).length>0&&n(E=>({...E,...T})),o(d)}s(!1),y.debug(`[useStoryScreenshots] Captured ${d}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import ke,{useState as sh,useEffect as ca,useMemo as C$,useCallback as T$}from"react";import{styled as I$}from"storybook/theming";$e();var F$=I$.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"}})),Hi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=ea({projectId:r||"",enabled:e&&!!r}),d=ke.useRef(!1);ca(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[g,p]=sh(new Set),[f,k]=sh(i||o[0]?.id||"");ca(()=>{i&&k(i)},[i]);let T=50,[E,I]=sh({}),D=T$(C=>{I(m=>({...m,[C]:(m[C]||1)+1}))},[]);ca(()=>{I({})},[l.variantFilters]),ca(()=>{l.expandedSets.forEach(C=>{let m=l.variantChildren[C];if(!m||m.length===0)return;let F=m;l.variantFilters.some(A=>A.value)&&(F=m.filter(A=>A.variantProperties?l.variantFilters.every(L=>L.value?A.variantProperties?.[L.property]===L.value:!0):!1));let S=E[C]||1,b=F.slice(0,S*T).map(A=>A.id);b.length>0&&l.fetchVariantThumbnails(C,b)})},[l.expandedSets,l.variantChildren,l.variantFilters,E]),ca(()=>{p(new Set)},[f]);let R=C$(()=>{let C=[];return l.filteredFrames.forEach(m=>{if(m.type==="COMPONENT_SET"&&m.children){let F=l.variantFilters.some(S=>S.value)?m.children.filter(S=>S.variantProperties?l.variantFilters.every(b=>b.value?S.variantProperties?.[b.property]===b.value:!0):!1):m.children;C.push(...F)}else C.push(m)}),C},[l.filteredFrames,l.variantFilters]),$=C=>{if(a)p(m=>{let F=new Set(m);return F.has(C.id)?F.delete(C.id):F.add(C.id),F});else{let m=l.resolveThumbnail(C.id);try{n({...C,thumbnail:m})}catch(F){y.error("[ComponentBrowserModal] onSelect threw error:",F)}t()}},P=()=>{let C=R.map(F=>F.id),m=C.every(F=>g.has(F));p(m?new Set:new Set(C))},z=()=>{if(u&&g.size>0){let C=R.filter(m=>g.has(m.id)).map(m=>({...m,thumbnail:l.resolveThumbnail(m.id)}));u(C),p(new Set)}},x=C=>{k(C),s?.(C)},w=C=>{C.target===C.currentTarget&&t()},v=o.find(C=>C.id===f);return e?ke.createElement(yk,{onClick:w},ke.createElement(bk,null,ke.createElement(Sk,null,ke.createElement(wk,null,"Link Figma Frames"),ke.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},ke.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"),ke.createElement(vk,{onClick:t},"\xD7"))),ke.createElement(kk,null,l.error&&ke.createElement(Pk,null,l.error),!l.error&&ke.createElement(ke.Fragment,null,o.length>0&&ke.createElement(Uk,null,ke.createElement(jk,null,"Story:"),ke.createElement(Hk,{value:f,onChange:C=>x(C.target.value)},o.map(C=>ke.createElement("option",{key:C.id,value:C.id},C.name,C.mappingsCount?` (${C.mappingsCount} linked)`:""))),v?.mappingsCount?ke.createElement(Wk,{hasMapping:!0},v.mappingsCount," frames linked"):null),ke.createElement(Ek,null,ke.createElement(Zl,null,ke.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:C=>l.setShowComponentSets(C.target.checked)}),"Component Sets"),ke.createElement(Zl,null,ke.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:C=>l.setShowFrames(C.target.checked)}),"Frames"),ke.createElement(Zl,null,ke.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:C=>l.setShowComponents(C.target.checked)}),"Components"),l.availablePages.length>1&&ke.createElement(Ui,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:C=>l.setFigmaPage(C.target.value),style:{marginLeft:"auto"}},ke.createElement("option",{value:""},"All pages"),l.availablePages.map(C=>ke.createElement("option",{key:C,value:C},C)))),l.filterSuggestion&&ke.createElement(Vk,null,ke.createElement(Gk,null,"AI suggests:"),ke.createElement(qk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([C,m])=>`${C}=${m}`).join(", ")),ke.createElement(Yk,{onClick:l.applySuggestedFilters},"Apply"),ke.createElement(Kk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&ke.createElement(Xk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&ke.createElement(tc,null,ke.createElement(sa,null,"Filters:"),l.availableFilters.map(({property:C,values:m})=>{let F=l.variantFilters.find(S=>S.property===C);return ke.createElement(Ui,{key:C,isActive:!!F?.value,value:F?.value||"",onChange:S=>l.handleFilterChange(C,S.target.value)},ke.createElement("option",{value:""},C),m.map(S=>ke.createElement("option",{key:S,value:S},C,"=",S)))}),l.variantFilters.some(C=>C.value)&&ke.createElement(nc,{onClick:l.clearFilters},"Clear All")),ke.createElement(Ck,{type:"text",placeholder:"Search frames...",value:l.search,onChange:C=>l.setSearch(C.target.value),autoFocus:!0}),a&&R.length>0&&ke.createElement(Qk,null,ke.createElement(Jk,{onClick:P},g.size===R.length?"Deselect All":"Select All Visible"),ke.createElement(Zk,null,g.size>0?`${g.size} selected of `:"Showing ",R.length," frames")),l.isLoading&&ke.createElement(_m,null,Array.from({length:6}).map((C,m)=>ke.createElement($k,{key:m},ke.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},ke.createElement(ec,{width:"100%",height:"100%"})),ke.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},ke.createElement(ec,{width:"80%",height:"16px"}),ke.createElement(ec,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&ke.createElement(Ak,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&ke.createElement(_m,null,l.filteredFrames.map(C=>ke.createElement(aa,{key:C.id,frame:C,thumbnail:l.thumbnails[C.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[C.id],variantChildren:l.variantChildren[C.id],variantFailed:l.variantFailed[C.id],isLoadingVariants:l.loadingVariants.has(C.id),isExpanded:l.expandedSets.has(C.id),isNew:l.recentlyAdded.has(C.name),onToggleExpand:l.toggleExpanded,onSelect:$,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:E[C.id]||1,onShowMore:D})),l.hasMore&&ke.createElement(F$,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&ke.createElement(eC,null,ke.createElement(tC,{disabled:g.size===0,onClick:z},"Link ",g.size," Selected")))):null};Ce();ct();var A$=Zt.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}),P$=Zt.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"})),L$=Zt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),M$=Zt.div({display:"flex",alignItems:"center",gap:"20px"}),B$=Zt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),D$=Zt.div({display:"flex",gap:"4px"}),RC=Zt(bo)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),R$=Zt(Cn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),z$=Zt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),N$=Zt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),O$=Zt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),_$=Zt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),$$=Zt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),U$=Zt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),j$=Zt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),H$=Zt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),W$=Zt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),V$=Zt.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"}})),zC=Zt.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"}})),NC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Wi("map"),[i,s]=Wi([]),[a,u]=Wi(!0),[c,l]=Wi(null),[d,g]=Wi(!1),[p,f]=Wi(null),k=LC({projectId:n}),{refreshMappings:T}=nt(),{featureFlags:E}=ce(),I=et.useMemo(()=>k.results?.mappings.map(b=>b.storyId)||[],[k.results]),D=DC(I),R=Ro(async()=>{u(!0);try{let b=await fetch("/index.json");if(!b.ok)throw new Error("Failed to fetch index.json");let A=await b.json(),L=A.entries||A.stories||{},B=Object.entries(L).filter(([,h])=>h.type==="story").map(([h,U])=>({id:h,name:U.name||h.split("--").pop()||h,title:U.title||"",importPath:U.importPath,componentTitle:U.title?.split("/").slice(0,-1).join("/")||U.title,figmaMapping:null}));try{let h=V(),U=localStorage.getItem("uicopilot_session_token"),W=await ne(`${h}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${U}`}});if(W.ok){let M=await W.json(),Y=new Map((M.mappings||[]).map(ee=>[ee.storyId,ee]));B.forEach(ee=>{let ge=Y.get(ee.id);ge&&ge.figmaNodeId&&(ee.figmaMapping={figmaNodeId:ge.figmaNodeId,figmaFrameName:ge.name||ge.figmaFrameName||""})})}}catch(h){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",h)}s(B);let N=B.find(h=>!h.figmaMapping);N?l(N.id):B.length>0&&l(B[0].id)}catch(b){console.error("[StoryMappingAssistant] Error fetching stories:",b)}finally{u(!1)}},[n]);E$(()=>{e&&R()},[e,R]);let $=Ro((b,A,L)=>{s(h=>h.map(U=>U.id===b?{...U,figmaMapping:{figmaNodeId:A,figmaFrameName:L}}:U));let B=i.findIndex(h=>h.id===b),N=i.find((h,U)=>U>B&&!h.figmaMapping);N&&l(N.id)},[i]),P=Ro(b=>{s(A=>A.map(L=>L.id===b?{...L,figmaMapping:null}:L))},[]),z=Ro(b=>{l(b),o("map")},[]),x=Ro(()=>{let b=i.filter(A=>A.figmaMapping).map(A=>A.id);k.collectAndMap(b)},[i,k]),w=Ro(()=>{let b=i.filter(A=>A.figmaMapping).map(A=>A.id);g(!1),k.rerun(b)},[i,k]),v=Ro(async b=>{await k.applyMappings(b),g(!1),k.reset(),R(),T()},[k,R,T]),C=Ro(()=>{g(!1),k.reset()},[k]);et.useEffect(()=>{k.results&&g(!0)},[k.results]);let m=b=>{b.target===b.currentTarget&&t()};if(!e)return null;let F=i.filter(b=>b.figmaMapping).length,S=i.length;return et.createElement(et.Fragment,null,et.createElement(A$,{onClick:m},et.createElement(P$,{onClick:b=>b.stopPropagation()},et.createElement(L$,null,et.createElement(M$,null,et.createElement(B$,null,et.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),et.createElement(D$,null,et.createElement(RC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),et.createElement(RC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),et.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},E.enableAutoMap&&!d&&!k.isCollecting&&!k.isMapping&&et.createElement(V$,{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(R$,{onClick:t},"\xD7"))),et.createElement(z$,null,(k.isCollecting||k.isMapping)&&et.createElement(_$,null,et.createElement($$,null,et.createElement(H$,null,et.createElement(W$,null)),et.createElement(U$,null,"Auto-mapping stories to Figma"),et.createElement(j$,null,k.progress),et.createElement(Ar,{onClick:k.cancel,variant:"ghost"},"Cancel"))),d&&k.results&&et.createElement(PC,{results:k.results,stories:i,onApply:v,onCancel:C,onRerun:w,isApplying:k.isApplying,isRerunning:k.isCollecting||k.isMapping,source:k.source,resolveThumbnail:b=>k.results?.thumbnailUrls?.[b],resolveStoryScreenshot:b=>D.screenshots[b],isCapturingScreenshots:D.isCapturing,onBrowse:b=>f(b)}),!d&&!k.isCollecting&&!k.isMapping&&(r==="map"?et.createElement(dC,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:$,projectId:n}):et.createElement(hC,{stories:i,loading:a,onLink:z,onUnlink:P,projectId:n}))),et.createElement(N$,null,et.createElement(O$,null,et.createElement("span",null,"Total: ",S," stories"),et.createElement(zC,{type:"mapped"},et.createElement("span",{className:"dot"}),F," mapped"),et.createElement(zC,{type:"unmapped"},et.createElement("span",{className:"dot"}),S-F," unmapped"))))),et.createElement(Hi,{isOpen:!!p,onClose:()=>f(null),onSelect:()=>f(null),projectId:n,initialSearch:p||void 0}))};ct();var OC=tr.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}})),q$=tr.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),Y$=tr.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),K$=tr.div({display:"flex",alignItems:"center",gap:"8px"}),X$=tr.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),Q$=tr.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"})),J$=tr.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"})),Z$=tr.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),e4=tr(gu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),t4=tr(gu)(({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)"}})),n4=tr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),r4=tr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:oe,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),o4=tr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),_C=()=>{let[e,t]=dc(!1),[n,r]=dc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Je(),{sessionToken:i}=we();G$(()=>{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(),z=P.entries||P.stories||{},x=Object.keys(z).filter(F=>z[F].type==="story").length,w=Object.keys(z).filter(F=>z[F].type==="story"),v=V(),C=await ne(`${v}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),m=0;if(C.ok){let F=await C.json(),S=F.mappings||F||[];if(Array.isArray(S)){let b=new Set(S.map(A=>A.storyId).filter(Boolean));m=w.filter(A=>b.has(A)).length}else{let b=await ne(`${v}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(b.ok){let A=await b.json();m=Math.min(A.mappedStoriesCount||0,x)}}}r({totalStories:x,mappedStories:m,loading:!1})}catch($){console.error("[FigmaMappingsSection] Error fetching stats:",$),r(P=>({...P,loading:!1}))}},[a,u]=dc(!1),[c,l]=dc(!1),d=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let $=V(),P=await ne(`${$}/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(w=>ne(`${$}/api/mappings?id=${encodeURIComponent(w.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch($){console.error("[FigmaMappingsSection] Unlink all failed:",$)}finally{u(!1)}},p=()=>t(!0),f=()=>{t(!1),o&&i&&s()};if(!o)return kt.createElement(OC,null,kt.createElement(n4,null,"Select a project to link Figma designs"));let{totalStories:k,loading:T}=n,E=Math.min(n.mappedStories,k),I=E===0?"none":E>=k?"complete":"partial",D=k>0?Math.min(100,Math.round(E/k*100)):0,R=I==="none"?"Link designs":"Manage";return kt.createElement(kt.Fragment,null,kt.createElement(OC,null,kt.createElement(q$,null,kt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},kt.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"}),kt.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"}),kt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),kt.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"}),kt.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"}))),kt.createElement(Y$,null,kt.createElement(Z$,null,"Figma Mappings"),kt.createElement(K$,null,T?kt.createElement(kt.Fragment,null,kt.createElement(r4,null),kt.createElement(o4,null,"Loading...")):kt.createElement(kt.Fragment,null,kt.createElement(X$,null,kt.createElement(Q$,{percent:D,state:I})),kt.createElement(J$,{state:I},`${E}/${k}`)))),E>0&&kt.createElement(t4,{onClick:d,disabled:T||a},a?"Unlinking...":"Unlink All"),kt.createElement(e4,{onClick:p,disabled:T},R)),e&&kt.createElement(NC,{isOpen:e,onClose:f,projectId:o}),kt.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 le,{useState as Vi,useEffect as gc,useCallback as $C,useRef as ah}from"react";import{styled as nr}from"storybook/theming";Ce();He();ct();var lh=nr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),ch=nr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),uh=nr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),lre=nr(Nr)({padding:"5px 12px",fontSize:"12px"}),ph=nr.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),fc=nr.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),i4=nr.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})),s4=nr.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),dh=nr.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),a4=nr.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),mc=nr.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),hc=nr.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),zo=nr.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),UC=new Set,jC=()=>{let{userRole:e,featureFlags:t}=ce(),[n,r]=Vi(null),[o,i]=Vi(!0),[s,a]=Vi(!1),[u,c]=Vi(!1),[l,d]=Vi(!1),[g,p]=Vi(!1),{selectedProjectId:f,projects:k}=Je(),{sessionToken:T}=we(),E=ah(null),I=ah(null),D=ah(null),R=$C(()=>{E.current&&(clearInterval(E.current),E.current=null),I.current&&(clearInterval(I.current),I.current=null),D.current&&(clearTimeout(D.current),D.current=null)},[]);gc(()=>R,[R]);let $=$C(async()=>{if(!(!f||!T))try{let S=V(),b=await ne(`${S}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${T}`}});if(b.ok){let A=await b.json();r(A)}}catch(S){console.error("[FigmaCacheSection] Error:",S)}finally{i(!1)}},[f,T]);gc(()=>{$()},[$]),gc(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||UC.has(f))return;let S=k.find(A=>A.id===f);(S?.figmaFileUrl||S?.figmaFileId)&&(UC.add(f),P())},[o,s,n?.structureStatus,f,k]),gc(()=>{let S=n?.thumbnailProgress?.status,b=n?.enrichmentProgress?.status,A=n?.thumbnailProgress?.cached??0,L=n?.thumbnailProgress?.total??0,B=S==="in-progress"||S==="pending"||L>0&&A<L,N=b==="in-progress"||b==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(B||N||h)||!n||n.structureStatus==="none")return;let W=setInterval(()=>{$()},3e3);return()=>{clearInterval(W)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,$]);let P=async()=>{if(!(!f||!T)){a(!0);try{let S=V();await ne(`${S}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${T}`}},6e4),await new Promise(b=>setTimeout(b,1e3)),await $(),setTimeout(async()=>{await $()},3e3)}catch(S){console.error("[FigmaCacheSection] Reload error:",S)}finally{a(!1)}}},z=async()=>{if(!(!f||!T)){c(!0);try{let S=V(),b=await ne(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:f})});console.log("[FigmaCacheSection] Cache invalidate response:",b.status),await ne(`${S}/api/figma/frames/invalidate?projectId=${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`}}).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(!(!f||!T)){R(),d(!0);try{let S=V();await ne(`${S}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:f})}),E.current=setInterval(async()=>{await $()},3e3),I.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)}}},w=async()=>{if(!(!f||!T)){p(!0);try{let S=V();await ne(`${S}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:f})}),await $()}catch(S){console.error("[FigmaCacheSection] Cancel error:",S)}finally{p(!1),d(!1),a(!1)}}},v=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!f)return null;if(o)return le.createElement(lh,null,le.createElement(ch,null,le.createElement(uh,null,"Figma Cache")),le.createElement(ph,null,le.createElement(fc,null,"Loading cache status\u2026")),le.createElement(mc,null,le.createElement(hc,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return le.createElement(lh,null,le.createElement(ch,null,le.createElement(uh,null,"Figma Cache"),le.createElement(Ar,{loading:s,onClick:P,loadingText:"Loading..."},"\u21BB Load")),s?le.createElement(le.Fragment,null,le.createElement(mc,null,le.createElement(hc,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),le.createElement(zo,null,le.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):le.createElement(ph,null,le.createElement(fc,null,"No cache \u2014 click Load to fetch from Figma")));let C=S=>{let b=Date.now()-new Date(S).getTime(),A=Math.floor(b/6e4);if(A<1)return"just now";if(A<60)return`${A}m ago`;let L=Math.floor(A/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`},m=n.cacheDiff,F=m&&(m.added.length>0||m.removed.length>0||m.renamed.length>0);return le.createElement(lh,null,le.createElement(ch,null,le.createElement(uh,null,"Figma Cache"," ",le.createElement(i4,{status:n.structureStatus},n.structureStatus)),le.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&le.createElement(Ar,{loading:l,onClick:x,loadingText:"Enriching..."},"Enrich"),le.createElement(Ar,{loading:u,onClick:z,variant:"ghost",loadingText:"Clearing..."},"Clear"),le.createElement(Ar,{loading:s,onClick:P,loadingText:"Reloading..."},"\u21BB Reload"),v&&le.createElement(Ar,{loading:g,onClick:w,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),s&&le.createElement(zo,null,le.createElement("span",null,"Downloading structure from Figma...")),le.createElement(ph,null,le.createElement(fc,null,le.createElement("strong",null,n.componentSetCount)," component sets"),le.createElement(fc,null,le.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&le.createElement(a4,null,"Updated ",C(n.structureCachedAt))),F&&le.createElement(s4,null,"Since last reload:"," ",m.added.length>0&&le.createElement(dh,{type:"added"},"+",m.added.length," added"),m.added.length>0&&m.removed.length>0&&" \xB7 ",m.removed.length>0&&le.createElement(dh,{type:"removed"},"\u2212",m.removed.length," removed"),(m.added.length>0||m.removed.length>0)&&m.renamed.length>0&&" \xB7 ",m.renamed.length>0&&le.createElement(dh,{type:"renamed"},m.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&le.createElement(le.Fragment,null,le.createElement(mc,null,le.createElement(hc,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),le.createElement(zo,null,le.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&le.createElement(le.Fragment,null," ",n.thumbnailProgress.currentName)),le.createElement("span",null,n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&le.createElement(zo,null,le.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)&&le.createElement(zo,null,le.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&&le.createElement(zo,null,le.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&le.createElement(le.Fragment,null,le.createElement(mc,null,le.createElement(hc,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),le.createElement(zo,null,le.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&le.createElement(le.Fragment,null," ",n.enrichmentProgress.currentName)),le.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&le.createElement(le.Fragment,null,le.createElement(zo,null,le.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&&le.createElement("div",{style:{marginTop:"6px"}},le.createElement(lc,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import xt,{useState as Gi}from"react";import{styled as Wr}from"storybook/theming";Ce();He();ct();var gh=Wr.div({padding:"12px 16px"}),l4=Wr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),HC=Wr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),WC=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:oe,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),c4=Wr.div({display:"flex",gap:"8px",alignItems:"center"}),u4=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:oe,boxShadow:`0 0 0 1px ${oe}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),VC=Wr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),p4=Wr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:oe,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),d4=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})),g4=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),GC=({onConnected:e})=>{let{sessionToken:t}=we(),[n,r]=Gi(!1),[o,i]=Gi(""),[s,a]=Gi(!1),[u,c]=Gi(null),[l,d]=Gi(null),[g,p]=Gi(!1),f=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let k=V(),T=await ne(`${k}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),E=await T.json();if(!T.ok){c({type:"error",message:E.error||"Failed to save token"});return}d(E.figmaUser?.handle||E.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${E.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?xt.createElement(gh,null,xt.createElement(HC,null,"Figma Personal Access Token"),xt.createElement(d4,null,xt.createElement("span",null,"\u2713 Connected as ",xt.createElement("strong",null,l)),xt.createElement(g4,{onClick:()=>{d(null),c(null)}},"Change token"))):n?xt.createElement(gh,null,xt.createElement(l4,null,xt.createElement(HC,null,"Figma Personal Access Token"),xt.createElement(WC,{onClick:()=>p(!g)},g?"Hide instructions":"How to generate")),g&&xt.createElement(p4,null,xt.createElement("ol",null,xt.createElement("li",null,"Open ",xt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),xt.createElement("li",null,"Click the ",xt.createElement("strong",null,"Security")," tab"),xt.createElement("li",null,"Scroll to ",xt.createElement("strong",null,"Personal access tokens")),xt.createElement("li",null,"Click ",xt.createElement("strong",null,"Generate new token")),xt.createElement("li",null,"Enable ",xt.createElement("strong",null,"File content: Read only")," under Scopes"),xt.createElement("li",null,"Copy the token and paste it below"))),xt.createElement(c4,null,xt.createElement(u4,{type:"password",value:o,onChange:k=>i(k.target.value),placeholder:"figd_...",onKeyDown:k=>{k.key==="Enter"&&o.trim()&&f()}}),xt.createElement(rn,{onClick:f,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&xt.createElement(VC,{variant:u.type},u.message),xt.createElement(VC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):xt.createElement(gh,null,xt.createElement(WC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};Ce();He();ct();var m4=yt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},yt.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"}),yt.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"}),yt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),yt.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"}),yt.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"})),fh=Pr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),h4=Pr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),x4=Pr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),y4=Pr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),mh=Pr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),b4=Pr.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"})),S4=Pr.div({display:"flex",alignItems:"center",gap:"8px"}),w4=Pr(kn)(({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"})),v4=Pr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Ere=Pr.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"}}),k4=Pr.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}})),YC=({hideHeader:e=!1})=>{let{sessionToken:t}=we(),[n,r]=xc(!1),[o,i]=xc(()=>{try{let p=sessionStorage.getItem("uicopilot_figma_connection");if(p){let{connected:f,ts:k}=JSON.parse(p);if(Date.now()-k<300*1e3)return f}}catch{}return null}),[s,a]=xc(!1),[u,c]=xc(!1);f4(()=>{if(!t)return;let p=V();ne(`${p}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(f=>f.json()).then(f=>{let k=!!f.connected;a(!!f.expired),i(k);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:k,ts:Date.now()}))}catch{}}).catch(()=>i(!1))},[t]);let l=qC(()=>{let p=V(),f=`${p}/api/auth/figma/login?addon=true`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100");let k=setInterval(async()=>{try{(await(await ne(`${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=qC(async()=>{try{r(!0);let p=V(),f=await ne(`${p}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(f.ok||f.status===404){i(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{r(!1)}},[t]),g=e?null:yt.createElement(h4,null,yt.createElement(x4,null,m4),yt.createElement(y4,null,"Figma Integration"));return o===null?yt.createElement(fh,null,g,yt.createElement(mh,null,yt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?yt.createElement(fh,null,g,yt.createElement(mh,null,yt.createElement(v4,null,s&&yt.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."),yt.createElement(rn,{onClick:l,style:{width:"100%"}},s?"Reconnect Figma":"Connect with Figma"),yt.createElement(k4,null,"or"),yt.createElement(GC,{onConnected:()=>i(!0)})))):yt.createElement(fh,null,g,yt.createElement(b4,null,yt.createElement(S4,null,yt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),yt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),yt.createElement(w4,{onClick:()=>c(!0),disabled:n},n?"Disconnecting...":"Disconnect")),yt.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)}),yt.createElement(mh,null,yt.createElement(xk,null),yt.createElement(_C,null),yt.createElement(jC,null)))};Ce();zn();var I4=mr.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"}),F4=mr.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"})),E4=mr.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})),A4=mr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),P4=mr(Cn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),L4=mr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),KC=mr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),XC=mr.div({display:"flex",alignItems:"center",gap:"10px"}),QC=mr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),M4=mr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:oe,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),B4=mr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),JC=mr.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"}})),ZC=({onClose:e})=>{let{isConnected:t}=we(),{selectedProjectId:n}=Je(),r=T4(t);return C4(()=>{!r.current&&t&&n&&e(),r.current=t},[t,n,e]),Lt.createElement(I4,{onClick:e},Lt.createElement(F4,{onClick:o=>o.stopPropagation()},Lt.createElement(E4,null,Lt.createElement(A4,null,"Settings"),Lt.createElement(P4,{onClick:e,title:"Close settings"},"\xD7")),Lt.createElement(L4,null,Lt.createElement(KC,null,Lt.createElement(XC,null,Lt.createElement(M4,null,"UI"),Lt.createElement(QC,null,Ft.NAME)),Lt.createElement(JC,null,Lt.createElement(dk,{onConnect:e}),t&&Lt.createElement(mk,null))),t&&n&&Lt.createElement(KC,null,Lt.createElement(XC,null,Lt.createElement(B4,null,Lt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Lt.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"}),Lt.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"}),Lt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Lt.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"}),Lt.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"}))),Lt.createElement(QC,null,"Figma Integration")),Lt.createElement(JC,null,Lt.createElement(YC,{hideHeader:!0}))))))};import ft,{useEffect as c1,useMemo as s3,useState as a3,useRef as l3}from"react";import{styled as Wn,keyframes as c3}from"storybook/theming";Ce();zn();Ce();import Kt,{useState as D4}from"react";import{styled as Hn}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 R4=Hn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),z4=Hn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),N4=Hn.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"}}),O4=Hn.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}})),_4=Hn.div({position:"relative",display:"inline-block"}),$4=Hn.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}})),U4=Hn.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"})),hh=Hn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),xh=Hn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),j4=Hn.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}})),H4=Hn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),W4=Hn.div({flex:1,minWidth:0}),V4=Hn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),G4=Hn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),q4=5,e1=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ce(),[r,o]=D4(!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<q4,l=(p,f)=>{f.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let f=e.includes(p);f&&e.length===1||!f&&!c||n||(t(p),o(!1))},g=p=>{let f=e.includes(p.id),k=f&&e.length===1,T=n||k||!f&&!c;return Kt.createElement(j4,{key:p.id,disabled:T,onClick:()=>d(p.id)},Kt.createElement(H4,{type:"checkbox",checked:f,disabled:T,onChange:()=>{},onClick:E=>E.stopPropagation()}),Kt.createElement(W4,null,Kt.createElement(V4,null,p.name),p.description&&Kt.createElement(G4,null,p.description)))};return Kt.createElement(R4,null,Kt.createElement(_4,null,Kt.createElement($4,{disabled:n,isOpen:r,onClick:()=>o(!r)},Kt.createElement("span",null,"Select model"),Kt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Kt.createElement(U4,null,Kt.createElement(hh,null,Kt.createElement(xh,null,"Anthropic"),i.map(g)),Kt.createElement(hh,null,Kt.createElement(xh,null,"OpenAI"),s.map(g)),Kt.createElement(hh,null,Kt.createElement(xh,null,"Google"),a.map(g)))),Kt.createElement(z4,null,u.map(p=>Kt.createElement(N4,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Kt.createElement(O4,{disabled:n,onClick:f=>l(p.id,f),title:"Remove model"},"\xD7")))))};import Ne,{useState as Y4,useEffect as K4}from"react";import{styled as en,keyframes as qi}from"storybook/theming";Ce();var X4=qi`
|
|
44
|
+
`,U_=yC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${$_} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),j_=yC.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}}})),Ar=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>xC.createElement(j_,{variant:r,disabled:t||e,onClick:n},e&&xC.createElement(U_,null),e&&i?i:o);He();import cn from"react";import{styled as la}from"storybook/theming";var bC=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"})),H_=la.div({display:"flex",alignItems:"center",gap:"12px"}),sc=la.span({whiteSpace:"nowrap"}),SC=la.div({display:"flex",alignItems:"center",gap:"8px"}),ac=la.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),lc=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Iw;return r?cn.createElement(bC,null,cn.createElement(sc,null,o.toLocaleString()," tokens"),cn.createElement(SC,null,cn.createElement(ac,null,"$",n.toFixed(4)),cn.createElement("span",null,"\xB7"),cn.createElement(ac,null,"\u20AA",i.toFixed(2)))):cn.createElement(bC,null,cn.createElement(H_,null,cn.createElement(sc,null,e.toLocaleString()," input"),cn.createElement("span",null,"+"),cn.createElement(sc,null,t.toLocaleString()," output"),cn.createElement("span",null,"="),cn.createElement(sc,null,cn.createElement("strong",null,o.toLocaleString())," tokens")),cn.createElement(SC,null,cn.createElement(ac,null,"$",n.toFixed(4)),cn.createElement("span",null,"\xB7"),cn.createElement(ac,null,"\u20AA",i.toFixed(2))))};import Hn from"react";import{styled as Mo}from"storybook/theming";function rh(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var W_=Mo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),wC=Mo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),V_=Mo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),G_=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})),q_=Mo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),Y_=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),K_=Mo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),X_=Mo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),vC=({data:e,color:t,compact:n})=>n?Hn.createElement(wC,{color:t},e.summary):Hn.createElement(W_,null,Hn.createElement(wC,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Hn.createElement(V_,null,e.mappings.map((r,o)=>Hn.createElement(Hn.Fragment,{key:o},Hn.createElement(G_,null,r.from," ",Hn.createElement(q_,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Hn.createElement(Y_,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Hn.createElement(Hn.Fragment,null,e.defaults.map((r,o)=>Hn.createElement(K_,{key:o},Hn.createElement(X_,null,r.choice),Hn.createElement("span",null,"\u2014 ",r.why)))));var Q_=gt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),J_=gt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),Z_=gt.div({display:"flex",flexDirection:"column",gap:"4px"}),e$=gt.div({display:"flex",alignItems:"center",gap:"10px"}),t$=gt.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"})),CC=gt.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})),n$=gt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),r$=gt.div({display:"flex",gap:"8px"}),o$=gt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),i$=gt(So)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),s$=gt.div({display:"flex",gap:"4px"}),cc=gt.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}})),a$=gt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),l$=gt.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}})),c$=gt.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}`}})),u$=gt.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"})),uc=gt.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}`})),p$=gt.img({width:"100%",height:"100%",objectFit:"contain"}),AC=gt.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)"}}})),TC=gt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),IC=gt.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"})),oh=gt.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"})),gne=gt.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"})),d$=gt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),g$=gt.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})),f$=gt.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}})),m$=gt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),h$=gt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),x$=gt.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})),y$=gt.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})),b$=gt.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"}})),fne=gt.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})),FC=({src:e,alt:t})=>{let[n,r]=pc(!1);return Fe.createElement(Fe.Fragment,null,!n&&Fe.createElement(AC,null),Fe.createElement(p$,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function EC(e){return e>=90?"high":e>=70?"medium":"low"}function S$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var PC=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:p})=>{let[g,d]=pc(()=>{let v=new Set;for(let C of e.mappings)C.confidence>=90&&v.add(C.storyId);return v}),[f,k]=pc(""),[T,E]=pc("all"),I=kC(()=>{let v=new Map;for(let C of t)v.set(C.id,{name:C.name,title:C.title});return v},[t]),D=kC(()=>{let v=e.mappings;if(T!=="all"&&(v=v.filter(C=>EC(C.confidence)===T)),f.trim()){let C=f.toLowerCase();v=v.filter(m=>{let F=I.get(m.storyId);return F?.name.toLowerCase().includes(C)||F?.title.toLowerCase().includes(C)||m.componentSetName.toLowerCase().includes(C)||m.figmaFrameName.toLowerCase().includes(C)})}return v},[e.mappings,T,f,I]),R=v=>{d(C=>{let m=new Set(C);return m.has(v)?m.delete(v):m.add(v),m})},$=()=>{let v=e.mappings.filter(C=>g.has(C.storyId));n(v)},P=e.mappings.filter(v=>v.confidence>=90).length,z=e.mappings.filter(v=>v.confidence>=70&&v.confidence<90).length,x=e.mappings.filter(v=>v.confidence<70).length,w=e.usage;return Fe.createElement(Q_,null,Fe.createElement(J_,null,Fe.createElement(Z_,null,Fe.createElement(e$,null,Fe.createElement(t$,null,"Auto-Map Results"),Fe.createElement(CC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Fe.createElement(CC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Fe.createElement(y$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Fe.createElement(n$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Fe.createElement(r$,null,a==="cache"&&o&&Fe.createElement(b$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Fe.createElement(Ar,{onClick:r,variant:"ghost"},"Cancel"),Fe.createElement(Ar,{loading:i,onClick:$,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Fe.createElement(o$,null,Fe.createElement(i$,{type:"text",placeholder:"Filter stories...",value:f,onChange:v=>k(v.target.value)}),Fe.createElement(s$,null,Fe.createElement(cc,{active:T==="all",onClick:()=>E("all")},"All ",e.mappings.length),P>0&&Fe.createElement(cc,{active:T==="high",onClick:()=>E("high")},"\u226590% (",P,")"),z>0&&Fe.createElement(cc,{active:T==="medium",onClick:()=>E("medium")},"70-89% (",z,")"),x>0&&Fe.createElement(cc,{active:T==="low",onClick:()=>E("low")},"<70% (",x,")"))),Fe.createElement(a$,null,D.map(v=>{let C=I.get(v.storyId),m=EC(v.confidence),F=g.has(v.storyId),S=m==="low";return Fe.createElement(l$,{key:v.storyId,dimmed:S&&!F},Fe.createElement(c$,{checked:F,onClick:()=>R(v.storyId)},F?"\u2713":""),(()=>{let b=c?.(v.storyId);return b?Fe.createElement(uc,null,Fe.createElement(FC,{src:b,alt:C?.name||v.storyId})):l?Fe.createElement(uc,null,Fe.createElement(AC,null)):Fe.createElement(u$,{bgColor:S?"#f1f5f9":"#eff6ff"},Fe.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:S?"#94a3b8":"#3b82f6"}},(C?.name||"?").substring(0,4)))})(),Fe.createElement(TC,null,Fe.createElement(IC,null,C?.name||v.storyId),Fe.createElement(oh,null,C?.title||"")),Fe.createElement(d$,null,"\u2192"),(()=>{let b=u?.(v.figmaNodeId),A=rh(v.reason),L=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return b?Fe.createElement(uc,{title:L},Fe.createElement(FC,{src:b,alt:v.figmaFrameName})):Fe.createElement(uc,{title:L},Fe.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Fe.createElement(TC,null,Fe.createElement(IC,null,v.componentSetName),Fe.createElement(oh,null,v.figmaFrameName),Fe.createElement(vC,{data:rh(v.reason),color:S$(m)})),Fe.createElement(g$,{level:m},v.confidence,"%"),p&&Fe.createElement(f$,{onClick:()=>p(v.componentSetName)},"Browse"))}),e.unmatched.length>0&&Fe.createElement(m$,null,Fe.createElement(oh,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Fe.createElement(h$,null,e.unmatched.map(v=>{let C=I.get(v);return Fe.createElement(x$,{key:v},Fe.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),C?`${C.name} (${C.title})`:v)})))),w&&a!=="cache"&&Fe.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Fe.createElement(lc,{inputTokens:w.inputTokens||0,outputTokens:w.outputTokens||0,costUsd:w.costUsd||0})))};He();$e();import{useState as Bo,useCallback as Do,useRef as w$}from"react";import{useStorybookApi as v$}from"storybook/manager-api";function LC({projectId:e}){let t=v$(),n=w$(null),[r,o]=Bo(!1),[i,s]=Bo(!1),[a,u]=Bo(!1),[c,l]=Bo(null),[p,g]=Bo(null),[d,f]=Bo(null),[k,T]=Bo(""),[E,I]=Bo(null),D=Do(async()=>{let C=await fetch("/index.json");if(!C.ok)throw new Error("Failed to fetch Storybook index");let m=await C.json(),F=m.entries||m.stories||{},S=Object.keys(F).filter(L=>F[L].type==="story");y.debug(`[useAutoMap] Found ${S.length} stories in index.json`);let b=[];for(let L of S){let B=F[L],N=t.getData(L),h={...N?.initialArgs||{}},U=N?.argTypes||{};for(let[W,M]of Object.entries(U))if(!(W in h)){let Y=M;if(Y.defaultValue!==void 0)h[W]=Y.defaultValue;else if(Y.table?.defaultValue?.summary!==void 0){let ee=Y.table.defaultValue.summary;ee==="false"?h[W]=!1:ee==="true"?h[W]=!0:h[W]=ee}}b.push({id:L,name:B.name||L.split("--").pop()||L,title:B.title||"",initialArgs:h,argTypes:U})}let A=b.filter(L=>Object.keys(L.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${b.length} stories, ${A.length} with args`),b},[t]),R=Do(async()=>{if(!e)return!1;try{let C=V(),m=localStorage.getItem("uicopilot_session_token");if(!m)return!1;let F=await fetch(`${C}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${m}`}});if(!F.ok)return!1;let S=await F.json();return S.hasSuggestions&&S.mappings?.length>0?(g(S),I("cache"),T(`Loaded ${S.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${S.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),$=Do(async C=>{o(!0),T("Collecting story information...");let m;try{if(m=await D(),C?.length&&(m=m.filter(S=>!C.includes(S.id)),y.debug(`[useAutoMap] After excluding mapped: ${m.length} stories`)),m.length===0){l("No unmapped stories found"),o(!1);return}f(m)}catch(S){l(S instanceof Error?S.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),T(`Analyzing ${m.length} stories against Figma components...`);let F=new AbortController;n.current=F;try{let S=V(),b=localStorage.getItem("uicopilot_session_token");if(!b)throw new Error("Not authenticated");let A=await fetch(`${S}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b}`},body:JSON.stringify({projectId:e,stories:m.map(B=>({id:B.id,name:B.name,title:B.title,initialArgs:B.initialArgs,argTypes:B.argTypes}))}),signal:F.signal});if(!A.ok){let B=await A.json();throw new Error(B.error||"Auto-map failed")}let L=await A.json();g(L),I("llm"),T(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(S){if(S instanceof DOMException&&S.name==="AbortError"){T("Cancelled");return}l(S instanceof Error?S.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),P=Do(async C=>{if(!e)return;if(l(null),g(null),I(null),o(!0),T("Checking for existing suggestions..."),await R()){o(!1);return}await $(C)},[e,R,$]),z=Do(async C=>{e&&(l(null),g(null),I(null),await $(C))},[e,$]),x=Do(async C=>{if(!(!e||C.length===0)){u(!0),T(`Applying ${C.length} mappings...`);try{let m=V(),F=localStorage.getItem("uicopilot_session_token");if(!F)throw new Error("Not authenticated");let S=0;for(let b of C)try{(await fetch(`${m}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F}`},body:JSON.stringify({projectId:e,storyId:b.storyId,figmaNodeId:b.figmaNodeId,name:b.figmaFrameName||b.componentSetName})})).ok?S++:y.warn(`[useAutoMap] Failed to apply mapping for ${b.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${b.storyId}:`,A)}T(`Applied ${S}/${C.length} mappings`),y.debug(`[useAutoMap] Applied ${S}/${C.length} mappings`)}catch(m){l(m instanceof Error?m.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),w=Do(()=>{n.current?.abort()},[]),v=Do(()=>{g(null),f(null),l(null),T(""),I(null)},[]);return{collectAndMap:P,rerun:z,loadExisting:R,applyMappings:x,cancel:w,reset:v,isCollecting:r,isMapping:i,isApplying:a,error:c,results:p,manifest:d,progress:k,source:E}}$e();import{useState as ih,useEffect as k$,useRef as MC}from"react";var BC=2;async function C$(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 DC(e){let[t,n]=ih({}),[r,o]=ih(0),[i,s]=ih(!1),a=MC(null),u=MC(""),c=e.join(",");return k$(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let p=0;return(async()=>{for(let d=0;d<e.length&&!l.signal.aborted;d+=BC){let f=e.slice(d,d+BC),k=await Promise.all(f.map(E=>C$(E,l.signal).then(I=>({id:E,img:I}))));if(l.signal.aborted)break;let T={};for(let{id:E,img:I}of k)p++,I&&(T[E]=I);Object.keys(T).length>0&&n(E=>({...E,...T})),o(p)}s(!1),y.debug(`[useStoryScreenshots] Captured ${p}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import ke,{useState as sh,useEffect as ca,useMemo as T$,useCallback as I$}from"react";import{styled as F$}from"storybook/theming";$e();var E$=F$.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"}})),Hi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=ea({projectId:r||"",enabled:e&&!!r}),p=ke.useRef(!1);ca(()=>{e&&c&&!p.current&&(l.setSearch(c),p.current=!0),e||(p.current=!1)},[e,c]);let[g,d]=sh(new Set),[f,k]=sh(i||o[0]?.id||"");ca(()=>{i&&k(i)},[i]);let T=50,[E,I]=sh({}),D=I$(C=>{I(m=>({...m,[C]:(m[C]||1)+1}))},[]);ca(()=>{I({})},[l.variantFilters]),ca(()=>{l.expandedSets.forEach(C=>{let m=l.variantChildren[C];if(!m||m.length===0)return;let F=m;l.variantFilters.some(A=>A.value)&&(F=m.filter(A=>A.variantProperties?l.variantFilters.every(L=>L.value?A.variantProperties?.[L.property]===L.value:!0):!1));let S=E[C]||1,b=F.slice(0,S*T).map(A=>A.id);b.length>0&&l.fetchVariantThumbnails(C,b)})},[l.expandedSets,l.variantChildren,l.variantFilters,E]),ca(()=>{d(new Set)},[f]);let R=T$(()=>{let C=[];return l.filteredFrames.forEach(m=>{if(m.type==="COMPONENT_SET"&&m.children){let F=l.variantFilters.some(S=>S.value)?m.children.filter(S=>S.variantProperties?l.variantFilters.every(b=>b.value?S.variantProperties?.[b.property]===b.value:!0):!1):m.children;C.push(...F)}else C.push(m)}),C},[l.filteredFrames,l.variantFilters]),$=C=>{if(a)d(m=>{let F=new Set(m);return F.has(C.id)?F.delete(C.id):F.add(C.id),F});else{let m=l.resolveThumbnail(C.id);try{n({...C,thumbnail:m})}catch(F){y.error("[ComponentBrowserModal] onSelect threw error:",F)}t()}},P=()=>{let C=R.map(F=>F.id),m=C.every(F=>g.has(F));d(m?new Set:new Set(C))},z=()=>{if(u&&g.size>0){let C=R.filter(m=>g.has(m.id)).map(m=>({...m,thumbnail:l.resolveThumbnail(m.id)}));u(C),d(new Set)}},x=C=>{k(C),s?.(C)},w=C=>{C.target===C.currentTarget&&t()},v=o.find(C=>C.id===f);return e?ke.createElement(yk,{onClick:w},ke.createElement(bk,null,ke.createElement(Sk,null,ke.createElement(wk,null,"Link Figma Frames"),ke.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},ke.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"),ke.createElement(vk,{onClick:t},"\xD7"))),ke.createElement(kk,null,l.error&&ke.createElement(Pk,null,l.error),!l.error&&ke.createElement(ke.Fragment,null,o.length>0&&ke.createElement(Uk,null,ke.createElement(jk,null,"Story:"),ke.createElement(Hk,{value:f,onChange:C=>x(C.target.value)},o.map(C=>ke.createElement("option",{key:C.id,value:C.id},C.name,C.mappingsCount?` (${C.mappingsCount} linked)`:""))),v?.mappingsCount?ke.createElement(Wk,{hasMapping:!0},v.mappingsCount," frames linked"):null),ke.createElement(Ek,null,ke.createElement(Zl,null,ke.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:C=>l.setShowComponentSets(C.target.checked)}),"Component Sets"),ke.createElement(Zl,null,ke.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:C=>l.setShowFrames(C.target.checked)}),"Frames"),ke.createElement(Zl,null,ke.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:C=>l.setShowComponents(C.target.checked)}),"Components"),l.availablePages.length>1&&ke.createElement(Ui,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:C=>l.setFigmaPage(C.target.value),style:{marginLeft:"auto"}},ke.createElement("option",{value:""},"All pages"),l.availablePages.map(C=>ke.createElement("option",{key:C,value:C},C)))),l.filterSuggestion&&ke.createElement(Vk,null,ke.createElement(Gk,null,"AI suggests:"),ke.createElement(qk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([C,m])=>`${C}=${m}`).join(", ")),ke.createElement(Yk,{onClick:l.applySuggestedFilters},"Apply"),ke.createElement(Kk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&ke.createElement(Xk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&ke.createElement(tc,null,ke.createElement(sa,null,"Filters:"),l.availableFilters.map(({property:C,values:m})=>{let F=l.variantFilters.find(S=>S.property===C);return ke.createElement(Ui,{key:C,isActive:!!F?.value,value:F?.value||"",onChange:S=>l.handleFilterChange(C,S.target.value)},ke.createElement("option",{value:""},C),m.map(S=>ke.createElement("option",{key:S,value:S},C,"=",S)))}),l.variantFilters.some(C=>C.value)&&ke.createElement(nc,{onClick:l.clearFilters},"Clear All")),ke.createElement(Ck,{type:"text",placeholder:"Search frames...",value:l.search,onChange:C=>l.setSearch(C.target.value),autoFocus:!0}),a&&R.length>0&&ke.createElement(Qk,null,ke.createElement(Jk,{onClick:P},g.size===R.length?"Deselect All":"Select All Visible"),ke.createElement(Zk,null,g.size>0?`${g.size} selected of `:"Showing ",R.length," frames")),l.isLoading&&ke.createElement(_m,null,Array.from({length:6}).map((C,m)=>ke.createElement($k,{key:m},ke.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},ke.createElement(ec,{width:"100%",height:"100%"})),ke.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},ke.createElement(ec,{width:"80%",height:"16px"}),ke.createElement(ec,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&ke.createElement(Ak,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&ke.createElement(_m,null,l.filteredFrames.map(C=>ke.createElement(aa,{key:C.id,frame:C,thumbnail:l.thumbnails[C.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[C.id],variantChildren:l.variantChildren[C.id],variantFailed:l.variantFailed[C.id],isLoadingVariants:l.loadingVariants.has(C.id),isExpanded:l.expandedSets.has(C.id),isNew:l.recentlyAdded.has(C.name),onToggleExpand:l.toggleExpanded,onSelect:$,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:E[C.id]||1,onShowMore:D})),l.hasMore&&ke.createElement(E$,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&ke.createElement(eC,null,ke.createElement(tC,{disabled:g.size===0,onClick:z},"Link ",g.size," Selected")))):null};Ce();ct();var P$=en.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}),L$=en.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"})),M$=en.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),B$=en.div({display:"flex",alignItems:"center",gap:"20px"}),D$=en.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),R$=en.div({display:"flex",gap:"4px"}),RC=en(bo)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),z$=en(In)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),N$=en.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),O$=en.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),_$=en.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),$$=en.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),U$=en.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),j$=en.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),H$=en.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),W$=en.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),V$=en.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),G$=en.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"}})),zC=en.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"}})),NC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Wi("map"),[i,s]=Wi([]),[a,u]=Wi(!0),[c,l]=Wi(null),[p,g]=Wi(!1),[d,f]=Wi(null),k=LC({projectId:n}),{refreshMappings:T}=nt(),{featureFlags:E}=ce(),I=et.useMemo(()=>k.results?.mappings.map(b=>b.storyId)||[],[k.results]),D=DC(I),R=Ro(async()=>{u(!0);try{let b=await fetch("/index.json");if(!b.ok)throw new Error("Failed to fetch index.json");let A=await b.json(),L=A.entries||A.stories||{},B=Object.entries(L).filter(([,h])=>h.type==="story").map(([h,U])=>({id:h,name:U.name||h.split("--").pop()||h,title:U.title||"",importPath:U.importPath,componentTitle:U.title?.split("/").slice(0,-1).join("/")||U.title,figmaMapping:null}));try{let h=V(),U=localStorage.getItem("uicopilot_session_token"),W=await ne(`${h}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${U}`}});if(W.ok){let M=await W.json(),Y=new Map((M.mappings||[]).map(ee=>[ee.storyId,ee]));B.forEach(ee=>{let ge=Y.get(ee.id);ge&&ge.figmaNodeId&&(ee.figmaMapping={figmaNodeId:ge.figmaNodeId,figmaFrameName:ge.name||ge.figmaFrameName||""})})}}catch(h){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",h)}s(B);let N=B.find(h=>!h.figmaMapping);N?l(N.id):B.length>0&&l(B[0].id)}catch(b){console.error("[StoryMappingAssistant] Error fetching stories:",b)}finally{u(!1)}},[n]);A$(()=>{e&&R()},[e,R]);let $=Ro((b,A,L)=>{s(h=>h.map(U=>U.id===b?{...U,figmaMapping:{figmaNodeId:A,figmaFrameName:L}}:U));let B=i.findIndex(h=>h.id===b),N=i.find((h,U)=>U>B&&!h.figmaMapping);N&&l(N.id)},[i]),P=Ro(b=>{s(A=>A.map(L=>L.id===b?{...L,figmaMapping:null}:L))},[]),z=Ro(b=>{l(b),o("map")},[]),x=Ro(()=>{let b=i.filter(A=>A.figmaMapping).map(A=>A.id);k.collectAndMap(b)},[i,k]),w=Ro(()=>{let b=i.filter(A=>A.figmaMapping).map(A=>A.id);g(!1),k.rerun(b)},[i,k]),v=Ro(async b=>{await k.applyMappings(b),g(!1),k.reset(),R(),T()},[k,R,T]),C=Ro(()=>{g(!1),k.reset()},[k]);et.useEffect(()=>{k.results&&g(!0)},[k.results]);let m=b=>{b.target===b.currentTarget&&t()};if(!e)return null;let F=i.filter(b=>b.figmaMapping).length,S=i.length;return et.createElement(et.Fragment,null,et.createElement(P$,{onClick:m},et.createElement(L$,{onClick:b=>b.stopPropagation()},et.createElement(M$,null,et.createElement(B$,null,et.createElement(D$,null,et.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),et.createElement(R$,null,et.createElement(RC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),et.createElement(RC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),et.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},E.enableAutoMap&&!p&&!k.isCollecting&&!k.isMapping&&et.createElement(G$,{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(z$,{onClick:t},"\xD7"))),et.createElement(N$,null,(k.isCollecting||k.isMapping)&&et.createElement($$,null,et.createElement(U$,null,et.createElement(W$,null,et.createElement(V$,null)),et.createElement(j$,null,"Auto-mapping stories to Figma"),et.createElement(H$,null,k.progress),et.createElement(Ar,{onClick:k.cancel,variant:"ghost"},"Cancel"))),p&&k.results&&et.createElement(PC,{results:k.results,stories:i,onApply:v,onCancel:C,onRerun:w,isApplying:k.isApplying,isRerunning:k.isCollecting||k.isMapping,source:k.source,resolveThumbnail:b=>k.results?.thumbnailUrls?.[b],resolveStoryScreenshot:b=>D.screenshots[b],isCapturingScreenshots:D.isCapturing,onBrowse:b=>f(b)}),!p&&!k.isCollecting&&!k.isMapping&&(r==="map"?et.createElement(dC,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:$,projectId:n}):et.createElement(hC,{stories:i,loading:a,onLink:z,onUnlink:P,projectId:n}))),et.createElement(O$,null,et.createElement(_$,null,et.createElement("span",null,"Total: ",S," stories"),et.createElement(zC,{type:"mapped"},et.createElement("span",{className:"dot"}),F," mapped"),et.createElement(zC,{type:"unmapped"},et.createElement("span",{className:"dot"}),S-F," unmapped"))))),et.createElement(Hi,{isOpen:!!d,onClose:()=>f(null),onSelect:()=>f(null),projectId:n,initialSearch:d||void 0}))};ct();var OC=tr.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}})),Y$=tr.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),K$=tr.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),X$=tr.div({display:"flex",alignItems:"center",gap:"8px"}),Q$=tr.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),J$=tr.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"})),Z$=tr.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"})),e4=tr.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),t4=tr(gu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),n4=tr(gu)(({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)"}})),r4=tr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),o4=tr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),i4=tr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),_C=()=>{let[e,t]=dc(!1),[n,r]=dc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Je(),{sessionToken:i}=we();q$(()=>{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(),z=P.entries||P.stories||{},x=Object.keys(z).filter(F=>z[F].type==="story").length,w=Object.keys(z).filter(F=>z[F].type==="story"),v=V(),C=await ne(`${v}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),m=0;if(C.ok){let F=await C.json(),S=F.mappings||F||[];if(Array.isArray(S)){let b=new Set(S.map(A=>A.storyId).filter(Boolean));m=w.filter(A=>b.has(A)).length}else{let b=await ne(`${v}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(b.ok){let A=await b.json();m=Math.min(A.mappedStoriesCount||0,x)}}}r({totalStories:x,mappedStories:m,loading:!1})}catch($){console.error("[FigmaMappingsSection] Error fetching stats:",$),r(P=>({...P,loading:!1}))}},[a,u]=dc(!1),[c,l]=dc(!1),p=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let $=V(),P=await ne(`${$}/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(w=>ne(`${$}/api/mappings?id=${encodeURIComponent(w.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch($){console.error("[FigmaMappingsSection] Unlink all failed:",$)}finally{u(!1)}},d=()=>t(!0),f=()=>{t(!1),o&&i&&s()};if(!o)return Ct.createElement(OC,null,Ct.createElement(r4,null,"Select a project to link Figma designs"));let{totalStories:k,loading:T}=n,E=Math.min(n.mappedStories,k),I=E===0?"none":E>=k?"complete":"partial",D=k>0?Math.min(100,Math.round(E/k*100)):0,R=I==="none"?"Link designs":"Manage";return Ct.createElement(Ct.Fragment,null,Ct.createElement(OC,null,Ct.createElement(Y$,null,Ct.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Ct.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"}),Ct.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"}),Ct.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Ct.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"}),Ct.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"}))),Ct.createElement(K$,null,Ct.createElement(e4,null,"Figma Mappings"),Ct.createElement(X$,null,T?Ct.createElement(Ct.Fragment,null,Ct.createElement(o4,null),Ct.createElement(i4,null,"Loading...")):Ct.createElement(Ct.Fragment,null,Ct.createElement(Q$,null,Ct.createElement(J$,{percent:D,state:I})),Ct.createElement(Z$,{state:I},`${E}/${k}`)))),E>0&&Ct.createElement(n4,{onClick:p,disabled:T||a},a?"Unlinking...":"Unlink All"),Ct.createElement(t4,{onClick:d,disabled:T},R)),e&&Ct.createElement(NC,{isOpen:e,onClose:f,projectId:o}),Ct.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 le,{useState as Vi,useEffect as gc,useCallback as $C,useRef as ah}from"react";import{styled as nr}from"storybook/theming";Ce();He();ct();var lh=nr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),ch=nr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),uh=nr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),mre=nr(Nr)({padding:"5px 12px",fontSize:"12px"}),ph=nr.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),fc=nr.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),s4=nr.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})),a4=nr.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),dh=nr.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),l4=nr.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),mc=nr.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),hc=nr.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),zo=nr.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),UC=new Set,jC=()=>{let{userRole:e,featureFlags:t}=ce(),[n,r]=Vi(null),[o,i]=Vi(!0),[s,a]=Vi(!1),[u,c]=Vi(!1),[l,p]=Vi(!1),[g,d]=Vi(!1),{selectedProjectId:f,projects:k}=Je(),{sessionToken:T}=we(),E=ah(null),I=ah(null),D=ah(null),R=$C(()=>{E.current&&(clearInterval(E.current),E.current=null),I.current&&(clearInterval(I.current),I.current=null),D.current&&(clearTimeout(D.current),D.current=null)},[]);gc(()=>R,[R]);let $=$C(async()=>{if(!(!f||!T))try{let S=V(),b=await ne(`${S}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${T}`}});if(b.ok){let A=await b.json();r(A)}}catch(S){console.error("[FigmaCacheSection] Error:",S)}finally{i(!1)}},[f,T]);gc(()=>{$()},[$]),gc(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||UC.has(f))return;let S=k.find(A=>A.id===f);(S?.figmaFileUrl||S?.figmaFileId)&&(UC.add(f),P())},[o,s,n?.structureStatus,f,k]),gc(()=>{let S=n?.thumbnailProgress?.status,b=n?.enrichmentProgress?.status,A=n?.thumbnailProgress?.cached??0,L=n?.thumbnailProgress?.total??0,B=S==="in-progress"||S==="pending"||L>0&&A<L,N=b==="in-progress"||b==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(B||N||h)||!n||n.structureStatus==="none")return;let W=setInterval(()=>{$()},3e3);return()=>{clearInterval(W)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,$]);let P=async()=>{if(!(!f||!T)){a(!0);try{let S=V();await ne(`${S}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${T}`}},6e4),await new Promise(b=>setTimeout(b,1e3)),await $(),setTimeout(async()=>{await $()},3e3)}catch(S){console.error("[FigmaCacheSection] Reload error:",S)}finally{a(!1)}}},z=async()=>{if(!(!f||!T)){c(!0);try{let S=V(),b=await ne(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:f})});console.log("[FigmaCacheSection] Cache invalidate response:",b.status),await ne(`${S}/api/figma/frames/invalidate?projectId=${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`}}).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(!(!f||!T)){R(),p(!0);try{let S=V();await ne(`${S}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:f})}),E.current=setInterval(async()=>{await $()},3e3),I.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(R(),p(!1),$())},3e3),D.current=setTimeout(()=>{R(),p(!1)},6e5)}catch(S){console.error("[FigmaCacheSection] Enrich error:",S),R(),p(!1)}}},w=async()=>{if(!(!f||!T)){d(!0);try{let S=V();await ne(`${S}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:f})}),await $()}catch(S){console.error("[FigmaCacheSection] Cancel error:",S)}finally{d(!1),p(!1),a(!1)}}},v=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!f)return null;if(o)return le.createElement(lh,null,le.createElement(ch,null,le.createElement(uh,null,"Figma Cache")),le.createElement(ph,null,le.createElement(fc,null,"Loading cache status\u2026")),le.createElement(mc,null,le.createElement(hc,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return le.createElement(lh,null,le.createElement(ch,null,le.createElement(uh,null,"Figma Cache"),le.createElement(Ar,{loading:s,onClick:P,loadingText:"Loading..."},"\u21BB Load")),s?le.createElement(le.Fragment,null,le.createElement(mc,null,le.createElement(hc,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),le.createElement(zo,null,le.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):le.createElement(ph,null,le.createElement(fc,null,"No cache \u2014 click Load to fetch from Figma")));let C=S=>{let b=Date.now()-new Date(S).getTime(),A=Math.floor(b/6e4);if(A<1)return"just now";if(A<60)return`${A}m ago`;let L=Math.floor(A/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`},m=n.cacheDiff,F=m&&(m.added.length>0||m.removed.length>0||m.renamed.length>0);return le.createElement(lh,null,le.createElement(ch,null,le.createElement(uh,null,"Figma Cache"," ",le.createElement(s4,{status:n.structureStatus},n.structureStatus)),le.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&le.createElement(Ar,{loading:l,onClick:x,loadingText:"Enriching..."},"Enrich"),le.createElement(Ar,{loading:u,onClick:z,variant:"ghost",loadingText:"Clearing..."},"Clear"),le.createElement(Ar,{loading:s,onClick:P,loadingText:"Reloading..."},"\u21BB Reload"),v&&le.createElement(Ar,{loading:g,onClick:w,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),s&&le.createElement(zo,null,le.createElement("span",null,"Downloading structure from Figma...")),le.createElement(ph,null,le.createElement(fc,null,le.createElement("strong",null,n.componentSetCount)," component sets"),le.createElement(fc,null,le.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&le.createElement(l4,null,"Updated ",C(n.structureCachedAt))),F&&le.createElement(a4,null,"Since last reload:"," ",m.added.length>0&&le.createElement(dh,{type:"added"},"+",m.added.length," added"),m.added.length>0&&m.removed.length>0&&" \xB7 ",m.removed.length>0&&le.createElement(dh,{type:"removed"},"\u2212",m.removed.length," removed"),(m.added.length>0||m.removed.length>0)&&m.renamed.length>0&&" \xB7 ",m.renamed.length>0&&le.createElement(dh,{type:"renamed"},m.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&le.createElement(le.Fragment,null,le.createElement(mc,null,le.createElement(hc,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),le.createElement(zo,null,le.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&le.createElement(le.Fragment,null," ",n.thumbnailProgress.currentName)),le.createElement("span",null,n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&le.createElement(zo,null,le.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)&&le.createElement(zo,null,le.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&&le.createElement(zo,null,le.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&le.createElement(le.Fragment,null,le.createElement(mc,null,le.createElement(hc,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),le.createElement(zo,null,le.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&le.createElement(le.Fragment,null," ",n.enrichmentProgress.currentName)),le.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&le.createElement(le.Fragment,null,le.createElement(zo,null,le.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&&le.createElement("div",{style:{marginTop:"6px"}},le.createElement(lc,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import yt,{useState as Gi}from"react";import{styled as Wr}from"storybook/theming";Ce();He();ct();var gh=Wr.div({padding:"12px 16px"}),c4=Wr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),HC=Wr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),WC=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:ae,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),u4=Wr.div({display:"flex",gap:"8px",alignItems:"center"}),p4=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:ae,boxShadow:`0 0 0 1px ${ae}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),VC=Wr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),d4=Wr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:ae,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),g4=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})),f4=Wr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),GC=({onConnected:e})=>{let{sessionToken:t}=we(),[n,r]=Gi(!1),[o,i]=Gi(""),[s,a]=Gi(!1),[u,c]=Gi(null),[l,p]=Gi(null),[g,d]=Gi(!1),f=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let k=V(),T=await ne(`${k}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),E=await T.json();if(!T.ok){c({type:"error",message:E.error||"Failed to save token"});return}p(E.figmaUser?.handle||E.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${E.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?yt.createElement(gh,null,yt.createElement(HC,null,"Figma Personal Access Token"),yt.createElement(g4,null,yt.createElement("span",null,"\u2713 Connected as ",yt.createElement("strong",null,l)),yt.createElement(f4,{onClick:()=>{p(null),c(null)}},"Change token"))):n?yt.createElement(gh,null,yt.createElement(c4,null,yt.createElement(HC,null,"Figma Personal Access Token"),yt.createElement(WC,{onClick:()=>d(!g)},g?"Hide instructions":"How to generate")),g&&yt.createElement(d4,null,yt.createElement("ol",null,yt.createElement("li",null,"Open ",yt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),yt.createElement("li",null,"Click the ",yt.createElement("strong",null,"Security")," tab"),yt.createElement("li",null,"Scroll to ",yt.createElement("strong",null,"Personal access tokens")),yt.createElement("li",null,"Click ",yt.createElement("strong",null,"Generate new token")),yt.createElement("li",null,"Enable ",yt.createElement("strong",null,"File content: Read only")," under Scopes"),yt.createElement("li",null,"Copy the token and paste it below"))),yt.createElement(u4,null,yt.createElement(p4,{type:"password",value:o,onChange:k=>i(k.target.value),placeholder:"figd_...",onKeyDown:k=>{k.key==="Enter"&&o.trim()&&f()}}),yt.createElement(on,{onClick:f,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&yt.createElement(VC,{variant:u.type},u.message),yt.createElement(VC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):yt.createElement(gh,null,yt.createElement(WC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};Ce();He();ct();var h4=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"})),fh=Pr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),x4=Pr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),y4=Pr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),b4=Pr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),mh=Pr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),S4=Pr.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"})),w4=Pr.div({display:"flex",alignItems:"center",gap:"8px"}),v4=Pr(Tn)(({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"})),k4=Pr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Rre=Pr.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"}}),C4=Pr.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}})),YC=({hideHeader:e=!1})=>{let{sessionToken:t}=we(),[n,r]=xc(!1),[o,i]=xc(()=>{try{let d=sessionStorage.getItem("uicopilot_figma_connection");if(d){let{connected:f,ts:k}=JSON.parse(d);if(Date.now()-k<300*1e3)return f}}catch{}return null}),[s,a]=xc(!1),[u,c]=xc(!1);m4(()=>{if(!t)return;let d=V();ne(`${d}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(f=>f.json()).then(f=>{let k=!!f.connected;a(!!f.expired),i(k);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:k,ts:Date.now()}))}catch{}}).catch(()=>i(!1))},[t]);let l=qC(()=>{let d=V(),f=`${d}/api/auth/figma/login?addon=true`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100");let k=setInterval(async()=>{try{(await(await ne(`${d}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(k),i(!0))}catch{}},2e3);setTimeout(()=>clearInterval(k),300*1e3)},[t]),p=qC(async()=>{try{r(!0);let d=V(),f=await ne(`${d}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(f.ok||f.status===404){i(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{r(!1)}},[t]),g=e?null:bt.createElement(x4,null,bt.createElement(y4,null,h4),bt.createElement(b4,null,"Figma Integration"));return o===null?bt.createElement(fh,null,g,bt.createElement(mh,null,bt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?bt.createElement(fh,null,g,bt.createElement(mh,null,bt.createElement(k4,null,s&&bt.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."),bt.createElement(on,{onClick:l,style:{width:"100%"}},s?"Reconnect Figma":"Connect with Figma"),bt.createElement(C4,null,"or"),bt.createElement(GC,{onConnected:()=>i(!0)})))):bt.createElement(fh,null,g,bt.createElement(S4,null,bt.createElement(w4,null,bt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),bt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),bt.createElement(v4,{onClick:()=>c(!0),disabled:n},n?"Disconnecting...":"Disconnect")),bt.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),p()},onCancel:()=>c(!1)}),bt.createElement(mh,null,bt.createElement(xk,null),bt.createElement(_C,null),bt.createElement(jC,null)))};Ce();Nn();var F4=mr.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"}),E4=mr.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"})),A4=mr.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})),P4=mr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),L4=mr(In)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),M4=mr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),KC=mr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),XC=mr.div({display:"flex",alignItems:"center",gap:"10px"}),QC=mr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),B4=mr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:ae,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),D4=mr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),JC=mr.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"}})),ZC=({onClose:e})=>{let{isConnected:t}=we(),{selectedProjectId:n}=Je(),r=I4(t);return T4(()=>{!r.current&&t&&n&&e(),r.current=t},[t,n,e]),Mt.createElement(F4,{onClick:e},Mt.createElement(E4,{onClick:o=>o.stopPropagation()},Mt.createElement(A4,null,Mt.createElement(P4,null,"Settings"),Mt.createElement(L4,{onClick:e,title:"Close settings"},"\xD7")),Mt.createElement(M4,null,Mt.createElement(KC,null,Mt.createElement(XC,null,Mt.createElement(B4,null,"UI"),Mt.createElement(QC,null,Et.NAME)),Mt.createElement(JC,null,Mt.createElement(dk,{onConnect:e}),t&&Mt.createElement(mk,null))),t&&n&&Mt.createElement(KC,null,Mt.createElement(XC,null,Mt.createElement(D4,null,Mt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Mt.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"}),Mt.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"}),Mt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Mt.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"}),Mt.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"}))),Mt.createElement(QC,null,"Figma Integration")),Mt.createElement(JC,null,Mt.createElement(YC,{hideHeader:!0}))))))};import mt,{useEffect as c1,useMemo as a3,useState as l3,useRef as c3}from"react";import{styled as Vn,keyframes as u3}from"storybook/theming";Ce();Nn();Ce();import Xt,{useState as R4}from"react";import{styled as Wn}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 z4=Wn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),N4=Wn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),O4=Wn.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"}}),_4=Wn.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}})),$4=Wn.div({position:"relative",display:"inline-block"}),U4=Wn.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}})),j4=Wn.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"})),hh=Wn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),xh=Wn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),H4=Wn.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}})),W4=Wn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),V4=Wn.div({flex:1,minWidth:0}),G4=Wn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),q4=Wn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),Y4=5,e1=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ce(),[r,o]=R4(!1),i=co.filter(d=>d.provider==="anthropic"&&!e.includes(d.id)),s=co.filter(d=>d.provider==="openai"&&!e.includes(d.id)),a=co.filter(d=>d.provider==="google"&&!e.includes(d.id)),u=co.filter(d=>e.includes(d.id)),c=e.length<Y4,l=(d,f)=>{f.stopPropagation(),e.length>1&&!n&&t(d)},p=d=>{let f=e.includes(d);f&&e.length===1||!f&&!c||n||(t(d),o(!1))},g=d=>{let f=e.includes(d.id),k=f&&e.length===1,T=n||k||!f&&!c;return Xt.createElement(H4,{key:d.id,disabled:T,onClick:()=>p(d.id)},Xt.createElement(W4,{type:"checkbox",checked:f,disabled:T,onChange:()=>{},onClick:E=>E.stopPropagation()}),Xt.createElement(V4,null,Xt.createElement(G4,null,d.name),d.description&&Xt.createElement(q4,null,d.description)))};return Xt.createElement(z4,null,Xt.createElement($4,null,Xt.createElement(U4,{disabled:n,isOpen:r,onClick:()=>o(!r)},Xt.createElement("span",null,"Select model"),Xt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Xt.createElement(j4,null,Xt.createElement(hh,null,Xt.createElement(xh,null,"Anthropic"),i.map(g)),Xt.createElement(hh,null,Xt.createElement(xh,null,"OpenAI"),s.map(g)),Xt.createElement(hh,null,Xt.createElement(xh,null,"Google"),a.map(g)))),Xt.createElement(N4,null,u.map(d=>Xt.createElement(O4,{key:d.id,disabled:n,provider:d.provider},d.name,e.length>1&&Xt.createElement(_4,{disabled:n,onClick:f=>l(d.id,f),title:"Remove model"},"\xD7")))))};import Ne,{useState as K4,useEffect as X4}from"react";import{styled as tn,keyframes as qi}from"storybook/theming";Ce();var Q4=qi`
|
|
45
45
|
0%, 100% {
|
|
46
46
|
opacity: 1;
|
|
47
47
|
transform: scale(1);
|
|
@@ -50,20 +50,20 @@ ${at}`).join(`
|
|
|
50
50
|
opacity: 0.4;
|
|
51
51
|
transform: scale(0.8);
|
|
52
52
|
}
|
|
53
|
-
`,
|
|
53
|
+
`,J4=qi`
|
|
54
54
|
0% { transform: rotate(0deg); }
|
|
55
55
|
100% { transform: rotate(360deg); }
|
|
56
56
|
`,r1=qi`
|
|
57
57
|
0% { opacity: 0; transform: translateY(2px); }
|
|
58
58
|
100% { opacity: 1; transform: translateY(0); }
|
|
59
|
-
`,
|
|
59
|
+
`,Z4=qi`
|
|
60
60
|
0%, 100% {
|
|
61
61
|
opacity: 1;
|
|
62
62
|
}
|
|
63
63
|
50% {
|
|
64
64
|
opacity: 0.6;
|
|
65
65
|
}
|
|
66
|
-
`,
|
|
66
|
+
`,e3=qi`
|
|
67
67
|
0% {
|
|
68
68
|
transform: translateY(0) rotate(0deg) scale(1);
|
|
69
69
|
opacity: 1;
|
|
@@ -75,27 +75,27 @@ ${at}`).join(`
|
|
|
75
75
|
transform: translateY(60px) rotate(720deg) scale(0.5);
|
|
76
76
|
opacity: 0;
|
|
77
77
|
}
|
|
78
|
-
`;var
|
|
78
|
+
`;var coe=tn.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),yh=tn.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),uoe=tn.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:`${r1} 0.3s ease-out`})),t3=qi`
|
|
79
79
|
from { transform: rotate(0deg); }
|
|
80
80
|
to { transform: rotate(360deg); }
|
|
81
|
-
`,ooe=en.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${e3} 0.8s linear infinite`,flexShrink:0})),t1=en.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"})),t3=en.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"})),ioe=en.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:`${Z4} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var ua=en.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),pa=en.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),n1=en.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),da=en.span(({color:e})=>({fontWeight:700,color:e})),n3=en.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}})),soe=en.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),aoe=en.span(({color:e=oe})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${X4} 1.2s ease-in-out infinite`,marginRight:"4px"})),loe=en.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return oe;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 oe;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${J4} 1.5s ease-in-out infinite`}:{}})),coe=en.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),uoe=en.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),r3=en.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${Q4} 1.2s linear infinite`,flexShrink:0}),o3=({color:e=oe})=>Ne.createElement(r3,null,Ne.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 Ne.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),poe=en.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:`${r1} 0.3s ease-out`}));function i3(e){let[t,n]=Y4(0);return K4(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var o1=({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=i3(e||t),{featureFlags:f}=ce(),k=f.showCosts,T=3.65,E=P=>P<.01?`$${P.toFixed(4)}`:P<.1?`$${P.toFixed(3)}`:`$${P.toFixed(2)}`,I=P=>{let z=P*T;return z<.01?`\u20AA${z.toFixed(4)}`:z<.1?`\u20AA${z.toFixed(3)}`:`\u20AA${z.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 Ne.createElement(yh,null,Ne.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},p,"s \xB7 Esc to stop"));if(t)return Ne.createElement(yh,null,Ne.createElement(t1,null,Ne.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement(o3,{color:"#7c3aed"}),Ne.createElement(da,{color:"#7c3aed"},"Verifying...")),c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement("span",{style:{color:"#6b7280"}},p,"s"))));if(r>0||o!==void 0){let P=(a||0)+(u||0),z=(d||0)>0,x=z&&a?Math.round(d/a*100):0,w=Math.max(o??0,i??0),v=m=>m>=80?"#16a34a":m>=50?"#ca8a04":"#dc2626",C=m=>m>=100?"\u25CF":m>=50?"\u25D0":"\u25CB";return Ne.createElement(yh,null,r===0?Ne.createElement(t3,null,Ne.createElement("span",null,"\u2713"),"Perfect!"):Ne.createElement(t1,null,Ne.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ne.createElement(n3,{tint:v(w),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},Ne.createElement("span",{className:"score-dot"}),Ne.createElement("span",{className:"score-label"},"Score"),Ne.createElement("span",{className:"score-value"},w)),k&&s!==void 0&&s>0&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement(da,{color:"#16a34a"},E(s)),Ne.createElement("span",{style:{color:"#6b7280"}},"/"),Ne.createElement(da,{color:"#16a34a"},I(s)))),k&&P>0&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${z?` \xB7 Cached: ${d?.toLocaleString()}`:""}`},Ne.createElement(n1,{color:"#7c3aed"},"#"),Ne.createElement(da,{color:"#7c3aed"},D(P)),Ne.createElement("span",{style:{color:"#6b7280"}},"tokens"),z&&Ne.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",x,"%"))),g!==void 0&&g>0&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement(n1,{color:"#6b7280"},"\u23F1"),Ne.createElement(da,{color:"#6b7280"},g,"s"))))}return null};var u3=Wn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),woe=Wn.div({display:"flex",gap:"8px",alignItems:"center"}),p3=c3({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),d3=Wn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${p3} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),g3=Wn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),f3=Wn.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"})),m3=Wn.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:ja},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)`}}}),h3=Wn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),x3=Wn.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),y3=Wn(hn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),b3=Wn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),i1=Wn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),s1=Wn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?ja:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),a1=Wn.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)"})),l1=Wn.input({position:"absolute",opacity:0,width:0,height:0}),S3=()=>{let[e,t]=a3(0),n=l3();c1(()=>(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 ft.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},bh=()=>{let{sessionToken:e}=js(),{usageData:t}=we(),{selectedProjectId:n}=io(),{currentMapping:r,hasMapping:o}=ni(),{loadingMapping:i,currentStoryId:s}=nt(),{startReview:a,cancelReview:u,isReviewing:c}=mm(),{isLoadingScreenshots:l}=ei(),{storybookImageUrl:d,figmaImageUrl:g,currentReviewId:p,reviewHistory:f,setReviewDetailTab:k,setReviewResults:T,setFigmaImageUrl:E,setStorybookImageUrl:I,setFullPrompt:D,setFullResponse:R,includeTextComparison:$,setIncludeTextComparison:P,usePromptCache:z,setUsePromptCache:x,isValidating:w,validationUsage:v,isGenerating:C,isApplying:m,streamingStatus:F,featureFlags:S,userRole:b,roleOverride:A,isReviewing:L}=ce(),B=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=f.find(fe=>fe.id===p),U=(N?.issues||[]).filter(fe=>!fe.dismissed).length,W=N?.complianceScore,M=N?.visualSimilarity,Y=(N?.costUsd||0)+(v?.costUsd||0),ee=(N?.inputTokens||0)+(v?.inputTokens||0),ge=(N?.outputTokens||0)+(v?.outputTokens||0),xe=s3(()=>{let fe=s?f.filter(me=>me.storyId===s):f,tt=fe.filter(me=>!me.parentReviewId).sort((me,se)=>new Date(se.createdAt).getTime()-new Date(me.createdAt).getTime()),he=fe.filter(me=>me.parentReviewId),ie=[];for(let me of tt){ie.push(me);let se=he.filter(O=>O.parentReviewId===me.id).sort((O,j)=>(O.iterationNumber||0)-(j.iterationNumber||0));ie.push(...se)}let K=he.filter(me=>!tt.some(se=>se.id===me.parentReviewId));return ie.push(...K),ie},[f,s]);c1(()=>{if(!c)return;let fe=tt=>{tt.key==="Escape"&&(tt.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let ae=o&&r?.figmaNodeId,Ke=C||m,be=B>0,Te=!!(e&&n&&!c&&!l&&!Ke&&s&&d&&ae&&g&&be),te=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)}},Be=()=>te(!1),Pe=fe=>{let tt=fe.target.value;if(tt){let he=f.find(ie=>ie.id===tt);he&&(T({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&&E(he.figmaImageData),he.storybookImageData&&I(he.storybookImageData),(A??b)==="admin"&&(D(he.aiPrompt||""),R(he.aiResponse||"")),k("issues"))}},pe=fe=>{let tt=new Date(fe),ie=new Date().getTime()-tt.getTime(),K=Math.floor(ie/6e4),me=Math.floor(ie/36e5),se=Math.floor(ie/864e5);return K<1?"Just now":K<60?`${K}m ago`:me<24?`${me}h ago`:se<7?`${se}d ago`:tt.toLocaleDateString()},Pt=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]||"":"",tn=fe=>{let tt=fe.split("--"),he=tt[tt.length-1]||fe;return he.charAt(0).toUpperCase()+he.slice(1)},Dr=(A??b)==="admin";return ft.createElement("div",null,ft.createElement(u3,null,S.enableModelSelection&&ft.createElement(e1,null),Dr&&ft.createElement(b3,null,ft.createElement(i1,{title:"Compare text content between Figma design and Storybook component"},ft.createElement(l1,{type:"checkbox",checked:$,onChange:fe=>P(fe.target.checked)}),ft.createElement(s1,{checked:$},ft.createElement(a1,{checked:$})),"Compare text"),S.showCosts&&ft.createElement(i1,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ft.createElement(l1,{type:"checkbox",checked:z,onChange:fe=>x(fe.target.checked)}),ft.createElement(s1,{checked:z},ft.createElement(a1,{checked:z})),"Cache prompt")),ft.createElement(f3,null,ft.createElement(m3,{variant:c?"yellow":"purple",disabled:c?!1:!Te,onClick:c?u:Be,title:c?"Click to stop review":e?n?s?ae?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 ${Ft.NAME} first`},c?ft.createElement(ft.Fragment,null,ft.createElement(d3,null),"Reviewing",ft.createElement(S3,null)):ft.createElement(ft.Fragment,null,ft.createElement(g3,null,ft.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ft.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ft.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),L?null:w||N?ft.createElement(o1,{isReviewing:!1,isValidating:w,streamingStatus:F,issueCount:U,score:W,visualSimilarity:M,costUsd:Y||N?.costUsd,inputTokens:ee||N?.inputTokens,outputTokens:ge||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,xe.length>0&&ft.createElement(x3,null,ft.createElement(y3,{value:p||"",onChange:Pe,title:"Review history"},ft.createElement("option",{value:""},"Select a review..."),xe.map(fe=>{let tt=!!fe.parentReviewId,he=tt?" \u21B3 ":"\u25CF ",ie=tt&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",K=fe.issuesCount??fe.issues?.length??0,me=fe.complianceScore??"--",se=Pt(fe.modelId);return ft.createElement("option",{key:fe.id,value:fe.id},he,ie,pe(fe.createdAt)," - ",K," issues (",me,"%)",se?` \xB7 ${se}`:"",fe.storyId?` \xB7 ${tn(fe.storyId)}`:"")}))))),!ae&&!i&&ft.createElement(h3,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import Coe,{useState as Toe}from"react";import{styled as u1}from"storybook/theming";var Eoe=u1.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Aoe=u1(bo)({padding:"8px 12px",fontSize:"12px"});import Moe,{useState as Boe}from"react";import{styled as Sh}from"storybook/theming";Ce();He();$e();ct();var $oe=Sh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),Uoe=Sh(Nr)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),joe=Sh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import Voe from"react";import{styled as w3}from"storybook/theming";var Yoe=w3.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));Ce();import Qoe from"react";import{styled as Vr}from"storybook/theming";var eie=Vr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),tie=Vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),nie=Vr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),rie=Vr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),oie=Vr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),iie=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"})),sie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),aie=Vr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),lie=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"}));Ce();import die,{useState as gie}from"react";import{styled as Gr}from"storybook/theming";var hie=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)`}}),xie=Gr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),yie=Gr.div({display:"flex",alignItems:"center",gap:"8px"}),bie=Gr.span({fontSize:"12px",opacity:.7}),Sie=Gr.span({fontSize:"13px",fontWeight:500}),wie=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})),vie=Gr.div({marginTop:"12px",fontSize:"11px"}),kie=Gr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),Cie=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"})),Tie=Gr.span({fontSize:"12px"});$e();He();import Xt from"react";import{styled as as}from"storybook/theming";import Br,{useEffect as fW}from"react";import{styled as Aa}from"storybook/theming";Ce();import di,{useState as N6}from"react";import{styled as es}from"storybook/theming";var p1={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 d1(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var v3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,k3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,C3={};function yc(e,t){return((t||C3).jsx?k3:v3).test(e)}var T3=/[ \t\n\f\r]/g;function wh(e){return typeof e=="object"?e.type==="text"?g1(e.value):!1:g1(e)}function g1(e){return e.replace(T3,"")===""}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 vh(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 cn=class{constructor(t,n){this.attribute=n,this.property=t}};cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;var fa={};Se(fa,{boolean:()=>Ge,booleanish:()=>_t,commaOrSpaceSeparated:()=>Vn,commaSeparated:()=>No,number:()=>X,overloadedBoolean:()=>bc,spaceSeparated:()=>wt});var I3=0,Ge=ii(),_t=ii(),bc=ii(),X=ii(),wt=ii(),No=ii(),Vn=ii();function ii(){return 2**++I3}var kh=Object.keys(fa),si=class extends cn{constructor(t,n,r,o){let i=-1;if(super(t,n),f1(this,"space",o),typeof r=="number")for(;++i<kh.length;){let s=kh[i];f1(this,kh[i],(r&fa[s])===fa[s])}}};si.prototype.defined=!0;function f1(e,t,n){n&&(e[t]=n)}function hr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new si(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 Ch=hr({properties:{ariaActiveDescendant:null,ariaAtomic:_t,ariaAutoComplete:null,ariaBusy:_t,ariaChecked:_t,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:wt,ariaCurrent:null,ariaDescribedBy:wt,ariaDetails:null,ariaDisabled:_t,ariaDropEffect:wt,ariaErrorMessage:null,ariaExpanded:_t,ariaFlowTo:wt,ariaGrabbed:_t,ariaHasPopup:null,ariaHidden:_t,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wt,ariaLevel:X,ariaLive:null,ariaModal:_t,ariaMultiLine:_t,ariaMultiSelectable:_t,ariaOrientation:null,ariaOwns:wt,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:_t,ariaReadOnly:_t,ariaRelevant:null,ariaRequired:_t,ariaRoleDescription:wt,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:_t,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 Sc(e,t){return t in e?e[t]:t}function wc(e,t){return Sc(e,t.toLowerCase())}var m1=hr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:No,acceptCharset:wt,accessKey:wt,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:wt,autoFocus:Ge,autoPlay:Ge,blocking:wt,capture:null,charSet:null,checked:Ge,cite:null,className:wt,cols:X,colSpan:null,content:null,contentEditable:_t,controls:Ge,controlsList:wt,coords:X|No,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:bc,draggable:_t,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:wt,height:X,hidden:bc,high:X,href:null,hrefLang:null,htmlFor:wt,httpEquiv:wt,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:wt,itemRef:wt,itemScope:Ge,itemType:wt,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:wt,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:wt,required:Ge,reversed:Ge,rows:X,rowSpan:X,sandbox:wt,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:_t,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:_t,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wt,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:_t,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:wc});var h1=hr({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:Vn,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:wt,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:Vn,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:wt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Vn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Vn,rev:Vn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Vn,requiredFeatures:Vn,requiredFonts:Vn,requiredFormats:Vn,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:Vn,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:Vn,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:Vn,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:Sc});var Th=hr({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 Ih=hr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wc});var Fh=hr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Eh={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 F3=/[A-Z]/g,x1=/-[a-z]/g,E3=/^data[-\w.:]+$/i;function Ah(e,t){let n=ga(t),r=t,o=cn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&E3.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(x1,P3);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!x1.test(i)){let s=i.replace(F3,A3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=si}return new o(r,t)}function A3(e){return"-"+e.toLowerCase()}function P3(e){return e.charAt(1).toUpperCase()}var y1=vh([Ch,m1,Th,Ih,Fh],"html"),vc=vh([Ch,h1,Th,Ih,Fh],"svg");function b1(e){return e.join(" ").trim()}var D1=Ua(P1(),1);var Cc=L1("end"),Yi=L1("start");function L1(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 Mh(e){let t=Yi(e),n=Cc(e);if(t&&n)return{start:t,end:n}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?M1(e.position):"start"in e||"end"in e?M1(e):"line"in e||"column"in e?Bh(e):""}function Bh(e){return B1(e&&e.line)+":"+B1(e&&e.column)}function M1(e){return Bh(e&&e.start)+"-"+Bh(e&&e.end)}function B1(e){return e&&typeof e=="number"?e:1}var Wt=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}};Wt.prototype.file="";Wt.prototype.name="";Wt.prototype.reason="";Wt.prototype.message="";Wt.prototype.stack="";Wt.prototype.column=void 0;Wt.prototype.line=void 0;Wt.prototype.ancestors=void 0;Wt.prototype.cause=void 0;Wt.prototype.fatal=void 0;Wt.prototype.place=void 0;Wt.prototype.ruleId=void 0;Wt.prototype.source=void 0;var Dh={}.hasOwnProperty,nU=new Map,rU=/[A-Z]/g,oU=new Set(["table","tbody","thead","tfoot","tr"]),iU=new Set(["td","th"]),R1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Rh(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=gU(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=dU(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"?vc:y1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=z1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function z1(e,t,n){if(t.type==="element")return sU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return aU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return cU(e,t,n);if(t.type==="mdxjsEsm")return lU(e,t);if(t.type==="root")return uU(e,t,n);if(t.type==="text")return pU(e,t)}function sU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=vc,e.schema=o),e.ancestors.push(t);let i=O1(e,t.tagName,!1),s=fU(e,t),a=Nh(e,t);return oU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!wh(u):!0})),N1(e,s,i,t),zh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function aU(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 lU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ha(e,t.position)}function cU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=vc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:O1(e,t.name,!0),s=mU(e,t),a=Nh(e,t);return N1(e,s,i,t),zh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function uU(e,t,n){let r={};return zh(r,Nh(e,t)),e.create(t,e.Fragment,r,n)}function pU(e,t){return t.value}function N1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function zh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function dU(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 gU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Yi(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 fU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Dh.call(t.properties,o)){let i=hU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&iU.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 mU(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 Nh(e,t){let n=[],r=-1,o=e.passKeys?new Map:nU;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=z1(e,i,s);a!==void 0&&n.push(a)}return n}function hU(e,t,n){let r=Ah(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?d1(n):b1(n)),r.property==="style"){let o=typeof n=="object"?n:xU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=yU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Eh[r.property]||r.property:r.attribute,n]}}function xU(e,t){try{return(0,D1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Wt("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=R1+"#cannot-parse-style-attribute",o}}function O1(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=yc(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=yc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return Dh.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 Wt("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=R1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function yU(e){let t={},n;for(n in e)Dh.call(e,n)&&(t[bU(n)]=e[n]);return t}function bU(e){let t=e.replace(rU,SU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function SU(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 E6,jsx as A6,jsxs as P6}from"react/jsx-runtime";import{useEffect as Nde,useState as Ode}from"react";var wU={};function Oh(e,t){let n=t||wU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return $1(e,r,o)}function $1(e,t,n){if(vU(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]=$1(e[o],t,n);return r.join("")}function vU(e){return!!(e&&typeof e=="object")}var U1=document.createElement("i");function Ki(e){let t="&"+e+";";U1.innerHTML=t;let n=U1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function fn(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 Fn(e,t){return e.length>0?(fn(e,e.length,0,t),e):t}var j1={}.hasOwnProperty;function H1(e){let t={},n=-1;for(;++n<e.length;)kU(t,e[n]);return t}function kU(e,t){let n;for(n in t){let o=(j1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){j1.call(o,s)||(o[s]=[]);let a=i[s];CU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function CU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);fn(e,0,0,r)}function Tc(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 rr=_o(/[A-Za-z]/),un=_o(/[\dA-Za-z]/),W1=_o(/[#-'*+\--9=?A-Z^-~]/);function ya(e){return e!==null&&(e<32||e===127)}var ba=_o(/\d/),V1=_o(/[\dA-Fa-f]/),G1=_o(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Vt(e){return e!==null&&(e<0||e===32)}function We(e){return e===-2||e===-1||e===32}var q1=_o(/\p{P}|\p{S}/u),Y1=_o(/\s/);function _o(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function xr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&un(e.charCodeAt(n+1))&&un(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 K1={tokenize:TU};function TU(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 ue(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var Q1={tokenize:IU},X1={tokenize:FU};function IU(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&&I();let R=t.events.length,$=R,P;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){P=t.events[$][1].end;break}E(r);let z=R;for(;z<t.events.length;)t.events[z][1].end={...P},z++;return fn(t.events,$+1,0,t.events.slice(R)),t.events.length=z,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return f(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(X1,l,d)(D)}function l(D){return o&&I(),E(r),g(D)}function d(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,f(D)}function g(D){return t.containerState={},e.attempt(X1,p,f)(D)}function p(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function f(D){if(D===null){o&&I(),E(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){T(e.exit("chunkFlow"),!0),E(0),e.consume(D);return}return ue(D)?(e.consume(D),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),k)}function T(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 z=t.events.length,x=z,w,v;for(;x--;)if(t.events[x][0]==="exit"&&t.events[x][1].type==="chunkFlow"){if(w){v=t.events[x][1].end;break}w=!0}for(E(r),P=z;P<t.events.length;)t.events[P][1].end={...v},P++;fn(t.events,x+1,0,t.events.slice(z)),t.events.length=P}}function E(D){let R=n.length;for(;R-- >D;){let $=n[R];t.containerState=$[1],$[0].exit.call(t,e)}n.length=D}function I(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function FU(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 _h(e){if(e===null||Vt(e)||Y1(e))return 1;if(q1(e))return 2}function Xi(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:EU,tokenize:AU};function EU(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};J1(d,-u),J1(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=Fn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Fn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Fn(c,Xi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Fn(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=Fn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,fn(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 AU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=_h(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=_h(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 J1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var $h={name:"autolink",tokenize:PU};function PU(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 rr(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||un(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||un(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):W1(p)?(e.consume(p),c):n(p)}function l(p){return un(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||un(p))&&r++<63){let f=p===45?g:d;return e.consume(p),f}return n(p)}}var $o={partial:!0,tokenize:LU};function LU(e,t,n){return r;function r(i){return We(i)?qe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var Ic={continuation:{tokenize:BU},exit:DU,name:"blockQuote",tokenize:MU};function MU(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 BU(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(Ic,t,n)(s)}}function DU(e){e.exit("blockQuote")}var Fc={name:"characterEscape",tokenize:RU};function RU(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 G1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Ec={name:"characterReference",tokenize:zU};function zU(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=un,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=V1,l):(e.enter("characterReferenceValue"),i=7,s=ba,l(d))}function l(d){if(d===59&&o){let g=e.exit("characterReferenceValue");return s===un&&!Ki(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 Z1={partial:!0,tokenize:OU},Ac={concrete:!0,name:"codeFenced",tokenize:NU};function NU(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 z=r.events[r.events.length-1];return i=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[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||ue(P)?(e.exit("codeFencedFence"),r.interrupt?t(P):e.check(Z1,k,R)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(P))}function g(P){return P===null||ue(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||ue(P)?d(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(P))}function f(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(P)):P===96&&P===a?n(P):(e.consume(P),f)}function k(P){return e.attempt(o,R,T)(P)}function T(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),E}function E(P){return i>0&&We(P)?qe(e,I,"linePrefix",i+1)(P):I(P)}function I(P){return P===null||ue(P)?e.check(Z1,k,R)(P):(e.enter("codeFlowValue"),D(P))}function D(P){return P===null||ue(P)?(e.exit("codeFlowValue"),I(P)):(e.consume(P),D)}function R(P){return e.exit("codeFenced"),t(P)}function $(P,z,x){let w=0;return v;function v(b){return P.enter("lineEnding"),P.consume(b),P.exit("lineEnding"),C}function C(b){return P.enter("codeFencedFence"),We(b)?qe(P,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):m(b)}function m(b){return b===a?(P.enter("codeFencedFenceSequence"),F(b)):x(b)}function F(b){return b===a?(w++,P.consume(b),F):w>=s?(P.exit("codeFencedFenceSequence"),We(b)?qe(P,S,"whitespace")(b):S(b)):x(b)}function S(b){return b===null||ue(b)?(P.exit("codeFencedFence"),z(b)):x(b)}}}function OU(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:$U},_U={partial:!0,tokenize:UU};function $U(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):ue(c)?e.attempt(_U,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ue(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function UU(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):ue(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):ue(s)?o(s):n(s)}}var Uh={name:"codeText",previous:HU,resolve:jU,tokenize:WU};function jU(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 HU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function WU(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)):ue(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||ue(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 Pc=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 Lc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Pc(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,VU(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 fn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function VU(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,f=0,k=0,T=[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,T.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):T.pop(),g=T.length;g--;){let E=a.slice(T[g],T[g+1]),I=i.pop();u.push([I,I+E.length-1]),e.splice(I,2,E)}for(u.reverse(),g=-1;++g<u.length;)c[f+u[g][0]]=f+u[g][1],f+=u[g][1]-u[g][0]-1;return c}var jh={resolve:qU,tokenize:YU},GU={partial:!0,tokenize:KU};function qU(e){return Lc(e),e}function YU(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):ue(a)?e.check(GU,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 KU(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||ue(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 Mc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return d;function d(E){return E===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(E),e.exit(i),g):E===null||E===32||E===41||ya(E)?n(E):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),k(E))}function g(E){return E===62?(e.enter(i),e.consume(E),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(E))}function p(E){return E===62?(e.exit("chunkString"),e.exit(a),g(E)):E===null||E===60||ue(E)?n(E):(e.consume(E),E===92?f:p)}function f(E){return E===60||E===62||E===92?(e.consume(E),p):p(E)}function k(E){return!l&&(E===null||E===41||Vt(E))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(E)):l<c&&E===40?(e.consume(E),l++,k):E===41?(e.consume(E),l--,k):E===null||E===32||E===40||ya(E)?n(E):(e.consume(E),E===92?T:k)}function T(E){return E===40||E===41||E===92?(e.consume(E),k):k(E)}}function Bc(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):ue(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||ue(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 Dc(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):ue(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||ue(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 li(e,t){let n;return r;function r(o){return ue(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 Hh={name:"definition",tokenize:QU},XU={partial:!0,tokenize:JU};function QU(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return Bc.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 Vt(p)?li(e,c)(p):c(p)}function c(p){return Mc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(XU,d,d)(p)}function d(p){return We(p)?qe(e,g,"whitespace")(p):g(p)}function g(p){return p===null||ue(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function JU(e,t,n){return r;function r(a){return Vt(a)?li(e,o)(a):n(a)}function o(a){return Dc(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||ue(a)?t(a):n(a)}}var Wh={name:"hardBreakEscape",tokenize:ZU};function ZU(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return ue(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var Vh={name:"headingAtx",resolve:e5,tokenize:t5};function e5(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"},fn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function t5(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||Vt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||ue(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||Vt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var eT=["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"],Gh=["pre","script","style","textarea"];var qh={concrete:!0,name:"htmlFlow",resolveTo:o5,tokenize:i5},n5={partial:!0,tokenize:a5},r5={partial:!0,tokenize:s5};function o5(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 i5(e,t,n){let r=this,o,i,s,a,u;return c;function c(M){return l(M)}function l(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),d}function d(M){return M===33?(e.consume(M),g):M===47?(e.consume(M),i=!0,k):M===63?(e.consume(M),o=3,r.interrupt?t:h):rr(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function g(M){return M===45?(e.consume(M),o=2,p):M===91?(e.consume(M),o=5,a=0,f):rr(M)?(e.consume(M),o=4,r.interrupt?t:h):n(M)}function p(M){return M===45?(e.consume(M),r.interrupt?t:h):n(M)}function f(M){let Y="CDATA[";return M===Y.charCodeAt(a++)?(e.consume(M),a===Y.length?r.interrupt?t:m:f):n(M)}function k(M){return rr(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function T(M){if(M===null||M===47||M===62||Vt(M)){let Y=M===47,ee=s.toLowerCase();return!Y&&!i&&Gh.includes(ee)?(o=1,r.interrupt?t(M):m(M)):eT.includes(s.toLowerCase())?(o=6,Y?(e.consume(M),E):r.interrupt?t(M):m(M)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?I(M):D(M))}return M===45||un(M)?(e.consume(M),s+=String.fromCharCode(M),T):n(M)}function E(M){return M===62?(e.consume(M),r.interrupt?t:m):n(M)}function I(M){return We(M)?(e.consume(M),I):v(M)}function D(M){return M===47?(e.consume(M),v):M===58||M===95||rr(M)?(e.consume(M),R):We(M)?(e.consume(M),D):v(M)}function R(M){return M===45||M===46||M===58||M===95||un(M)?(e.consume(M),R):$(M)}function $(M){return M===61?(e.consume(M),P):We(M)?(e.consume(M),$):D(M)}function P(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),u=M,z):We(M)?(e.consume(M),P):x(M)}function z(M){return M===u?(e.consume(M),u=null,w):M===null||ue(M)?n(M):(e.consume(M),z)}function x(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Vt(M)?$(M):(e.consume(M),x)}function w(M){return M===47||M===62||We(M)?D(M):n(M)}function v(M){return M===62?(e.consume(M),C):n(M)}function C(M){return M===null||ue(M)?m(M):We(M)?(e.consume(M),C):n(M)}function m(M){return M===45&&o===2?(e.consume(M),A):M===60&&o===1?(e.consume(M),L):M===62&&o===4?(e.consume(M),U):M===63&&o===3?(e.consume(M),h):M===93&&o===5?(e.consume(M),N):ue(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(n5,W,F)(M)):M===null||ue(M)?(e.exit("htmlFlowData"),F(M)):(e.consume(M),m)}function F(M){return e.check(r5,S,W)(M)}function S(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),b}function b(M){return M===null||ue(M)?F(M):(e.enter("htmlFlowData"),m(M))}function A(M){return M===45?(e.consume(M),h):m(M)}function L(M){return M===47?(e.consume(M),s="",B):m(M)}function B(M){if(M===62){let Y=s.toLowerCase();return Gh.includes(Y)?(e.consume(M),U):m(M)}return rr(M)&&s.length<8?(e.consume(M),s+=String.fromCharCode(M),B):m(M)}function N(M){return M===93?(e.consume(M),h):m(M)}function h(M){return M===62?(e.consume(M),U):M===45&&o===2?(e.consume(M),h):m(M)}function U(M){return M===null||ue(M)?(e.exit("htmlFlowData"),W(M)):(e.consume(M),U)}function W(M){return e.exit("htmlFlow"),t(M)}}function s5(e,t,n){let r=this;return o;function o(s){return ue(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 a5(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt($o,t,n)}}var Yh={name:"htmlText",tokenize:l5};function l5(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):rr(h)?(e.consume(h),x):n(h)}function c(h){return h===45?(e.consume(h),l):h===91?(e.consume(h),i=0,f):rr(h)?(e.consume(h),I):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):ue(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?A(h):h===45?g(h):d(h)}function f(h){let U="CDATA[";return h===U.charCodeAt(i++)?(e.consume(h),i===U.length?k:f):n(h)}function k(h){return h===null?n(h):h===93?(e.consume(h),T):ue(h)?(s=k,L(h)):(e.consume(h),k)}function T(h){return h===93?(e.consume(h),E):k(h)}function E(h){return h===62?A(h):h===93?(e.consume(h),E):k(h)}function I(h){return h===null||h===62?A(h):ue(h)?(s=I,L(h)):(e.consume(h),I)}function D(h){return h===null?n(h):h===63?(e.consume(h),R):ue(h)?(s=D,L(h)):(e.consume(h),D)}function R(h){return h===62?A(h):D(h)}function $(h){return rr(h)?(e.consume(h),P):n(h)}function P(h){return h===45||un(h)?(e.consume(h),P):z(h)}function z(h){return ue(h)?(s=z,L(h)):We(h)?(e.consume(h),z):A(h)}function x(h){return h===45||un(h)?(e.consume(h),x):h===47||h===62||Vt(h)?w(h):n(h)}function w(h){return h===47?(e.consume(h),A):h===58||h===95||rr(h)?(e.consume(h),v):ue(h)?(s=w,L(h)):We(h)?(e.consume(h),w):A(h)}function v(h){return h===45||h===46||h===58||h===95||un(h)?(e.consume(h),v):C(h)}function C(h){return h===61?(e.consume(h),m):ue(h)?(s=C,L(h)):We(h)?(e.consume(h),C):w(h)}function m(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),o=h,F):ue(h)?(s=m,L(h)):We(h)?(e.consume(h),m):(e.consume(h),S)}function F(h){return h===o?(e.consume(h),o=void 0,b):h===null?n(h):ue(h)?(s=F,L(h)):(e.consume(h),F)}function S(h){return h===null||h===34||h===39||h===60||h===61||h===96?n(h):h===47||h===62||Vt(h)?w(h):(e.consume(h),S)}function b(h){return h===47||h===62||Vt(h)?w(h):n(h)}function A(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"),B}function B(h){return We(h)?qe(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):N(h)}function N(h){return e.enter("htmlTextData"),s(h)}}var ci={name:"labelEnd",resolveAll:d5,resolveTo:g5,tokenize:f5},c5={tokenize:m5},u5={tokenize:h5},p5={tokenize:x5};function d5(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&&fn(e,0,e.length,n),e}function g5(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=Fn(a,e.slice(i+1,i+r+3)),a=Fn(a,[["enter",l,t]]),a=Fn(a,Xi(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Fn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Fn(a,e.slice(s+1)),a=Fn(a,[["exit",u,t]]),fn(e,i,e.length,a),e}function f5(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(c5,l,s?l:d)(g):g===91?e.attempt(u5,l,s?c:d)(g):s?l(g):d(g)}function c(g){return e.attempt(p5,l,d)(g)}function l(g){return t(g)}function d(g){return i._balanced=!0,n(g)}}function m5(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 Vt(d)?li(e,i)(d):i(d)}function i(d){return d===41?l(d):Mc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return Vt(d)?li(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?Dc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return Vt(d)?li(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 h5(e,t,n){let r=this;return o;function o(a){return Bc.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 x5(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 Kh={name:"labelStartImage",resolveAll:ci.resolveAll,tokenize:y5};function y5(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 Xh={name:"labelStartLink",resolveAll:ci.resolveAll,tokenize:b5};function b5(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:S5};function S5(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}var ui={name:"thematicBreak",tokenize:w5};function w5(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||ue(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 Sn={continuation:{tokenize:T5},exit:F5,name:"list",tokenize:C5},v5={partial:!0,tokenize:E5},k5={partial:!0,tokenize:I5};function C5(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 f=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(f==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ba(p)){if(r.containerState.type||(r.containerState.type=f,e.enter(f,{_container:!0})),f==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ui,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(v5,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 T5(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(k5,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(Sn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function I5(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 F5(e){e.exit(this.containerState.type)}function E5(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 Rc={name:"setextUnderline",resolveTo:A5,tokenize:P5};function A5(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 P5(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||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var tT={tokenize:L5};function L5(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(jh,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 nT={resolveAll:sT()},rT=iT("string"),oT=iT("text");function iT(e){return{resolveAll:sT(e==="text"?M5: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 sT(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 M5(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 Qh={};Se(Qh,{attentionMarkers:()=>$5,contentInitial:()=>D5,disable:()=>U5,document:()=>B5,flow:()=>z5,flowInitial:()=>R5,insideSpan:()=>_5,string:()=>N5,text:()=>O5});var B5={42:Sn,43:Sn,45:Sn,48:Sn,49:Sn,50:Sn,51:Sn,52:Sn,53:Sn,54:Sn,55:Sn,56:Sn,57:Sn,62:Ic},D5={91:Hh},R5={[-2]:wa,[-1]:wa,32:wa},z5={35:Vh,42:ui,45:[Rc,ui],60:qh,61:Rc,95:ui,96:Ac,126:Ac},N5={38:Ec,92:Fc},O5={[-5]:ka,[-4]:ka,[-3]:ka,33:Kh,38:Ec,42:Sa,60:[$h,Yh],91:Xh,92:[Wh,Fc],93:ci,95:Sa,96:Uh},_5={null:[Sa,nT]},$5={null:[42,95]},U5={null:[]};function aT(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:w(z),check:w(x),consume:R,enter:$,exit:P,interrupt:w(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:E,events:[],now:T,parser:e,previous:null,sliceSerialize:f,sliceStream:k,write:p},d=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function p(F){return s=Fn(s,F),I(),s[s.length-1]!==null?[]:(v(t,0),l.events=Xi(i,l.events,l),l.events)}function f(F,S){return H5(k(F),S)}function k(F){return j5(s,F)}function T(){let{_bufferIndex:F,_index:S,line:b,column:A,offset:L}=r;return{_bufferIndex:F,_index:S,line:b,column:A,offset:L}}function E(F){o[F.line]=F.column,m()}function I(){let F;for(;r._index<s.length;){let S=s[r._index];if(typeof S=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<S.length;)D(S.charCodeAt(r._bufferIndex));else D(S)}}function D(F){u=void 0,g=F,d=d(F)}function R(F){ue(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,m()):F!==-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=F,u=!0}function $(F,S){let b=S||{};return b.type=F,b.start=T(),l.events.push(["enter",b,l]),a.push(b),b}function P(F){let S=a.pop();return S.end=T(),l.events.push(["exit",S,l]),S}function z(F,S){v(F,S.from)}function x(F,S){S.restore()}function w(F,S){return b;function b(A,L,B){let N,h,U,W;return Array.isArray(A)?Y(A):"tokenize"in A?Y([A]):M(A);function M(ae){return Ke;function Ke(be){let Te=be!==null&&ae[be],te=be!==null&&ae.null,Be=[...Array.isArray(Te)?Te:Te?[Te]:[],...Array.isArray(te)?te:te?[te]:[]];return Y(Be)(be)}}function Y(ae){return N=ae,h=0,ae.length===0?B:ee(ae[h])}function ee(ae){return Ke;function Ke(be){return W=C(),U=ae,ae.partial||(l.currentConstruct=ae),ae.name&&l.parser.constructs.disable.null.includes(ae.name)?xe(be):ae.tokenize.call(S?Object.assign(Object.create(l),S):l,c,ge,xe)(be)}}function ge(ae){return u=!0,F(U,W),L}function xe(ae){return u=!0,W.restore(),++h<N.length?ee(N[h]):B}}}function v(F,S){F.resolveAll&&!i.includes(F)&&i.push(F),F.resolve&&fn(l.events,S,l.events.length-S,F.resolve(l.events.slice(S),l)),F.resolveTo&&(l.events=F.resolveTo(l.events,l))}function C(){let F=T(),S=l.previous,b=l.currentConstruct,A=l.events.length,L=Array.from(a);return{from:A,restore:B};function B(){r=F,l.previous=S,l.currentConstruct=b,l.events.length=A,a=L,m()}}function m(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function j5(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 H5(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
|
+
`,poe=tn.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${t3} 0.8s linear infinite`,flexShrink:0})),t1=tn.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"})),n3=tn.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"})),doe=tn.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:`${e3} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var ua=tn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),pa=tn.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),n1=tn.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),da=tn.span(({color:e})=>({fontWeight:700,color:e})),r3=tn.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}})),goe=tn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),foe=tn.span(({color:e=ae})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${Q4} 1.2s ease-in-out infinite`,marginRight:"4px"})),moe=tn.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return ae;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 ae;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${Z4} 1.5s ease-in-out infinite`}:{}})),hoe=tn.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),xoe=tn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),o3=tn.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${J4} 1.2s linear infinite`,flexShrink:0}),i3=({color:e=ae})=>Ne.createElement(o3,null,Ne.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 Ne.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),yoe=tn.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:`${r1} 0.3s ease-out`}));function s3(e){let[t,n]=K4(0);return X4(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var o1=({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:p,durationSeconds:g})=>{let d=s3(e||t),{featureFlags:f}=ce(),k=f.showCosts,T=3.65,E=P=>P<.01?`$${P.toFixed(4)}`:P<.1?`$${P.toFixed(3)}`:`$${P.toFixed(2)}`,I=P=>{let z=P*T;return z<.01?`\u20AA${z.toFixed(4)}`:z<.1?`\u20AA${z.toFixed(3)}`:`\u20AA${z.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 Ne.createElement(yh,null,Ne.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},d,"s \xB7 Esc to stop"));if(t)return Ne.createElement(yh,null,Ne.createElement(t1,null,Ne.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement(i3,{color:"#7c3aed"}),Ne.createElement(da,{color:"#7c3aed"},"Verifying...")),c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement("span",{style:{color:"#6b7280"}},d,"s"))));if(r>0||o!==void 0){let P=(a||0)+(u||0),z=(p||0)>0,x=z&&a?Math.round(p/a*100):0,w=Math.max(o??0,i??0),v=m=>m>=80?"#16a34a":m>=50?"#ca8a04":"#dc2626",C=m=>m>=100?"\u25CF":m>=50?"\u25D0":"\u25CB";return Ne.createElement(yh,null,r===0?Ne.createElement(n3,null,Ne.createElement("span",null,"\u2713"),"Perfect!"):Ne.createElement(t1,null,Ne.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ne.createElement(r3,{tint:v(w),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},Ne.createElement("span",{className:"score-dot"}),Ne.createElement("span",{className:"score-label"},"Score"),Ne.createElement("span",{className:"score-value"},w)),k&&s!==void 0&&s>0&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement(da,{color:"#16a34a"},E(s)),Ne.createElement("span",{style:{color:"#6b7280"}},"/"),Ne.createElement(da,{color:"#16a34a"},I(s)))),k&&P>0&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${z?` \xB7 Cached: ${p?.toLocaleString()}`:""}`},Ne.createElement(n1,{color:"#7c3aed"},"#"),Ne.createElement(da,{color:"#7c3aed"},D(P)),Ne.createElement("span",{style:{color:"#6b7280"}},"tokens"),z&&Ne.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",x,"%"))),g!==void 0&&g>0&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ua,null,"|"),Ne.createElement(pa,null,Ne.createElement(n1,{color:"#6b7280"},"\u23F1"),Ne.createElement(da,{color:"#6b7280"},g,"s"))))}return null};var p3=Vn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),Eoe=Vn.div({display:"flex",gap:"8px",alignItems:"center"}),d3=u3({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),g3=Vn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${d3} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),f3=Vn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),m3=Vn.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"})),h3=Vn.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:ja},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)`}}}),x3=Vn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),y3=Vn.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),b3=Vn(xn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),S3=Vn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),i1=Vn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),s1=Vn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?ja:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),a1=Vn.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)"})),l1=Vn.input({position:"absolute",opacity:0,width:0,height:0}),w3=()=>{let[e,t]=l3(0),n=c3();c1(()=>(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 mt.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},bh=()=>{let{sessionToken:e}=js(),{usageData:t}=we(),{selectedProjectId:n}=io(),{currentMapping:r,hasMapping:o}=ni(),{loadingMapping:i,currentStoryId:s}=nt(),{startReview:a,cancelReview:u,isReviewing:c}=mm(),{isLoadingScreenshots:l}=ei(),{storybookImageUrl:p,figmaImageUrl:g,currentReviewId:d,reviewHistory:f,setReviewDetailTab:k,setReviewResults:T,setFigmaImageUrl:E,setStorybookImageUrl:I,setFullPrompt:D,setFullResponse:R,includeTextComparison:$,setIncludeTextComparison:P,usePromptCache:z,setUsePromptCache:x,isValidating:w,validationUsage:v,isGenerating:C,isApplying:m,streamingStatus:F,featureFlags:S,userRole:b,roleOverride:A,isReviewing:L}=ce(),B=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=f.find(fe=>fe.id===d),U=(N?.issues||[]).filter(fe=>!fe.dismissed).length,W=N?.complianceScore,M=N?.visualSimilarity,Y=(N?.costUsd||0)+(v?.costUsd||0),ee=(N?.inputTokens||0)+(v?.inputTokens||0),ge=(N?.outputTokens||0)+(v?.outputTokens||0),xe=a3(()=>{let fe=s?f.filter(me=>me.storyId===s):f,tt=fe.filter(me=>!me.parentReviewId).sort((me,ie)=>new Date(ie.createdAt).getTime()-new Date(me.createdAt).getTime()),he=fe.filter(me=>me.parentReviewId),oe=[];for(let me of tt){oe.push(me);let ie=he.filter(O=>O.parentReviewId===me.id).sort((O,j)=>(O.iterationNumber||0)-(j.iterationNumber||0));oe.push(...ie)}let K=he.filter(me=>!tt.some(ie=>ie.id===me.parentReviewId));return oe.push(...K),oe},[f,s]);c1(()=>{if(!c)return;let fe=tt=>{tt.key==="Escape"&&(tt.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let se=o&&r?.figmaNodeId,Ke=C||m,be=B>0,Te=!!(e&&n&&!c&&!l&&!Ke&&s&&p&&se&&g&&be),te=async(fe=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{k("chat"),await a({isIteration:fe,parentReviewId:fe?d:void 0})}catch(tt){console.error("[ReviewActions] Review error:",tt)}},Be=()=>te(!1),Pe=fe=>{let tt=fe.target.value;if(tt){let he=f.find(oe=>oe.id===tt);he&&(T({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&&E(he.figmaImageData),he.storybookImageData&&I(he.storybookImageData),(A??b)==="admin"&&(D(he.aiPrompt||""),R(he.aiResponse||"")),k("issues"))}},pe=fe=>{let tt=new Date(fe),oe=new Date().getTime()-tt.getTime(),K=Math.floor(oe/6e4),me=Math.floor(oe/36e5),ie=Math.floor(oe/864e5);return K<1?"Just now":K<60?`${K}m ago`:me<24?`${me}h ago`:ie<7?`${ie}d ago`:tt.toLocaleDateString()},Lt=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]||"":"",nn=fe=>{let tt=fe.split("--"),he=tt[tt.length-1]||fe;return he.charAt(0).toUpperCase()+he.slice(1)},Dr=(A??b)==="admin";return mt.createElement("div",null,mt.createElement(p3,null,S.enableModelSelection&&mt.createElement(e1,null),Dr&&mt.createElement(S3,null,mt.createElement(i1,{title:"Compare text content between Figma design and Storybook component"},mt.createElement(l1,{type:"checkbox",checked:$,onChange:fe=>P(fe.target.checked)}),mt.createElement(s1,{checked:$},mt.createElement(a1,{checked:$})),"Compare text"),S.showCosts&&mt.createElement(i1,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},mt.createElement(l1,{type:"checkbox",checked:z,onChange:fe=>x(fe.target.checked)}),mt.createElement(s1,{checked:z},mt.createElement(a1,{checked:z})),"Cache prompt")),mt.createElement(m3,null,mt.createElement(h3,{variant:c?"yellow":"purple",disabled:c?!1:!Te,onClick:c?u:Be,title:c?"Click to stop review":e?n?s?se?l?"Loading screenshots...":Ke?"Wait for fixes to complete...":p?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 ${Et.NAME} first`},c?mt.createElement(mt.Fragment,null,mt.createElement(g3,null),"Reviewing",mt.createElement(w3,null)):mt.createElement(mt.Fragment,null,mt.createElement(f3,null,mt.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",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"}))),"Review")),L?null:w||N?mt.createElement(o1,{isReviewing:!1,isValidating:w,streamingStatus:F,issueCount:U,score:W,visualSimilarity:M,costUsd:Y||N?.costUsd,inputTokens:ee||N?.inputTokens,outputTokens:ge||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,xe.length>0&&mt.createElement(y3,null,mt.createElement(b3,{value:d||"",onChange:Pe,title:"Review history"},mt.createElement("option",{value:""},"Select a review..."),xe.map(fe=>{let tt=!!fe.parentReviewId,he=tt?" \u21B3 ":"\u25CF ",oe=tt&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",K=fe.issuesCount??fe.issues?.length??0,me=fe.complianceScore??"--",ie=Lt(fe.modelId);return mt.createElement("option",{key:fe.id,value:fe.id},he,oe,pe(fe.createdAt)," - ",K," issues (",me,"%)",ie?` \xB7 ${ie}`:"",fe.storyId?` \xB7 ${nn(fe.storyId)}`:"")}))))),!se&&!i&&mt.createElement(x3,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import Loe,{useState as Moe}from"react";import{styled as u1}from"storybook/theming";var Roe=u1.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),zoe=u1(bo)({padding:"8px 12px",fontSize:"12px"});import _oe,{useState as $oe}from"react";import{styled as Sh}from"storybook/theming";Ce();He();$e();ct();var qoe=Sh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),Yoe=Sh(Nr)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),Koe=Sh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import Joe from"react";import{styled as v3}from"storybook/theming";var tie=v3.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));Ce();import oie from"react";import{styled as Vr}from"storybook/theming";var aie=Vr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),lie=Vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),cie=Vr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),uie=Vr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),pie=Vr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),die=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"})),gie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),fie=Vr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),mie=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)"}}})),hie=Vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));Ce();import bie,{useState as Sie}from"react";import{styled as Gr}from"storybook/theming";var kie=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)`}}),Cie=Gr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Tie=Gr.div({display:"flex",alignItems:"center",gap:"8px"}),Iie=Gr.span({fontSize:"12px",opacity:.7}),Fie=Gr.span({fontSize:"13px",fontWeight:500}),Eie=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})),Aie=Gr.div({marginTop:"12px",fontSize:"11px"}),Pie=Gr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),Lie=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"})),Mie=Gr.span({fontSize:"12px"});$e();He();import Qt from"react";import{styled as as}from"storybook/theming";import Br,{useEffect as wW}from"react";import{styled as Aa}from"storybook/theming";Ce();import di,{useState as OU}from"react";import{styled as es}from"storybook/theming";var p1={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 d1(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var k3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,C3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,T3={};function yc(e,t){return((t||T3).jsx?C3:k3).test(e)}var I3=/[ \t\n\f\r]/g;function wh(e){return typeof e=="object"?e.type==="text"?g1(e.value):!1:g1(e)}function g1(e){return e.replace(I3,"")===""}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 vh(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 un=class{constructor(t,n){this.attribute=n,this.property=t}};un.prototype.attribute="";un.prototype.booleanish=!1;un.prototype.boolean=!1;un.prototype.commaOrSpaceSeparated=!1;un.prototype.commaSeparated=!1;un.prototype.defined=!1;un.prototype.mustUseProperty=!1;un.prototype.number=!1;un.prototype.overloadedBoolean=!1;un.prototype.property="";un.prototype.spaceSeparated=!1;un.prototype.space=void 0;var fa={};Se(fa,{boolean:()=>Ge,booleanish:()=>$t,commaOrSpaceSeparated:()=>Gn,commaSeparated:()=>No,number:()=>X,overloadedBoolean:()=>bc,spaceSeparated:()=>vt});var F3=0,Ge=ii(),$t=ii(),bc=ii(),X=ii(),vt=ii(),No=ii(),Gn=ii();function ii(){return 2**++F3}var kh=Object.keys(fa),si=class extends un{constructor(t,n,r,o){let i=-1;if(super(t,n),f1(this,"space",o),typeof r=="number")for(;++i<kh.length;){let s=kh[i];f1(this,kh[i],(r&fa[s])===fa[s])}}};si.prototype.defined=!0;function f1(e,t,n){n&&(e[t]=n)}function hr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new si(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 Ch=hr({properties:{ariaActiveDescendant:null,ariaAtomic:$t,ariaAutoComplete:null,ariaBusy:$t,ariaChecked:$t,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:vt,ariaCurrent:null,ariaDescribedBy:vt,ariaDetails:null,ariaDisabled:$t,ariaDropEffect:vt,ariaErrorMessage:null,ariaExpanded:$t,ariaFlowTo:vt,ariaGrabbed:$t,ariaHasPopup:null,ariaHidden:$t,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:vt,ariaLevel:X,ariaLive:null,ariaModal:$t,ariaMultiLine:$t,ariaMultiSelectable:$t,ariaOrientation:null,ariaOwns:vt,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:$t,ariaReadOnly:$t,ariaRelevant:null,ariaRequired:$t,ariaRoleDescription:vt,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:$t,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 Sc(e,t){return t in e?e[t]:t}function wc(e,t){return Sc(e,t.toLowerCase())}var m1=hr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:No,acceptCharset:vt,accessKey:vt,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:vt,autoFocus:Ge,autoPlay:Ge,blocking:vt,capture:null,charSet:null,checked:Ge,cite:null,className:vt,cols:X,colSpan:null,content:null,contentEditable:$t,controls:Ge,controlsList:vt,coords:X|No,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:bc,draggable:$t,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:vt,height:X,hidden:bc,high:X,href:null,hrefLang:null,htmlFor:vt,httpEquiv:vt,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:vt,itemRef:vt,itemScope:Ge,itemType:vt,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:vt,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:vt,required:Ge,reversed:Ge,rows:X,rowSpan:X,sandbox:vt,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:$t,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:$t,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:vt,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:$t,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:wc});var h1=hr({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:Gn,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:vt,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:Gn,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:vt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,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:Gn,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:Gn,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:Gn,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:Sc});var Th=hr({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 Ih=hr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wc});var Fh=hr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Eh={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 E3=/[A-Z]/g,x1=/-[a-z]/g,A3=/^data[-\w.:]+$/i;function Ah(e,t){let n=ga(t),r=t,o=un;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&A3.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(x1,L3);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!x1.test(i)){let s=i.replace(E3,P3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=si}return new o(r,t)}function P3(e){return"-"+e.toLowerCase()}function L3(e){return e.charAt(1).toUpperCase()}var y1=vh([Ch,m1,Th,Ih,Fh],"html"),vc=vh([Ch,h1,Th,Ih,Fh],"svg");function b1(e){return e.join(" ").trim()}var D1=Ua(P1(),1);var Cc=L1("end"),Yi=L1("start");function L1(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 Mh(e){let t=Yi(e),n=Cc(e);if(t&&n)return{start:t,end:n}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?M1(e.position):"start"in e||"end"in e?M1(e):"line"in e||"column"in e?Bh(e):""}function Bh(e){return B1(e&&e.line)+":"+B1(e&&e.column)}function M1(e){return Bh(e&&e.start)+"-"+Bh(e&&e.end)}function B1(e){return e&&typeof e=="number"?e:1}var Vt=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}};Vt.prototype.file="";Vt.prototype.name="";Vt.prototype.reason="";Vt.prototype.message="";Vt.prototype.stack="";Vt.prototype.column=void 0;Vt.prototype.line=void 0;Vt.prototype.ancestors=void 0;Vt.prototype.cause=void 0;Vt.prototype.fatal=void 0;Vt.prototype.place=void 0;Vt.prototype.ruleId=void 0;Vt.prototype.source=void 0;var Dh={}.hasOwnProperty,r5=new Map,o5=/[A-Z]/g,i5=new Set(["table","tbody","thead","tfoot","tr"]),s5=new Set(["td","th"]),R1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Rh(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=f5(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=g5(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"?vc:y1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=z1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function z1(e,t,n){if(t.type==="element")return a5(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return l5(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return u5(e,t,n);if(t.type==="mdxjsEsm")return c5(e,t);if(t.type==="root")return p5(e,t,n);if(t.type==="text")return d5(e,t)}function a5(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=vc,e.schema=o),e.ancestors.push(t);let i=O1(e,t.tagName,!1),s=m5(e,t),a=Nh(e,t);return i5.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!wh(u):!0})),N1(e,s,i,t),zh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function l5(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 c5(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ha(e,t.position)}function u5(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=vc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:O1(e,t.name,!0),s=h5(e,t),a=Nh(e,t);return N1(e,s,i,t),zh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function p5(e,t,n){let r={};return zh(r,Nh(e,t)),e.create(t,e.Fragment,r,n)}function d5(e,t){return t.value}function N1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function zh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function g5(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 f5(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Yi(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 m5(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Dh.call(t.properties,o)){let i=x5(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&s5.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 h5(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 Nh(e,t){let n=[],r=-1,o=e.passKeys?new Map:r5;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=z1(e,i,s);a!==void 0&&n.push(a)}return n}function x5(e,t,n){let r=Ah(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?d1(n):b1(n)),r.property==="style"){let o=typeof n=="object"?n:y5(e,String(n));return e.stylePropertyNameCase==="css"&&(o=b5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Eh[r.property]||r.property:r.attribute,n]}}function y5(e,t){try{return(0,D1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Vt("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=R1+"#cannot-parse-style-attribute",o}}function O1(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=yc(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=yc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return Dh.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 Vt("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=R1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function b5(e){let t={},n;for(n in e)Dh.call(e,n)&&(t[S5(n)]=e[n]);return t}function S5(e){let t=e.replace(o5,w5);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function w5(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 AU,jsx as PU,jsxs as LU}from"react/jsx-runtime";import{useEffect as Wde,useState as Vde}from"react";var v5={};function Oh(e,t){let n=t||v5,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return $1(e,r,o)}function $1(e,t,n){if(k5(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]=$1(e[o],t,n);return r.join("")}function k5(e){return!!(e&&typeof e=="object")}var U1=document.createElement("i");function Ki(e){let t="&"+e+";";U1.innerHTML=t;let n=U1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function mn(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 An(e,t){return e.length>0?(mn(e,e.length,0,t),e):t}var j1={}.hasOwnProperty;function H1(e){let t={},n=-1;for(;++n<e.length;)C5(t,e[n]);return t}function C5(e,t){let n;for(n in t){let o=(j1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){j1.call(o,s)||(o[s]=[]);let a=i[s];T5(o[s],Array.isArray(a)?a:a?[a]:[])}}}function T5(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);mn(e,0,0,r)}function Tc(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 rr=_o(/[A-Za-z]/),pn=_o(/[\dA-Za-z]/),W1=_o(/[#-'*+\--9=?A-Z^-~]/);function ya(e){return e!==null&&(e<32||e===127)}var ba=_o(/\d/),V1=_o(/[\dA-Fa-f]/),G1=_o(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Gt(e){return e!==null&&(e<0||e===32)}function We(e){return e===-2||e===-1||e===32}var q1=_o(/\p{P}|\p{S}/u),Y1=_o(/\s/);function _o(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function xr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&pn(e.charCodeAt(n+1))&&pn(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 K1={tokenize:I5};function I5(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 ue(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var Q1={tokenize:F5},X1={tokenize:E5};function F5(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&&I();let R=t.events.length,$=R,P;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){P=t.events[$][1].end;break}E(r);let z=R;for(;z<t.events.length;)t.events[z][1].end={...P},z++;return mn(t.events,$+1,0,t.events.slice(R)),t.events.length=z,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return f(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(X1,l,p)(D)}function l(D){return o&&I(),E(r),g(D)}function p(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,f(D)}function g(D){return t.containerState={},e.attempt(X1,d,f)(D)}function d(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function f(D){if(D===null){o&&I(),E(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){T(e.exit("chunkFlow"),!0),E(0),e.consume(D);return}return ue(D)?(e.consume(D),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),k)}function T(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 z=t.events.length,x=z,w,v;for(;x--;)if(t.events[x][0]==="exit"&&t.events[x][1].type==="chunkFlow"){if(w){v=t.events[x][1].end;break}w=!0}for(E(r),P=z;P<t.events.length;)t.events[P][1].end={...v},P++;mn(t.events,x+1,0,t.events.slice(z)),t.events.length=P}}function E(D){let R=n.length;for(;R-- >D;){let $=n[R];t.containerState=$[1],$[0].exit.call(t,e)}n.length=D}function I(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function E5(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 _h(e){if(e===null||Gt(e)||Y1(e))return 1;if(q1(e))return 2}function Xi(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:A5,tokenize:P5};function A5(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 p={...e[r][1].end},g={...e[n][1].start};J1(p,-u),J1(g,u),s={type:u>1?"strongSequence":"emphasisSequence",start:p,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=An(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=An(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=An(c,Xi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=An(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=An(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,mn(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 P5(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=_h(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=_h(u),p=!l||l===2&&o||n.includes(u),g=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?p:p&&(o||!g)),c._close=!!(i===42?g:g&&(l||!p)),t(u)}}function J1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var $h={name:"autolink",tokenize:L5};function L5(e,t,n){let r=0;return o;function o(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(d){return rr(d)?(e.consume(d),s):d===64?n(d):c(d)}function s(d){return d===43||d===45||d===46||pn(d)?(r=1,a(d)):c(d)}function a(d){return d===58?(e.consume(d),r=0,u):(d===43||d===45||d===46||pn(d))&&r++<32?(e.consume(d),a):(r=0,c(d))}function u(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):d===null||d===32||d===60||ya(d)?n(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),l):W1(d)?(e.consume(d),c):n(d)}function l(d){return pn(d)?p(d):n(d)}function p(d){return d===46?(e.consume(d),r=0,l):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):g(d)}function g(d){if((d===45||pn(d))&&r++<63){let f=d===45?g:p;return e.consume(d),f}return n(d)}}var $o={partial:!0,tokenize:M5};function M5(e,t,n){return r;function r(i){return We(i)?qe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var Ic={continuation:{tokenize:D5},exit:R5,name:"blockQuote",tokenize:B5};function B5(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 D5(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(Ic,t,n)(s)}}function R5(e){e.exit("blockQuote")}var Fc={name:"characterEscape",tokenize:z5};function z5(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 G1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Ec={name:"characterReference",tokenize:N5};function N5(e,t,n){let r=this,o=0,i,s;return a;function a(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=pn,l(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=V1,l):(e.enter("characterReferenceValue"),i=7,s=ba,l(p))}function l(p){if(p===59&&o){let g=e.exit("characterReferenceValue");return s===pn&&!Ki(r.sliceSerialize(g))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(p)&&o++<i?(e.consume(p),l):n(p)}}var Z1={partial:!0,tokenize:_5},Ac={concrete:!0,name:"codeFenced",tokenize:O5};function O5(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 z=r.events[r.events.length-1];return i=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[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,p,"whitespace")(P):p(P))}function p(P){return P===null||ue(P)?(e.exit("codeFencedFence"),r.interrupt?t(P):e.check(Z1,k,R)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(P))}function g(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(P)):We(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,d,"whitespace")(P)):P===96&&P===a?n(P):(e.consume(P),g)}function d(P){return P===null||ue(P)?p(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(P))}function f(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(P)):P===96&&P===a?n(P):(e.consume(P),f)}function k(P){return e.attempt(o,R,T)(P)}function T(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),E}function E(P){return i>0&&We(P)?qe(e,I,"linePrefix",i+1)(P):I(P)}function I(P){return P===null||ue(P)?e.check(Z1,k,R)(P):(e.enter("codeFlowValue"),D(P))}function D(P){return P===null||ue(P)?(e.exit("codeFlowValue"),I(P)):(e.consume(P),D)}function R(P){return e.exit("codeFenced"),t(P)}function $(P,z,x){let w=0;return v;function v(b){return P.enter("lineEnding"),P.consume(b),P.exit("lineEnding"),C}function C(b){return P.enter("codeFencedFence"),We(b)?qe(P,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):m(b)}function m(b){return b===a?(P.enter("codeFencedFenceSequence"),F(b)):x(b)}function F(b){return b===a?(w++,P.consume(b),F):w>=s?(P.exit("codeFencedFenceSequence"),We(b)?qe(P,S,"whitespace")(b):S(b)):x(b)}function S(b){return b===null||ue(b)?(P.exit("codeFencedFence"),z(b)):x(b)}}}function _5(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:U5},$5={partial:!0,tokenize:j5};function U5(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):ue(c)?e.attempt($5,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ue(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function j5(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):ue(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):ue(s)?o(s):n(s)}}var Uh={name:"codeText",previous:W5,resolve:H5,tokenize:V5};function H5(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 W5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function V5(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,p(g)):ue(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||ue(g)?(e.exit("codeTextData"),c(g)):(e.consume(g),l)}function p(g){return g===96?(e.consume(g),i++,p):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(s.type="codeTextData",l(g))}}var Pc=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 Lc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Pc(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,G5(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 mn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function G5(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,p,g=-1,d=n,f=0,k=0,T=[k];for(;d;){for(;e.get(++o)[1]!==d;);i.push(o),d._tokenizer||(l=r.sliceStream(d),d.next||l.push(null),p&&s.defineSkip(d.start),d._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),d._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),p=d,d=d.next}for(d=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,T.push(k),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(s.events=[],d?(d._tokenizer=void 0,d.previous=void 0):T.pop(),g=T.length;g--;){let E=a.slice(T[g],T[g+1]),I=i.pop();u.push([I,I+E.length-1]),e.splice(I,2,E)}for(u.reverse(),g=-1;++g<u.length;)c[f+u[g][0]]=f+u[g][1],f+=u[g][1]-u[g][0]-1;return c}var jh={resolve:Y5,tokenize:K5},q5={partial:!0,tokenize:X5};function Y5(e){return Lc(e),e}function K5(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):ue(a)?e.check(q5,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 X5(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||ue(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 Mc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return p;function p(E){return E===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(E),e.exit(i),g):E===null||E===32||E===41||ya(E)?n(E):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),k(E))}function g(E){return E===62?(e.enter(i),e.consume(E),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(E))}function d(E){return E===62?(e.exit("chunkString"),e.exit(a),g(E)):E===null||E===60||ue(E)?n(E):(e.consume(E),E===92?f:d)}function f(E){return E===60||E===62||E===92?(e.consume(E),d):d(E)}function k(E){return!l&&(E===null||E===41||Gt(E))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(E)):l<c&&E===40?(e.consume(E),l++,k):E===41?(e.consume(E),l--,k):E===null||E===32||E===40||ya(E)?n(E):(e.consume(E),E===92?T:k)}function T(E){return E===40||E===41||E===92?(e.consume(E),k):k(E)}}function Bc(e,t,n,r,o,i){let s=this,a=0,u;return c;function c(d){return e.enter(r),e.enter(o),e.consume(d),e.exit(o),e.enter(i),l}function l(d){return a>999||d===null||d===91||d===93&&!u||d===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):d===93?(e.exit(i),e.enter(o),e.consume(d),e.exit(o),e.exit(r),t):ue(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===null||d===91||d===93||ue(d)||a++>999?(e.exit("chunkString"),l(d)):(e.consume(d),u||(u=!We(d)),d===92?g:p)}function g(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function Dc(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):ue(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||ue(g)?(e.exit("chunkString"),c(g)):(e.consume(g),g===92?p:l)}function p(g){return g===s||g===92?(e.consume(g),l):l(g)}}function li(e,t){let n;return r;function r(o){return ue(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 Hh={name:"definition",tokenize:J5},Q5={partial:!0,tokenize:Z5};function J5(e,t,n){let r=this,o;return i;function i(d){return e.enter("definition"),s(d)}function s(d){return Bc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return o=po(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),u):n(d)}function u(d){return Gt(d)?li(e,c)(d):c(d)}function c(d){return Mc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function l(d){return e.attempt(Q5,p,p)(d)}function p(d){return We(d)?qe(e,g,"whitespace")(d):g(d)}function g(d){return d===null||ue(d)?(e.exit("definition"),r.parser.defined.push(o),t(d)):n(d)}}function Z5(e,t,n){return r;function r(a){return Gt(a)?li(e,o)(a):n(a)}function o(a){return Dc(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||ue(a)?t(a):n(a)}}var Wh={name:"hardBreakEscape",tokenize:e6};function e6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return ue(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var Vh={name:"headingAtx",resolve:t6,tokenize:n6};function t6(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"},mn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function n6(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||Gt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||ue(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||Gt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var eT=["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"],Gh=["pre","script","style","textarea"];var qh={concrete:!0,name:"htmlFlow",resolveTo:i6,tokenize:s6},r6={partial:!0,tokenize:l6},o6={partial:!0,tokenize:a6};function i6(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 s6(e,t,n){let r=this,o,i,s,a,u;return c;function c(M){return l(M)}function l(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),p}function p(M){return M===33?(e.consume(M),g):M===47?(e.consume(M),i=!0,k):M===63?(e.consume(M),o=3,r.interrupt?t:h):rr(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function g(M){return M===45?(e.consume(M),o=2,d):M===91?(e.consume(M),o=5,a=0,f):rr(M)?(e.consume(M),o=4,r.interrupt?t:h):n(M)}function d(M){return M===45?(e.consume(M),r.interrupt?t:h):n(M)}function f(M){let Y="CDATA[";return M===Y.charCodeAt(a++)?(e.consume(M),a===Y.length?r.interrupt?t:m:f):n(M)}function k(M){return rr(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function T(M){if(M===null||M===47||M===62||Gt(M)){let Y=M===47,ee=s.toLowerCase();return!Y&&!i&&Gh.includes(ee)?(o=1,r.interrupt?t(M):m(M)):eT.includes(s.toLowerCase())?(o=6,Y?(e.consume(M),E):r.interrupt?t(M):m(M)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?I(M):D(M))}return M===45||pn(M)?(e.consume(M),s+=String.fromCharCode(M),T):n(M)}function E(M){return M===62?(e.consume(M),r.interrupt?t:m):n(M)}function I(M){return We(M)?(e.consume(M),I):v(M)}function D(M){return M===47?(e.consume(M),v):M===58||M===95||rr(M)?(e.consume(M),R):We(M)?(e.consume(M),D):v(M)}function R(M){return M===45||M===46||M===58||M===95||pn(M)?(e.consume(M),R):$(M)}function $(M){return M===61?(e.consume(M),P):We(M)?(e.consume(M),$):D(M)}function P(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),u=M,z):We(M)?(e.consume(M),P):x(M)}function z(M){return M===u?(e.consume(M),u=null,w):M===null||ue(M)?n(M):(e.consume(M),z)}function x(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Gt(M)?$(M):(e.consume(M),x)}function w(M){return M===47||M===62||We(M)?D(M):n(M)}function v(M){return M===62?(e.consume(M),C):n(M)}function C(M){return M===null||ue(M)?m(M):We(M)?(e.consume(M),C):n(M)}function m(M){return M===45&&o===2?(e.consume(M),A):M===60&&o===1?(e.consume(M),L):M===62&&o===4?(e.consume(M),U):M===63&&o===3?(e.consume(M),h):M===93&&o===5?(e.consume(M),N):ue(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(r6,W,F)(M)):M===null||ue(M)?(e.exit("htmlFlowData"),F(M)):(e.consume(M),m)}function F(M){return e.check(o6,S,W)(M)}function S(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),b}function b(M){return M===null||ue(M)?F(M):(e.enter("htmlFlowData"),m(M))}function A(M){return M===45?(e.consume(M),h):m(M)}function L(M){return M===47?(e.consume(M),s="",B):m(M)}function B(M){if(M===62){let Y=s.toLowerCase();return Gh.includes(Y)?(e.consume(M),U):m(M)}return rr(M)&&s.length<8?(e.consume(M),s+=String.fromCharCode(M),B):m(M)}function N(M){return M===93?(e.consume(M),h):m(M)}function h(M){return M===62?(e.consume(M),U):M===45&&o===2?(e.consume(M),h):m(M)}function U(M){return M===null||ue(M)?(e.exit("htmlFlowData"),W(M)):(e.consume(M),U)}function W(M){return e.exit("htmlFlow"),t(M)}}function a6(e,t,n){let r=this;return o;function o(s){return ue(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 l6(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt($o,t,n)}}var Yh={name:"htmlText",tokenize:c6};function c6(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):rr(h)?(e.consume(h),x):n(h)}function c(h){return h===45?(e.consume(h),l):h===91?(e.consume(h),i=0,f):rr(h)?(e.consume(h),I):n(h)}function l(h){return h===45?(e.consume(h),d):n(h)}function p(h){return h===null?n(h):h===45?(e.consume(h),g):ue(h)?(s=p,L(h)):(e.consume(h),p)}function g(h){return h===45?(e.consume(h),d):p(h)}function d(h){return h===62?A(h):h===45?g(h):p(h)}function f(h){let U="CDATA[";return h===U.charCodeAt(i++)?(e.consume(h),i===U.length?k:f):n(h)}function k(h){return h===null?n(h):h===93?(e.consume(h),T):ue(h)?(s=k,L(h)):(e.consume(h),k)}function T(h){return h===93?(e.consume(h),E):k(h)}function E(h){return h===62?A(h):h===93?(e.consume(h),E):k(h)}function I(h){return h===null||h===62?A(h):ue(h)?(s=I,L(h)):(e.consume(h),I)}function D(h){return h===null?n(h):h===63?(e.consume(h),R):ue(h)?(s=D,L(h)):(e.consume(h),D)}function R(h){return h===62?A(h):D(h)}function $(h){return rr(h)?(e.consume(h),P):n(h)}function P(h){return h===45||pn(h)?(e.consume(h),P):z(h)}function z(h){return ue(h)?(s=z,L(h)):We(h)?(e.consume(h),z):A(h)}function x(h){return h===45||pn(h)?(e.consume(h),x):h===47||h===62||Gt(h)?w(h):n(h)}function w(h){return h===47?(e.consume(h),A):h===58||h===95||rr(h)?(e.consume(h),v):ue(h)?(s=w,L(h)):We(h)?(e.consume(h),w):A(h)}function v(h){return h===45||h===46||h===58||h===95||pn(h)?(e.consume(h),v):C(h)}function C(h){return h===61?(e.consume(h),m):ue(h)?(s=C,L(h)):We(h)?(e.consume(h),C):w(h)}function m(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),o=h,F):ue(h)?(s=m,L(h)):We(h)?(e.consume(h),m):(e.consume(h),S)}function F(h){return h===o?(e.consume(h),o=void 0,b):h===null?n(h):ue(h)?(s=F,L(h)):(e.consume(h),F)}function S(h){return h===null||h===34||h===39||h===60||h===61||h===96?n(h):h===47||h===62||Gt(h)?w(h):(e.consume(h),S)}function b(h){return h===47||h===62||Gt(h)?w(h):n(h)}function A(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"),B}function B(h){return We(h)?qe(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):N(h)}function N(h){return e.enter("htmlTextData"),s(h)}}var ci={name:"labelEnd",resolveAll:g6,resolveTo:f6,tokenize:m6},u6={tokenize:h6},p6={tokenize:x6},d6={tokenize:y6};function g6(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&&mn(e,0,e.length,n),e}function f6(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=An(a,e.slice(i+1,i+r+3)),a=An(a,[["enter",l,t]]),a=An(a,Xi(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=An(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=An(a,e.slice(s+1)),a=An(a,[["exit",u,t]]),mn(e,i,e.length,a),e}function m6(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?p(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(u6,l,s?l:p)(g):g===91?e.attempt(p6,l,s?c:p)(g):s?l(g):p(g)}function c(g){return e.attempt(d6,l,p)(g)}function l(g){return t(g)}function p(g){return i._balanced=!0,n(g)}}function h6(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),o}function o(p){return Gt(p)?li(e,i)(p):i(p)}function i(p){return p===41?l(p):Mc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function s(p){return Gt(p)?li(e,u)(p):l(p)}function a(p){return n(p)}function u(p){return p===34||p===39||p===40?Dc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):l(p)}function c(p){return Gt(p)?li(e,l)(p):l(p)}function l(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function x6(e,t,n){let r=this;return o;function o(a){return Bc.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 y6(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 Kh={name:"labelStartImage",resolveAll:ci.resolveAll,tokenize:b6};function b6(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 Xh={name:"labelStartLink",resolveAll:ci.resolveAll,tokenize:S6};function S6(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:w6};function w6(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}var ui={name:"thematicBreak",tokenize:v6};function v6(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||ue(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 wn={continuation:{tokenize:I6},exit:E6,name:"list",tokenize:T6},k6={partial:!0,tokenize:A6},C6={partial:!0,tokenize:F6};function T6(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(d){let f=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(f==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:ba(d)){if(r.containerState.type||(r.containerState.type=f,e.enter(f,{_container:!0})),f==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(ui,n,c)(d):c(d);if(!r.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(d)}return n(d)}function u(d){return ba(d)&&++s<10?(e.consume(d),u):(!r.interrupt||s<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),c(d)):n(d)}function c(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||d,e.check($o,r.interrupt?n:l,e.attempt(k6,g,p))}function l(d){return r.containerState.initialBlankLine=!0,i++,g(d)}function p(d){return We(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),g):n(d)}function g(d){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function I6(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(C6,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(wn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function F6(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 E6(e){e.exit(this.containerState.type)}function A6(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 Rc={name:"setextUnderline",resolveTo:P6,tokenize:L6};function P6(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 L6(e,t,n){let r=this,o;return i;function i(c){let l=r.events.length,p;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){p=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(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||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var tT={tokenize:M6};function M6(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(jh,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 nT={resolveAll:sT()},rT=iT("string"),oT=iT("text");function iT(e){return{resolveAll:sT(e==="text"?B6: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 p=o[l],g=-1;if(p)for(;++g<p.length;){let d=p[g];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function sT(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 B6(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 Qh={};Se(Qh,{attentionMarkers:()=>U6,contentInitial:()=>R6,disable:()=>j6,document:()=>D6,flow:()=>N6,flowInitial:()=>z6,insideSpan:()=>$6,string:()=>O6,text:()=>_6});var D6={42:wn,43:wn,45:wn,48:wn,49:wn,50:wn,51:wn,52:wn,53:wn,54:wn,55:wn,56:wn,57:wn,62:Ic},R6={91:Hh},z6={[-2]:wa,[-1]:wa,32:wa},N6={35:Vh,42:ui,45:[Rc,ui],60:qh,61:Rc,95:ui,96:Ac,126:Ac},O6={38:Ec,92:Fc},_6={[-5]:ka,[-4]:ka,[-3]:ka,33:Kh,38:Ec,42:Sa,60:[$h,Yh],91:Xh,92:[Wh,Fc],93:ci,95:Sa,96:Uh},$6={null:[Sa,nT]},U6={null:[42,95]},j6={null:[]};function aT(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:w(z),check:w(x),consume:R,enter:$,exit:P,interrupt:w(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:E,events:[],now:T,parser:e,previous:null,sliceSerialize:f,sliceStream:k,write:d},p=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function d(F){return s=An(s,F),I(),s[s.length-1]!==null?[]:(v(t,0),l.events=Xi(i,l.events,l),l.events)}function f(F,S){return W6(k(F),S)}function k(F){return H6(s,F)}function T(){let{_bufferIndex:F,_index:S,line:b,column:A,offset:L}=r;return{_bufferIndex:F,_index:S,line:b,column:A,offset:L}}function E(F){o[F.line]=F.column,m()}function I(){let F;for(;r._index<s.length;){let S=s[r._index];if(typeof S=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<S.length;)D(S.charCodeAt(r._bufferIndex));else D(S)}}function D(F){u=void 0,g=F,p=p(F)}function R(F){ue(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,m()):F!==-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=F,u=!0}function $(F,S){let b=S||{};return b.type=F,b.start=T(),l.events.push(["enter",b,l]),a.push(b),b}function P(F){let S=a.pop();return S.end=T(),l.events.push(["exit",S,l]),S}function z(F,S){v(F,S.from)}function x(F,S){S.restore()}function w(F,S){return b;function b(A,L,B){let N,h,U,W;return Array.isArray(A)?Y(A):"tokenize"in A?Y([A]):M(A);function M(se){return Ke;function Ke(be){let Te=be!==null&&se[be],te=be!==null&&se.null,Be=[...Array.isArray(Te)?Te:Te?[Te]:[],...Array.isArray(te)?te:te?[te]:[]];return Y(Be)(be)}}function Y(se){return N=se,h=0,se.length===0?B:ee(se[h])}function ee(se){return Ke;function Ke(be){return W=C(),U=se,se.partial||(l.currentConstruct=se),se.name&&l.parser.constructs.disable.null.includes(se.name)?xe(be):se.tokenize.call(S?Object.assign(Object.create(l),S):l,c,ge,xe)(be)}}function ge(se){return u=!0,F(U,W),L}function xe(se){return u=!0,W.restore(),++h<N.length?ee(N[h]):B}}}function v(F,S){F.resolveAll&&!i.includes(F)&&i.push(F),F.resolve&&mn(l.events,S,l.events.length-S,F.resolve(l.events.slice(S),l)),F.resolveTo&&(l.events=F.resolveTo(l.events,l))}function C(){let F=T(),S=l.previous,b=l.currentConstruct,A=l.events.length,L=Array.from(a);return{from:A,restore:B};function B(){r=F,l.previous=S,l.currentConstruct=b,l.events.length=A,a=L,m()}}function m(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function H6(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 W6(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 Jh(e){let r={constructs:H1([Qh,...(e||{}).extensions||[]]),content:o(K1),defined:[],document:o(Q1),flow:o(tT),lazy:{},string:o(rT),text:o(oT)};return r;function o(i){return s;function s(a){return aT(r,i,a)}}}function Zh(e){for(;!Lc(e););return e}var lT=/[\0\t\n\r]/g;function ex(){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(lT.lastIndex=d,c=lT.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 W5=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function cT(e){return e.replace(W5,V5)}function V5(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Tc(n.slice(i?2:1),i?16:10)}return Ki(n)||e}var pT={}.hasOwnProperty;function tx(e,t,n){return typeof t!="string"&&(n=t,t=void 0),G5(n)(Zh(Jh(n).document().write(ex()(e,t,!0))))}function G5(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(fe),autolinkProtocol:w,autolinkEmail:w,atxHeading:i(pe),blockQuote:i(be),characterEscape:w,characterReference:w,codeFenced:i(Te),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Te,s),codeText:i(te,s),codeTextData:w,data:w,codeFlowValue:w,definition:i(Be),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(Pe),hardBreakEscape:i(Pt),hardBreakTrailing:i(Pt),htmlFlow:i(tn,s),htmlFlowData:w,htmlText:i(tn,s),htmlTextData:w,image:i(Dr),label:s,link:i(fe),listItem:i(he),listItemValue:g,listOrdered:i(tt,d),listUnordered:i(tt),paragraph:i(ie),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(pe),strong:i(K),thematicBreak:i(se)},exit:{atxHeading:u(),atxHeadingSequence:$,autolink:u(),autolinkEmail:Ke,autolinkProtocol:ae,blockQuote:u(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:ge,characterReference:xe,codeFenced:u(T),codeFencedFence:k,codeFencedFenceInfo:p,codeFencedFenceMeta:f,codeFlowValue:v,codeIndented:u(E),codeText:u(b),codeTextData:v,data:v,definition:u(),definitionDestinationString:R,definitionLabelString:I,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(m),hardBreakTrailing:u(m),htmlFlow:u(F),htmlFlowData:v,htmlText:u(S),htmlTextData:v,image:u(L),label:N,labelText:B,lineEnding:C,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:Y,resourceDestinationString:h,resourceTitleString:U,resource:W,setextHeading:u(x),setextHeadingLineSequence:z,setextHeadingText:P,strong:u(),thematicBreak:u()}};dT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let j={type:"root",children:[]},H={stack:[j],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Ee=[],De=-1;for(;++De<O.length;)if(O[De][1].type==="listOrdered"||O[De][1].type==="listUnordered")if(O[De][0]==="enter")Ee.push(De);else{let bt=Ee.pop();De=o(O,bt,De)}for(De=-1;++De<O.length;){let bt=t[O[De][0]];pT.call(bt,O[De][1].type)&&bt[O[De][1].type].call(Object.assign({sliceSerialize:O[De][2].sliceSerialize},H),O[De][1])}if(H.tokenStack.length>0){let bt=H.tokenStack[H.tokenStack.length-1];(bt[1]||uT).call(H,void 0,bt[0])}for(j.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})},De=-1;++De<t.transforms.length;)j=t.transforms[De](j)||j;return j}function o(O,j,H){let Ee=j-1,De=-1,bt=!1,Yn,or,An,ho;for(;++Ee<=H;){let wn=O[Ee];switch(wn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{wn[0]==="enter"?De++:De--,ho=void 0;break}case"lineEndingBlank":{wn[0]==="enter"&&(Yn&&!ho&&!De&&!An&&(An=Ee),ho=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ho=void 0}if(!De&&wn[0]==="enter"&&wn[1].type==="listItemPrefix"||De===-1&&wn[0]==="exit"&&(wn[1].type==="listUnordered"||wn[1].type==="listOrdered")){if(Yn){let Rr=Ee;for(or=void 0;Rr--;){let nn=O[Rr];if(nn[1].type==="lineEnding"||nn[1].type==="lineEndingBlank"){if(nn[0]==="exit")continue;or&&(O[or][1].type="lineEndingBlank",bt=!0),nn[1].type="lineEnding",or=Rr}else if(!(nn[1].type==="linePrefix"||nn[1].type==="blockQuotePrefix"||nn[1].type==="blockQuotePrefixWhitespace"||nn[1].type==="blockQuoteMarker"||nn[1].type==="listItemIndent"))break}An&&(!or||An<or)&&(Yn._spread=!0),Yn.end=Object.assign({},or?O[or][1].start:wn[1].end),O.splice(or||Ee,0,["exit",Yn,wn[2]]),Ee++,H++}if(wn[1].type==="listItemPrefix"){let Rr={type:"listItem",_spread:!1,start:Object.assign({},wn[1].start),end:void 0};Yn=Rr,O.splice(Ee,0,["enter",Rr,wn[2]]),Ee++,H++,An=void 0,ho=!0}}}return O[j][1]._spread=bt,H}function i(O,j){return H;function H(Ee){a.call(this,O(Ee),Ee),j&&j.call(this,Ee)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,j,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([j,H||void 0]),O.position={start:Uo(j.start),end:void 0}}function u(O){return j;function j(H){O&&O.call(this,H),c.call(this,H)}}function c(O,j){let H=this.stack.pop(),Ee=this.tokenStack.pop();if(Ee)Ee[0].type!==O.type&&(j?j.call(this,O,Ee[0]):(Ee[1]||uT).call(this,O,Ee[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 Oh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),j=this.stack[this.stack.length-1];j.lang=O}function f(){let O=this.resume(),j=this.stack[this.stack.length-1];j.meta=O}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/(\r?\n|\r)$/g,"")}function I(O){let j=this.resume(),H=this.stack[this.stack.length-1];H.label=j,H.identifier=po(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function R(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function $(O){let j=this.stack[this.stack.length-1];if(!j.depth){let H=this.sliceSerialize(O).length;j.depth=H}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function z(O){let j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function x(){this.data.setextHeadingSlurpLineEnding=void 0}function w(O){let H=this.stack[this.stack.length-1].children,Ee=H[H.length-1];(!Ee||Ee.type!=="text")&&(Ee=me(),Ee.position={start:Uo(O.start),end:void 0},H.push(Ee)),this.stack.push(Ee)}function v(O){let j=this.stack.pop();j.value+=this.sliceSerialize(O),j.position.end=Uo(O.end)}function C(O){let j=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=j.children[j.children.length-1];H.position.end=Uo(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(j.type)&&(w.call(this,O),v.call(this,O))}function m(){this.data.atHardBreak=!0}function F(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function S(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function b(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function A(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,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 j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function B(O){let j=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=cT(j),H.identifier=po(j).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],j=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Ee=O.children;H.children=Ee}else H.alt=j}function h(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function U(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function W(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function Y(O){let j=this.resume(),H=this.stack[this.stack.length-1];H.label=j,H.identifier=po(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function ee(O){this.data.characterReferenceType=O.type}function ge(O){let j=this.sliceSerialize(O),H=this.data.characterReferenceType,Ee;H?(Ee=Tc(j,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ee=Ki(j);let De=this.stack[this.stack.length-1];De.value+=Ee}function xe(O){let j=this.stack.pop();j.position.end=Uo(O.end)}function ae(O){v.call(this,O);let j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(O)}function Ke(O){v.call(this,O);let j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(O)}function be(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function te(){return{type:"inlineCode",value:""}}function Be(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Pe(){return{type:"emphasis",children:[]}}function pe(){return{type:"heading",depth:0,children:[]}}function Pt(){return{type:"break"}}function tn(){return{type:"html",value:""}}function Dr(){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 ie(){return{type:"paragraph",children:[]}}function K(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function se(){return{type:"thematicBreak"}}}function Uo(e){return{line:e.line,column:e.column,offset:e.offset}}function dT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?dT(e,r):q5(e,r)}}function q5(e,t){let n;for(n in t)if(pT.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 uT(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 zc(e){let t=this;t.parser=n;function n(r){return tx(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gT(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 fT(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{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 Jh(e){let r={constructs:H1([Qh,...(e||{}).extensions||[]]),content:o(K1),defined:[],document:o(Q1),flow:o(tT),lazy:{},string:o(rT),text:o(oT)};return r;function o(i){return s;function s(a){return aT(r,i,a)}}}function Zh(e){for(;!Lc(e););return e}var lT=/[\0\t\n\r]/g;function ex(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,p,g,d;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),p=0,t="",n&&(i.charCodeAt(0)===65279&&p++,n=void 0);p<i.length;){if(lT.lastIndex=p,c=lT.exec(i),g=c&&c.index!==void 0?c.index:i.length,d=i.charCodeAt(g),!c){t=i.slice(p);break}if(d===10&&p===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<g&&(u.push(i.slice(p,g)),e+=g-p),d){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}p=g+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var V6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function cT(e){return e.replace(V6,G6)}function G6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Tc(n.slice(i?2:1),i?16:10)}return Ki(n)||e}var pT={}.hasOwnProperty;function tx(e,t,n){return typeof t!="string"&&(n=t,t=void 0),q6(n)(Zh(Jh(n).document().write(ex()(e,t,!0))))}function q6(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(fe),autolinkProtocol:w,autolinkEmail:w,atxHeading:i(pe),blockQuote:i(be),characterEscape:w,characterReference:w,codeFenced:i(Te),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Te,s),codeText:i(te,s),codeTextData:w,data:w,codeFlowValue:w,definition:i(Be),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(Pe),hardBreakEscape:i(Lt),hardBreakTrailing:i(Lt),htmlFlow:i(nn,s),htmlFlowData:w,htmlText:i(nn,s),htmlTextData:w,image:i(Dr),label:s,link:i(fe),listItem:i(he),listItemValue:g,listOrdered:i(tt,p),listUnordered:i(tt),paragraph:i(oe),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(pe),strong:i(K),thematicBreak:i(ie)},exit:{atxHeading:u(),atxHeadingSequence:$,autolink:u(),autolinkEmail:Ke,autolinkProtocol:se,blockQuote:u(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:ge,characterReference:xe,codeFenced:u(T),codeFencedFence:k,codeFencedFenceInfo:d,codeFencedFenceMeta:f,codeFlowValue:v,codeIndented:u(E),codeText:u(b),codeTextData:v,data:v,definition:u(),definitionDestinationString:R,definitionLabelString:I,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(m),hardBreakTrailing:u(m),htmlFlow:u(F),htmlFlowData:v,htmlText:u(S),htmlTextData:v,image:u(L),label:N,labelText:B,lineEnding:C,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:Y,resourceDestinationString:h,resourceTitleString:U,resource:W,setextHeading:u(x),setextHeadingLineSequence:z,setextHeadingText:P,strong:u(),thematicBreak:u()}};dT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let j={type:"root",children:[]},H={stack:[j],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Ee=[],De=-1;for(;++De<O.length;)if(O[De][1].type==="listOrdered"||O[De][1].type==="listUnordered")if(O[De][0]==="enter")Ee.push(De);else{let St=Ee.pop();De=o(O,St,De)}for(De=-1;++De<O.length;){let St=t[O[De][0]];pT.call(St,O[De][1].type)&&St[O[De][1].type].call(Object.assign({sliceSerialize:O[De][2].sliceSerialize},H),O[De][1])}if(H.tokenStack.length>0){let St=H.tokenStack[H.tokenStack.length-1];(St[1]||uT).call(H,void 0,St[0])}for(j.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})},De=-1;++De<t.transforms.length;)j=t.transforms[De](j)||j;return j}function o(O,j,H){let Ee=j-1,De=-1,St=!1,Yn,or,Pn,ho;for(;++Ee<=H;){let kn=O[Ee];switch(kn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{kn[0]==="enter"?De++:De--,ho=void 0;break}case"lineEndingBlank":{kn[0]==="enter"&&(Yn&&!ho&&!De&&!Pn&&(Pn=Ee),ho=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ho=void 0}if(!De&&kn[0]==="enter"&&kn[1].type==="listItemPrefix"||De===-1&&kn[0]==="exit"&&(kn[1].type==="listUnordered"||kn[1].type==="listOrdered")){if(Yn){let Rr=Ee;for(or=void 0;Rr--;){let rn=O[Rr];if(rn[1].type==="lineEnding"||rn[1].type==="lineEndingBlank"){if(rn[0]==="exit")continue;or&&(O[or][1].type="lineEndingBlank",St=!0),rn[1].type="lineEnding",or=Rr}else if(!(rn[1].type==="linePrefix"||rn[1].type==="blockQuotePrefix"||rn[1].type==="blockQuotePrefixWhitespace"||rn[1].type==="blockQuoteMarker"||rn[1].type==="listItemIndent"))break}Pn&&(!or||Pn<or)&&(Yn._spread=!0),Yn.end=Object.assign({},or?O[or][1].start:kn[1].end),O.splice(or||Ee,0,["exit",Yn,kn[2]]),Ee++,H++}if(kn[1].type==="listItemPrefix"){let Rr={type:"listItem",_spread:!1,start:Object.assign({},kn[1].start),end:void 0};Yn=Rr,O.splice(Ee,0,["enter",Rr,kn[2]]),Ee++,H++,Pn=void 0,ho=!0}}}return O[j][1]._spread=St,H}function i(O,j){return H;function H(Ee){a.call(this,O(Ee),Ee),j&&j.call(this,Ee)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,j,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([j,H||void 0]),O.position={start:Uo(j.start),end:void 0}}function u(O){return j;function j(H){O&&O.call(this,H),c.call(this,H)}}function c(O,j){let H=this.stack.pop(),Ee=this.tokenStack.pop();if(Ee)Ee[0].type!==O.type&&(j?j.call(this,O,Ee[0]):(Ee[1]||uT).call(this,O,Ee[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 Oh(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function d(){let O=this.resume(),j=this.stack[this.stack.length-1];j.lang=O}function f(){let O=this.resume(),j=this.stack[this.stack.length-1];j.meta=O}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/(\r?\n|\r)$/g,"")}function I(O){let j=this.resume(),H=this.stack[this.stack.length-1];H.label=j,H.identifier=po(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function R(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function $(O){let j=this.stack[this.stack.length-1];if(!j.depth){let H=this.sliceSerialize(O).length;j.depth=H}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function z(O){let j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function x(){this.data.setextHeadingSlurpLineEnding=void 0}function w(O){let H=this.stack[this.stack.length-1].children,Ee=H[H.length-1];(!Ee||Ee.type!=="text")&&(Ee=me(),Ee.position={start:Uo(O.start),end:void 0},H.push(Ee)),this.stack.push(Ee)}function v(O){let j=this.stack.pop();j.value+=this.sliceSerialize(O),j.position.end=Uo(O.end)}function C(O){let j=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=j.children[j.children.length-1];H.position.end=Uo(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(j.type)&&(w.call(this,O),v.call(this,O))}function m(){this.data.atHardBreak=!0}function F(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function S(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function b(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function A(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,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 j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function B(O){let j=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=cT(j),H.identifier=po(j).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],j=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Ee=O.children;H.children=Ee}else H.alt=j}function h(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function U(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function W(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function Y(O){let j=this.resume(),H=this.stack[this.stack.length-1];H.label=j,H.identifier=po(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function ee(O){this.data.characterReferenceType=O.type}function ge(O){let j=this.sliceSerialize(O),H=this.data.characterReferenceType,Ee;H?(Ee=Tc(j,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ee=Ki(j);let De=this.stack[this.stack.length-1];De.value+=Ee}function xe(O){let j=this.stack.pop();j.position.end=Uo(O.end)}function se(O){v.call(this,O);let j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(O)}function Ke(O){v.call(this,O);let j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(O)}function be(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function te(){return{type:"inlineCode",value:""}}function Be(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Pe(){return{type:"emphasis",children:[]}}function pe(){return{type:"heading",depth:0,children:[]}}function Lt(){return{type:"break"}}function nn(){return{type:"html",value:""}}function Dr(){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 oe(){return{type:"paragraph",children:[]}}function K(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}function Uo(e){return{line:e.line,column:e.column,offset:e.offset}}function dT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?dT(e,r):Y6(e,r)}}function Y6(e,t){let n;for(n in t)if(pT.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 uT(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 zc(e){let t=this;t.parser=n;function n(r){return tx(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gT(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 fT(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
84
84
|
`}]}function mT(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 hT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yT(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=xr(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 bT(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 ST(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Nc(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 wT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Nc(e,t);let o={src:xr(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 vT(e,t){let n={src:xr(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 kT(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 CT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Nc(e,t);let o={href:xr(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 TT(e,t){let n={href:xr(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 IT(e,t,n){let r=e.all(t),o=n?
|
|
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 hT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yT(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=xr(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 bT(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 ST(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Nc(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 wT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Nc(e,t);let o={src:xr(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 vT(e,t){let n={src:xr(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 kT(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 CT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Nc(e,t);let o={href:xr(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 TT(e,t){let n={href:xr(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 IT(e,t,n){let r=e.all(t),o=n?K6(n):FT(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],p;l&&l.type==="element"&&l.tagName==="p"?p=l:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.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
|
|
87
|
+
`});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function K6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=FT(n[r])}return t}function FT(e){let t=e.spread;return t??e.children.length>1}function ET(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 AT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function LT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function MT(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=Yi(t.children[1]),u=Cc(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 BT(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 p=t.children[u],g={},d=s?s[u]:void 0;d&&(g.align=d);let f={type:"element",tagName:i,properties:g,children:[]};p&&(f.children=e.all(p),e.patch(p,f),f=e.applyData(p,f)),c.push(f)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function DT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(RT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(RT(t.slice(o),o>0,!1)),i.join("")}function RT(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 NT(e,t){let n={type:"text",value:zT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function OT(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var _T={blockquote:gT,break:fT,code:mT,delete:hT,emphasis:xT,footnoteReference:yT,heading:bT,html:ST,imageReference:wT,image:vT,inlineCode:kT,linkReference:CT,link:TT,listItem:IT,list:ET,paragraph:AT,root:PT,strong:LT,table:MT,tableCell:DT,tableRow:BT,text:NT,thematicBreak:OT,toml:Oc,yaml:Oc,definition:Oc,footnoteDefinition:Oc};function Oc(){}var $T=typeof self=="object"?self:globalThis,Z6=(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 $T[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 $T[i](s),o)};return r},ox=e=>Z6(new Map,e)(0);var Qi="",{toString:eU}={},{keys:tU}=Object,Ca=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=eU.call(e).slice(8,-1);switch(n){case"Array":return[1,Qi];case"Object":return[2,Qi];case"Date":return[3,Qi];case"RegExp":return[4,Qi];case"Map":return[5,Qi];case"Set":return[6,Qi];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},$c=([e,t])=>e===0&&(t==="function"||t==="symbol"),nU=(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=[],p=o([a,l],s);for(let g of s)l.push(i(g));return p}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=[],p=o([a,l],s);for(let g of tU(s))(e||!$c(Ca(s[g])))&&l.push([i(g),i(s[g])]);return p}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:p}=s;return o([a,{source:l,flags:p}],s)}case 5:{let l=[],p=o([a,l],s);for(let[g,d]of s)(e||!($c(Ca(g))||$c(Ca(d))))&&l.push([i(g),i(d)]);return p}case 6:{let l=[],p=o([a,l],s);for(let g of s)(e||!$c(Ca(g)))&&l.push(i(g));return p}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},ix=(e,{json:t,lossy:n}={})=>{let r=[];return nU(!(t||n),!!t,new Map,r)(e),r};var Ji=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ox(ix(e,t)):structuredClone(e):(e,t)=>ox(ix(e,t));function rU(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 oU(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function VT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||rU,r=e.options.footnoteBackLabel||oU,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),p=String(c.identifier).toUpperCase(),g=xr(p.toLowerCase()),d=0,f=[],k=e.footnoteCounts.get(p);for(;k!==void 0&&++d<=k;){f.length>0&&f.push({type:"text",value:" "});let I=typeof n=="string"?n:n(u,d);typeof I=="string"&&(I={type:"text",value:I}),f.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,d),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}let T=l[l.length-1];if(T&&T.type==="element"&&T.tagName==="p"){let I=T.children[T.children.length-1];I&&I.type==="text"?I.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...f)}else l.push(...f);let E={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(l,!0)};e.patch(c,E),a.push(E)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Ji(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 Uc=(function(e){if(e==null)return
|
|
89
|
+
`}]}}var Uc=(function(e){if(e==null)return lU;if(typeof e=="function")return jc(e);if(typeof e=="object")return Array.isArray(e)?iU(e):sU(e);if(typeof e=="string")return aU(e);throw new Error("Expected function, string, or object as test")});function iU(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Uc(e[n]);return jc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function sU(e){let t=e;return jc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function aU(e){return jc(t);function t(n){return n&&n.type===e}}function jc(e){return t;function t(n,r,o){return!!(cU(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function lU(){return!0}function cU(e){return e!==null&&typeof e=="object"&&"type"in e}var GT=[],sx=!0,Hc=!1,ax="skip";function lx(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Uc(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){let d=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(d?"<"+d+">":""))+")"})}return g;function g(){let d=GT,f,k,T;if((!t||i(u,c,l[l.length-1]||void 0))&&(d=uU(n(u,l)),d[0]===Hc))return d;if("children"in u&&u.children){let E=u;if(E.children&&d[0]!==ax)for(k=(r?E.children.length:-1)+s,T=l.concat(E);k>-1&&k<E.children.length;){let I=E.children[k];if(f=a(I,k,T)(),f[0]===Hc)return f;k=typeof f[1]=="number"?f[1]:k+s}}return d}}}function uU(e){return Array.isArray(e)?e:typeof e=="number"?[sx,e]:e==null?GT:[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),lx(e,i,a,o);function a(u,c){let l=c[c.length-1],p=l?l.children.indexOf(u):void 0;return s(u,p,l)}}var cx={}.hasOwnProperty,pU={};function YT(e,t){let n=t||pU,r=new Map,o=new Map,i=new Map,s={..._T,...n.handlers},a={all:c,applyData:gU,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:dU,wrap:mU};return Ta(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let p=l.type==="definition"?r:o,g=String(l.identifier).toUpperCase();p.has(g)||p.set(g,l)}}),a;function u(l,p){let g=l.type,d=a.handlers[g];if(cx.call(a.handlers,g)&&d)return d(a,l,p);if(a.options.passThrough&&a.options.passThrough.includes(g)){if("children"in l){let{children:k,...T}=l,E=Ji(T);return E.children=a.all(l),E}return Ji(l)}return(a.options.unknownHandler||fU)(a,l,p)}function c(l){let p=[];if("children"in l){let g=l.children,d=-1;for(;++d<g.length;){let f=a.one(g[d],l);if(f){if(d&&g[d-1].type==="break"&&(!Array.isArray(f)&&f.type==="text"&&(f.value=qT(f.value)),!Array.isArray(f)&&f.type==="element")){let k=f.children[0];k&&k.type==="text"&&(k.value=qT(k.value))}Array.isArray(f)?p.push(...f):p.push(f)}}}return p}}function dU(e,t){e.position&&(t.position=Mh(e))}function gU(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,Ji(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function fU(e,t){let n=t.data||{},r="value"in t&&!(cx.call(n,"hProperties")||cx.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 mU(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
92
|
`}),n}function qT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Wc(e,t){let n=YT(e,t),r=n.one(e,void 0),o=VT(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 Vc(e,t){return e&&"run"in e?async function(n,r){let o=Wc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Wc(n,{file:r,...e||t})}}function ux(e){if(e)throw e}var Yc=Ua(rI(),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 px(){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?oI(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 oI(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 Lr={basename:m6,dirname:h6,extname:x6,join:y6,sep:"/"};function m6(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 h6(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 x6(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 y6(...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?".":b6(n)}function b6(e){Fa(e);let t=e.codePointAt(0)===47,n=S6(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function S6(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 iI={cwd:w6};function w6(){return"/"}function Zi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function sI(e){if(typeof e=="string")e=new URL(e);else if(!Zi(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 v6(e)}function v6(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 dx=["history","path","basename","stem","extname","dirname"],pi=class{constructor(t){let n;t?Zi(t)?n={path:t}:typeof t=="string"||k6(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":iI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<dx.length;){let i=dx[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)dx.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Lr.basename(this.path):void 0}set basename(t){fx(t,"basename"),gx(t,"basename"),this.path=Lr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Lr.dirname(this.path):void 0}set dirname(t){aI(this.basename,"dirname"),this.path=Lr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Lr.extname(this.path):void 0}set extname(t){if(gx(t,"extname"),aI(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=Lr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Zi(t)&&(t=sI(t)),fx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Lr.basename(this.path,this.extname):void 0}set stem(t){fx(t,"stem"),gx(t,"stem"),this.path=Lr.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 Wt(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 gx(e,t){if(e&&e.includes(Lr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Lr.sep+"`")}function fx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function aI(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function k6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var lI=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var C6={}.hasOwnProperty,yx=class e extends lI{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=px()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,Yc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(xx("data",this.frozen),this.namespace[t]=n,this):C6.call(this.namespace,t)&&this.namespace[t]||void 0:t?(xx("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 mx("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),mx("process",this.parser||this.Parser),hx("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,f=r.stringify(p,g);I6(f)?g.value=f:g.result=f,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(),mx("processSync",this.parser||this.Parser),hx("processSync",this.compiler||this.Compiler),this.process(t,o),uI("processSync","process",n),r;function o(i,s){n=!0,ux(i),r=s}}run(t,n,r){cI(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),uI("runSync","run",r),o;function i(s,a){ux(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=qc(n),o=this.compiler||this.Compiler;return hx("stringify",o),cI(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(xx("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,Yc.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,...f]=l,k=r[g][1];Ia(k)&&Ia(p)&&(p=(0,Yc.default)(!0,k,p)),r[g]=[c,p,...f]}}}},bx=new yx().freeze();function mx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function hx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xx(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 cI(e){if(!Ia(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uI(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function qc(e){return T6(e)?e:new pi(e)}function T6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function I6(e){return typeof e=="string"||F6(e)}function F6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var L6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",pI=[],dI={allowDangerousHtml:!0},M6=/^(https?|ircs?|mailto|xmpp)$/i,B6=[{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 Sx(e){let t=D6(e),n=R6(e);return z6(t.runSync(t.parse(n),n),e)}function D6(e){let t=e.rehypePlugins||pI,n=e.remarkPlugins||pI,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dI}:dI;return bx().use(zc).use(n).use(Vc,r).use(t)}function R6(e){let t=e.children||"",n=new pi;return typeof t=="string"?n.value=t:(""+t,void 0),n}function z6(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||gI;for(let l of B6)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+L6+l.id,void 0);return n&&i&&void 0,Ta(e,c),Rh(e,{Fragment:E6,components:o,ignoreInvalidStyle:!0,jsx:A6,jsxs:P6,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 f=l.properties[p],k=xa[p];(k===null||k.includes(l.tagName))&&(l.properties[p]=u(String(f||""),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 gI(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||M6.test(e.slice(0,t))?e:""}Ce();var O6=es.div({display:"flex",flexDirection:"column",gap:"12px"}),_6=es.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),$6=es.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),U6=es(kn)({padding:"6px 12px",fontSize:"12px"}),j6=es.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:p1.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}})),H6=es.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),wx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ce(),[r,o]=N6(!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?di.createElement(O6,null,di.createElement(_6,null,di.createElement($6,null,"Full Prompt"),di.createElement(U6,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),di.createElement(j6,null,di.createElement(Sx,null,e))):di.createElement(H6,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import go,{useRef as W6}from"react";import{styled as Mr}from"storybook/theming";Ce();var V6=Mr.div({display:"flex",flexDirection:"column",gap:"8px"}),sge=Mr.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"}}),G6=Mr.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})),q6=Mr.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})),age=Mr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),fI=Mr.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||oe,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||oe,backgroundColor:e.background.warning||"#ffedd5"}})),Y6=Mr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),K6=Mr.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"})),X6=Mr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),Q6=Mr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),lge=Mr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function J6(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 vx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ce(),s=W6(null);if((i??o)!=="admin")return null;let u=r?n.find(f=>f.id===r):null,c=u?u.issues.length>0&&u.issues.every(f=>f.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(f=>f.role==="assistant"||f.role==="system"&&f.content.includes("auto-dismissed")),g=d.length===0&&!!t;if(d.length===0&&!g)return go.createElement(Y6,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(V6,null,l&&go.createElement(K6,null,go.createElement(X6,null,"Component Matches Design"),go.createElement(Q6,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(G6,{ref:s},p.map((f,k)=>go.createElement(q6,{key:k,role:f.role},f.role==="system"?go.createElement(fI,null,f.content):go.createElement(fI,{dangerouslySetInnerHTML:{__html:J6(f.content)}})))))};import yr from"react";import{styled as jo}from"storybook/theming";Ce();$e();var Z6=jo.div({display:"flex",flexDirection:"column",gap:"12px"}),ej=jo.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),tj=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}}}),mI=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"}}),nj=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"})),hI=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||oe,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||oe,backgroundColor:e.background.warning||"#ffedd5"}})),xI=jo.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),rj=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 yI(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 oj(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 bI=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ce();if((i??o)!=="admin")return null;yr.useEffect(()=>{e&&(y.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([l,d])=>{y.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?yr.createElement(xI,null,"No models selected. Select multiple models to compare results."):yr.createElement(Z6,null,yr.createElement(ej,null,a.map(l=>{let d=co.find(E=>E.id===l),g=c[l],f=oj(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),k=l===u;if(!d)return null;let T=t&&!g?.completed;return yr.createElement(tj,{key:l,isActive:k,provider:d.provider,onClick:()=>n(l)},d.name,g&&f.issueCount>0&&yr.createElement(mI,{variant:"issues",value:f.issueCount},f.issueCount," issues"),g&&f.score!==null&&yr.createElement(mI,{variant:"score",value:f.score},"Score: ",f.score),T&&yr.createElement(rj,null))})),yr.createElement(nj,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>yr.createElement(hI,{key:d,dangerouslySetInnerHTML:{__html:yI(l.content)}})):c[u]?.fullResponse?yr.createElement(hI,{dangerouslySetInnerHTML:{__html:yI(c[u].fullResponse)}}):yr.createElement(xI,null,t?`Waiting for ${co.find(l=>l.id===u)?.name}...`:`No response yet for ${co.find(l=>l.id===u)?.name}`)))};import _e from"react";import{styled as Ct}from"storybook/theming";Ce();zn();Ce();import{useCallback as kx}from"react";$e();function SI(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ce(),{sessionToken:r}=we(),o=kx(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=kx((a,u)=>{e(a,u,"user");let c=o(a);if(!c){y.debug("[useIssuePersistence] Dismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Dismiss skipped \u2014 no session token");return}Kl(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=kx(a=>{t(a);let u=o(a);if(!u){y.debug("[useIssuePersistence] Undismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Undismiss skipped \u2014 no session token");return}Kl(u,!1,void 0,"user",r).then(c=>{c.success||y.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import q,{useMemo as S8,useState as w8,useEffect as v8}from"react";import{styled as st,keyframes as k8}from"storybook/theming";import Z,{useState as Ex,useRef as uH,useCallback as zI,memo as pH}from"react";import{styled as Me}from"storybook/theming";import En,{useState as wI}from"react";import{styled as Gn}from"storybook/theming";var ij=[{id:"false-positive",icon:"\u{1F50D}",label:"False positive",description:"AI misidentified this \u2014 not a real issue"},{id:"planned",icon:"\u{1F4CB}",label:"Planned",description:"Real issue \u2014 will fix in a future sprint"},{id:"wont-fix",icon:"\u{1F6AB}",label:"Won't fix",description:"Intentional deviation from the Figma design"},{id:"no-figma-state",icon:"\u{1F5BC}\uFE0F",label:"No Figma state",description:"No matching Figma frame for this story variant"}],sj=Gn.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}),aj=Gn.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"8px",padding:"24px",maxWidth:"480px",width:"90%",boxShadow:e.base==="dark"?"0 10px 40px rgba(0, 0, 0, 0.5)":"0 10px 40px rgba(0, 0, 0, 0.2)",border:`1px solid ${e.appBorderColor}`})),lj=Gn.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"4px"})),cj=Gn.p(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,marginBottom:"16px",lineHeight:"1.4",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),uj=Gn.div({display:"flex",flexDirection:"column",gap:"8px",marginBottom:"16px"}),pj=Gn.button(({theme:e,selected:t})=>({display:"flex",alignItems:"flex-start",gap:"12px",padding:"10px 14px",borderRadius:"6px",border:`2px solid ${t?oe:e.appBorderColor}`,backgroundColor:t?e.base==="dark"?"rgba(234,88,12,0.08)":"rgba(234,88,12,0.05)":e.background.app,cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.15s, background-color 0.15s","&:hover":{borderColor:t?oe:e.color.mediumdark,backgroundColor:t?e.base==="dark"?"rgba(234,88,12,0.1)":"rgba(234,88,12,0.07)":e.background.hoverable}})),dj=Gn.span({fontSize:"16px",lineHeight:"1.4",flexShrink:0}),gj=Gn.div({display:"flex",flexDirection:"column",gap:"2px"}),fj=Gn.span(({theme:e,selected:t})=>({fontSize:"13px",fontWeight:600,color:t?oe:e.color.defaultText})),mj=Gn.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,lineHeight:"1.4"})),hj=Gn.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),xj=Gn.textarea(({theme:e})=>({width:"100%",minHeight:"60px",padding:"8px 10px",fontSize:"13px",borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",marginBottom:"20px",boxSizing:"border-box","&:focus":{outline:"none",borderColor:oe},"&::placeholder":{color:e.textMutedColor}})),yj=Gn.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),bj=Gn.button(({theme:e,disabled:t})=>({padding:"8px 16px",fontSize:"13px",fontWeight:600,borderRadius:"4px",border:"none",cursor:t?"not-allowed":"pointer",backgroundColor:t?e.color.medium:oe,color:t?e.color.mediumdark:"#ffffff",transition:"background-color 0.15s","&:hover":{backgroundColor:t?e.color.medium:"#c2410c"}})),vI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=wI(null),[s,a]=wI("");if(!e)return null;let u=()=>{o&&(n(o,s.trim()||void 0),i(null),a(""))},c=()=>{i(null),a(""),r()};return En.createElement(sj,{onClick:l=>l.target===l.currentTarget&&c()},En.createElement(aj,null,En.createElement(lj,null,"Dismiss Issue"),En.createElement(cj,{title:t},t),En.createElement(uj,null,ij.map(l=>En.createElement(pj,{key:l.id,selected:o===l.id,onClick:()=>i(l.id)},En.createElement(dj,null,l.icon),En.createElement(gj,null,En.createElement(fj,{selected:o===l.id},l.label),En.createElement(mj,null,l.description))))),En.createElement(hj,{htmlFor:"dismiss-note"},"Note (optional)"),En.createElement(xj,{id:"dismiss-note",value:s,onChange:l=>a(l.target.value),placeholder:"Add context..."}),En.createElement(yj,null,En.createElement(Nr,{onClick:c},"Cancel"),En.createElement(bj,{disabled:!o,onClick:u},"Dismiss Issue"))))};Ce();import Le from"react";import{styled as it}from"storybook/theming";var Oe={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"},Sj=it.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),wj=it.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),vj=it.div({position:"relative",backgroundColor:Oe.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Age=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Oe.dash,padding:"0 8px",height:18,fontSize:11}),Pge=it.div({position:"absolute",color:Oe.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Lge=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%)"}})),Mge=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}})),kj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Oe.errBg:Oe.borderBoxBg,border:`1px solid ${e.isErr?Oe.err:Oe.borderBoxStroke}`,borderRadius:6,padding:0})),Cj=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Oe.text}),Tj=it.span({fontWeight:500,fontSize:11}),Bge=it.span({color:Oe.dash}),Ij=it.div(e=>({position:"relative",backgroundColor:e.isErr?Oe.errBg:Oe.paddingBg,border:`1px solid ${e.isErr?Oe.err:Oe.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),Fj=it.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Oe.text,fontStyle:"italic"}),Kc=it.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Oe.err:Oe.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%)"}})),Ej=it.div(e=>({backgroundColor:e.isErr?Oe.errBg:"#fff",border:`1.5px dashed ${e.isErr?Oe.err:Oe.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Oe.err:Oe.text,fontWeight:e.isErr?600:400})),Aj=it.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Oe.dim,fontFamily:"monospace"}),Pj=it.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Oe.ok,padding:"4px 8px 6px"}),Dge=it.div({fontSize:11,fontWeight:600,color:Oe.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Rge=it.span({fontSize:12,color:Oe.dim}),Lj=it.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),Mj=it.div({fontSize:9,color:Oe.dim,marginTop:2}),Bj=({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?Uj(n):null,f=d.padding||p||{top:0,right:0,bottom:0,left:0},k=d.strokeWeight??(a?ts(n)??0:0),T=d.width??(u?jj(n)??"\u2014":"\u2014"),E=d.height??(u?Hj(n)??"\u2014":"\u2014");return Le.createElement(Le.Fragment,null,Le.createElement(vj,null,Le.createElement(kj,{isErr:a},Le.createElement(Cj,null,Le.createElement(Tj,null,"Border"),Le.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Oe.err:Oe.dim}},k)),Le.createElement(Ij,{isErr:s},Le.createElement(Fj,null,"Padding"),Le.createElement(Kc,{side:"top",isErr:s},f.top),Le.createElement(Kc,{side:"right",isErr:s},f.right),Le.createElement(Kc,{side:"bottom",isErr:s},f.bottom),Le.createElement(Kc,{side:"left",isErr:s},f.left),Le.createElement(Ej,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Le.createElement(Lj,{src:l,alt:"Figma element"}),Le.createElement(Mj,null,T," \xD7 ",E)))),Le.createElement(Aj,null,"border-box")),Le.createElement(Pj,null,"\u2192 ",n))},kI=it.div({backgroundColor:Oe.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),Dj=it.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),Cx=it.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Oe.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),Rj=it.div({position:"absolute",border:`1.5px dashed ${Oe.err}`,pointerEvents:"none",zIndex:0}),zj=it.div({position:"absolute",border:`1.5px dashed ${Oe.blue}`,pointerEvents:"none",zIndex:0}),CI=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%)"}})),zge=it.div({fontSize:12,color:Oe.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),Nj=it.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),TI=it.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Oe.err:Oe.ok})),Oj=it.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),II=it.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),FI=it.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Oe.err:Oe.ok})),EI=it.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Oe.err:Oe.ok,textDecoration:e.variant==="err"?"line-through":"none"})),_j=it.span({fontSize:16,color:Oe.dim,paddingBottom:20}),AI=it.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function PI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var $j=({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?ts(n):14),p=o.fontWeight??(a?ts(n):600),k=(o.lineHeight??(u?ts(n):null))||Math.round((g||14)*1.43),T=`${Math.min(Math.max(g||14,24),48)}px`;if(d)return Le.createElement(Le.Fragment,null,Le.createElement(kI,null,Le.createElement(Dj,null,Le.createElement(zj,{style:{top:-6,left:0,right:0,bottom:-6}}),Le.createElement(Rj,{style:{top:2,left:8,right:8,bottom:2}}),Le.createElement(CI,{color:s?Oe.err:"#7b3030",side:"left"},s?t:`${g}px`),Le.createElement(CI,{color:u?Oe.err:"#7b3030",side:"right"},u?t:`${k}px`),Le.createElement(Cx,{fSize:T,fWeight:String(p||600)},"Ag")),Le.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Le.createElement(AI,{color:Oe.err},"\u2508\u2508 font-size",s?" \u2717":""),Le.createElement(AI,{color:Oe.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Le.createElement(Nj,null,Le.createElement(TI,{variant:"err"},t),Le.createElement("span",{style:{color:Oe.dim}},"\u2192"),Le.createElement(TI,{variant:"ok"},n))));let E=a?t:String(p||600),I=a?n:E,D=ts(t),R=ts(n);return Le.createElement(Le.Fragment,null,Le.createElement(kI,null,Le.createElement(Oj,null,Le.createElement(II,null,Le.createElement(FI,{variant:"err"},"Current"),Le.createElement(Cx,{fSize:T,fWeight:a?E:String(p||600),style:{color:Oe.err}},c?t:"Ag"),Le.createElement(EI,{variant:"err"},a&&D?`${t} (${PI(D)})`:t)),Le.createElement(_j,null,"\u2192"),Le.createElement(II,null,Le.createElement(FI,{variant:"ok"},"Figma"),Le.createElement(Cx,{fSize:T,fWeight:a?I:String(p||600),style:{color:Oe.ok}},c?n:"Ag"),Le.createElement(EI,{variant:"ok"},a&&R?`${n} (${PI(R)})`:n)))))};function Uj(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 ts(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function jj(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function Hj(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var LI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function Wj(e){if(LI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return LI.has(t)}var MI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=Wj(e.property);return Le.createElement(Sj,null,Le.createElement(wj,null,"\u25BE Layer properties",t?"":" (from review)"),n?Le.createElement($j,{...e}):Le.createElement(Bj,{...e}))};import qr from"react";import{styled as Yr}from"storybook/theming";var Vj={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)"}},Gj=Yr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),qj=Yr.div(({theme:e,category:t})=>{let n=Vj[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}`}}),Yj=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}}}),Kj=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"}}),Xj=Yr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),Qj=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"}}),Jj=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"}}),Zj=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"}}),eH=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}`})),tH=Yr.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),nH=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},BI=({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=nH(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),g=e.generatedFix?.filePath||e.file;return qr.createElement(Gj,null,qr.createElement(qj,{category:e.type},e.type),e.status!=="pending"&&qr.createElement(Yj,{status:e.status},e.status),n&&t&&qr.createElement(Kj,null,t),d&&qr.createElement(Xj,null,c.ai&&!l&&qr.createElement(Qj,null,c.ai),c.programmatic&&qr.createElement(Jj,null,"Pre-filter: ",c.programmatic)),a&&qr.createElement(Zj,{title:u},"Unreliable"),e.dismissed&&qr.createElement(eH,null,"Dismissed"),i&&s&&g&&qr.createElement(tH,null,g))};import qn from"react";import{styled as Ho}from"storybook/theming";var rH=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},oH=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",iH=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"})),Tx=Ho.div({display:"flex",gap:"8px",alignItems:"baseline"}),Ix=Ho.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),Fx=Ho.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),sH=Ho(Fx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),aH=Ho(Fx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),lH=Ho.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
|
|
93
|
+
`},o)),i}function Vc(e,t){return e&&"run"in e?async function(n,r){let o=Wc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Wc(n,{file:r,...e||t})}}function ux(e){if(e)throw e}var Yc=Ua(rI(),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 px(){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],p=-1;if(u){s(u);return}for(;++p<o.length;)(c[p]===null||c[p]===void 0)&&(c[p]=o[p]);o=c,l?oI(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 oI(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 Lr={basename:hU,dirname:xU,extname:yU,join:bU,sep:"/"};function hU(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 xU(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 yU(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 bU(...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?".":SU(n)}function SU(e){Fa(e);let t=e.codePointAt(0)===47,n=wU(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function wU(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 iI={cwd:vU};function vU(){return"/"}function Zi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function sI(e){if(typeof e=="string")e=new URL(e);else if(!Zi(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 kU(e)}function kU(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 dx=["history","path","basename","stem","extname","dirname"],pi=class{constructor(t){let n;t?Zi(t)?n={path:t}:typeof t=="string"||CU(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":iI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<dx.length;){let i=dx[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)dx.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Lr.basename(this.path):void 0}set basename(t){fx(t,"basename"),gx(t,"basename"),this.path=Lr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Lr.dirname(this.path):void 0}set dirname(t){aI(this.basename,"dirname"),this.path=Lr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Lr.extname(this.path):void 0}set extname(t){if(gx(t,"extname"),aI(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=Lr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Zi(t)&&(t=sI(t)),fx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Lr.basename(this.path,this.extname):void 0}set stem(t){fx(t,"stem"),gx(t,"stem"),this.path=Lr.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 Vt(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 gx(e,t){if(e&&e.includes(Lr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Lr.sep+"`")}function fx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function aI(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function CU(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var lI=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var TU={}.hasOwnProperty,yx=class e extends lI{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=px()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,Yc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(xx("data",this.frozen),this.namespace[t]=n,this):TU.call(this.namespace,t)&&this.namespace[t]||void 0:t?(xx("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 mx("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),mx("process",this.parser||this.Parser),hx("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,p,g){if(l||!p||!g)return c(l);let d=p,f=r.stringify(d,g);FU(f)?g.value=f:g.result=f,c(l,g)});function c(l,p){l||!p?s(l):i?i(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),mx("processSync",this.parser||this.Parser),hx("processSync",this.compiler||this.Compiler),this.process(t,o),uI("processSync","process",n),r;function o(i,s){n=!0,ux(i),r=s}}run(t,n,r){cI(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,p,g){let d=p||t;l?a(l):s?s(d):r(void 0,d,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),uI("runSync","run",r),o;function i(s,a){ux(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=qc(n),o=this.compiler||this.Compiler;return hx("stringify",o),cI(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(xx("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,...p]=c;u(l,p)}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,Yc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let p=c[l];i(p)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let p=-1,g=-1;for(;++p<r.length;)if(r[p][0]===c){g=p;break}if(g===-1)r.push([c,...l]);else if(l.length>0){let[d,...f]=l,k=r[g][1];Ia(k)&&Ia(d)&&(d=(0,Yc.default)(!0,k,d)),r[g]=[c,d,...f]}}}},bx=new yx().freeze();function mx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function hx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xx(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 cI(e){if(!Ia(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uI(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function qc(e){return IU(e)?e:new pi(e)}function IU(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function FU(e){return typeof e=="string"||EU(e)}function EU(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var MU="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",pI=[],dI={allowDangerousHtml:!0},BU=/^(https?|ircs?|mailto|xmpp)$/i,DU=[{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 Sx(e){let t=RU(e),n=zU(e);return NU(t.runSync(t.parse(n),n),e)}function RU(e){let t=e.rehypePlugins||pI,n=e.remarkPlugins||pI,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dI}:dI;return bx().use(zc).use(n).use(Vc,r).use(t)}function zU(e){let t=e.children||"",n=new pi;return typeof t=="string"?n.value=t:(""+t,void 0),n}function NU(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||gI;for(let l of DU)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+MU+l.id,void 0);return n&&i&&void 0,Ta(e,c),Rh(e,{Fragment:AU,components:o,ignoreInvalidStyle:!0,jsx:PU,jsxs:LU,passKeys:!0,passNode:!0});function c(l,p,g){if(l.type==="raw"&&g&&typeof p=="number")return s?g.children.splice(p,1):g.children[p]={type:"text",value:l.value},p;if(l.type==="element"){let d;for(d in xa)if(Object.hasOwn(xa,d)&&Object.hasOwn(l.properties,d)){let f=l.properties[d],k=xa[d];(k===null||k.includes(l.tagName))&&(l.properties[d]=u(String(f||""),d,l))}}if(l.type==="element"){let d=n?!n.includes(l.tagName):i?i.includes(l.tagName):!1;if(!d&&r&&typeof p=="number"&&(d=!r(l,p,g)),d&&g&&typeof p=="number")return a&&l.children?g.children.splice(p,1,...l.children):g.children.splice(p,1),p}}}function gI(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||BU.test(e.slice(0,t))?e:""}Ce();var _U=es.div({display:"flex",flexDirection:"column",gap:"12px"}),$U=es.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),UU=es.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),jU=es(Tn)({padding:"6px 12px",fontSize:"12px"}),HU=es.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:p1.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}})),WU=es.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),wx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ce(),[r,o]=OU(!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?di.createElement(_U,null,di.createElement($U,null,di.createElement(UU,null,"Full Prompt"),di.createElement(jU,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),di.createElement(HU,null,di.createElement(Sx,null,e))):di.createElement(WU,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import go,{useRef as VU}from"react";import{styled as Mr}from"storybook/theming";Ce();var GU=Mr.div({display:"flex",flexDirection:"column",gap:"8px"}),gge=Mr.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"}}),qU=Mr.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})),YU=Mr.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})),fge=Mr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),fI=Mr.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||ae,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||ae,backgroundColor:e.background.warning||"#ffedd5"}})),KU=Mr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),XU=Mr.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"})),QU=Mr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),JU=Mr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),mge=Mr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function ZU(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 vx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ce(),s=VU(null);if((i??o)!=="admin")return null;let u=r?n.find(f=>f.id===r):null,c=u?u.issues.length>0&&u.issues.every(f=>f.dismissed):!1,l=u&&(u.complianceScore===100||c),p=e.filter(f=>f.role==="assistant"||f.role==="system"&&f.content.includes("auto-dismissed")),g=p.length===0&&!!t;if(p.length===0&&!g)return go.createElement(KU,null,"No AI response yet. The AI's analysis will appear here as it streams.");let d=p.length>0?p:[{role:"assistant",content:t}];return go.createElement(GU,null,l&&go.createElement(XU,null,go.createElement(QU,null,"Component Matches Design"),go.createElement(JU,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(qU,{ref:s},d.map((f,k)=>go.createElement(YU,{key:k,role:f.role},f.role==="system"?go.createElement(fI,null,f.content):go.createElement(fI,{dangerouslySetInnerHTML:{__html:ZU(f.content)}})))))};import yr from"react";import{styled as jo}from"storybook/theming";Ce();$e();var ej=jo.div({display:"flex",flexDirection:"column",gap:"12px"}),tj=jo.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),nj=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}}}),mI=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"}}),rj=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"})),hI=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||ae,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||ae,backgroundColor:e.background.warning||"#ffedd5"}})),xI=jo.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),oj=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 yI(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 ij(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 bI=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ce();if((i??o)!=="admin")return null;yr.useEffect(()=>{e&&(y.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([l,p])=>{y.debug(`[ModelResultsTabs] ${l}:`,{hasStreamingMessages:!!p.streamingMessages,streamingMessagesLength:p.streamingMessages?.length||0,streamingMessagesPreview:p.streamingMessages?.[0]?.content?.substring(0,100),hasFullResponse:!!p.fullResponse,fullResponsePreview:p.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?yr.createElement(xI,null,"No models selected. Select multiple models to compare results."):yr.createElement(ej,null,yr.createElement(tj,null,a.map(l=>{let p=co.find(E=>E.id===l),g=c[l],f=ij(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),k=l===u;if(!p)return null;let T=t&&!g?.completed;return yr.createElement(nj,{key:l,isActive:k,provider:p.provider,onClick:()=>n(l)},p.name,g&&f.issueCount>0&&yr.createElement(mI,{variant:"issues",value:f.issueCount},f.issueCount," issues"),g&&f.score!==null&&yr.createElement(mI,{variant:"score",value:f.score},"Score: ",f.score),T&&yr.createElement(oj,null))})),yr.createElement(rj,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,p)=>yr.createElement(hI,{key:p,dangerouslySetInnerHTML:{__html:yI(l.content)}})):c[u]?.fullResponse?yr.createElement(hI,{dangerouslySetInnerHTML:{__html:yI(c[u].fullResponse)}}):yr.createElement(xI,null,t?`Waiting for ${co.find(l=>l.id===u)?.name}...`:`No response yet for ${co.find(l=>l.id===u)?.name}`)))};import _e from"react";import{styled as Tt}from"storybook/theming";Ce();Nn();Ce();import{useCallback as kx}from"react";$e();function SI(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ce(),{sessionToken:r}=we(),o=kx(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=kx((a,u)=>{e(a,u,"user");let c=o(a);if(!c){y.debug("[useIssuePersistence] Dismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Dismiss skipped \u2014 no session token");return}Kl(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=kx(a=>{t(a);let u=o(a);if(!u){y.debug("[useIssuePersistence] Undismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Undismiss skipped \u2014 no session token");return}Kl(u,!1,void 0,"user",r).then(c=>{c.success||y.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import q,{useMemo as FH,useState as EH,useEffect as AH}from"react";import{styled as st,keyframes as PH}from"storybook/theming";import Z,{useState as Ex,useRef as x8,useCallback as NI,memo as y8}from"react";import{styled as Me}from"storybook/theming";import ut,{useState as wI}from"react";import{styled as vn}from"storybook/theming";var sj=()=>ut.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ut.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),aj=()=>ut.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("circle",{cx:"12",cy:"12",r:"10"}),ut.createElement("polyline",{points:"12 6 12 12 16 14"})),lj=()=>ut.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("circle",{cx:"12",cy:"12",r:"10"}),ut.createElement("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})),cj=()=>ut.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})),uj=()=>ut.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("path",{d:"M12 3l1.68 5.17L19 10l-5.32 1.83L12 17l-1.68-5.17L5 10l5.32-1.83z"}),ut.createElement("path",{d:"M5 3l.74 2.26L8 6l-2.26.74L5 9l-.74-2.26L2 6l2.26-.74z"}),ut.createElement("path",{d:"M19 15l.74 2.26L22 18l-2.26.74L19 21l-.74-2.26L16 18l2.26-.74z"})),vI=[{id:"false-positive",Icon:sj,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:aj,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:lj,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:cj,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:uj,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)"}],pj=vn.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}),dj=vn.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"})),gj=vn.div({display:"flex",flexDirection:"column",gap:"4px"}),fj=vn.h3(({theme:e})=>({fontSize:"17px",fontWeight:700,color:e.color.defaultText,margin:0})),mj=vn.p(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,margin:0,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),hj=vn.div({display:"flex",flexDirection:"column",gap:"6px"}),xj=vn.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}})),yj=vn.div(({color:e,bg:t})=>({width:"36px",height:"36px",borderRadius:"7px",backgroundColor:t,color:e,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),bj=vn.div({display:"flex",flexDirection:"column",gap:"2px",minWidth:0,flex:1}),Sj=vn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,lineHeight:"1.3"})),wj=vn.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,lineHeight:"1.4"})),vj=vn.div({display:"flex",flexDirection:"column",gap:"6px"}),kj=vn.label(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.defaultText})),Cj=vn.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}})),Tj=vn.div({display:"flex",justifyContent:"flex-end",gap:"8px"}),Ij=vn.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}})),kI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=wI(null),[s,a]=wI("");if(!e)return null;let u=vI.find(p=>p.id===o),c=()=>{o&&(n(o,s.trim()||void 0),i(null),a(""))},l=()=>{i(null),a(""),r()};return ut.createElement(pj,{onClick:p=>p.target===p.currentTarget&&l()},ut.createElement(dj,null,ut.createElement(gj,null,ut.createElement(fj,null,"Dismiss Issue"),ut.createElement(mj,{title:t},t)),ut.createElement(hj,{role:"radiogroup"},vI.map(({id:p,Icon:g,label:d,description:f,color:k,bg:T})=>ut.createElement(xj,{key:p,selected:o===p,accentColor:k,onClick:()=>i(p),role:"radio","aria-checked":o===p},ut.createElement(yj,{color:k,bg:T},ut.createElement(g,null)),ut.createElement(bj,null,ut.createElement(Sj,null,d),ut.createElement(wj,null,f))))),ut.createElement(vj,null,ut.createElement(kj,{htmlFor:"dismiss-note"},"Note (optional)"),ut.createElement(Cj,{id:"dismiss-note",placeholder:"Add context\u2026",value:s,onChange:p=>a(p.target.value),rows:3})),ut.createElement(Tj,null,ut.createElement(Nr,{onClick:l},"Cancel"),ut.createElement(Ij,{disabled:!o,accentColor:u?.color,onClick:c},"Dismiss Issue"))))};Ce();import Le from"react";import{styled as it}from"storybook/theming";var Oe={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"},Fj=it.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),Ej=it.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),Aj=it.div({position:"relative",backgroundColor:Oe.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),zge=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Oe.dash,padding:"0 8px",height:18,fontSize:11}),Nge=it.div({position:"absolute",color:Oe.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Oge=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%)"}})),_ge=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}})),Pj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Oe.errBg:Oe.borderBoxBg,border:`1px solid ${e.isErr?Oe.err:Oe.borderBoxStroke}`,borderRadius:6,padding:0})),Lj=it.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Oe.text}),Mj=it.span({fontWeight:500,fontSize:11}),$ge=it.span({color:Oe.dash}),Bj=it.div(e=>({position:"relative",backgroundColor:e.isErr?Oe.errBg:Oe.paddingBg,border:`1px solid ${e.isErr?Oe.err:Oe.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),Dj=it.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Oe.text,fontStyle:"italic"}),Kc=it.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Oe.err:Oe.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%)"}})),Rj=it.div(e=>({backgroundColor:e.isErr?Oe.errBg:"#fff",border:`1.5px dashed ${e.isErr?Oe.err:Oe.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Oe.err:Oe.text,fontWeight:e.isErr?600:400})),zj=it.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Oe.dim,fontFamily:"monospace"}),Nj=it.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Oe.ok,padding:"4px 8px 6px"}),Uge=it.div({fontSize:11,fontWeight:600,color:Oe.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),jge=it.span({fontSize:12,color:Oe.dim}),Oj=it.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),_j=it.div({fontSize:9,color:Oe.dim,marginTop:2}),$j=({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(),p=r||{},d=!(!!r&&Object.keys(r).length>0)&&s?Yj(n):null,f=p.padding||d||{top:0,right:0,bottom:0,left:0},k=p.strokeWeight??(a?ts(n)??0:0),T=p.width??(u?Kj(n)??"\u2014":"\u2014"),E=p.height??(u?Xj(n)??"\u2014":"\u2014");return Le.createElement(Le.Fragment,null,Le.createElement(Aj,null,Le.createElement(Pj,{isErr:a},Le.createElement(Lj,null,Le.createElement(Mj,null,"Border"),Le.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Oe.err:Oe.dim}},k)),Le.createElement(Bj,{isErr:s},Le.createElement(Dj,null,"Padding"),Le.createElement(Kc,{side:"top",isErr:s},f.top),Le.createElement(Kc,{side:"right",isErr:s},f.right),Le.createElement(Kc,{side:"bottom",isErr:s},f.bottom),Le.createElement(Kc,{side:"left",isErr:s},f.left),Le.createElement(Rj,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Le.createElement(Oj,{src:l,alt:"Figma element"}),Le.createElement(_j,null,T," \xD7 ",E)))),Le.createElement(zj,null,"border-box")),Le.createElement(Nj,null,"\u2192 ",n))},CI=it.div({backgroundColor:Oe.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),Uj=it.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),Cx=it.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Oe.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),jj=it.div({position:"absolute",border:`1.5px dashed ${Oe.err}`,pointerEvents:"none",zIndex:0}),Hj=it.div({position:"absolute",border:`1.5px dashed ${Oe.blue}`,pointerEvents:"none",zIndex:0}),TI=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%)"}})),Hge=it.div({fontSize:12,color:Oe.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),Wj=it.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),II=it.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Oe.err:Oe.ok})),Vj=it.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),FI=it.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),EI=it.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Oe.err:Oe.ok})),AI=it.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Oe.err:Oe.ok,textDecoration:e.variant==="err"?"line-through":"none"})),Gj=it.span({fontSize:16,color:Oe.dim,paddingBottom:20}),PI=it.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function LI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var qj=({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"),p=s||u,g=o.fontSize??(s?ts(n):14),d=o.fontWeight??(a?ts(n):600),k=(o.lineHeight??(u?ts(n):null))||Math.round((g||14)*1.43),T=`${Math.min(Math.max(g||14,24),48)}px`;if(p)return Le.createElement(Le.Fragment,null,Le.createElement(CI,null,Le.createElement(Uj,null,Le.createElement(Hj,{style:{top:-6,left:0,right:0,bottom:-6}}),Le.createElement(jj,{style:{top:2,left:8,right:8,bottom:2}}),Le.createElement(TI,{color:s?Oe.err:"#7b3030",side:"left"},s?t:`${g}px`),Le.createElement(TI,{color:u?Oe.err:"#7b3030",side:"right"},u?t:`${k}px`),Le.createElement(Cx,{fSize:T,fWeight:String(d||600)},"Ag")),Le.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Le.createElement(PI,{color:Oe.err},"\u2508\u2508 font-size",s?" \u2717":""),Le.createElement(PI,{color:Oe.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Le.createElement(Wj,null,Le.createElement(II,{variant:"err"},t),Le.createElement("span",{style:{color:Oe.dim}},"\u2192"),Le.createElement(II,{variant:"ok"},n))));let E=a?t:String(d||600),I=a?n:E,D=ts(t),R=ts(n);return Le.createElement(Le.Fragment,null,Le.createElement(CI,null,Le.createElement(Vj,null,Le.createElement(FI,null,Le.createElement(EI,{variant:"err"},"Current"),Le.createElement(Cx,{fSize:T,fWeight:a?E:String(d||600),style:{color:Oe.err}},c?t:"Ag"),Le.createElement(AI,{variant:"err"},a&&D?`${t} (${LI(D)})`:t)),Le.createElement(Gj,null,"\u2192"),Le.createElement(FI,null,Le.createElement(EI,{variant:"ok"},"Figma"),Le.createElement(Cx,{fSize:T,fWeight:a?I:String(d||600),style:{color:Oe.ok}},c?n:"Ag"),Le.createElement(AI,{variant:"ok"},a&&R?`${n} (${LI(R)})`:n)))))};function Yj(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 ts(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function Kj(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function Xj(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var MI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function Qj(e){if(MI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return MI.has(t)}var BI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=Qj(e.property);return Le.createElement(Fj,null,Le.createElement(Ej,null,"\u25BE Layer properties",t?"":" (from review)"),n?Le.createElement(qj,{...e}):Le.createElement($j,{...e}))};import qr from"react";import{styled as Yr}from"storybook/theming";var Jj={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)"}},Zj=Yr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),e8=Yr.div(({theme:e,category:t})=>{let n=Jj[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}`}}),t8=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}}}),n8=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"}}),r8=Yr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),o8=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"}}),i8=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"}}),s8=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"}}),a8=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}`})),l8=Yr.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),c8=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},DI=({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=c8(e.detectedBy),l=o&&c.ai===o,p=r&&!l&&(c.ai||c.programmatic),g=e.generatedFix?.filePath||e.file;return qr.createElement(Zj,null,qr.createElement(e8,{category:e.type},e.type),e.status!=="pending"&&qr.createElement(t8,{status:e.status},e.status),n&&t&&qr.createElement(n8,null,t),p&&qr.createElement(r8,null,c.ai&&!l&&qr.createElement(o8,null,c.ai),c.programmatic&&qr.createElement(i8,null,"Pre-filter: ",c.programmatic)),a&&qr.createElement(s8,{title:u},"Unreliable"),e.dismissed&&qr.createElement(a8,null,"Dismissed"),i&&s&&g&&qr.createElement(l8,null,g))};import qn from"react";import{styled as Ho}from"storybook/theming";var u8=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},p8=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",d8=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"})),Tx=Ho.div({display:"flex",gap:"8px",alignItems:"baseline"}),Ix=Ho.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),Fx=Ho.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),g8=Ho(Fx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),f8=Ho(Fx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),m8=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)"})),cH=Ho.span({display:"flex",alignItems:"center"}),DI=({value:e,isStrikethrough:t=!1})=>{let n=rH(e),r=oH(e),o=t?sH:aH;return n?qn.createElement(cH,null,qn.createElement(lH,{color:n,title:`Color: ${n}`}),qn.createElement(o,null,r)):qn.createElement(o,null,r)},RI=({property:e,currentValue:t,suggestedValue:n})=>qn.createElement(iH,null,qn.createElement(Tx,null,qn.createElement(Ix,null,"Property"),qn.createElement(Fx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&qn.createElement(Tx,null,qn.createElement(Ix,null,"Current"),qn.createElement(DI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&qn.createElement(Tx,null,qn.createElement(Ix,null,"Expected"),qn.createElement(DI,{value:n,isStrikethrough:!1})));Ce();var NI=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 dH(e){if(NI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return NI.has(t)}var gH=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"}})),Jge=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),fH=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),mH=Me.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),hH=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:oe},"&:checked":{backgroundColor:oe,borderColor:oe},"&: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"}})),xH=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"}})),yH=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})),Zge=Me.div({flex:1,minWidth:0}),efe=Me.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),bH=Me.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Ax=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"}})),SH=Me(Ax)(({theme:e})=>({"&:hover":{color:e.color.negative}})),tfe=Me.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),nfe=Me.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),wH=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),rfe=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"})),ofe=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),vH=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"}})),kH=Me.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${oe}`})),CH=Me.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:oe,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),TH=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"}})),IH=Me.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),OI=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"})),ife=Me.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),FH=Me(Cn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),sfe=Me(FH)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),EH=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}`})),_I=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"})),AH=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}`})),PH=Me.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),LH=Me.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),MH=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})),$I=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),UI=Me.details({marginBottom:"8px"}),jI=Me.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),BH=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"})),DH=Me.div({display:"flex",gap:"8px",marginTop:"8px"}),RH=Me(kn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),zH=Me(Nr)({padding:"6px 12px",fontSize:"12px"}),afe=Me(rn)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),lfe=Me.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),NH=Me.div({display:"flex",alignItems:"center",gap:"12px"}),OH=Me.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:oe,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),_H=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}}})),$H=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"})),HI=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"})),WI=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}`})),VI=Me.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),GI=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)"}}),qI=Me.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),YI=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},
|
|
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)"})),h8=Ho.span({display:"flex",alignItems:"center"}),RI=({value:e,isStrikethrough:t=!1})=>{let n=u8(e),r=p8(e),o=t?g8:f8;return n?qn.createElement(h8,null,qn.createElement(m8,{color:n,title:`Color: ${n}`}),qn.createElement(o,null,r)):qn.createElement(o,null,r)},zI=({property:e,currentValue:t,suggestedValue:n})=>qn.createElement(d8,null,qn.createElement(Tx,null,qn.createElement(Ix,null,"Property"),qn.createElement(Fx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&qn.createElement(Tx,null,qn.createElement(Ix,null,"Current"),qn.createElement(RI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&qn.createElement(Tx,null,qn.createElement(Ix,null,"Expected"),qn.createElement(RI,{value:n,isStrikethrough:!1})));Ce();var OI=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 b8(e){if(OI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return OI.has(t)}var S8=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"}})),ife=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),w8=Me.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),v8=Me.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),k8=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:ae},"&:checked":{backgroundColor:ae,borderColor:ae},"&: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"}})),C8=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"}})),T8=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})),sfe=Me.div({flex:1,minWidth:0}),afe=Me.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),I8=Me.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Ax=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"}})),F8=Me(Ax)(({theme:e})=>({"&:hover":{color:e.color.negative}})),lfe=Me.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),cfe=Me.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),E8=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),ufe=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"})),pfe=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),A8=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"}})),P8=Me.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${ae}`})),L8=Me.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:ae,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),M8=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"}})),B8=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"})),dfe=Me.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),D8=Me(In)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),gfe=Me(D8)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),R8=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}`})),$I=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"})),z8=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}`})),N8=Me.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),O8=Me.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),_8=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})),UI=Me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),jI=Me.details({marginBottom:"8px"}),HI=Me.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),$8=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"})),U8=Me.div({display:"flex",gap:"8px",marginTop:"8px"}),j8=Me(Tn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),H8=Me(Nr)({padding:"6px 12px",fontSize:"12px"}),ffe=Me(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),mfe=Me.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),W8=Me.div({display:"flex",alignItems:"center",gap:"12px"}),V8=Me.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),G8=Me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),hfe=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}}})),q8=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"})),WI=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"})),VI=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}`})),GI=Me.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),qI=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)"}}),YI=Me.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),KI=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},Y8=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},K8=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,XI=y8(({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:p}=ce(),[g,d]=Ex(!1),[f,k]=Ex(!1),[T,E]=Ex(!1),I=x8(null),D=NI(()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{p(e.id),E(!0)},100)},[e.id,p]),R=NI(()=>{I.current&&clearTimeout(I.current),I.current=null,p(null),E(!1)},[p]),$=()=>{e.dismissed?s(e.id):d(!0)},P=(w,v)=>{let C=v?`${w}: ${v}`:w;i(e.id,C),d(!1)},z=async()=>{let w=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&w.push(`Property: ${e.property}`),e.currentValue&&w.push(`Current: ${e.currentValue}`),e.suggestedValue&&w.push(`Expected: ${e.suggestedValue}`),e.file&&w.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&w.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&w.push(`
|
|
99
99
|
Suggested code:
|
|
100
100
|
\`\`\`
|
|
101
101
|
${e.suggestedCode}
|
|
@@ -109,25 +109,25 @@ Diff:
|
|
|
109
109
|
\`\`\`diff
|
|
110
110
|
${C.diffPreview}
|
|
111
111
|
\`\`\``),C.error&&w.push(`Error: ${C.error}`)}let v=w.filter(Boolean).join(`
|
|
112
|
-
`);try{await navigator.clipboard.writeText(v),k(!0),setTimeout(()=>k(!1),2e3)}catch(C){console.error("Failed to copy:",C)}},x=e.generatedFix?.status==="applied";return Z.createElement(Z.Fragment,null,Z.createElement(
|
|
112
|
+
`);try{await navigator.clipboard.writeText(v),k(!0),setTimeout(()=>k(!1),2e3)}catch(C){console.error("Failed to copy:",C)}},x=e.generatedFix?.status==="applied";return Z.createElement(Z.Fragment,null,Z.createElement(S8,{dismissed:!!e.dismissed,fixApplied:x,onMouseEnter:D,onMouseLeave:R},Z.createElement(w8,null,Z.createElement(k8,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),Z.createElement(C8,{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(T8,{severity:e.severity},e.severity),Z.createElement(v8,null,e.title),Z.createElement(I8,null,Z.createElement(Ax,{onClick:z,title:"Copy issue details"},f?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(Ax,{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(F8,{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(DI,{issue:e,modelDisplayName:K8(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(E8,null,e.description),e.property&&Z.createElement(zI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&T&&e.property&&e.currentValue&&e.suggestedValue&&b8(e.property)&&Z.createElement(BI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&Z.createElement(A8,null,Z.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&Z.createElement(P8,null,Z.createElement(L8,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((w,v)=>Z.createElement(M8,{key:`${w.property}-${v}`},Z.createElement(B8,null,w.property),Z.createElement(_I,{type:"current"},w.currentValue),Z.createElement(_I,{type:"suggested"},w.suggestedValue)))),e.dismissed&&Z.createElement(R8,null,Z.createElement("strong",null,"Filtered by:")," ",Y8(e.dismissedBy),e.dismissReason&&Z.createElement(Z.Fragment,null,Z.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&Z.createElement($I,null,Z.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&Z.createElement(z8,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?Z.createElement(W8,{style:{margin:0}},Z.createElement(V8,null),Z.createElement(G8,{style:{margin:0}},"Generating fix...")):Z.createElement(Z.Fragment,null,Z.createElement(N8,null,Z.createElement(O8,null,"AI-Generated Fix"),Z.createElement(_8,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&Z.createElement(UI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&Z.createElement(UI,{style:{fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?Z.createElement(jI,null,Z.createElement(HI,null,"View Diff"),Z.createElement(q8,null,Z.createElement(WI,{side:"old"},Z.createElement(VI,{side:"old"},"Old"),Z.createElement(GI,null,KI(e.generatedFix.diffPreview).map((w,v)=>Z.createElement(qI,{key:`old-${v}`,type:w.oldLine.type},w.oldLine.content||"\xA0")))),Z.createElement(WI,{side:"new"},Z.createElement(VI,{side:"new"},"New"),Z.createElement(GI,null,KI(e.generatedFix.diffPreview).map((w,v)=>Z.createElement(qI,{key:`new-${v}`,type:w.newLine.type},w.newLine.content||"\xA0")))))):e.generatedFix.code&&Z.createElement(jI,null,Z.createElement(HI,null,"View Generated Code"),Z.createElement($8,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&Z.createElement($I,null,Z.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&Z.createElement(U8,null,Z.createElement(j8,{onClick:()=>a(e.id)},"Apply Fix"),u&&Z.createElement(H8,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&Z.createElement(YI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&Z.createElement(YI,{status:"applied"},"\u2713 Fix applied successfully")))),Z.createElement(kI,{isOpen:g,issueTitle:e.title,onConfirm:P,onCancel:()=>d(!1)}))});import Px from"react";import{styled as Lx,keyframes as X8}from"storybook/theming";var Q8=X8`
|
|
113
113
|
0% { transform: rotate(0deg); }
|
|
114
114
|
100% { transform: rotate(360deg); }
|
|
115
|
-
`,
|
|
115
|
+
`,J8=Lx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),Z8=Lx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${Q8} 0.8s linear infinite`})),eH=Lx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Xc=({label:e="Loading..."})=>Px.createElement(J8,null,Px.createElement(Z8,null),Px.createElement(eH,null,e));Ce();import ht,{useState as tH,useEffect as nH,useRef as rH}from"react";import{styled as hn,keyframes as Ea}from"storybook/theming";var ns="#8b6cc1",oH="rgba(139, 108, 193, 0.2)",ZI="rgba(139, 108, 193, 0.15)",iH="rgba(139, 108, 193, 0.1)",sH="rgba(139, 108, 193, 0.5)",eF=Ea`
|
|
116
116
|
from { transform: rotate(0deg); }
|
|
117
117
|
to { transform: rotate(360deg); }
|
|
118
|
-
`,
|
|
118
|
+
`,aH=Ea`
|
|
119
119
|
from { transform: rotate(0deg); }
|
|
120
120
|
to { transform: rotate(-360deg); }
|
|
121
|
-
`,
|
|
121
|
+
`,lH=Ea`
|
|
122
122
|
0%, 100% { opacity: 1; transform: scale(1); }
|
|
123
123
|
50% { opacity: 0.6; transform: scale(1.05); }
|
|
124
|
-
`,
|
|
124
|
+
`,cH=Ea`
|
|
125
125
|
from { opacity: 0; transform: translateY(8px); }
|
|
126
126
|
to { opacity: 1; transform: translateY(0); }
|
|
127
|
-
`,
|
|
127
|
+
`,uH=Ea`
|
|
128
128
|
0%, 100% { opacity: 1; }
|
|
129
129
|
50% { opacity: 0.4; }
|
|
130
|
-
`,
|
|
130
|
+
`,pH=hn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${cH} 0.4s ease-out`}),dH=hn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),gH=hn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${ZI} 0%, transparent 70%)`,animation:`${lH} 2s ease-in-out infinite`}),fH=hn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${oH}`}),mH=hn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:ns,borderRightColor:ns,animation:`${eF} 1.2s linear infinite`}),hH=hn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${ZI}`}),xH=hn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:sH,animation:`${aH} 1.8s linear infinite`}),yH=hn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),bH=hn.div({position:"absolute",inset:0,animation:`${eF} 3s linear infinite`}),SH=hn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:ns}),wH=()=>ht.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:ns,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.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"}),ht.createElement("path",{d:"M5 3v4"}),ht.createElement("path",{d:"M3 5h4"}),ht.createElement("path",{d:"M19 17v4"}),ht.createElement("path",{d:"M17 19h4"})),vH=hn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),kH=hn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),CH=hn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),Mx=hn.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:iH,color:ns},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),QI=hn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),JI=hn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:ns,animation:`${uH} 1.5s ease-in-out infinite`}),TH=hn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),IH=()=>ht.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("polyline",{points:"20 6 9 17 4 12"})),tF=()=>{let{streamingProgress:e}=ce(),t=(e||0)>25,[n,r]=tH(0),o=rH();return nH(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),ht.createElement(pH,null,ht.createElement(dH,null,ht.createElement(gH,null),ht.createElement(fH,null),ht.createElement(mH,null),ht.createElement(hH,null),ht.createElement(xH,null),ht.createElement(yH,null,ht.createElement(wH,null)),ht.createElement(bH,null,ht.createElement(SH,null))),ht.createElement(vH,null,"Analyzing designs"),ht.createElement(kH,null,"AI is comparing screenshots and detecting issues"),ht.createElement(CH,null,ht.createElement(Mx,{variant:t?"done":"active"},t?ht.createElement(IH,null):ht.createElement(JI,null),"Screenshots"),ht.createElement(QI,null),ht.createElement(Mx,{variant:t?"active":"pending"},t?ht.createElement(JI,null):null,"Analysis"),ht.createElement(QI,null),ht.createElement(Mx,{variant:"pending"},"Report")),ht.createElement(TH,null,n,"s \xB7 Esc to stop"))};Ce();var Dfe=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}})),Rfe=st.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:ae})),LH=st.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),MH=st.div({display:"flex",gap:"8px"}),nF=st(xn)({flex:1}),BH=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}})),DH=st.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),RH=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"}})),zH=st.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),NH=st.div({display:"flex",alignItems:"center",gap:"2px"}),Qc=st(In)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Bx=st.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),OH=st.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),zfe=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:ae};case"selected":return{bg:e.color.tertiary,text:ae};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:ae};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"}}),_H=st.div({display:"flex",flexDirection:"column"}),$H=st.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),rF=st.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),oF=st.div({fontSize:"36px",marginBottom:"12px"}),iF=st.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),sF=st.div({fontSize:"12px"}),UH=PH`
|
|
131
131
|
0% {
|
|
132
132
|
transform: translateY(0) rotate(0deg) scale(1);
|
|
133
133
|
opacity: 1;
|
|
@@ -139,35 +139,35 @@ ${C.diffPreview}
|
|
|
139
139
|
transform: translateY(120px) rotate(720deg) scale(0.3);
|
|
140
140
|
opacity: 0;
|
|
141
141
|
}
|
|
142
|
-
`;var
|
|
142
|
+
`;var Nfe=st.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Ofe=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:`${UH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var jH=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}}})),HH=st(In)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),aF=st.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),lF=st(Tn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),cF=st(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),uF=st(on)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),WH=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}}),VH=st.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),GH=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}}),qH=st.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),YH=st.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),Jc=st.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),Zc=st.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),KH=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},pF=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:p,onSelectNone:g,onSelectAllFixes:d,onApplyFixes:f,onApplyFix:k,onCopyAllFixes:T,onGenerateFixes:E,onDismiss:I,onUndismiss:D,isGenerating:R=!1,isApplying:$=!1,isCopying:P=!1,applyFixesResult:z,onDismissResult:x,generationTiming:w,generationUsage:v,generationProgress:C,autoApplySupported:m=!0,hasReviewBeenRun:F=!1,isLoadingReview:S=!1,isReviewing:b=!1,selfReview:A})=>{let[L,B]=q.useState("all"),[N,h]=q.useState("all"),[U,W]=q.useState(!1),[M,Y]=q.useState(!0),{includeComponentIssues:ee,setIncludeComponentIssues:ge,featureFlags:xe}=ce(),se=q.useRef(null),[Ke,be]=EH(0);AH(()=>{if(!R){be(0);return}let oe=setInterval(()=>be(K=>K+1),1e3);return()=>clearInterval(oe)},[R]);let Te=async()=>{let oe=te.map(H=>{let Ee=[`[${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 De=H.generatedFix;if(Ee.push(""),Ee.push("--- AI-Generated Fix ---"),Ee.push(`Fix Status: ${De.status}`),De.confidence!==void 0){let St=De.confidence>1?De.confidence:Math.round(De.confidence*100);Ee.push(`Confidence: ${St}%`)}De.strategy&&Ee.push(`Strategy: ${De.strategy}`),De.filePath&&Ee.push(`Target file: ${De.filePath}`),De.code&&Ee.push(`Generated code:
|
|
143
143
|
${De.code}`),De.diffPreview&&Ee.push(`Diff:
|
|
144
144
|
${De.diffPreview}`),De.error&&Ee.push(`Error: ${De.error}`)}return Ee.push(""),Ee.filter(Boolean).join(`
|
|
145
145
|
`)}).join(`
|
|
146
146
|
---
|
|
147
147
|
|
|
148
|
-
`),K=te.filter(H=>H.generatedFix?.status==="applied").length,me=te.filter(H=>H.generatedFix?.status==="ready").length,
|
|
148
|
+
`),K=te.filter(H=>H.generatedFix?.status==="applied").length,me=te.filter(H=>H.generatedFix?.status==="ready").length,ie=K>0||me>0?` | Fixes: ${K} applied, ${me} ready`:"",O=r!==void 0?` | Similarity: ${r}%`:"",j=`Score: ${n}/100${O} | ${te.length} issues${ie}
|
|
149
149
|
|
|
150
|
-
`;try{await navigator.clipboard.writeText(j+ie),W(!0),setTimeout(()=>W(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};q.useEffect(()=>{z&&ae.current&&ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[z]);let te=S8(()=>e.filter(ie=>{let K=L==="all"||ie.severity===L,me=N==="all"||ie.status===N,se=ee||!j8(ie);return K&&me&&se}),[e,L,N,ee]),Be=()=>{te.forEach(ie=>{ie.selectedForFix||l(ie.id)})},Pe=()=>{te.forEach(ie=>{ie.selectedForFix&&l(ie.id)})},pe=()=>{te.forEach(ie=>{ie.generatedFix&&ie.generatedFix.status==="ready"&&!ie.selectedForFix&&l(ie.id)})},Pt=te.filter(ie=>ie.selectedForFix).length,tn=te.filter(ie=>ie.severity==="critical").length,Dr=te.filter(ie=>ie.severity==="major").length,fe=te.filter(ie=>ie.severity==="minor").length,tt=te.filter(ie=>ie.generatedFix&&ie.generatedFix.status==="ready").length,he=te.filter(ie=>ie.selectedForFix&&ie.generatedFix&&ie.generatedFix.status==="ready").length;return e.length===0?S?q.createElement(Xc,{label:"Loading review..."}):b?q.createElement(eF,null):q.createElement(nF,null,q.createElement(rF,null,F?"\u2728":"\u{1F441}\uFE0F"),q.createElement(oF,null,F?"No issues found":"No review yet"),q.createElement(iF,null,F?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):q.createElement(C8,{"data-testid":"issues-panel"},q.createElement(T8,null,q.createElement(tF,{value:L,onChange:ie=>B(ie.target.value)},q.createElement("option",{value:"all"},"All Severities"),q.createElement("option",{value:"critical"},"Critical Only"),q.createElement("option",{value:"major"},"Major Only"),q.createElement("option",{value:"minor"},"Minor Only")),q.createElement(tF,{value:N,onChange:ie=>h(ie.target.value)},q.createElement("option",{value:"all"},"All Statuses"),q.createElement("option",{value:"pending"},"Pending"),q.createElement("option",{value:"applied"},"Applied"),q.createElement("option",{value:"verified"},"Verified"),q.createElement("option",{value:"failed"},"Failed"))),q.createElement("div",null,q.createElement(I8,{isOpen:M,onClick:()=>Y(!M)},q.createElement(F8,null,q.createElement(E8,{isOpen:M},q.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},q.createElement("polyline",{points:"6 9 12 15 18 9"}))),q.createElement(L8,null,te.length," issues"),(()=>{if(te.length===0)return null;let ie=te.map(se=>se.generatedFix?.filePath||se.file).filter(Boolean);if(ie.length===0)return null;let K=ie[0];return ie.every(se=>se===K)?q.createElement(B8,null,"in ",K):null})(),q.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},tn>0&&q.createElement(Bx,{variant:"critical"},tn," critical"),Dr>0&&q.createElement(Bx,{variant:"major"},Dr," major"),fe>0&&q.createElement(Bx,{variant:"minor"},fe," minor"))),q.createElement(P8,{onClick:ie=>ie.stopPropagation()},q.createElement(Qc,{onClick:Be},"All"),q.createElement(Qc,{onClick:Pe},"None"),q.createElement(Qc,{onClick:Te},U?"\u2713":"\u2398"," Copy"),tt>0&&q.createElement(Qc,{onClick:pe},"Fixes (",tt,")"))),z&&q.createElement(R8,{ref:ae,variant:z.error||z.failed>0?"warning":"success"},z.error?q.createElement(q.Fragment,null,z.error):z.failed>0?q.createElement(q.Fragment,null,"Applied ",z.succeeded,"/",z.total," ","fixes. ",z.failed," failed. Run a new review to verify."):q.createElement(q.Fragment,null,"Applied ",z.total," fix",z.total!==1?"es":"","! Run a new review to verify changes."),x&&q.createElement(z8,{onClick:x},"\u2715")),Pt>0&&q.createElement(sF,null,w&&q.createElement(Wo,{variant:"timing"},w.durationSec,"s (",w.issueCount," ","fixes)"),v&&q.createElement(q.Fragment,null,q.createElement(Wo,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),q.createElement(Wo,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"#"," ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),q.createElement(Wo,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&E&&q.createElement(cF,{disabled:R||$||P,onClick:E},q.createElement("span",null,"\u{1F916}"),R&&C?`Generating ${C.completed}/${C.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${Pt} Issue${Pt>1?"s":""}`),xe.enableFixApply&&m&&f&&q.createElement(aF,{disabled:R||$||he===0,onClick:f},$?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!m&&T&&q.createElement(lF,{disabled:R||P||he===0,copied:P,onClick:T},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")),A&&!R&&q.createElement(N8,{confidence:A.overallConfidence},q.createElement(O8,null,q.createElement($8,null,"AI Self-Review"),q.createElement(_8,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),q.createElement(U8,null,A.variantSafety&&q.createElement(Jc,null,q.createElement(Zc,null,"Variant safety:"," "),A.variantSafety),A.gaps.length>0&&q.createElement(Jc,null,q.createElement(Zc,null,"Gaps: "),q.createElement("ul",null,A.gaps.map((ie,K)=>q.createElement("li",{key:K},ie)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&q.createElement(Jc,null,q.createElement(Zc,null,"Why not 100%:"," "),q.createElement("ul",null,A.reasonsNotPerfect.map((ie,K)=>q.createElement("li",{key:K},ie)))),A.suggestions&&A.suggestions.length>0&&q.createElement(Jc,null,q.createElement(Zc,null,"Suggestions: "),q.createElement("ul",null,A.suggestions.map((ie,K)=>q.createElement("li",{key:K},ie)))))),M&&q.createElement(A8,null,te.length===0?q.createElement(nF,null,q.createElement(rF,null,"\u{1F50D}"),q.createElement(oF,null,"No issues match current filters"),q.createElement(iF,null,"Try adjusting your severity or status filters")):q.createElement(M8,null,(()=>{let ie={};te.forEach(j=>{let H=j.detectedBy;H&&(ie[H]=(ie[H]||0)+1)});let K=Object.entries(ie).sort((j,H)=>H[1]-j[1])[0],me=K&&K[1]>te.length/2?K[0]:void 0,se=te.map(j=>j.generatedFix?.filePath||j.file).filter(Boolean),O=se.length>0&&se.every(j=>j===se[0]);return te.map(j=>q.createElement(KI,{key:j.id,issue:j,modelId:t,dominantDetector:me,showFilePath:!O,onToggleSelection:l,onDismiss:I,onUndismiss:D,onApplyFix:k}))})()))),Pt>0&&q.createElement(sF,null,w&&q.createElement(Wo,{variant:"timing"},w.durationSec,"s (",w.issueCount," ","fixes)"),v&&q.createElement(q.Fragment,null,q.createElement(Wo,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),q.createElement(Wo,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"#"," ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),q.createElement(Wo,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&E&&q.createElement(cF,{disabled:R||$||P,onClick:E},q.createElement("span",null,"\u{1F916}"),R&&C?`Generating ${C.completed}/${C.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${Pt} Issue${Pt>1?"s":""}`),xe.enableFixApply&&m&&f&&q.createElement(aF,{disabled:R||$||he===0,onClick:f},$?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!m&&T&&q.createElement(lF,{disabled:R||P||he===0,copied:P,onClick:T},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")))};$e();var H8=Ct.div({display:"flex",flexDirection:"column"}),W8=Ct.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),V8=Ct.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Dx=Ct.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:oe}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),G8=Ct.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),Hfe=Ct.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),Wfe=Ct.div({fontSize:"48px",marginBottom:"16px"}),Vfe=Ct.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),Gfe=Ct.div({fontSize:"14px",opacity:.8}),q8=Ct.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),Y8=Ct.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),K8=Ct(Cn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),X8=Ct(Nr)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),Q8=Ct.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),J8=Ct.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),Z8=Ct.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),eW=Ct.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),tW=Ct.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}})),nW=Ct.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),rW=Ct.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),oW=Ct.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}})),iW=Ct.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),eu={"false-positive":{icon:"\u{1F50D}",label:"False positive",group:"False Positive"},planned:{icon:"\u{1F4CB}",label:"Planned",group:"Planned"},"wont-fix":{icon:"\u{1F6AB}",label:"Won't fix",group:"Won't Fix"},"no-figma-state":{icon:"\u{1F5BC}\uFE0F",label:"No Figma state",group:"No Figma State"}},gF=e=>{if(!e)return{categoryId:null,note:""};let t=e.indexOf(": "),n=t>-1?e.slice(0,t):e.trim();return eu[n]?{categoryId:n,note:t>-1?e.slice(t+2):""}:{categoryId:null,note:e}},sW=e=>{if(!e)return"Other";let{categoryId:t}=gF(e);if(t&&eu[t])return eu[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"},pF=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},aW=Ct.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"}}),lW=Ct.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"}})),zx=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||zx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},dF=(e,t)=>{switch(e||zx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Auto";case"user":return"Manual";default:return"Auto"}},uW=Ct.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),pW=Ct.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),dW=Ct.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"})),gW=Ct(cy)({marginTop:"12px"}),Rx=class extends _e.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){y.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?_e.createElement(uW,null,_e.createElement(pW,null,"\u26A0\uFE0F Issues Panel Error"),_e.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),_e.createElement(dW,null,this.state.error?.message||"Unknown error",`
|
|
150
|
+
`;try{await navigator.clipboard.writeText(j+oe),W(!0),setTimeout(()=>W(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};q.useEffect(()=>{z&&se.current&&se.current.scrollIntoView({behavior:"smooth",block:"start"})},[z]);let te=FH(()=>e.filter(oe=>{let K=L==="all"||oe.severity===L,me=N==="all"||oe.status===N,ie=ee||!KH(oe);return K&&me&&ie}),[e,L,N,ee]),Be=()=>{te.forEach(oe=>{oe.selectedForFix||l(oe.id)})},Pe=()=>{te.forEach(oe=>{oe.selectedForFix&&l(oe.id)})},pe=()=>{te.forEach(oe=>{oe.generatedFix&&oe.generatedFix.status==="ready"&&!oe.selectedForFix&&l(oe.id)})},Lt=te.filter(oe=>oe.selectedForFix).length,nn=te.filter(oe=>oe.severity==="critical").length,Dr=te.filter(oe=>oe.severity==="major").length,fe=te.filter(oe=>oe.severity==="minor").length,tt=te.filter(oe=>oe.generatedFix&&oe.generatedFix.status==="ready").length,he=te.filter(oe=>oe.selectedForFix&&oe.generatedFix&&oe.generatedFix.status==="ready").length;return e.length===0?S?q.createElement(Xc,{label:"Loading review..."}):b?q.createElement(tF,null):q.createElement(rF,null,q.createElement(oF,null,F?"\u2728":"\u{1F441}\uFE0F"),q.createElement(iF,null,F?"No issues found":"No review yet"),q.createElement(sF,null,F?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):q.createElement(LH,{"data-testid":"issues-panel"},q.createElement(MH,null,q.createElement(nF,{value:L,onChange:oe=>B(oe.target.value)},q.createElement("option",{value:"all"},"All Severities"),q.createElement("option",{value:"critical"},"Critical Only"),q.createElement("option",{value:"major"},"Major Only"),q.createElement("option",{value:"minor"},"Minor Only")),q.createElement(nF,{value:N,onChange:oe=>h(oe.target.value)},q.createElement("option",{value:"all"},"All Statuses"),q.createElement("option",{value:"pending"},"Pending"),q.createElement("option",{value:"applied"},"Applied"),q.createElement("option",{value:"verified"},"Verified"),q.createElement("option",{value:"failed"},"Failed"))),q.createElement("div",null,q.createElement(BH,{isOpen:M,onClick:()=>Y(!M)},q.createElement(DH,null,q.createElement(RH,{isOpen:M},q.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},q.createElement("polyline",{points:"6 9 12 15 18 9"}))),q.createElement(OH,null,te.length," issues"),(()=>{if(te.length===0)return null;let oe=te.map(ie=>ie.generatedFix?.filePath||ie.file).filter(Boolean);if(oe.length===0)return null;let K=oe[0];return oe.every(ie=>ie===K)?q.createElement($H,null,"in ",K):null})(),q.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},nn>0&&q.createElement(Bx,{variant:"critical"},nn," critical"),Dr>0&&q.createElement(Bx,{variant:"major"},Dr," major"),fe>0&&q.createElement(Bx,{variant:"minor"},fe," minor"))),q.createElement(NH,{onClick:oe=>oe.stopPropagation()},q.createElement(Qc,{onClick:Be},"All"),q.createElement(Qc,{onClick:Pe},"None"),q.createElement(Qc,{onClick:Te},U?"\u2713":"\u2398"," Copy"),tt>0&&q.createElement(Qc,{onClick:pe},"Fixes (",tt,")"))),z&&q.createElement(jH,{ref:se,variant:z.error||z.failed>0?"warning":"success"},z.error?q.createElement(q.Fragment,null,z.error):z.failed>0?q.createElement(q.Fragment,null,"Applied ",z.succeeded,"/",z.total," ","fixes. ",z.failed," failed. Run a new review to verify."):q.createElement(q.Fragment,null,"Applied ",z.total," fix",z.total!==1?"es":"","! Run a new review to verify changes."),x&&q.createElement(HH,{onClick:x},"\u2715")),Lt>0&&q.createElement(aF,null,w&&q.createElement(Wo,{variant:"timing"},w.durationSec,"s (",w.issueCount," ","fixes)"),v&&q.createElement(q.Fragment,null,q.createElement(Wo,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),q.createElement(Wo,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"#"," ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),q.createElement(Wo,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&E&&q.createElement(uF,{disabled:R||$||P,onClick:E},q.createElement("span",null,"\u{1F916}"),R&&C?`Generating ${C.completed}/${C.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${Lt} Issue${Lt>1?"s":""}`),xe.enableFixApply&&m&&f&&q.createElement(lF,{disabled:R||$||he===0,onClick:f},$?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!m&&T&&q.createElement(cF,{disabled:R||P||he===0,copied:P,onClick:T},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")),A&&!R&&q.createElement(WH,{confidence:A.overallConfidence},q.createElement(VH,null,q.createElement(qH,null,"AI Self-Review"),q.createElement(GH,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),q.createElement(YH,null,A.variantSafety&&q.createElement(Jc,null,q.createElement(Zc,null,"Variant safety:"," "),A.variantSafety),A.gaps.length>0&&q.createElement(Jc,null,q.createElement(Zc,null,"Gaps: "),q.createElement("ul",null,A.gaps.map((oe,K)=>q.createElement("li",{key:K},oe)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&q.createElement(Jc,null,q.createElement(Zc,null,"Why not 100%:"," "),q.createElement("ul",null,A.reasonsNotPerfect.map((oe,K)=>q.createElement("li",{key:K},oe)))),A.suggestions&&A.suggestions.length>0&&q.createElement(Jc,null,q.createElement(Zc,null,"Suggestions: "),q.createElement("ul",null,A.suggestions.map((oe,K)=>q.createElement("li",{key:K},oe)))))),M&&q.createElement(zH,null,te.length===0?q.createElement(rF,null,q.createElement(oF,null,"\u{1F50D}"),q.createElement(iF,null,"No issues match current filters"),q.createElement(sF,null,"Try adjusting your severity or status filters")):q.createElement(_H,null,(()=>{let oe={};te.forEach(j=>{let H=j.detectedBy;H&&(oe[H]=(oe[H]||0)+1)});let K=Object.entries(oe).sort((j,H)=>H[1]-j[1])[0],me=K&&K[1]>te.length/2?K[0]:void 0,ie=te.map(j=>j.generatedFix?.filePath||j.file).filter(Boolean),O=ie.length>0&&ie.every(j=>j===ie[0]);return te.map(j=>q.createElement(XI,{key:j.id,issue:j,modelId:t,dominantDetector:me,showFilePath:!O,onToggleSelection:l,onDismiss:I,onUndismiss:D,onApplyFix:k}))})()))),Lt>0&&q.createElement(aF,null,w&&q.createElement(Wo,{variant:"timing"},w.durationSec,"s (",w.issueCount," ","fixes)"),v&&q.createElement(q.Fragment,null,q.createElement(Wo,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),q.createElement(Wo,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"#"," ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),q.createElement(Wo,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&E&&q.createElement(uF,{disabled:R||$||P,onClick:E},q.createElement("span",null,"\u{1F916}"),R&&C?`Generating ${C.completed}/${C.total}... (${Ke}s)`:R?`Generating... (${Ke}s)`:`Generate Fixes for ${Lt} Issue${Lt>1?"s":""}`),xe.enableFixApply&&m&&f&&q.createElement(lF,{disabled:R||$||he===0,onClick:f},$?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!m&&T&&q.createElement(cF,{disabled:R||P||he===0,copied:P,onClick:T},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")))};$e();var XH=Tt.div({display:"flex",flexDirection:"column"}),QH=Tt.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),JH=Tt.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Dx=Tt.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:ae}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),ZH=Tt.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),Xfe=Tt.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),Qfe=Tt.div({fontSize:"48px",marginBottom:"16px"}),Jfe=Tt.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),Zfe=Tt.div({fontSize:"14px",opacity:.8}),eW=Tt.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),tW=Tt.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),nW=Tt(In)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),rW=Tt(Nr)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),oW=Tt.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),iW=Tt.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),sW=Tt.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),aW=Tt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),lW=Tt.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}})),cW=Tt.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),uW=Tt.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),pW=Tt.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}})),dW=Tt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),eu={"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"}},fF=e=>{if(!e)return{categoryId:null,note:""};let t=e.indexOf(": "),n=t>-1?e.slice(0,t):e.trim();return eu[n]?{categoryId:n,note:t>-1?e.slice(t+2):""}:{categoryId:null,note:e}},gW=e=>{if(!e)return"Other";let{categoryId:t}=fF(e);if(t&&eu[t])return eu[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"},dF=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},fW=Tt.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"}}),mW=Tt.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"}})),zx=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"},hW=(e,t)=>{switch(e||zx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},gF=(e,t)=>{switch(e||zx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Auto";case"user":return"Manual";default:return"Auto"}},xW=Tt.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),yW=Tt.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),bW=Tt.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"})),SW=Tt(cy)({marginTop:"12px"}),Rx=class extends _e.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){y.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?_e.createElement(xW,null,_e.createElement(yW,null,"\u26A0\uFE0F Issues Panel Error"),_e.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),_e.createElement(bW,null,this.state.error?.message||"Unknown error",`
|
|
151
151
|
|
|
152
|
-
`,this.state.error?.stack),_e.createElement(
|
|
152
|
+
`,this.state.error?.stack),_e.createElement(SW,{onClick:this.handleReset},"Try Again")):this.props.children}},mF=()=>{let{currentStoryId:e}=nt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=ce(),{dismissAndSync:a,undismissAndSync:u}=SI(),{loadingMapping:c}=nt(),l=!!e&&!t&&!n&&c,[p,g]=_e.useState(!1),[d,f]=_e.useState(!1),[k,T]=_e.useState(!1),{isSupported:E,isDetecting:I}=km(),{refreshStorybookOnly:D}=ei(),{generateBatchFixes:R,isGenerating:$,error:P,timing:z,progress:x,usage:w,selfReview:v,lastStorybookRoot:C}=bm(),{applyFixes:m,isApplying:F}=ym({onComplete:D,storybookRoot:C}),S=r.find(K=>K.id===t),b=S?.issues||[],A=_e.useMemo(()=>b.filter(K=>!K.dismissed),[b]),L=_e.useMemo(()=>b.filter(K=>K.dismissed),[b]),B=_e.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]),N=A,h=S?.modelId||"unknown",U=A.filter(K=>K.severity==="critical").length,W=A.filter(K=>K.severity==="major").length,M=A.filter(K=>K.severity==="minor").length,Y=S?Io(U,W,M):void 0;_e.useEffect(()=>{!e||Y==null||Ur(e,{score:Y,issueCount:A.length,criticalCount:U,majorCount:W,minorCount:M})},[Y,e,A.length,U,W,M]);let ee=S?.visualSimilarity,ge=S?.costUsd,xe=S?.reviewDurationMs,se=S?.inputTokens,Ke=S?.outputTokens,be=S?.cacheCreationTokens,Te=S?.cacheReadTokens,te=S?.parentReviewId?r.find(K=>K.id===S.parentReviewId):null,Be=_e.useMemo(()=>{if(!te||!S)return null;let K=new Set(te.issues.map(H=>`${H.type}:${H.property||""}:${H.description}`)),me=new Set(N.map(H=>`${H.type}:${H.property||""}:${H.description}`)),ie=te.issues.filter(H=>!me.has(`${H.type}:${H.property||""}:${H.description}`)).length,O=N.filter(H=>K.has(`${H.type}:${H.property||""}:${H.description}`)).length,j=N.filter(H=>!K.has(`${H.type}:${H.property||""}:${H.description}`)).length;return{resolved:ie,remaining:O,newIssues:j}},[te,S,N]),Pe=()=>{N.forEach(K=>{K.selectedForFix||o(K.id)})},pe=()=>{N.forEach(K=>{K.selectedForFix&&o(K.id)})},Lt=()=>{N.forEach(K=>{K.generatedFix&&K.generatedFix.status==="ready"&&!K.selectedForFix&&o(K.id)})},{featureFlags:nn}=ce(),Dr=()=>{if(!nn.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let K=N.filter(me=>me.selectedForFix);if(K.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${K.length} issue(s)`,K),R(K)},fe=()=>{if(!nn.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let K=N.filter(ie=>ie.selectedForFix&&ie.generatedFix&&ie.generatedFix.status==="ready"&&ie.generatedFix.code&&ie.generatedFix.filePath);if(K.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let me=K.map(ie=>({id:ie.id,reviewId:ie.reviewId,type:ie.type,severity:ie.severity,title:ie.title,description:ie.description,generatedFix:ie.generatedFix,storyId:S?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${me.length} issue(s)`,me),m(me)},tt=K=>{let me=N.find(O=>O.id===K);if(!me){y.warn("[IssuesPanel] Issue not found:",K);return}if(!me.generatedFix||me.generatedFix.status!=="ready"||!me.generatedFix.code||!me.generatedFix.filePath){y.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",K);return}let ie={id:me.id,reviewId:me.reviewId,type:me.type,severity:me.severity,title:me.title,description:me.description,generatedFix:me.generatedFix,storyId:S?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",ie),m([ie])},he=async()=>{let K=N.filter(ie=>ie.selectedForFix&&ie.generatedFix&&ie.generatedFix.status==="ready"&&ie.generatedFix.code&&ie.generatedFix.filePath);if(K.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let me=K.map(ie=>{let O=ie.generatedFix,j=[];return j.push(`// File: ${O.filePath}`),j.push(`// Issue: ${ie.title||ie.description}`),ie.currentValue&&j.push(`// Actual: ${ie.currentValue}`),ie.suggestedValue&&j.push(`// Expected (Figma): ${ie.suggestedValue}`),O.diffPreview&&(j.push("//"),j.push("// Diff:"),O.diffPreview.split(`
|
|
153
153
|
`).forEach(H=>{j.push(`// ${H}`)})),j.push("//"),j.push("// Full Fixed Code:"),j.push(O.code),j.join(`
|
|
154
154
|
`)}).join(`
|
|
155
155
|
|
|
156
156
|
`+"=".repeat(60)+`
|
|
157
157
|
|
|
158
|
-
`);f(!0);try{await Cm(me)?y.debug(`[IssuesPanel] Copied ${K.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>f(!1),1500)}catch(
|
|
158
|
+
`);f(!0);try{await Cm(me)?y.debug(`[IssuesPanel] Copied ${K.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>f(!1),1500)}catch(ie){y.error("[IssuesPanel] Error copying fixes:",ie),f(!1)}},oe=async K=>{K.stopPropagation();let me=L.map(O=>[`[${O.severity.toUpperCase()}] ${O.title||O.description}`,`Phase: ${gF(O.dismissedBy,O.dismissReason)}`,O.dismissReason?`Reason: ${dF(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
|
---
|
|
162
162
|
|
|
163
|
-
`),
|
|
163
|
+
`),ie=`Filtered Issues (${L.length})
|
|
164
164
|
${"=".repeat(40)}
|
|
165
165
|
|
|
166
|
-
`;try{await navigator.clipboard.writeText(se+me),T(!0),setTimeout(()=>T(!1),2e3)}catch(O){y.error("Failed to copy dismissed issues:",O)}};return _e.createElement(H8,null,Be&&_e.createElement(W8,null,_e.createElement(V8,null,"\u{1F4CA} Progress:"),_e.createElement(Dx,{variant:"resolved"},"\u2705 ",Be.resolved," resolved"),_e.createElement(Dx,{variant:"remaining"},"\u23F3 ",Be.remaining," remaining"),Be.newIssues>0&&_e.createElement(Dx,{variant:"new"},"\u{1F195} ",Be.newIssues," new"),_e.createElement(G8,null,"Iteration ",S?.iterationNumber||1)),_e.createElement(Rx,null,_e.createElement(uF,{issues:N,modelId:h,complianceScore:Y,visualSimilarity:ee,costUsd:ge,reviewDurationMs:xe,inputTokens:ae,outputTokens:Ke,cacheCreationTokens:be,cacheReadTokens:Te,onToggleSelection:o,onSelectAll:Pe,onSelectNone:pe,onSelectAllFixes:Pt,onGenerateFixes:Dr,onApplyFixes:fe,onApplyFix:tt,onCopyAllFixes:he,onDismiss:a,onUndismiss:u,isGenerating:$,isApplying:F,isCopying:p,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:z,generationUsage:w,hasReviewBeenRun:!!S,isLoadingReview:l,isReviewing:n,generationProgress:x,autoApplySupported:E,selfReview:v})),L.length>0&&_e.createElement(q8,null,_e.createElement(Y8,null,_e.createElement(K8,{onClick:()=>g(!d)},_e.createElement("span",null,d?"\u25BC":"\u25B6"),_e.createElement("span",null,"Filtered out"),_e.createElement(Q8,null,L.length),_e.createElement(lW,null,B.postAiValidation>0&&_e.createElement("span",null,"\u2699\uFE0F ",B.postAiValidation),B.aiValidation>0&&_e.createElement("span",null,"\u2726 ",B.aiValidation),B.user>0&&_e.createElement("span",null,"\u{1F464} ",B.user))),_e.createElement(X8,{onClick:ie},k?"\u2713 Copied!":"Copy")),d&&_e.createElement(J8,null,(()=>{let K=L.reduce((O,j)=>{let H=sW(j.dismissReason);return O[H]||(O[H]=[]),O[H].push(j),O},{}),me=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(K).sort((O,j)=>me.indexOf(O)-me.indexOf(j)).map(O=>_e.createElement(_e.Fragment,{key:O},_e.createElement(oW,null,O,_e.createElement(iW,null,K[O].length)),K[O].map(j=>_e.createElement(Z8,{key:j.id},_e.createElement(eW,null,_e.createElement(aW,{phase:j.dismissedBy||zx(j.dismissReason)||"post-ai-validation"},cW(j.dismissedBy,j.dismissReason)," ",dF(j.dismissedBy,j.dismissReason)),_e.createElement(tW,{onClick:()=>u(j.id),title:"Restore to active issues"},"\u21A9 Restore")),_e.createElement(nW,null,"[",j.severity.toUpperCase(),"]"," ",j.title||j.description),j.dismissReason&&(()=>{let{categoryId:H,note:Ee}=gF(j.dismissReason),De=H?eu[H]:null;return _e.createElement(rW,null,De?_e.createElement(_e.Fragment,null,De.icon," ",De.label,Ee?` \u2014 ${Ee}`:""):pF(j.dismissReason))})()))))})())))};var mW=Aa.div({marginTop:"20px"}),hW=Aa.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),xW=Aa.div({display:"flex",alignItems:"center"}),Nx=Aa(bo)({padding:"10px 16px"}),yW=Aa.div({minHeight:"200px"}),Ox=()=>{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 fW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Br.createElement(mW,null,Br.createElement(hW,null,Br.createElement(xW,null,a&&Br.createElement(Nx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Br.createElement(Nx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Br.createElement(Nx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Br.createElement(yW,null,a&&e==="chat"&&(u?Br.createElement(bI,null):Br.createElement(vx,null)),e==="issues"&&Br.createElement(fF,null),a&&e==="prompt"&&Br.createElement(wx,null)))};Ce();import G,{useState as fo,useRef as Hx,useEffect as vW,useMemo as kW}from"react";import{styled as vt,useTheme as CW}from"storybook/theming";He();$e();var tu={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Pa="uicopilot_feature_flags";function _x(){try{let e=localStorage.getItem(Pa);if(e){let t=JSON.parse(e);return{...tu,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return tu}function bW(e,t){try{let r={..._x(),[e]:t},o={};for(let i in r){let s=i;r[s]!==tu[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Pa,JSON.stringify(o)):localStorage.removeItem(Pa),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function SW(){try{localStorage.removeItem(Pa),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function $x(e){return _x()[e]}function wW(){let e=Object.keys(tu).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Pa,JSON.stringify(e)),y.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){y.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:_x,set:bW,reset:SW,enableAll:wW,isEnabled:$x}});$e();ct();import At from"react";var mF=()=>At.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"},At.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),At.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"},nu=()=>At.createElement("svg",{...La},At.createElement("circle",{cx:"11",cy:"11",r:"8"}),At.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),hF=()=>At.createElement("svg",{...La},At.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),At.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),At.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),At.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),At.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),At.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),xF=()=>At.createElement("svg",{...La},At.createElement("polyline",{points:"23 4 23 10 17 10"}),At.createElement("polyline",{points:"1 20 1 14 7 14"}),At.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"})),Ux=()=>At.createElement("svg",{...La},At.createElement("circle",{cx:"11",cy:"11",r:"8"}),At.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),At.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),At.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),jx=()=>At.createElement("svg",{...La},At.createElement("circle",{cx:"11",cy:"11",r:"8"}),At.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),At.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var Ma=vt.div({marginTop:"20px"}),Wx=vt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Vx=vt.div({display:"flex",alignItems:"center",gap:"12px"}),Ba=vt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),xme=vt.div({display:"flex",gap:"8px"}),yme=vt.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}})),yF=vt.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})),ru=vt.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})),ou=vt.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})),iu=vt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),gi=vt.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"}})),TW=vt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),IW=vt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),FW=vt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),bme=vt.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"}})),EW=vt.div({position:"relative",display:"inline-block"}),Sme=vt.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})),AW=vt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),PW=vt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),LW=vt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),MW=vt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),BW=vt.input({flex:1}),Gx=vt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),wme=vt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),bF=vt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),rs=vt.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%"}}})),os=vt.div({textAlign:"center",zIndex:1}),is=vt.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)"}}})),ss=vt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),qx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=CW(),{currentMapping:o,loadingMapping:i}=nt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:g}=ce(),{selectedProjectId:p}=Je(),{sessionToken:f}=we(),{openComponentBrowser:k}=Ws(),{hasMapping:T,deleteMapping:E,setCurrentMapping:I}=ni(),D=$x("enableHoverHighlight"),[R,$]=fo("side-by-side"),[P,z]=fo(.5),[x,w]=fo(!1),[v,C]=fo(!1),[m,F]=fo(!1),[S,b]=fo(!1),[A,L]=fo(!1),B=async()=>{F(!1);try{let be=o?.id;be&&await E(be),I(null)}catch(be){y.error("[ScreenshotComparison] Failed to unlink:",be)}};vW(()=>{C(!1)},[s]);let[N,h]=fo(null),[U,W]=fo(null),M=Hx(null),Y=Hx(null),ee=Hx(null),ge=kW(()=>{if(!D||!l||!g)return null;let be=d.find(Te=>Te.id===g);return be?.issues&&be.issues.find(Te=>Te.id===l)||null},[l,g,d]),xe=be=>{let Te=be.currentTarget;C(!0),!gt.getState().figmaDimensions&&Te.naturalWidth&&Te.naturalHeight&>.getState().setFigmaDimensions({width:Te.naturalWidth,height:Te.naturalHeight}),requestAnimationFrame(()=>{if(Y.current){let{clientWidth:Be,clientHeight:Pe}=Y.current;Be&&Pe&&W({width:Be,height:Pe})}})},ae=()=>{requestAnimationFrame(()=>{if(M.current){let{clientWidth:be,clientHeight:Te}=M.current;be&&Te&&h({width:be,height:Te})}})},Ke=async()=>{if(!(!p||!f)){w(!0);try{let be=V();await ne(`${be}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(be){y.error("Failed to refresh Figma:",be)}finally{w(!1)}}};return e?G.createElement(Ma,null,G.createElement(Wx,null,G.createElement(Vx,null,G.createElement(Ba,null,"Screenshot Comparison"))),G.createElement(bF,null,G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading Figma..."))),G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading Storybook..."))))):!s&&!a&&!o?i?G.createElement(Ma,null,G.createElement(Wx,null,G.createElement(Vx,null,G.createElement(Ba,null,"Screenshot Comparison"))),G.createElement(bF,null,G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading..."))))):G.createElement(Ma,null,G.createElement(Ba,null,"Screenshot Comparison"),G.createElement(ru,null,G.createElement(ou,null,"Figma Design"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:k,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},G.createElement(nu,null))),G.createElement(Gx,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},G.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),G.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?G.createElement(Ma,null,G.createElement(Ba,null,"Screenshot Comparison"),G.createElement(Gx,{style:{lineHeight:"1.6"}},G.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u{1F440} Ready to compare"),G.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the ",G.createElement("strong",null,"Review")," button above to capture both the Figma frame and your Storybook component, then check for differences."))):G.createElement(Ma,{ref:ee},G.createElement(Wx,null,G.createElement(Vx,null,G.createElement(Ba,null,"Screenshot Comparison"))),R==="side-by-side"?G.createElement(yF,{layout:"side-by-side"},o&&s&&!t?G.createElement(ru,{zoomed:S},G.createElement(ou,null,"Figma Design"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:()=>b(be=>!be),title:S?"Shrink preview":"Enlarge preview","aria-label":S?"Shrink preview":"Enlarge preview"},S?G.createElement(jx,null):G.createElement(Ux,null)),T&&G.createElement(gi,{accent:r.color.secondary,onClick:k,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},G.createElement(nu,null)),G.createElement(gi,{accent:r.color.positive,onClick:Ke,disabled:x,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},G.createElement(xF,null)),T&&G.createElement(gi,{accent:r.color.negative,onClick:()=>F(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},G.createElement(hF,null))),G.createElement(FW,null,G.createElement(IW,{ref:Y,src:s,alt:"Figma design",onLoad:xe,style:{opacity:v?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?G.createElement(ru,null,G.createElement(ou,null,"Figma Design"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:k,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},G.createElement(nu,null))),G.createElement(Gx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?G.createElement(ru,{zoomed:A},G.createElement(ou,null,"Storybook Component"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:()=>L(be=>!be),title:A?"Shrink preview":"Enlarge preview","aria-label":A?"Shrink preview":"Enlarge preview"},A?G.createElement(jx,null):G.createElement(Ux,null))),G.createElement(TW,{ref:M,src:a,alt:"Storybook component",onLoad:ae})):G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,n?"Refreshing Storybook...":"Loading Storybook...")))):G.createElement(G.Fragment,null,G.createElement(yF,{layout:"overlay"},G.createElement(EW,null,s&&a?G.createElement(G.Fragment,null,G.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},G.createElement(AW,{ref:M,src:a,alt:"Storybook component",onLoad:ae,style:{maxHeight:"150px"}}),N&&G.createElement(PW,{src:s,alt:"Figma design overlay",style:{opacity:P,width:N.width,height:N.height,objectFit:"fill"}})),G.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},G.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",G.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),N&&` \u2022 ${N.width}\xD7${N.height}px`)):G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading Images..."))))),a&&s&&G.createElement(LW,null,G.createElement(MW,null,"Figma Opacity:"),G.createElement(BW,{type:"range",min:"0",max:"1",step:"0.01",value:P,onChange:be=>z(parseFloat(be.target.value))}),G.createElement("span",null,Math.round(P*100),"%"))),G.createElement(jr,{isOpen:m,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:B,onCancel:()=>F(!1)}))};Ce();ct();var DW=as.div({height:"100%"}),Yx=as.div({marginBottom:"20px"}),SF=as.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"})),wF=as.span({fontSize:"16px",flexShrink:0}),RW=as.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})),vF=as.div({flex:1}),Kx=()=>{let{reviewError:e,getCurrentReview:t}=ce(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Ws(),{selectedProjectId:s}=io(),{setCurrentMapping:a}=ni(),{currentStoryId:u,currentStoryName:c}=nt(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:g,screenshotError:p,setFigmaImageDirect:f}=ei(),k=async T=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",T),y.debug("[ReviewPanel] frame.id:",T?.id);let E=gt.getState(),I=E.selectedProjectId,D=E.currentStoryId,R=E.currentStoryName,$=E.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",I),y.debug("[ReviewPanel] currentStoryId (from store):",D),y.debug("[ReviewPanel] currentStoryName (from store):",R),T.thumbnail&&D&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),f(D,T.id,T.thumbnail));try{let P=V(),z=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!z),y.debug("[ReviewPanel] dashboardUrl:",P),!z||!I||!D){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!z,selectedProjectId:I,currentStoryId:D});return}let x=$?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:I,storyId:D,name:R,figmaNodeId:T.id,figmaFileKey:x});let w=await ne(`${P}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:I,storyId:D,name:R,figmaNodeId:T.id,figmaFileKey:x})});if(w.ok){let v=await w.json();v.mapping&&(a(v.mapping),T.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),gt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",v.mapping))}else{let v=await w.text();y.error("[ReviewPanel] Failed to save mapping:",v)}}catch(P){y.error("[ReviewPanel] Error saving mapping:",P)}};return Xt.createElement(DW,null,Xt.createElement(Yx,null,Xt.createElement(bh,null)),e&&Xt.createElement(SF,null,Xt.createElement(wF,null,"\u26A0\uFE0F"),Xt.createElement(vF,null,e)),p&&Xt.createElement(SF,null,Xt.createElement(wF,null,"\u26A0\uFE0F"),Xt.createElement(vF,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Xt.createElement(RW,null,Xt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Xt.createElement("span",null,Xt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Xt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Xt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Xt.createElement(Yx,null,Xt.createElement(qx,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:g})),Xt.createElement(Yx,null,Xt.createElement(Ox,null)),Xt.createElement(Hi,{isOpen:r,onClose:o,onSelect:k,figmaFileUrl:i||"",projectId:s||void 0}))};Ce();$e();He();ct();import{useEffect as kF,useState as zW,useRef as Xx,useCallback as NW}from"react";var OW=V(),_W=2e3;function CF(){let{sessionToken:e,usageData:t,setUsageData:n}=we(),[r,o]=zW(null),i=Xx(null),s=Xx(!1),a=Xx(0);kF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=NW(()=>{o(null)},[]);return kF(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<_W){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{y.debug("[useBalanceRefresh] Refreshing balance...");let g=await ne(`${OW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let p=await g.json(),f=p.creditBalance,k=i.current;if(k!==null&&f>k){let T=f-k;o({message:`Credits added! +${Math.floor(T)} credit(s)`,previousBalance:k,newBalance:f}),y.debug("[useBalanceRefresh] Credits added:",T)}i.current=f,n(p),y.debug("[useBalanceRefresh] Balance updated:",f)}}catch(g){y.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}}Ce();Ce();He();$e();ct();Mf();import{useEffect as $W,useRef as UW}from"react";var jW=300*1e3,TF="uicopilot_feature_flags_fetched_at";function HW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(TF);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<jW}catch{return!1}}var Qx=null,WW={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 IF(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ce(),{sessionToken:r,resetAuth:o}=we(),i=UW(null);$W(()=>{if(!r||r===i.current)return;if(i.current=r,HW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Qx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${V()}/api/addon/flags`;Qx=ne(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw y.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=>{y.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"&&bw());let c=a.role==="admin"&&n?WW[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(TF,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Qx=null})},[r,e,t])}Ce();He();zn();var qW={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},YW=br.div`
|
|
166
|
+
`;try{await navigator.clipboard.writeText(ie+me),T(!0),setTimeout(()=>T(!1),2e3)}catch(O){y.error("Failed to copy dismissed issues:",O)}};return _e.createElement(XH,null,Be&&_e.createElement(QH,null,_e.createElement(JH,null,"\u{1F4CA} Progress:"),_e.createElement(Dx,{variant:"resolved"},"\u2705 ",Be.resolved," resolved"),_e.createElement(Dx,{variant:"remaining"},"\u23F3 ",Be.remaining," remaining"),Be.newIssues>0&&_e.createElement(Dx,{variant:"new"},"\u{1F195} ",Be.newIssues," new"),_e.createElement(ZH,null,"Iteration ",S?.iterationNumber||1)),_e.createElement(Rx,null,_e.createElement(pF,{issues:N,modelId:h,complianceScore:Y,visualSimilarity:ee,costUsd:ge,reviewDurationMs:xe,inputTokens:se,outputTokens:Ke,cacheCreationTokens:be,cacheReadTokens:Te,onToggleSelection:o,onSelectAll:Pe,onSelectNone:pe,onSelectAllFixes:Lt,onGenerateFixes:Dr,onApplyFixes:fe,onApplyFix:tt,onCopyAllFixes:he,onDismiss:a,onUndismiss:u,isGenerating:$,isApplying:F,isCopying:d,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:z,generationUsage:w,hasReviewBeenRun:!!S,isLoadingReview:l,isReviewing:n,generationProgress:x,autoApplySupported:E,selfReview:v})),L.length>0&&_e.createElement(eW,null,_e.createElement(tW,null,_e.createElement(nW,{onClick:()=>g(!p)},_e.createElement("span",null,p?"\u25BC":"\u25B6"),_e.createElement("span",null,"Filtered out"),_e.createElement(oW,null,L.length),_e.createElement(mW,null,B.postAiValidation>0&&_e.createElement("span",null,"\u2699\uFE0F ",B.postAiValidation),B.aiValidation>0&&_e.createElement("span",null,"\u2726 ",B.aiValidation),B.user>0&&_e.createElement("span",null,"\u{1F464} ",B.user))),_e.createElement(rW,{onClick:oe},k?"\u2713 Copied!":"Copy")),p&&_e.createElement(iW,null,(()=>{let K=L.reduce((O,j)=>{let H=gW(j.dismissReason);return O[H]||(O[H]=[]),O[H].push(j),O},{}),me=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(K).sort((O,j)=>me.indexOf(O)-me.indexOf(j)).map(O=>_e.createElement(_e.Fragment,{key:O},_e.createElement(pW,null,O,_e.createElement(dW,null,K[O].length)),K[O].map(j=>_e.createElement(sW,{key:j.id},_e.createElement(aW,null,_e.createElement(fW,{phase:j.dismissedBy||zx(j.dismissReason)||"post-ai-validation"},hW(j.dismissedBy,j.dismissReason)," ",gF(j.dismissedBy,j.dismissReason)),_e.createElement(lW,{onClick:()=>u(j.id),title:"Restore to active issues"},"\u21A9 Restore")),_e.createElement(cW,null,"[",j.severity.toUpperCase(),"]"," ",j.title||j.description),j.dismissReason&&(()=>{let{categoryId:H,note:Ee}=fF(j.dismissReason),De=H?eu[H]:null;return _e.createElement(uW,null,De?_e.createElement(_e.Fragment,null,De.icon," ",De.label,Ee?` \u2014 ${Ee}`:""):dF(j.dismissReason))})()))))})())))};var vW=Aa.div({marginTop:"20px"}),kW=Aa.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),CW=Aa.div({display:"flex",alignItems:"center"}),Nx=Aa(bo)({padding:"10px 16px"}),TW=Aa.div({minHeight:"200px"}),Ox=()=>{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 wW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Br.createElement(vW,null,Br.createElement(kW,null,Br.createElement(CW,null,a&&Br.createElement(Nx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Br.createElement(Nx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Br.createElement(Nx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Br.createElement(TW,null,a&&e==="chat"&&(u?Br.createElement(bI,null):Br.createElement(vx,null)),e==="issues"&&Br.createElement(mF,null),a&&e==="prompt"&&Br.createElement(wx,null)))};Ce();import G,{useState as fo,useRef as Hx,useEffect as AW,useMemo as PW}from"react";import{styled as kt,useTheme as LW}from"storybook/theming";He();$e();var tu={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Pa="uicopilot_feature_flags";function _x(){try{let e=localStorage.getItem(Pa);if(e){let t=JSON.parse(e);return{...tu,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return tu}function IW(e,t){try{let r={..._x(),[e]:t},o={};for(let i in r){let s=i;r[s]!==tu[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Pa,JSON.stringify(o)):localStorage.removeItem(Pa),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function FW(){try{localStorage.removeItem(Pa),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function $x(e){return _x()[e]}function EW(){let e=Object.keys(tu).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Pa,JSON.stringify(e)),y.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){y.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:_x,set:IW,reset:FW,enableAll:EW,isEnabled:$x}});$e();ct();import Pt from"react";var hF=()=>Pt.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"},Pt.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Pt.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"},nu=()=>Pt.createElement("svg",{...La},Pt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Pt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),xF=()=>Pt.createElement("svg",{...La},Pt.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Pt.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Pt.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Pt.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Pt.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Pt.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),yF=()=>Pt.createElement("svg",{...La},Pt.createElement("polyline",{points:"23 4 23 10 17 10"}),Pt.createElement("polyline",{points:"1 20 1 14 7 14"}),Pt.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"})),Ux=()=>Pt.createElement("svg",{...La},Pt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Pt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Pt.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Pt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),jx=()=>Pt.createElement("svg",{...La},Pt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Pt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Pt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var Ma=kt.div({marginTop:"20px"}),Wx=kt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Vx=kt.div({display:"flex",alignItems:"center",gap:"12px"}),Ba=kt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Cme=kt.div({display:"flex",gap:"8px"}),Tme=kt.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}})),bF=kt.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})),ru=kt.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})),ou=kt.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})),iu=kt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),gi=kt.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"}})),MW=kt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),BW=kt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),DW=kt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),Ime=kt.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"}})),RW=kt.div({position:"relative",display:"inline-block"}),Fme=kt.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})),zW=kt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),NW=kt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),OW=kt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),_W=kt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),$W=kt.input({flex:1}),Gx=kt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),Eme=kt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),SF=kt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),rs=kt.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%"}}})),os=kt.div({textAlign:"center",zIndex:1}),is=kt.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)"}}})),ss=kt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),qx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=LW(),{currentMapping:o,loadingMapping:i}=nt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:p,currentReviewId:g}=ce(),{selectedProjectId:d}=Je(),{sessionToken:f}=we(),{openComponentBrowser:k}=Ws(),{hasMapping:T,deleteMapping:E,setCurrentMapping:I}=ni(),D=$x("enableHoverHighlight"),[R,$]=fo("side-by-side"),[P,z]=fo(.5),[x,w]=fo(!1),[v,C]=fo(!1),[m,F]=fo(!1),[S,b]=fo(!1),[A,L]=fo(!1),B=async()=>{F(!1);try{let be=o?.id;be&&await E(be),I(null)}catch(be){y.error("[ScreenshotComparison] Failed to unlink:",be)}};AW(()=>{C(!1)},[s]);let[N,h]=fo(null),[U,W]=fo(null),M=Hx(null),Y=Hx(null),ee=Hx(null),ge=PW(()=>{if(!D||!l||!g)return null;let be=p.find(Te=>Te.id===g);return be?.issues&&be.issues.find(Te=>Te.id===l)||null},[l,g,p]),xe=be=>{let Te=be.currentTarget;C(!0),!ft.getState().figmaDimensions&&Te.naturalWidth&&Te.naturalHeight&&ft.getState().setFigmaDimensions({width:Te.naturalWidth,height:Te.naturalHeight}),requestAnimationFrame(()=>{if(Y.current){let{clientWidth:Be,clientHeight:Pe}=Y.current;Be&&Pe&&W({width:Be,height:Pe})}})},se=()=>{requestAnimationFrame(()=>{if(M.current){let{clientWidth:be,clientHeight:Te}=M.current;be&&Te&&h({width:be,height:Te})}})},Ke=async()=>{if(!(!d||!f)){w(!0);try{let be=V();await ne(`${be}/api/figma/frames/invalidate?projectId=${d}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(be){y.error("Failed to refresh Figma:",be)}finally{w(!1)}}};return e?G.createElement(Ma,null,G.createElement(Wx,null,G.createElement(Vx,null,G.createElement(Ba,null,"Screenshot Comparison"))),G.createElement(SF,null,G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading Figma..."))),G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading Storybook..."))))):!s&&!a&&!o?i?G.createElement(Ma,null,G.createElement(Wx,null,G.createElement(Vx,null,G.createElement(Ba,null,"Screenshot Comparison"))),G.createElement(SF,null,G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading..."))))):G.createElement(Ma,null,G.createElement(Ba,null,"Screenshot Comparison"),G.createElement(ru,null,G.createElement(ou,null,"Figma Design"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:k,disabled:!d,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},G.createElement(nu,null))),G.createElement(Gx,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},G.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),G.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?G.createElement(Ma,null,G.createElement(Ba,null,"Screenshot Comparison"),G.createElement(Gx,{style:{lineHeight:"1.6"}},G.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u{1F440} Ready to compare"),G.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the ",G.createElement("strong",null,"Review")," button above to capture both the Figma frame and your Storybook component, then check for differences."))):G.createElement(Ma,{ref:ee},G.createElement(Wx,null,G.createElement(Vx,null,G.createElement(Ba,null,"Screenshot Comparison"))),R==="side-by-side"?G.createElement(bF,{layout:"side-by-side"},o&&s&&!t?G.createElement(ru,{zoomed:S},G.createElement(ou,null,"Figma Design"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:()=>b(be=>!be),title:S?"Shrink preview":"Enlarge preview","aria-label":S?"Shrink preview":"Enlarge preview"},S?G.createElement(jx,null):G.createElement(Ux,null)),T&&G.createElement(gi,{accent:r.color.secondary,onClick:k,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},G.createElement(nu,null)),G.createElement(gi,{accent:r.color.positive,onClick:Ke,disabled:x,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},G.createElement(yF,null)),T&&G.createElement(gi,{accent:r.color.negative,onClick:()=>F(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},G.createElement(xF,null))),G.createElement(DW,null,G.createElement(BW,{ref:Y,src:s,alt:"Figma design",onLoad:xe,style:{opacity:v?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?G.createElement(ru,null,G.createElement(ou,null,"Figma Design"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:k,disabled:!d,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},G.createElement(nu,null))),G.createElement(Gx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?G.createElement(ru,{zoomed:A},G.createElement(ou,null,"Storybook Component"),G.createElement(iu,null,G.createElement(gi,{accent:r.color.secondary,onClick:()=>L(be=>!be),title:A?"Shrink preview":"Enlarge preview","aria-label":A?"Shrink preview":"Enlarge preview"},A?G.createElement(jx,null):G.createElement(Ux,null))),G.createElement(MW,{ref:M,src:a,alt:"Storybook component",onLoad:se})):G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,n?"Refreshing Storybook...":"Loading Storybook...")))):G.createElement(G.Fragment,null,G.createElement(bF,{layout:"overlay"},G.createElement(RW,null,s&&a?G.createElement(G.Fragment,null,G.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},G.createElement(zW,{ref:M,src:a,alt:"Storybook component",onLoad:se,style:{maxHeight:"150px"}}),N&&G.createElement(NW,{src:s,alt:"Figma design overlay",style:{opacity:P,width:N.width,height:N.height,objectFit:"fill"}})),G.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},G.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",G.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),N&&` \u2022 ${N.width}\xD7${N.height}px`)):G.createElement(rs,null,G.createElement(os,null,G.createElement(is,null),G.createElement(ss,null,"Loading Images..."))))),a&&s&&G.createElement(OW,null,G.createElement(_W,null,"Figma Opacity:"),G.createElement($W,{type:"range",min:"0",max:"1",step:"0.01",value:P,onChange:be=>z(parseFloat(be.target.value))}),G.createElement("span",null,Math.round(P*100),"%"))),G.createElement(jr,{isOpen:m,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:B,onCancel:()=>F(!1)}))};Ce();ct();var UW=as.div({height:"100%"}),Yx=as.div({marginBottom:"20px"}),wF=as.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=as.span({fontSize:"16px",flexShrink:0}),jW=as.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=as.div({flex:1}),Kx=()=>{let{reviewError:e,getCurrentReview:t}=ce(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Ws(),{selectedProjectId:s}=io(),{setCurrentMapping:a}=ni(),{currentStoryId:u,currentStoryName:c}=nt(),{isLoadingScreenshots:l,isLoadingFigma:p,isLoadingStorybook:g,screenshotError:d,setFigmaImageDirect:f}=ei(),k=async T=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",T),y.debug("[ReviewPanel] frame.id:",T?.id);let E=ft.getState(),I=E.selectedProjectId,D=E.currentStoryId,R=E.currentStoryName,$=E.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",I),y.debug("[ReviewPanel] currentStoryId (from store):",D),y.debug("[ReviewPanel] currentStoryName (from store):",R),T.thumbnail&&D&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),f(D,T.id,T.thumbnail));try{let P=V(),z=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!z),y.debug("[ReviewPanel] dashboardUrl:",P),!z||!I||!D){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!z,selectedProjectId:I,currentStoryId:D});return}let x=$?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:I,storyId:D,name:R,figmaNodeId:T.id,figmaFileKey:x});let w=await ne(`${P}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:I,storyId:D,name:R,figmaNodeId:T.id,figmaFileKey:x})});if(w.ok){let v=await w.json();v.mapping&&(a(v.mapping),T.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),ft.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",v.mapping))}else{let v=await w.text();y.error("[ReviewPanel] Failed to save mapping:",v)}}catch(P){y.error("[ReviewPanel] Error saving mapping:",P)}};return Qt.createElement(UW,null,Qt.createElement(Yx,null,Qt.createElement(bh,null)),e&&Qt.createElement(wF,null,Qt.createElement(vF,null,"\u26A0\uFE0F"),Qt.createElement(kF,null,e)),d&&Qt.createElement(wF,null,Qt.createElement(vF,null,"\u26A0\uFE0F"),Qt.createElement(kF,null,"Screenshot loading error: ",d)),n?.variantMismatch&&Qt.createElement(jW,null,Qt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Qt.createElement("span",null,Qt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Qt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Qt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Qt.createElement(Yx,null,Qt.createElement(qx,{isLoading:l,isLoadingFigma:p,isLoadingStorybook:g})),Qt.createElement(Yx,null,Qt.createElement(Ox,null)),Qt.createElement(Hi,{isOpen:r,onClose:o,onSelect:k,figmaFileUrl:i||"",projectId:s||void 0}))};Ce();$e();He();ct();import{useEffect as CF,useState as HW,useRef as Xx,useCallback as WW}from"react";var VW=V(),GW=2e3;function TF(){let{sessionToken:e,usageData:t,setUsageData:n}=we(),[r,o]=HW(null),i=Xx(null),s=Xx(!1),a=Xx(0);CF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=WW(()=>{o(null)},[]);return CF(()=>{if(!e)return;let c=async()=>{let p=Date.now();if(s.current||p-a.current<GW){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=p;try{y.debug("[useBalanceRefresh] Refreshing balance...");let g=await ne(`${VW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let d=await g.json(),f=d.creditBalance,k=i.current;if(k!==null&&f>k){let T=f-k;o({message:`Credits added! +${Math.floor(T)} credit(s)`,previousBalance:k,newBalance:f}),y.debug("[useBalanceRefresh] Credits added:",T)}i.current=f,n(d),y.debug("[useBalanceRefresh] Balance updated:",f)}}catch(g){y.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}}Ce();Ce();He();$e();ct();Mf();import{useEffect as qW,useRef as YW}from"react";var KW=300*1e3,IF="uicopilot_feature_flags_fetched_at";function XW(){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<KW}catch{return!1}}var Qx=null,QW={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}=we(),i=YW(null);qW(()=>{if(!r||r===i.current)return;if(i.current=r,XW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Qx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${V()}/api/addon/flags`;Qx=ne(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw y.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=>{y.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"&&bw());let c=a.role==="admin"&&n?QW[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=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Qx=null})},[r,e,t])}Ce();He();Nn();var eV={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},tV=br.div`
|
|
167
167
|
position: fixed;
|
|
168
168
|
top: 16px;
|
|
169
169
|
right: 16px;
|
|
170
|
-
background: ${({variant:e})=>
|
|
170
|
+
background: ${({variant:e})=>eV[e||"success"]};
|
|
171
171
|
color: white;
|
|
172
172
|
padding: 12px 20px;
|
|
173
173
|
border-radius: 8px;
|
|
@@ -187,12 +187,12 @@ ${"=".repeat(40)}
|
|
|
187
187
|
opacity: 1;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
`,
|
|
190
|
+
`,nV=br.span`
|
|
191
191
|
font-size: 20px;
|
|
192
|
-
`,
|
|
192
|
+
`,rV=br.span`
|
|
193
193
|
font-weight: 500;
|
|
194
194
|
font-size: 14px;
|
|
195
|
-
`,
|
|
195
|
+
`,oV=br.button`
|
|
196
196
|
background: rgba(255, 255, 255, 0.2);
|
|
197
197
|
border: none;
|
|
198
198
|
color: white;
|
|
@@ -208,15 +208,15 @@ ${"=".repeat(40)}
|
|
|
208
208
|
&:hover {
|
|
209
209
|
background: rgba(255, 255, 255, 0.3);
|
|
210
210
|
}
|
|
211
|
-
`,
|
|
211
|
+
`,iV=br.div`
|
|
212
212
|
padding: 8px 16px;
|
|
213
213
|
border-top: 1px solid ${({theme:e})=>e.appBorderColor};
|
|
214
214
|
font-size: 11px;
|
|
215
215
|
color: ${({theme:e})=>e.color.mediumdark};
|
|
216
216
|
text-align: center;
|
|
217
217
|
opacity: 0.7;
|
|
218
|
-
`,
|
|
219
|
-
`);r=p.pop()||"";for(let f of p)if(f.startsWith("data: "))try{let k=JSON.parse(f.slice(6));if(k.type==="complete"){o=k.complianceScore??k.validation?.complianceScore??null;let E=(k.issues||[]).filter(I=>!I.dismissed);i=E.filter(I=>I.severity==="critical").length,s=E.filter(I=>I.severity==="major").length,a=E.filter(I=>I.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 su(e,t,n,r,o){e&&e.set([{value:n,typeId:cV,storyId:t,title:r,description:o}])}async function dV(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 DF(e,t,n,r,o,i){su(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await dV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await uV(`${lV}/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 pV(u,i),{score:l,criticalCount:d,majorCount:g,minorCount:p,costUsd:f,inputTokens:k,outputTokens:T}=c;if(l!==null){let E=d>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",I=[`Score: ${l}`];d>0&&I.push(`${d} critical`),g>0&&I.push(`${g} major`),p>0&&I.push(`${p} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return su(o,e.storyId,E,D,I.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:f,inputTokens:k,outputTokens:T}}return su(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){y.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return su(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var fV=V(),Da="uireview/badge";function RF(){let e=!1,t=!1;try{let n=gV.getChannel();n.on(Zx,async()=>{if(!t){t=!0,e=!1;try{await xV(n,()=>e)}finally{t=!1}}}),n.on(ey,()=>{e=!0})}catch{}}async function Jx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${fV}/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 mV(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function mV(e){try{if(typeof au!="function")return;let t=au(Da);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Da]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Da];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Da,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 hV(){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 xV(e,t){let n=await Jx();if(n.length===0){e.emit(za,{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 T=JSON.parse(k);Array.isArray(T)&&T.length>0&&(i=T[0])}}catch{}let s=null;try{typeof au=="function"&&(s=au(Da))}catch{}let a=hV(),u=0,c=0,l=0,d=0,g=0,p=0;e.emit(Ra,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let f=n.map(k=>()=>DF(k,r,o,i,s,t));await BF(f,a,(k,T)=>{if(T&&typeof T=="object"&&"score"in T){let E=T;E.score!==null&&E.score>=90?u++:E.score!==null&&E.score>=70?c++:l++,d+=E.costUsd||0,g+=E.inputTokens||0,p+=E.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${k+1}/${n.length} done:`,n[k].storyName,T),e.emit(Ra,{total:n.length,completed:u+c+l,currentStoryName:n[k].storyName})},t),e.emit(za,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:g,outputTokens:p})}var bV=mo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),SV=mo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),wV=mo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),NF=mo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),OF=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}})),vV=mo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),kV=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})),ls=mo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Zx="uireview/review-all-start",ey="uireview/review-all-cancel",Ra="uireview/review-all-progress",za="uireview/review-all-complete";function $F(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var UF=()=>{let[e,t]=Na(!1),[n,r]=Na(null),[o,i]=Na(null),[s,a]=Na(null),[u,c]=Na($F);ty(()=>{let f=()=>c($F()),k=setInterval(f,2e3);return window.addEventListener("storage",f),()=>{clearInterval(k),window.removeEventListener("storage",f)}},[]),ty(()=>{let f=()=>{Jx().then(I=>{a(I.length)}).catch(()=>{})},k=setTimeout(f,3e3),T=null;try{T=lu.getChannel(),T.on("storyChanged",f),T.on("uireview/mappings-changed",f)}catch{}let E=setInterval(f,6e4);return()=>{clearTimeout(k),clearInterval(E),T&&(T.off("storyChanged",f),T.off("uireview/mappings-changed",f))}},[]),ty(()=>{let f;try{f=lu.getChannel()}catch{return}let k=E=>{r(E),t(!0)},T=E=>{t(!1),r(null),i({total:E.total,passed:E.passed,failed:E.failed,warned:E.warnCount||0,costUsd:E.costUsd||0})};return f.on(Ra,k),f.on(za,T),()=>{f.off(Ra,k),f.off(za,T)}},[]);let l=zF(()=>{try{lu.getChannel().emit(Zx),t(!0),i(null)}catch{}},[]),d=zF(()=>{try{lu.getChannel().emit(ey)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,p=yV();return u?Gt.createElement(bV,null,Gt.createElement(SV,null,Gt.createElement(wV,null,"UI Review"),e?Gt.createElement(OF,{running:!0,onClick:d},"Cancel"):Gt.createElement(OF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Gt.createElement(Gt.Fragment,null,Gt.createElement(_F,null,Gt.createElement(ls,{dotColor:p.color.positive},"Pass (",o.passed,")"),Gt.createElement(ls,{dotColor:p.color.warning},"Warn (",o.warned,")"),Gt.createElement(ls,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Gt.createElement(NF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Gt.createElement(_F,null,Gt.createElement(ls,{dotColor:p.color.positive},"Pass"),Gt.createElement(ls,{dotColor:p.color.warning},"Warn"),Gt.createElement(ls,{dotColor:p.color.negative},"Fail")),e&&n&&Gt.createElement(Gt.Fragment,null,Gt.createElement(vV,null,Gt.createElement(kV,{percent:g})),Gt.createElement(NF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as HF from"@sentry/react";var CV="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",jF=!1;function TV(){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 WF(){if(!jF){jF=!0;try{HF.init({dsn:CV,environment:TV(),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{}}}WF();var uu="uireview",FV=`${uu}/panel`,EV=`${uu}/tool`,VF=`${uu}/test-provider`;cu.register(uu,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof ry=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=ry("uireview/badge");zv(t);let n=ry("uireview/mapped");_v(n),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");cu.add(EV,{type:ny.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Oa.createElement(MF,null)}),RF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&cu.add(VF,{type:ny.experimental_TEST_PROVIDER,id:VF,render:()=>Oa.createElement(UF,null)}),cu.add(FV,{type:ny.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Oa.createElement(IV,{active:t||!1},Oa.createElement(Nf,null,Oa.createElement(PF,null)))})});
|
|
218
|
+
`,sV=br.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),aV=br.div({fontSize:"32px"}),lV=br.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),cV=br.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),EF=br.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=br.span({flex:1}),PF=br.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}=we(),{currentStoryId:s}=nt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:p}=ce(),[g,d]=JW(!1),f=()=>{l(null),o&&fetch(`${V()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{p({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};hm(),Bm(),FF(),Tm(),vm();let{notification:k,dismissNotification:T}=TF();ZW(()=>{if(k){let P=setTimeout(T,5e3);return()=>clearTimeout(P)}},[k,T]);let E=t.find(P=>P.id===e),I=r&&!!e&&!!E,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=nt(),$=I&&!!s&&!a&&R;return Rt.createElement(fu,{header:Rt.createElement(mu,{toolbar:Rt.createElement($f,{onOpenSettings:()=>d(!0)})}),footer:Rt.createElement(iV,null,Et.NAME," v","0.5.23")},k&&Rt.createElement(tV,{variant:k.variant||"success"},Rt.createElement(nV,null,k.variant==="error"?"!":k.variant==="warning"?"\u26A0":"+"),Rt.createElement(rV,null,k.message),Rt.createElement(oV,{onClick:T},"x")),i&&Rt.createElement(EF,null,Rt.createElement("span",null,"\u26A0"),Rt.createElement(AF,null,i),Rt.createElement(PF,{onClick:()=>d(!0)},"Reconnect")),u==="admin"&&c&&Rt.createElement(EF,null,Rt.createElement("span",null,"\u{1F441}"),Rt.createElement(AF,null,"Previewing as ",c),Rt.createElement(PF,{onClick:f},"Exit preview")),D||$?Rt.createElement(Xc,{label:D?"Loading...":"Loading review..."}):I?Rt.createElement(Kx,null):Rt.createElement(sV,null,Rt.createElement(aV,null,"\u2699"),Rt.createElement(lV,null,i?"Connection issue":`Set up ${Et.NAME}`),Rt.createElement(cV,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Rt.createElement(on,{onClick:()=>d(!0)},i?"Reconnect":"Open Settings")),g&&Rt.createElement(ZC,{onClose:()=>d(!1)}))};import MF,{useCallback as uV}from"react";import{useStorybookApi as pV}from"storybook/manager-api";import{IconButton as dV}from"storybook/internal/components";var gV="uireview",fV=`${gV}/panel`,BF=()=>{let e=pV(),t=uV(()=>{e.togglePanel(!0),e.setSelectedPanel(fV)},[e]);return MF.createElement(dV,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},MF.createElement(hF,null))};Ce();import qt,{useState as Na,useCallback as NF,useEffect as ty}from"react";import{styled as mo,useTheme as TV}from"storybook/theming";import{addons as lu}from"storybook/manager-api";He();$e();import{addons as SV,experimental_getStatusStore as au}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 mV=V(),hV="uireview/badge";async function xV(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;y.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function yV(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:p,value:g}=await e.read();if(p)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let d=r.split(`
|
|
219
|
+
`);r=d.pop()||"";for(let f of d)if(f.startsWith("data: "))try{let k=JSON.parse(f.slice(6));if(k.type==="complete"){o=k.complianceScore??k.validation?.complianceScore??null;let E=(k.issues||[]).filter(I=>!I.dismissed);i=E.filter(I=>I.severity==="critical").length,s=E.filter(I=>I.severity==="major").length,a=E.filter(I=>I.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 su(e,t,n,r,o){e&&e.set([{value:n,typeId:hV,storyId:t,title:r,description:o}])}async function bV(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){su(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await bV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await xV(`${mV}/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 yV(u,i),{score:l,criticalCount:p,majorCount:g,minorCount:d,costUsd:f,inputTokens:k,outputTokens:T}=c;if(l!==null){let E=p>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",I=[`Score: ${l}`];p>0&&I.push(`${p} critical`),g>0&&I.push(`${g} major`),d>0&&I.push(`${d} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return su(o,e.storyId,E,D,I.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:f,inputTokens:k,outputTokens:T}}return su(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){y.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return su(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var wV=V(),Da="uireview/badge";function zF(){let e=!1,t=!1;try{let n=SV.getChannel();n.on(Zx,async()=>{if(!t){t=!0,e=!1;try{await CV(n,()=>e)}finally{t=!1}}}),n.on(ey,()=>{e=!0})}catch{}}async function Jx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${wV}/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 vV(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function vV(e){try{if(typeof au!="function")return;let t=au(Da);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Da]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Da];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Da,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 kV(){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 CV(e,t){let n=await Jx();if(n.length===0){e.emit(za,{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 T=JSON.parse(k);Array.isArray(T)&&T.length>0&&(i=T[0])}}catch{}let s=null;try{typeof au=="function"&&(s=au(Da))}catch{}let a=kV(),u=0,c=0,l=0,p=0,g=0,d=0;e.emit(Ra,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let f=n.map(k=>()=>RF(k,r,o,i,s,t));await DF(f,a,(k,T)=>{if(T&&typeof T=="object"&&"score"in T){let E=T;E.score!==null&&E.score>=90?u++:E.score!==null&&E.score>=70?c++:l++,p+=E.costUsd||0,g+=E.inputTokens||0,d+=E.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${k+1}/${n.length} done:`,n[k].storyName,T),e.emit(Ra,{total:n.length,completed:u+c+l,currentStoryName:n[k].storyName})},t),e.emit(za,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:p,inputTokens:g,outputTokens:d})}var IV=mo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),FV=mo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),EV=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}})),AV=mo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),PV=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})),ls=mo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Zx="uireview/review-all-start",ey="uireview/review-all-cancel",Ra="uireview/review-all-progress",za="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]=Na(!1),[n,r]=Na(null),[o,i]=Na(null),[s,a]=Na(null),[u,c]=Na(UF);ty(()=>{let f=()=>c(UF()),k=setInterval(f,2e3);return window.addEventListener("storage",f),()=>{clearInterval(k),window.removeEventListener("storage",f)}},[]),ty(()=>{let f=()=>{Jx().then(I=>{a(I.length)}).catch(()=>{})},k=setTimeout(f,3e3),T=null;try{T=lu.getChannel(),T.on("storyChanged",f),T.on("uireview/mappings-changed",f)}catch{}let E=setInterval(f,6e4);return()=>{clearTimeout(k),clearInterval(E),T&&(T.off("storyChanged",f),T.off("uireview/mappings-changed",f))}},[]),ty(()=>{let f;try{f=lu.getChannel()}catch{return}let k=E=>{r(E),t(!0)},T=E=>{t(!1),r(null),i({total:E.total,passed:E.passed,failed:E.failed,warned:E.warnCount||0,costUsd:E.costUsd||0})};return f.on(Ra,k),f.on(za,T),()=>{f.off(Ra,k),f.off(za,T)}},[]);let l=NF(()=>{try{lu.getChannel().emit(Zx),t(!0),i(null)}catch{}},[]),p=NF(()=>{try{lu.getChannel().emit(ey)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,d=TV();return u?qt.createElement(IV,null,qt.createElement(FV,null,qt.createElement(EV,null,"UI Review"),e?qt.createElement(_F,{running:!0,onClick:p},"Cancel"):qt.createElement(_F,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?qt.createElement(qt.Fragment,null,qt.createElement($F,null,qt.createElement(ls,{dotColor:d.color.positive},"Pass (",o.passed,")"),qt.createElement(ls,{dotColor:d.color.warning},"Warn (",o.warned,")"),qt.createElement(ls,{dotColor:d.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&qt.createElement(OF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:qt.createElement($F,null,qt.createElement(ls,{dotColor:d.color.positive},"Pass"),qt.createElement(ls,{dotColor:d.color.warning},"Warn"),qt.createElement(ls,{dotColor:d.color.negative},"Fail")),e&&n&&qt.createElement(qt.Fragment,null,qt.createElement(AV,null,qt.createElement(PV,{percent:g})),qt.createElement(OF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as WF from"@sentry/react";var LV="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",HF=!1;function MV(){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:LV,environment:MV(),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 uu="uireview",DV=`${uu}/panel`,RV=`${uu}/tool`,GF=`${uu}/test-provider`;cu.register(uu,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof ry=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=ry("uireview/badge");zv(t);let n=ry("uireview/mapped");_v(n),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");cu.add(RV,{type:ny.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Oa.createElement(BF,null)}),zF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&cu.add(GF,{type:ny.experimental_TEST_PROVIDER,id:GF,render:()=>Oa.createElement(jF,null)}),cu.add(DV,{type:ny.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Oa.createElement(BV,{active:t||!1},Oa.createElement(Nf,null,Oa.createElement(LF,null)))})});
|
|
220
220
|
/*! Bundled license information:
|
|
221
221
|
|
|
222
222
|
@noble/hashes/utils.js:
|