@uicopilot/storybook-addon 0.5.5 → 0.5.6
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/dist/manager.mjs +44 -44
- package/package.json +1 -1
package/dist/manager.mjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
var xF=Object.create;var Aa=Object.defineProperty;var yF=Object.getOwnPropertyDescriptor;var bF=Object.getOwnPropertyNames;var SF=Object.getPrototypeOf,wF=Object.prototype.hasOwnProperty;var vF=(e,t,n)=>t in e?Aa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var Jn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ye=(e,t)=>{for(var n in t)Aa(e,n,{get:t[n],enumerable:!0})},kF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bF(t))!wF.call(e,o)&&o!==n&&Aa(e,o,{get:()=>t[o],enumerable:!(r=yF(t,o))||r.enumerable});return e};var Pa=(e,t,n)=>(n=e!=null?xF(SF(e)):{},kF(t||!e||!e.__esModule?Aa(n,"default",{value:e,enumerable:!0}):n,e));var Zn=(e,t,n)=>vF(e,typeof t!="symbol"?t+"":t,n);function Qx(){try{return typeof window<"u"&&localStorage.getItem(FF)==="true"}catch{return!1}}var FF,y,De=$(()=>{"use strict";FF="uicopilot:debug";y={debug:(...e)=>{Qx()&&console.log(...e)},info:(...e)=>{Qx()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import EF,{createContext as AF,useContext as PF,useReducer as LF,useMemo as Jx}from"react";function MF(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)),y.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function ru({children:e}){let[t,n]=LF(MF,zF),r=Jx(()=>({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}})},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=Jx(()=>({...t,...r}),[t,r]);return EF.createElement(ey.Provider,{value:o},e)}function we(){let e=PF(ey);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var BF,DF,RF,Zx,zF,ey,ou=$(()=>{"use strict";De();BF=()=>{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"))};BF();DF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),RF=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Zx=DF(),zF={isConnected:!!Zx,sessionToken:Zx,apiKey:RF(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},ey=AF(null)});import NF,{createContext as OF,useContext as _F,useReducer as $F,useMemo as ty,useRef as UF,useEffect as jF}from"react";function HF(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 iu({children:e}){let[t,n]=$F(HF,VF),r=UF(t);jF(()=>{r.current=t},[t]);let o=ty(()=>({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=ty(()=>({...t,...o}),[t,o]);return NF.createElement(ny.Provider,{value:i},e)}function Ze(){let e=_F(ny);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var WF,VF,ny,su=$(()=>{"use strict";WF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),VF={projects:[],selectedProjectId:WF(),loadingProjects:!1,currentStorybookPath:null},ny=OF(null)});import GF,{createContext as qF,useContext as YF,useReducer as KF,useMemo as ry}from"react";function XF(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>oy)for(let o of r.slice(0,r.length-oy))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 au({children:e}){let[t,n]=KF(XF,QF),r=ry(()=>({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}})},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=ry(()=>({...t,...r}),[t,r]);return GF.createElement(iy.Provider,{value:o},e)}function rt(){let e=YF(iy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var oy,QF,iy,lu=$(()=>{"use strict";oy=200;QF={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},iy=qF(null)});var sy=$(()=>{"use strict"});var cu=$(()=>{"use strict"});function _t(e){return e>=48&&e<=57}function Pn(e){return _t(e)||e>=65&&e<=70||e>=97&&e<=102}function Ra(e){return e>=65&&e<=90}function ZF(e){return e>=97&&e<=122}function eE(e){return Ra(e)||ZF(e)}function tE(e){return e>=128}function Da(e){return eE(e)||tE(e)||e===95}function za(e){return Da(e)||_t(e)||e===45}function nE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function os(e){return e===10||e===13||e===12}function Ar(e){return os(e)||e===32||e===9}function An(e,t){return!(e!==92||os(t)||t===0)}function oi(e,t,n){return e===45?Da(t)||t===45||An(t,n):Da(e)?!0:e===92?An(e,t):!1}function Na(e,t,n){return e===43||e===45?_t(t)?2:t===46&&_t(n)?3:0:e===46?_t(t)?2:0:_t(e)?1:0}function Oa(e){return e===65279||e===65534?1:0}function $a(e){return e<128?uu[e]:_a}var uu,rE,is,pu,_a,du,ss=$(()=>{"use strict";uu=new Array(128),rE=128,is=130,pu=131,_a=132,du=133;for(let e=0;e<uu.length;e++)uu[e]=Ar(e)&&is||_t(e)&&pu||Da(e)&&_a||nE(e)&&du||e||rE});function ii(e,t){return t<e.length?e.charCodeAt(t):0}function Ua(e,t,n){return n===13&&ii(e,t+1)===10?2:1}function _r(e,t,n){let r=e.charCodeAt(t);return Ra(r)&&(r=r|32),r===n}function $r(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(Ra(s)&&(s=s|32),s!==i)return!1}return!0}function ay(e,t){for(;t>=0&&Ar(e.charCodeAt(t));t--);return t+1}function as(e,t){for(;t<e.length&&Ar(e.charCodeAt(t));t++);return t}function fu(e,t){for(;t<e.length&&_t(e.charCodeAt(t));t++);return t}function Ur(e,t){if(t+=2,Pn(ii(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Pn(ii(e,t));t++);let n=ii(e,t);Ar(n)&&(t+=Ua(e,t,n))}return t}function ls(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!za(n)){if(An(n,ii(e,t+1))){t=Ur(e,t)-1;continue}break}}return t}function Do(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),_t(n)&&(t=fu(e,t+1),n=e.charCodeAt(t)),n===46&&_t(e.charCodeAt(t+1))&&(t+=2,t=fu(e,t)),_r(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),_t(n)&&(t=fu(e,t+1+r+1))}return t}function ja(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}An(n,ii(e,t+1))&&(t=Ur(e,t))}return t}function Ha(e){if(e.length===1&&!Pn(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 Wa=$(()=>{"use strict";ss()});var si,gu=$(()=>{"use strict";si=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"]});function ai(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var mu=$(()=>{"use strict"});function uy(e){let t=e.source,n=t.length,r=t.length>0?Oa(t.charCodeAt(0)):0,o=ai(e.lines,n),i=ai(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===ly||c===cy||c===oE)&&(c===cy&&u+1<n&&t.charCodeAt(u+1)===ly&&(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 ly,oE,cy,Va,py=$(()=>{"use strict";mu();ss();ly=10,oE=12,cy=13;Va=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||uy(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||uy(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 dy(e,t,n){return e<t?t:e>n?n:e}var gr,mr,cs,qa,ao,hr,Ga,fy=$(()=>{"use strict";mu();Wa();gu();gr=16777215,mr=24,cs=1,qa=2,ao=new Uint8Array(32);ao[2]=22;ao[21]=22;ao[19]=20;ao[23]=24;hr=new Uint8Array(32);hr[2]=cs;hr[21]=cs;hr[19]=cs;hr[23]=cs;hr[22]=qa;hr[20]=qa;hr[24]=qa;Ga=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=ai(this.offsetAndType,t.length+1),i=ai(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,f)=>{let p=s++;if(o[p]=l<<mr|f,a===-1&&(a=d),i[p]=c,l===u){let g=i[c];i[c]=p,c=g,u=ao[o[g]>>mr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=ao[l])}),o[s]=0<<mr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let f=i[d];f!==l&&(i[l]=f)}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]>>mr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&gr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?$r(this.source,this.offsetAndType[t-1]&gr,this.offsetAndType[t]&gr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&gr:this.offsetAndType[this.tokenCount]&gr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[dy(t,0,this.tokenCount)]&gr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[dy(t,0,this.tokenCount)]>>mr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return hr[t]===cs}isBlockCloserTokenType(t){return hr[t]===qa}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(hr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return ao[n]===o?r:-1}else if(hr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return ao[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]&gr,n=this.offsetAndType[n],this.tokenType=n>>mr,this.tokenEnd=n&gr):(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>>mr,this.tokenEnd=t&gr):(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]&gr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>mr)&&(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&gr,a=i>>mr;r=s,t(a,o,s,n)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((n,r,o,i)=>{t[i]={idx:i,type:si[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function lo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=Do(e,c),oi(n(c),n(c+1),n(c+2))){l=12,c=ls(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=ls(e,c),$r(e,d,c,"url")&&n(c)===40){if(c=as(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 f=e.charCodeAt(c);switch($a(f)){case d:c++;return;case is:if(os(f)){c+=Ua(e,c,f),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);os(p)?c+=Ua(e,c+1,p):An(f,p)&&(c=Ur(e,c)-1);break}}}function s(){for(l=7,c=as(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch($a(d)){case 41:c++;return;case is:if(c=as(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=ja(e,c),l=8;return;case 34:case 39:case 40:case du:c=ja(e,c),l=8;return;case 92:if(An(d,n(c+1))){c=Ur(e,c)-1;break}c=ja(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Oa(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch($a(d)){case is:l=13,c=as(e,c+1);break;case 34:i();break;case 35:za(n(c+1))||An(n(c+1),n(c+2))?(l=4,c=ls(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:Na(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Na(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):oi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Na(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:oi(n(c+1),n(c+2),n(c+3))?(l=3,c=ls(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:An(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 pu:r();break;case _a:o();break;default:l=9,c++}t(l,u,u=c)}}var nr=$(()=>{"use strict";ss();Wa();cu();cu();gu();ss();Wa();py();fy()});var li,Vn,ps=$(()=>{"use strict";li=null,Vn=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 li!==null?(r=li,li=li.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=li,li=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 zo(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
|
|
2
|
-
`)}})}var
|
|
1
|
+
var xF=Object.create;var Pa=Object.defineProperty;var yF=Object.getOwnPropertyDescriptor;var bF=Object.getOwnPropertyNames;var SF=Object.getPrototypeOf,wF=Object.prototype.hasOwnProperty;var vF=(e,t,n)=>t in e?Pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var Jn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xe=(e,t)=>{for(var n in t)Pa(e,n,{get:t[n],enumerable:!0})},kF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bF(t))!wF.call(e,o)&&o!==n&&Pa(e,o,{get:()=>t[o],enumerable:!(r=yF(t,o))||r.enumerable});return e};var La=(e,t,n)=>(n=e!=null?xF(SF(e)):{},kF(t||!e||!e.__esModule?Pa(n,"default",{value:e,enumerable:!0}):n,e));var Zn=(e,t,n)=>vF(e,typeof t!="symbol"?t+"":t,n);function Qx(){try{return typeof window<"u"&&localStorage.getItem(FF)==="true"}catch{return!1}}var FF,y,De=$(()=>{"use strict";FF="uicopilot:debug";y={debug:(...e)=>{Qx()&&console.log(...e)},info:(...e)=>{Qx()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import EF,{createContext as AF,useContext as PF,useReducer as LF,useMemo as Jx}from"react";function MF(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)),y.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function ru({children:e}){let[t,n]=LF(MF,zF),r=Jx(()=>({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}})},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=Jx(()=>({...t,...r}),[t,r]);return EF.createElement(ey.Provider,{value:o},e)}function Se(){let e=PF(ey);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var BF,DF,RF,Zx,zF,ey,ou=$(()=>{"use strict";De();BF=()=>{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"))};BF();DF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),RF=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Zx=DF(),zF={isConnected:!!Zx,sessionToken:Zx,apiKey:RF(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},ey=AF(null)});import NF,{createContext as OF,useContext as _F,useReducer as $F,useMemo as ty,useRef as UF,useEffect as jF}from"react";function HF(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 iu({children:e}){let[t,n]=$F(HF,VF),r=UF(t);jF(()=>{r.current=t},[t]);let o=ty(()=>({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=ty(()=>({...t,...o}),[t,o]);return NF.createElement(ny.Provider,{value:i},e)}function Ze(){let e=_F(ny);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var WF,VF,ny,su=$(()=>{"use strict";WF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),VF={projects:[],selectedProjectId:WF(),loadingProjects:!1,currentStorybookPath:null},ny=OF(null)});import GF,{createContext as qF,useContext as YF,useReducer as KF,useMemo as ry}from"react";function XF(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>oy)for(let o of r.slice(0,r.length-oy))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 au({children:e}){let[t,n]=KF(XF,QF),r=ry(()=>({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}})},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=ry(()=>({...t,...r}),[t,r]);return GF.createElement(iy.Provider,{value:o},e)}function rt(){let e=YF(iy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var oy,QF,iy,lu=$(()=>{"use strict";oy=200;QF={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},iy=qF(null)});var sy=$(()=>{"use strict"});var cu=$(()=>{"use strict"});function _t(e){return e>=48&&e<=57}function Pn(e){return _t(e)||e>=65&&e<=70||e>=97&&e<=102}function za(e){return e>=65&&e<=90}function ZF(e){return e>=97&&e<=122}function eE(e){return za(e)||ZF(e)}function tE(e){return e>=128}function Ra(e){return eE(e)||tE(e)||e===95}function Na(e){return Ra(e)||_t(e)||e===45}function nE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function os(e){return e===10||e===13||e===12}function Ar(e){return os(e)||e===32||e===9}function An(e,t){return!(e!==92||os(t)||t===0)}function oi(e,t,n){return e===45?Ra(t)||t===45||An(t,n):Ra(e)?!0:e===92?An(e,t):!1}function Oa(e,t,n){return e===43||e===45?_t(t)?2:t===46&&_t(n)?3:0:e===46?_t(t)?2:0:_t(e)?1:0}function _a(e){return e===65279||e===65534?1:0}function Ua(e){return e<128?uu[e]:$a}var uu,rE,is,pu,$a,du,ss=$(()=>{"use strict";uu=new Array(128),rE=128,is=130,pu=131,$a=132,du=133;for(let e=0;e<uu.length;e++)uu[e]=Ar(e)&&is||_t(e)&&pu||Ra(e)&&$a||nE(e)&&du||e||rE});function ii(e,t){return t<e.length?e.charCodeAt(t):0}function ja(e,t,n){return n===13&&ii(e,t+1)===10?2:1}function _r(e,t,n){let r=e.charCodeAt(t);return za(r)&&(r=r|32),r===n}function $r(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(za(s)&&(s=s|32),s!==i)return!1}return!0}function ay(e,t){for(;t>=0&&Ar(e.charCodeAt(t));t--);return t+1}function as(e,t){for(;t<e.length&&Ar(e.charCodeAt(t));t++);return t}function fu(e,t){for(;t<e.length&&_t(e.charCodeAt(t));t++);return t}function Ur(e,t){if(t+=2,Pn(ii(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Pn(ii(e,t));t++);let n=ii(e,t);Ar(n)&&(t+=ja(e,t,n))}return t}function ls(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Na(n)){if(An(n,ii(e,t+1))){t=Ur(e,t)-1;continue}break}}return t}function Do(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),_t(n)&&(t=fu(e,t+1),n=e.charCodeAt(t)),n===46&&_t(e.charCodeAt(t+1))&&(t+=2,t=fu(e,t)),_r(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),_t(n)&&(t=fu(e,t+1+r+1))}return t}function Ha(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}An(n,ii(e,t+1))&&(t=Ur(e,t))}return t}function Wa(e){if(e.length===1&&!Pn(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 Va=$(()=>{"use strict";ss()});var si,gu=$(()=>{"use strict";si=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"]});function ai(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var mu=$(()=>{"use strict"});function uy(e){let t=e.source,n=t.length,r=t.length>0?_a(t.charCodeAt(0)):0,o=ai(e.lines,n),i=ai(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===ly||c===cy||c===oE)&&(c===cy&&u+1<n&&t.charCodeAt(u+1)===ly&&(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 ly,oE,cy,Ga,py=$(()=>{"use strict";mu();ss();ly=10,oE=12,cy=13;Ga=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||uy(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||uy(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 dy(e,t,n){return e<t?t:e>n?n:e}var gr,mr,cs,Ya,ao,hr,qa,fy=$(()=>{"use strict";mu();Va();gu();gr=16777215,mr=24,cs=1,Ya=2,ao=new Uint8Array(32);ao[2]=22;ao[21]=22;ao[19]=20;ao[23]=24;hr=new Uint8Array(32);hr[2]=cs;hr[21]=cs;hr[19]=cs;hr[23]=cs;hr[22]=Ya;hr[20]=Ya;hr[24]=Ya;qa=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=ai(this.offsetAndType,t.length+1),i=ai(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,f)=>{let d=s++;if(o[d]=l<<mr|f,a===-1&&(a=p),i[d]=c,l===u){let m=i[c];i[c]=d,c=m,u=ao[o[m]>>mr]}else this.isBlockOpenerTokenType(l)&&(c=d,u=ao[l])}),o[s]=0<<mr|r,i[s]=s;for(let l=0;l<s;l++){let p=i[l];if(p<=l){let f=i[p];f!==l&&(i[l]=f)}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]>>mr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&gr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?$r(this.source,this.offsetAndType[t-1]&gr,this.offsetAndType[t]&gr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&gr:this.offsetAndType[this.tokenCount]&gr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[dy(t,0,this.tokenCount)]&gr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[dy(t,0,this.tokenCount)]>>mr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return hr[t]===cs}isBlockCloserTokenType(t){return hr[t]===Ya}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(hr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return ao[n]===o?r:-1}else if(hr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return ao[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]&gr,n=this.offsetAndType[n],this.tokenType=n>>mr,this.tokenEnd=n&gr):(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>>mr,this.tokenEnd=t&gr):(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]&gr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>mr)&&(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&gr,a=i>>mr;r=s,t(a,o,s,n)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((n,r,o,i)=>{t[i]={idx:i,type:si[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function lo(e,t){function n(p){return p<a?e.charCodeAt(p):0}function r(){if(c=Do(e,c),oi(n(c),n(c+1),n(c+2))){l=12,c=ls(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let p=c;if(c=ls(e,c),$r(e,p,c,"url")&&n(c)===40){if(c=as(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 f=e.charCodeAt(c);switch(Ua(f)){case p:c++;return;case is:if(os(f)){c+=ja(e,c,f),l=6;return}break;case 92:if(c===e.length-1)break;let d=n(c+1);os(d)?c+=ja(e,c+1,d):An(f,d)&&(c=Ur(e,c)-1);break}}}function s(){for(l=7,c=as(e,c);c<e.length;c++){let p=e.charCodeAt(c);switch(Ua(p)){case 41:c++;return;case is:if(c=as(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=Ha(e,c),l=8;return;case 34:case 39:case 40:case du:c=Ha(e,c),l=8;return;case 92:if(An(p,n(c+1))){c=Ur(e,c)-1;break}c=Ha(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=_a(n(0)),c=u,l;for(;c<a;){let p=e.charCodeAt(c);switch(Ua(p)){case is:l=13,c=as(e,c+1);break;case 34:i();break;case 35:Na(n(c+1))||An(n(c+1),n(c+2))?(l=4,c=ls(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:Oa(p,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Oa(p,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):oi(p,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Oa(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:oi(n(c+1),n(c+2),n(c+3))?(l=3,c=ls(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:An(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 pu:r();break;case $a:o();break;default:l=9,c++}t(l,u,u=c)}}var nr=$(()=>{"use strict";ss();Va();cu();cu();gu();ss();Va();py();fy()});var li,Vn,ps=$(()=>{"use strict";li=null,Vn=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 li!==null?(r=li,li=li.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=li,li=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 zo(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
|
|
2
|
+
`)}})}var Xa=$(()=>{"use strict"});function hy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(m,w){return c.slice(m,w).map((k,F)=>String(m+F+1).padStart(f)+" |"+k).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),f=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>hu&&(d=n-gy+3,n=gy-2);for(let m=l;m<=p;m++)m>=0&&m<c.length&&(c[m]=c[m].replace(/\t/g,my),c[m]=(d>0&&c[m].length>d?"\u2026":"")+c[m].substr(d,hu-2)+(c[m].length>d+hu-1?"\u2026":""));return[s(l,t),new Array(n+f+2).join("-")+"^",s(t,p)].filter(Boolean).join(`
|
|
5
5
|
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function xu(e,t,n,r,o,i=1,s=1){return Object.assign(zo("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return hy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
|
|
6
|
-
`+hy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var hu,gy,my,xy=$(()=>{"use strict";Ka();hu=100,gy=60,my=" "});function yy(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 by=$(()=>{"use strict"});function cE(e){return function(){return this[e]()}}function bu(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:bu(e.atrule),pseudo:bu(e.pseudo),node:bu(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]=cE(r);break}return{config:t,...t,...t.node}}function vy(e){let t="",n="<unknown>",r=!1,o=ci,i=!1,s=new Va,a=Object.assign(new Ga,uE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:yy,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Sy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Sy||l===yu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===iE||l===yu?1:0},consumeUntilSemicolonIncluded(l){return l===yu?2:0},createList:ci,createSingleNodeList:ci,getFirstListNode:ci,getLastListNode:ci,parseWithFallback(l,d){let f=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(f-this.tokenIndex);let g=d.call(this);return i=!0,o(p,g),i=!1,g}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==wy);return wy},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 _r(t,l,d)},cmpStr(l,d,f){return $r(t,l,d,f)},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,Do(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=si[l].slice(0,-6).replace(/-/g," ").replace(/^./,g=>g.toUpperCase()),f=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(sE)&&(this.next(),p++,f="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,f="Percent sign is expected");break}this.error(f,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),f=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,f!==null?f.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let f=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(ay(t,t.length-1)):s.getLocation(this.tokenStart);throw new xu(l||"Unexpected input",t,f.offset,f.line,f.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>si[a.getTokenType(l)],getTokenStart:l=>a.getTokenStart(l),getTokenEnd:l=>a.getTokenEnd(l),getTokenValue:l=>a.source.substring(a.getTokenStart(l),a.getTokenEnd(l)),substring:(l,d)=>a.source.substring(l,d),balance:a.balance.subarray(0,a.tokenCount+1),isBlockOpenerTokenType:a.isBlockOpenerTokenType,isBlockCloserTokenType:a.isBlockCloserTokenType,getBlockTokenPairIndex:l=>a.getBlockTokenPairIndex(l),getLocation:l=>s.getLocation(l,n),getRangeLocation:(l,d)=>s.getLocationRange(l,d,n)});return Object.assign(function(l,d){t=l,d=d||{},a.setSource(t,lo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:ci,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:f="default",list:p=!0,onComment:g,onToken:S}=d;if(!(f in a.context))throw new Error("Unknown context `"+f+"`");Object.assign(a,p?lE:aE),Array.isArray(S)?a.forEachToken((F,k,R)=>{S.push({type:F,start:k,end:R})}):typeof S=="function"&&a.forEachToken(S.bind(u())),typeof g=="function"&&a.forEachToken((F,k,R)=>{if(F===25){let z=a.getLocation(k,R),_=$r(t,R-2,R,"*/")?t.slice(k+2,R-2):t.slice(k+2,R);g(_,z)}});let C=a.context[f].call(a,d);return a.eof||a.error(),C},{SyntaxError:xu,config:a.config})}var ci,iE,sE,yu,Sy,wy,aE,lE,ky=$(()=>{"use strict";ps();xy();nr();by();ci=()=>{},iE=33,sE=35,yu=59,Sy=123,wy=0,aE={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}},lE={createList(){return new Vn},createSingleNodeList(e){return new Vn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Ty=Jn(Su=>{"use strict";var Cy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Su.encode=function(e){if(0<=e&&e<Cy.length)return Cy[e];throw new TypeError("Must be between 0 and 63: "+e)};Su.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 Py=Jn(vu=>{"use strict";var Iy=Ty(),wu=5,Fy=1<<wu,Ey=Fy-1,Ay=Fy;function pE(e){return e<0?(-e<<1)+1:(e<<1)+0}function dE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}vu.encode=function(t){var n="",r,o=pE(t);do r=o&Ey,o>>>=wu,o>0&&(r|=Ay),n+=Iy.encode(r);while(o>0);return n};vu.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=Iy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Ay),u&=Ey,i=i+(u<<s),s+=wu}while(a);r.value=dE(i),r.rest=n}});var Xa=Jn(nn=>{"use strict";function fE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}nn.getArg=fE;var Ly=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,gE=/^data:.+\,.+$/;function ds(e){var t=e.match(Ly);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}nn.urlParse=ds;function ui(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}nn.urlGenerate=ui;var mE=32;function hE(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>mE&&t.pop(),i}}var ku=hE(function(t){var n=t,r=ds(t);if(r){if(!r.path)return t;n=r.path}for(var o=nn.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,ui(r)):n});nn.normalize=ku;function My(e,t){e===""&&(e="."),t===""&&(t=".");var n=ds(t),r=ds(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),ui(n);if(n||t.match(gE))return t;if(r&&!r.host&&!r.path)return r.host=t,ui(r);var o=t.charAt(0)==="/"?t:ku(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,ui(r)):o}nn.join=My;nn.isAbsolute=function(e){return e.charAt(0)==="/"||Ly.test(e)};function xE(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)}nn.relative=xE;var By=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Dy(e){return e}function yE(e){return Ry(e)?"$"+e:e}nn.toSetString=By?Dy:yE;function bE(e){return Ry(e)?e.slice(1):e}nn.fromSetString=By?Dy:bE;function Ry(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 SE(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)}nn.compareByOriginalPositions=SE;function wE(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)}nn.compareByOriginalPositionsNoSource=wE;function vE(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)}nn.compareByGeneratedPositionsDeflated=vE;function kE(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)}nn.compareByGeneratedPositionsDeflatedNoLine=kE;function jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function CE(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)}nn.compareByGeneratedPositionsInflated=CE;function TE(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}nn.parseSourceMapInput=TE;function IE(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ds(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=My(ui(r),t)}return ku(t)}nn.computeSourceURL=IE});var Ny=Jn(zy=>{"use strict";var Cu=Xa(),Tu=Object.prototype.hasOwnProperty,No=typeof Map<"u";function Hr(){this._array=[],this._set=No?new Map:Object.create(null)}Hr.fromArray=function(t,n){for(var r=new Hr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Hr.prototype.size=function(){return No?this._set.size:Object.getOwnPropertyNames(this._set).length};Hr.prototype.add=function(t,n){var r=No?t:Cu.toSetString(t),o=No?this.has(t):Tu.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(No?this._set.set(t,i):this._set[r]=i)};Hr.prototype.has=function(t){if(No)return this._set.has(t);var n=Cu.toSetString(t);return Tu.call(this._set,n)};Hr.prototype.indexOf=function(t){if(No){var n=this._set.get(t);if(n>=0)return n}else{var r=Cu.toSetString(t);if(Tu.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Hr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Hr.prototype.toArray=function(){return this._array.slice()};zy.ArraySet=Hr});var $y=Jn(_y=>{"use strict";var Oy=Xa();function FE(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||Oy.compareByGeneratedPositionsInflated(e,t)<=0}function Qa(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Qa.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};Qa.prototype.add=function(t){FE(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Qa.prototype.toArray=function(){return this._sorted||(this._array.sort(Oy.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};_y.MappingList=Qa});var jy=Jn(Uy=>{"use strict";var fs=Py(),$t=Xa(),Ja=Ny().ArraySet,EE=$y().MappingList;function rr(e){e||(e={}),this._file=$t.getArg(e,"file",null),this._sourceRoot=$t.getArg(e,"sourceRoot",null),this._skipValidation=$t.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=$t.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Ja,this._names=new Ja,this._mappings=new EE,this._sourcesContents=null}rr.prototype._version=3;rr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new rr(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=$t.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=$t.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};rr.prototype.addMapping=function(t){var n=$t.getArg(t,"generated"),r=$t.getArg(t,"original",null),o=$t.getArg(t,"source",null),i=$t.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}))};rr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=$t.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[$t.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[$t.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};rr.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=$t.relative(i,o));var s=new Ja,a=new Ja;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=$t.join(r,u.source)),i!=null&&(u.source=$t.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=$t.join(r,u)),i!=null&&(u=$t.relative(i,u)),this.setSourceContent(u,c))},this)};rr.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)}};rr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,f=this._mappings.toArray(),p=0,g=f.length;p<g;p++){if(c=f[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!$t.compareByGeneratedPositionsInflated(c,f[p-1]))continue;u+=","}u+=fs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=fs.encode(d-s),s=d,u+=fs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=fs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=fs.encode(l-i),i=l)),a+=u}return a};rr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=$t.relative(n,r));var o=$t.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};rr.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};rr.prototype.toString=function(){return JSON.stringify(this.toJSON())};Uy.SourceMapGenerator=rr});function Vy(e){let t=new Wy.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(f){if(f.loc&&f.loc.start&&Hy.has(f.type)){let p=f.loc.start.line,g=f.loc.start.column-1;(r.line!==p||r.column!==g)&&(r.line=p,r.column=g,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:f.loc.source,original:r,generated:n}))}c.call(this,f),u&&Hy.has(f.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(f,p,g){for(let S=0;S<f.length;S++)f.charCodeAt(S)===10?(s++,a=0):a++;l(f,p,g)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var Wy,Hy,Gy=$(()=>{"use strict";Wy=Pa(jy(),1),Hy=new Set(["Atrule","Selector","Declaration"])});var Za={};ye(Za,{safe:()=>Fu,spec:()=>ME});function Yy(e){let t=new Set(e.map(([n,r])=>Iu(n)<<16|Iu(r)));return function(n,r,o){let i=Iu(r,o),s=o.charCodeAt(0),a=s===PE&&r!==1&&r!==2&&r!==15||s===AE?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var AE,PE,Iu,qy,LE,ME,Fu,Ky=$(()=>{"use strict";AE=43,PE=45,Iu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),qy=[[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],["/","*"]],LE=qy.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,"-"]]);ME=Yy(qy),Fu=Yy(LE)});function DE(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 Xy(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:Fu,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)===BE&&this.emit(`
|
|
7
|
-
`,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=Vy(s)),r.mode in
|
|
6
|
+
`+hy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var hu,gy,my,xy=$(()=>{"use strict";Xa();hu=100,gy=60,my=" "});function yy(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 by=$(()=>{"use strict"});function cE(e){return function(){return this[e]()}}function bu(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:bu(e.atrule),pseudo:bu(e.pseudo),node:bu(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]=cE(r);break}return{config:t,...t,...t.node}}function vy(e){let t="",n="<unknown>",r=!1,o=ci,i=!1,s=new Ga,a=Object.assign(new qa,uE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:yy,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Sy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Sy||l===yu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===iE||l===yu?1:0},consumeUntilSemicolonIncluded(l){return l===yu?2:0},createList:ci,createSingleNodeList:ci,getFirstListNode:ci,getLastListNode:ci,parseWithFallback(l,p){let f=this.tokenIndex;try{return l.call(this)}catch(d){if(i)throw d;this.skip(f-this.tokenIndex);let m=p.call(this);return i=!0,o(d,m),i=!1,m}},lookupNonWSType(l){let p;do if(p=this.lookupType(l++),p!==13&&p!==25)return p;while(p!==wy);return wy},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 _r(t,l,p)},cmpStr(l,p,f){return $r(t,l,p,f)},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,Do(t,this.tokenStart));return this.eat(l),p},eat(l){if(this.tokenType!==l){let p=si[l].slice(0,-6).replace(/-/g," ").replace(/^./,m=>m.toUpperCase()),f=`${/[[\](){}]/.test(p)?`"${p}"`:p} is expected`,d=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(d=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(sE)&&(this.next(),d++,f="Name is expected");break;case 11:this.tokenType===10&&(d=this.tokenEnd,f="Percent sign is expected");break}this.error(f,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),f=this.getLastListNode(l);return s.getLocationRange(p!==null?p.loc.start.offset-s.startOffset:this.tokenStart,f!==null?f.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,p){let f=typeof p<"u"&&p<t.length?s.getLocation(p):this.eof?s.getLocation(ay(t,t.length-1)):s.getLocation(this.tokenStart);throw new xu(l||"Unexpected input",t,f.offset,f.line,f.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>si[a.getTokenType(l)],getTokenStart:l=>a.getTokenStart(l),getTokenEnd:l=>a.getTokenEnd(l),getTokenValue:l=>a.source.substring(a.getTokenStart(l),a.getTokenEnd(l)),substring:(l,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,lo),s.setSource(t,p.offset,p.line,p.column),n=p.filename||"<unknown>",r=!!p.positions,o=typeof p.onParseError=="function"?p.onParseError:ci,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:f="default",list:d=!0,onComment:m,onToken:w}=p;if(!(f in a.context))throw new Error("Unknown context `"+f+"`");Object.assign(a,d?lE:aE),Array.isArray(w)?a.forEachToken((F,C,z)=>{w.push({type:F,start:C,end:z})}):typeof w=="function"&&a.forEachToken(w.bind(u())),typeof m=="function"&&a.forEachToken((F,C,z)=>{if(F===25){let R=a.getLocation(C,z),O=$r(t,z-2,z,"*/")?t.slice(C+2,z-2):t.slice(C+2,z);m(O,R)}});let k=a.context[f].call(a,p);return a.eof||a.error(),k},{SyntaxError:xu,config:a.config})}var ci,iE,sE,yu,Sy,wy,aE,lE,ky=$(()=>{"use strict";ps();xy();nr();by();ci=()=>{},iE=33,sE=35,yu=59,Sy=123,wy=0,aE={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}},lE={createList(){return new Vn},createSingleNodeList(e){return new Vn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Ty=Jn(Su=>{"use strict";var Cy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Su.encode=function(e){if(0<=e&&e<Cy.length)return Cy[e];throw new TypeError("Must be between 0 and 63: "+e)};Su.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 Py=Jn(vu=>{"use strict";var Iy=Ty(),wu=5,Fy=1<<wu,Ey=Fy-1,Ay=Fy;function pE(e){return e<0?(-e<<1)+1:(e<<1)+0}function dE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}vu.encode=function(t){var n="",r,o=pE(t);do r=o&Ey,o>>>=wu,o>0&&(r|=Ay),n+=Iy.encode(r);while(o>0);return n};vu.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=Iy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Ay),u&=Ey,i=i+(u<<s),s+=wu}while(a);r.value=dE(i),r.rest=n}});var Qa=Jn(nn=>{"use strict";function fE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}nn.getArg=fE;var Ly=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,gE=/^data:.+\,.+$/;function ds(e){var t=e.match(Ly);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}nn.urlParse=ds;function ui(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}nn.urlGenerate=ui;var mE=32;function hE(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>mE&&t.pop(),i}}var ku=hE(function(t){var n=t,r=ds(t);if(r){if(!r.path)return t;n=r.path}for(var o=nn.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,ui(r)):n});nn.normalize=ku;function My(e,t){e===""&&(e="."),t===""&&(t=".");var n=ds(t),r=ds(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),ui(n);if(n||t.match(gE))return t;if(r&&!r.host&&!r.path)return r.host=t,ui(r);var o=t.charAt(0)==="/"?t:ku(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,ui(r)):o}nn.join=My;nn.isAbsolute=function(e){return e.charAt(0)==="/"||Ly.test(e)};function xE(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)}nn.relative=xE;var By=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Dy(e){return e}function yE(e){return Ry(e)?"$"+e:e}nn.toSetString=By?Dy:yE;function bE(e){return Ry(e)?e.slice(1):e}nn.fromSetString=By?Dy:bE;function Ry(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 SE(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)}nn.compareByOriginalPositions=SE;function wE(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)}nn.compareByOriginalPositionsNoSource=wE;function vE(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)}nn.compareByGeneratedPositionsDeflated=vE;function kE(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)}nn.compareByGeneratedPositionsDeflatedNoLine=kE;function jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function CE(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)}nn.compareByGeneratedPositionsInflated=CE;function TE(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}nn.parseSourceMapInput=TE;function IE(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ds(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=My(ui(r),t)}return ku(t)}nn.computeSourceURL=IE});var Ny=Jn(zy=>{"use strict";var Cu=Qa(),Tu=Object.prototype.hasOwnProperty,No=typeof Map<"u";function Hr(){this._array=[],this._set=No?new Map:Object.create(null)}Hr.fromArray=function(t,n){for(var r=new Hr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Hr.prototype.size=function(){return No?this._set.size:Object.getOwnPropertyNames(this._set).length};Hr.prototype.add=function(t,n){var r=No?t:Cu.toSetString(t),o=No?this.has(t):Tu.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(No?this._set.set(t,i):this._set[r]=i)};Hr.prototype.has=function(t){if(No)return this._set.has(t);var n=Cu.toSetString(t);return Tu.call(this._set,n)};Hr.prototype.indexOf=function(t){if(No){var n=this._set.get(t);if(n>=0)return n}else{var r=Cu.toSetString(t);if(Tu.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Hr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Hr.prototype.toArray=function(){return this._array.slice()};zy.ArraySet=Hr});var $y=Jn(_y=>{"use strict";var Oy=Qa();function FE(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||Oy.compareByGeneratedPositionsInflated(e,t)<=0}function Ja(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Ja.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};Ja.prototype.add=function(t){FE(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Ja.prototype.toArray=function(){return this._sorted||(this._array.sort(Oy.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};_y.MappingList=Ja});var jy=Jn(Uy=>{"use strict";var fs=Py(),$t=Qa(),Za=Ny().ArraySet,EE=$y().MappingList;function rr(e){e||(e={}),this._file=$t.getArg(e,"file",null),this._sourceRoot=$t.getArg(e,"sourceRoot",null),this._skipValidation=$t.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=$t.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Za,this._names=new Za,this._mappings=new EE,this._sourcesContents=null}rr.prototype._version=3;rr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new rr(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=$t.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=$t.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};rr.prototype.addMapping=function(t){var n=$t.getArg(t,"generated"),r=$t.getArg(t,"original",null),o=$t.getArg(t,"source",null),i=$t.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}))};rr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=$t.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[$t.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[$t.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};rr.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=$t.relative(i,o));var s=new Za,a=new Za;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=$t.join(r,u.source)),i!=null&&(u.source=$t.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=$t.join(r,u)),i!=null&&(u=$t.relative(i,u)),this.setSourceContent(u,c))},this)};rr.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)}};rr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,p,f=this._mappings.toArray(),d=0,m=f.length;d<m;d++){if(c=f[d],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(d>0){if(!$t.compareByGeneratedPositionsInflated(c,f[d-1]))continue;u+=","}u+=fs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(p=this._sources.indexOf(c.source),u+=fs.encode(p-s),s=p,u+=fs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=fs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=fs.encode(l-i),i=l)),a+=u}return a};rr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=$t.relative(n,r));var o=$t.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};rr.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};rr.prototype.toString=function(){return JSON.stringify(this.toJSON())};Uy.SourceMapGenerator=rr});function Vy(e){let t=new Wy.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(f){if(f.loc&&f.loc.start&&Hy.has(f.type)){let d=f.loc.start.line,m=f.loc.start.column-1;(r.line!==d||r.column!==m)&&(r.line=d,r.column=m,n.line=s,n.column=a,u&&(u=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(i)),u=!0,t.addMapping({source:f.loc.source,original:r,generated:n}))}c.call(this,f),u&&Hy.has(f.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(f,d,m){for(let w=0;w<f.length;w++)f.charCodeAt(w)===10?(s++,a=0):a++;l(f,d,m)};let p=e.result;return e.result=function(){return u&&t.addMapping(i),{css:p(),map:t}},e}var Wy,Hy,Gy=$(()=>{"use strict";Wy=La(jy(),1),Hy=new Set(["Atrule","Selector","Declaration"])});var el={};xe(el,{safe:()=>Fu,spec:()=>ME});function Yy(e){let t=new Set(e.map(([n,r])=>Iu(n)<<16|Iu(r)));return function(n,r,o){let i=Iu(r,o),s=o.charCodeAt(0),a=s===PE&&r!==1&&r!==2&&r!==15||s===AE?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var AE,PE,Iu,qy,LE,ME,Fu,Ky=$(()=>{"use strict";AE=43,PE=45,Iu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),qy=[[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],["/","*"]],LE=qy.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,"-"]]);ME=Yy(qy),Fu=Yy(LE)});function DE(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 Xy(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:Fu,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)===BE&&this.emit(`
|
|
7
|
+
`,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=Vy(s)),r.mode in el&&(s.tokenBefore=el[r.mode]));let a={node:u=>s.node(u),children:DE,token:(u,c)=>s.token(u,c),tokenize:u=>lo(u,(c,l,p)=>{s.token(c,u.slice(l,p),l!==0)})};return s.node(n),s.result()}}var BE,Qy=$(()=>{"use strict";nr();Gy();Ky();BE=92});function Jy(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Vn)&&(n.children=new Vn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Vn&&(n.children=n.children.toArray())}}),t}}}var Zy=$(()=>{"use strict";ps()});function eb(e){return typeof e=="function"?e:gs}function tb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function RE(e,t){let n=t.structure,r=[];for(let o in n){if(Eu.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 zE(e){let t={};for(let n in e.node)if(Eu.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]=RE(n,r)}return t}function nb(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 rb({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 ob(e){let t=zE(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Eu.call(t,c)&&t[c]!==null&&(n[c]=nb(t[c],!1),r[c]=nb(t[c],!0));let s=rb(n),a=rb(r),u=function(c,l){function p(F,C,z){let R=f.call(k,F,C,z);return R===o?!0:R===i?!1:!!(m.hasOwnProperty(F.type)&&m[F.type](F,k,p,w)||d.call(k,F,C,z)===o)}let f=gs,d=gs,m=n,w=(F,C,z,R)=>F||p(C,z,R),k={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")f=l;else if(l&&(f=eb(l.enter),d=eb(l.leave),l.reverse&&(m=r),l.visit)){if(s.hasOwnProperty(l.visit))m=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");f=tb(f,l.visit),d=tb(d,l.visit)}if(f===gs&&d===gs)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(f,d,m){if(l.call(this,f,d,m))return p=f,o}),p},u.findLast=function(c,l){let p=null;return u(c,{reverse:!0,enter(f,d,m){if(l.call(this,f,d,m))return p=f,o}}),p},u.findAll=function(c,l){let p=[];return u(c,function(f,d,m){l.call(this,f,d,m)&&p.push(f)}),p},u}var Eu,gs,ib=$(()=>{"use strict";({hasOwnProperty:Eu}=Object.prototype),gs=function(){}});function NE(e){return e}function OE(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 _E(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 $E(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>tl(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function tl(e,t,n,r){let o;switch(e.type){case"Group":o=$E(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return tl(e.term,t,n,r)+t(OE(e),e);case"Boolean":o="<boolean-expr["+tl(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(_E(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 pi(e,t){let n=NE,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),tl(e,n,r,o)}var Au=$(()=>{"use strict"});function UE(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 f=0;f<n.length;f++){let d=n[f].value;f===r&&(a=d.length,s=c.length),i!==null&&n[f].node===i&&(f<=r?u++:u=0),c+=d}return r===n.length||u>1?(l=nl(i||t,"end")||ms(sb,c),p=ms(l)):(l=nl(i,"start")||ms(nl(t,"start")||sb,c.slice(0,s)),p=nl(i,"end")||ms(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:p}}function nl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?ms(n):n:null}function ms({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 sb,di,ab,lb=$(()=>{"use strict";Xa();Au();sb={offset:0,line:1,column:1};di=function(e,t){let n=zo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},ab=function(e,t,n,r){let o=zo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=UE(r,n);return o.rawMessage=e,o.syntax=t?pi(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
|
|
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 sl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===ol&&e.charCodeAt(t+1)===ol}function cb(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===ol&&e.charCodeAt(t+1)!==ol){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function jE(e){if(rl.has(e))return rl.get(e);let t=e.toLowerCase(),n=rl.get(t);if(n===void 0){let r=sl(t,0),o=r?"":cb(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return rl.set(e,n),n}function HE(e){if(fi.has(e))return fi.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=sl(t,n.length);if(!r&&(t=t.toLowerCase(),fi.has(t))){let a=fi.get(t);return fi.set(e,a),a}let o=r?"":cb(t,n.length),i=t.substr(0,n.length+o.length),s=Object.freeze({basename:t.substr(i.length),name:t.substr(n.length),hack:n,vendor:o,prefix:i,custom:r});return fi.set(e,s),s}var rl,fi,ol,il,Pu,al=$(()=>{"use strict";rl=new Map,fi=new Map,ol=45,il=jE,Pu=HE});var gi,ll=$(()=>{"use strict";gi=["initial","inherit","unset","revert","revert-layer"]});function Bu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function hs(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function co(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===xs||o===Pr){if(n)return 0;t++}for(;t<e.value.length;t++)if(!_t(e.value.charCodeAt(t)))return 0;return r+1}function Mu(e,t,n){let r=!1,o=hs(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Bu(e,xs)||Bu(e,Pr)){if(r=!0,o=hs(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!==xs&&i!==Pr)return 0}return co(e,r?0:1,r,o)}function Du(e,t){let n=0;if(!e)return 0;if(e.type===10)return co(e,0,VE,n);if(e.type===1&&e.value.charCodeAt(0)===Pr){if(!_r(e.value,1,Lu))return 0;switch(e.value.length){case 2:return Mu(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==Pr?0:(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n));default:return e.value.charCodeAt(2)!==Pr?0:co(e,3,mi,n)}}else if(e.type===1||Bu(e,xs)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!_r(e.value,0,Lu))return 0;switch(e.value.length){case 1:return Mu(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==Pr?0:(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n));default:return e.value.charCodeAt(1)!==Pr?0:co(e,2,mi,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===xs||r===Pr?1:0,i=o;for(;i<e.value.length&&_t(e.value.charCodeAt(i));i++);return i===o||!_r(e.value,i,Lu)?0:i+1===e.value.length?Mu(t(++n),n,t):e.value.charCodeAt(i+1)!==Pr?0:i+2===e.value.length?(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n)):co(e,i+2,mi,n)}return 0}var xs,Pr,Lu,mi,VE,ub=$(()=>{"use strict";nr();xs=43,Pr=45,Lu=110,mi=!0,VE=!1});function Ru(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function YE(e,t){return e.value.charCodeAt(0)===t}function ys(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===pb&&n&&r!==0)return ys(e,t+r+1,!1),6;if(!Pn(i)||++r>6)return 0}return r}function cl(e,t,n){if(!e)return 0;for(;Ru(n(t),db);){if(++e>6)return 0;t++}return t}function zu(e,t){let n=0;if(e===null||e.type!==1||!_r(e.value,0,qE)||(e=t(++n),e===null))return 0;if(Ru(e,GE))return e=t(++n),e===null?0:e.type===1?cl(ys(e,0,!0),++n,t):Ru(e,db)?cl(1,++n,t):0;if(e.type===10){let r=ys(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!YE(e,pb)||!ys(e,1,!1)?0:n+1:cl(r,n,t))}return e.type===12?cl(ys(e,1,!0),++n,t):0}var GE,pb,db,qE,fb=$(()=>{"use strict";nr();GE=43,pb=45,db=63,qE=117});function yr(e,t){return t<e.length?e.charCodeAt(t):0}function mb(e,t){return $r(e,0,e.length,t)}function hb(e,t){for(let n=0;n<t.length;n++)if(mb(e,t[n]))return!0;return!1}function xb(e,t){return t!==e.length-2?!1:yr(e,t)===92&&_t(yr(e,t+1))}function ul(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 ZE(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=ju.get(e.type);break}o++}while(e=t(o));return o}function or(e,t){return function(n,r,o){return n===null?0:n.type===2&&hb(n.value,t)?ZE(n,r):e(n,r,o)}}function Ft(e){return function(t){return t===null||t.type!==e?0:1}}function eA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return hb(t,gi)||mb(t,"default")?0:1}function yb(e){return e===null||e.type!==1||yr(e.value,0)!==45||yr(e.value,1)!==45?0:1}function tA(e){return!yb(e)||e.value==="--"?0:1}function nA(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(!Pn(yr(e.value,n)))return 0;return 1}function rA(e){return e===null||e.type!==4||!oi(yr(e.value,1),yr(e.value,2),yr(e.value,3))?0:1}function oA(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=ju.get(e.type);break}o++}while(e=t(o));return o}function iA(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=ju.get(e.type);break}o++}while(e=t(o));return o}function Vr(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Do(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!xb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return ul(r,t.value,o)?0:1}}function sA(e,t,n){return e===null||e.type!==11||ul(n,e.value,e.value.length-1)?0:1}function bb(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 aA(e,t,n){if(e===null)return 0;let r=Do(e.value,0);return!(r===e.value.length)&&!xb(e.value,r)||ul(n,e.value,r)?0:1}function lA(e,t,n){if(e===null||e.type!==10)return 0;let r=yr(e.value,0)===43||yr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!_t(yr(e.value,r)))return 0;return ul(n,e.value,r)?0:1}function dA(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:or(Vr(null),Wr),angle:or(Vr(t),Wr),decibel:or(Vr(n),Wr),frequency:or(Vr(r),Wr),flex:or(Vr(o),Wr),length:or(bb(Vr(i)),Wr),resolution:or(Vr(s),Wr),semitones:or(Vr(a),Wr),time:or(Vr(u),Wr)}}function fA(e){let t=new Set;for(let n of pA)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 Sb(e){return{...cA,...uA,...dA(e),"attr-unit":fA(e)}}var Nu,Ou,_u,KE,XE,QE,$u,Uu,gb,JE,Wr,ju,cA,uA,pA,wb=$(()=>{"use strict";ll();ub();fb();nr();Nu=["calc(","-moz-calc(","-webkit-calc("],Ou=["min(","max(","clamp("],_u=["round(","mod(","rem("],KE=["sin(","cos(","tan("],XE=["asin(","acos(","atan(","atan2("],QE=["pow(","sqrt(","log(","exp(","sign("],$u=["hypot("],Uu=["abs("],gb=[...Nu,...Ou,..._u,...KE,...QE,...$u,...Uu],JE=[...Nu,...Ou,..._u,...$u,...Uu],Wr=[...Nu,...Ou,..._u,...XE,...$u,...Uu],ju=new Map([[2,22],[21,22],[19,20],[23,24]]);cA={"ident-token":Ft(1),"function-token":Ft(2),"at-keyword-token":Ft(3),"hash-token":Ft(4),"string-token":Ft(5),"bad-string-token":Ft(6),"url-token":Ft(7),"bad-url-token":Ft(8),"delim-token":Ft(9),"number-token":Ft(10),"percentage-token":Ft(11),"dimension-token":Ft(12),"whitespace-token":Ft(13),"CDO-token":Ft(14),"CDC-token":Ft(15),"colon-token":Ft(16),"semicolon-token":Ft(17),"comma-token":Ft(18),"[-token":Ft(19),"]-token":Ft(20),"(-token":Ft(21),")-token":Ft(22),"{-token":Ft(23),"}-token":Ft(24)},uA={string:Ft(5),ident:Ft(1),percentage:or(sA,JE),zero:bb(),number:or(aA,gb),integer:or(lA,gb),"custom-ident":eA,"dashed-ident":yb,"custom-property-name":tA,"hex-color":nA,"id-selector":rA,"an-plus-b":Du,urange:zu,"declaration-value":oA,"any-value":iA},pA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var pl={};xe(pl,{angle:()=>mA,decibel:()=>SA,flex:()=>bA,frequency:()=>xA,length:()=>gA,resolution:()=>yA,semitones:()=>wA,time:()=>hA});var gA,mA,hA,xA,yA,bA,SA,wA,vb=$(()=>{"use strict";gA=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],mA=["deg","grad","rad","turn"],hA=["s","ms"],xA=["hz","khz"],yA=["dpi","dpcm","dppx","x"],bA=["fr"],SA=["db"],wA=["st"]});function kb(e,t,n){return Object.assign(zo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
|
|
11
11
|
`+t+`
|
|
12
|
-
--`+new Array((n||t.length)+1).join("-")+"^"})}var Cb=$(()=>{"use strict";Ka()});var vA,kA,CA,TA,IA,Tb,pl,Ib=$(()=>{"use strict";Cb();vA=9,kA=10,CA=12,TA=13,IA=32,Tb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),pl=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&&Tb[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!==TA&&n!==kA&&n!==CA&&n!==IA&&n!==vA)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 kb(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||Tb[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 Mb(e){let t=null,n=null;return e.eat(gl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Yu?(e.pos++,e.skipWs(),e.charCode()!==Vu&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(Vu),{min:Number(t),max:n?Number(n):0}}function BA(e){let t=null,n=!1;switch(e.charCode()){case zb:e.pos++,t={min:0,max:0};break;case qu:e.pos++,t={min:1,max:0};break;case fl:e.pos++,t={min:0,max:1};break;case Gu:e.pos++,n=!0,e.charCode()===gl?t=Mb(e):e.charCode()===fl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case gl:t=Mb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Gr(e,t){let n=BA(e);return n!==null?(n.term=t,e.charCode()===Gu&&e.charCodeAt(e.pos-1)===qu||e.charCode()===fl&&e.charCodeAt(e.pos-1)===Vu?Gr(e,n):n):t}function Hu(e){let t=e.peek();return t===""?null:Gr(e,{type:"Token",value:t})}function DA(e){let t;return e.eat(Ku),e.eat(dl),t=e.scanWord(),e.eat(dl),e.eat(Wu),Gr(e,{type:"Property",name:t})}function RA(e){let t=null,n=null,r=1;return e.eat(bs),e.charCode()===Eb&&(e.peek(),r=-1),r==-1&&e.charCode()===Pb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Yu),e.skipWs(),e.charCode()===Pb?e.peek():(r=1,e.charCode()===Eb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(hi),{type:"Range",min:t,max:n}}function zA(e){let t,n=null;if(e.eat(Ku),t=e.scanWord(),t==="boolean-expr"){e.eat(bs);let r=ml(e,hi);return e.eat(hi),e.eat(Wu),Gr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Db&&e.nextCharCode()===Rb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===bs&&(e.skipWs(),n=RA(e)),e.eat(Wu),Gr(e,{type:"Type",name:t,opts:n})}function NA(e){let t=e.scanWord();return e.charCode()===Db?(e.pos++,{type:"Function",name:t}):Gr(e,{type:"Keyword",name:t})}function OA(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)=>Lb[o]-Lb[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 ml(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?ml(e,Rb):$A(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:OA(r,n)||" ",disallowEmpty:!1,explicit:!1}}function _A(e){let t;return e.eat(bs),t=ml(e,hi),e.eat(hi),t.explicit=!0,e.charCode()===Bb&&(e.pos++,t.disallowEmpty=!0),t}function $A(e){let t=e.charCode();switch(t){case hi:break;case bs:return Gr(e,_A(e));case Ku:return e.nextCharCode()===dl?DA(e):zA(e);case Ab:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Ab?2:1))};case Fb:return e.pos++,e.eat(Fb),{type:"Combinator",value:"&&"};case Yu:return e.pos++,{type:"Comma"};case dl:return Gr(e,{type:"String",value:e.scanString()});case LA:case FA:case EA:case PA:case AA:return{type:"Spaces",value:e.scanSpaces()};case MA:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Hu(e);case zb:case qu:case fl:case Gu:case Bb:break;case gl:if(t=e.nextCharCode(),t<48||t>57)return Hu(e);break;default:return e.isNameCharCode(t)?NA(e):Hu(e)}}function Ss(e){let t=new pl(e),n=ml(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var FA,EA,AA,PA,LA,Bb,Gu,Fb,dl,Db,Rb,zb,qu,Yu,Eb,Ku,Wu,fl,MA,bs,hi,gl,Ab,Vu,Pb,Lb,Xu=$(()=>{"use strict";Ib();FA=9,EA=10,AA=12,PA=13,LA=32,Bb=33,Gu=35,Fb=38,dl=39,Db=40,Rb=41,zb=42,qu=43,Yu=44,Eb=45,Ku=60,Wu=62,fl=63,MA=64,bs=91,hi=93,gl=123,Ab=124,Vu=125,Pb=8734,Lb={" ":1,"&&":2,"||":3,"|":4}});function Nb(e){return typeof e=="function"?e:ws}function Qu(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=ws,i=ws;if(typeof t=="function"?o=t:t&&(o=Nb(t.enter),i=Nb(t.leave)),o===ws&&i===ws)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var ws,Ob=$(()=>{"use strict";ws=function(){}});var Ju=$(()=>{"use strict";Au();Xu();Ob()});function HA(e){let t=[];return lo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function _b(e,t){return typeof e=="string"?HA(e):t.generate(e,jA)}var jA,$b=$(()=>{"use strict";nr();jA={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 xn(e,t,n){return t===ut&&n===yt||e===ut&&t===ut&&n===ut?e:(e.type==="If"&&e.else===yt&&t===ut&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function jb(e){return e.length>2&&e.charCodeAt(e.length-2)===WA&&e.charCodeAt(e.length-1)===VA}function Ub(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&jb(e.name)}function uo(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function vs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=vs(e.match,t,n),e.then=vs(e.then,t,n),e.else=vs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Zu(e,t,n){switch(e){case" ":{let r=ut;for(let o=t.length-1;o>=0;o--){let i=t[o];r=xn(i,r,yt)}return r}case"|":{let r=yt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(Ub(s)&&(o===null&&i>0&&Ub(t[i-1])&&(o=Object.create(null),r=xn({type:"Enum",map:o},ut,r)),o!==null)){let a=(jb(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=xn(s,ut,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=yt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Zu(e,t.filter(function(a){return a!==i}),!1):s=ut,r=xn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?ut:yt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Zu(e,t.filter(function(a){return a!==i}),!0):s=ut,r=xn(i,s,r)}return r}}}function GA(e){let t=ut,n=xi(e.term);if(e.max===0)n=xn(n,hl,yt),t=xn(n,null,yt),t.then=xn(ut,ut,t),e.comma&&(t.then.else=xn({type:"Comma",syntax:e},t,yt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,yt)),t=xn(n,xn(ut,ut,t),yt);if(e.min===0)t=xn(ut,ut,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,yt)),t=xn(n,t,yt);return t}function xi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Zu(e.combinator,e.terms.map(xi),!1);return e.disallowEmpty&&(t=xn(t,hl,yt)),t}case"Multiplier":return GA(e);case"Boolean":{let t=xi(e.term),n=xi(uo([uo([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),uo([{type:"Type",name:"!boolean-group"},uo([{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=xi(uo([{type:"Type",name:"!term"},uo([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return vs(r,{"!term":t,"!self":n}),vs(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 ks(e,t){return typeof e=="string"&&(e=Ss(e)),{type:"MatchGraph",match:xi(e),syntax:t||null,source:e}}var ut,yt,hl,WA,VA,ep=$(()=>{"use strict";Xu();ut={type:"Match"},yt={type:"Mismatch"},hl={type:"DisallowEmpty"},WA=40,VA=41});function JA(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function tp(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 ZA(e){return e.type!==9?!1:e.value!=="?"}function Gb(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||ZA(e)}function qb(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function eP(e,t,n){function r(){do k++,F=k<e.length?e[k]:null;while(F!==null&&(F.type===13||F.type===25))}function o(_){let M=k+_;return M<e.length?e[M]:null}function i(_,M){return{nextState:_,matchStack:z,syntaxStack:d,thenStack:f,tokenIndex:k,prev:M}}function s(_){f={nextState:_,matchStack:z,syntaxStack:d,prev:f}}function a(_){p=i(_,p)}function u(){z={type:YA,syntax:t.syntax,token:F,prev:z},r(),g=null,k>R&&(R=k)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},z={type:np,syntax:t.syntax,token:z.token,prev:z}}function l(){z.type===np?z=z.prev:z={type:Yb,syntax:d.syntax,token:z.token,prev:z},d=d.prev}let d=null,f=null,p=null,g=null,S=0,C=null,F=null,k=-1,R=0,z={type:qA,syntax:null,token:null,prev:null};for(r();C===null&&++S<Vb;)switch(t.type){case"Match":if(f===null){if(F!==null&&(k!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=yt;break}C=Wb;break}if(t=f.nextState,t===hl)if(f.matchStack===z){t=yt;break}else t=ut;for(;f.syntaxStack!==d;)l();f=f.prev;break;case"Mismatch":if(g!==null&&g!==!1)(p===null||k>p.tokenIndex)&&(p=g,g=!1);else if(p===null){C=KA;break}t=p.nextState,f=p.thenStack,d=p.syntaxStack,z=p.matchStack,k=p.tokenIndex,F=k<e.length?e[k]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==yt&&a(t.else),t.then!==ut&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let B=t.syntax.terms;if(t.index===B.length){if(t.mask===0||t.syntax.all){t=yt;break}t=ut;break}if(t.mask===(1<<B.length)-1){t=ut;break}for(;t.index<B.length;t.index++){let m=1<<t.index;if((t.mask&m)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|m}),t=B[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let B=F.value.toLowerCase();if(B.indexOf("\\")!==-1&&(B=B.replace(/\\[09].*$/,"")),Hb.call(t.map,B)){t=t.map[B];break}}t=yt;break;case"Generic":{let B=d!==null?d.opts:null,m=k+Math.floor(t.fn(F,o,B));if(!isNaN(m)&&m>k){for(;k<m;)u();t=ut}else t=yt;break}case"Type":case"Property":{let B=t.type==="Type"?"types":"properties",m=Hb.call(n,B)?n[B][t.name]:null;if(!m||!m.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(g!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){g===null&&(g=i(t,p)),t=yt;break}c(),t=m.matchRef||m.match;break}case"Keyword":{let B=t.name;if(F!==null){let m=F.value;if(m.indexOf("\\")!==-1&&(m=m.replace(/\\[09].*$/,"")),tp(m,B)){u(),t=ut;break}}t=yt;break}case"AtKeyword":case"Function":if(F!==null&&tp(F.value,t.name)){u(),t=ut;break}t=yt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=ut;break}t=yt;break;case"Comma":F!==null&&F.type===18?Gb(z.token)?t=yt:(u(),t=qb(F)?yt:ut):t=Gb(z.token)||qb(F)?ut:yt;break;case"String":let _="",M=k;for(;M<e.length&&_.length<t.value.length;M++)_+=e[M].value;if(tp(_,t.value)){for(;k<M;)u();t=ut}else t=yt;break;default:throw new Error("Unknown node type: "+t.type)}switch(QA+=S,C){case null:console.warn("[csstree-match] BREAK after "+Vb+" iterations"),C=XA,z=null;break;case Wb:for(;d!==null;)l();break;default:z=null}return{tokens:e,reason:C,iterations:S,match:z,longestMatch:R}}function rp(e,t,n){let r=eP(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=JA(o).prev;o!==null;){switch(o.type){case np:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Yb: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 Hb,qA,YA,np,Yb,Wb,KA,XA,Vb,QA,Kb=$(()=>{"use strict";ep();({hasOwnProperty:Hb}=Object.prototype),qA=0,YA=1,np=2,Yb=3,Wb="Match",KA="Mismatch",XA="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Vb=15e3,QA=0});var ip={};ye(ip,{getTrace:()=>Xb,isKeyword:()=>rP,isProperty:()=>nP,isType:()=>tP});function Xb(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 tP(e,t){return op(this,e,n=>n.type==="Type"&&n.name===t)}function nP(e,t){return op(this,e,n=>n.type==="Property"&&n.name===t)}function rP(e){return op(this,e,t=>t.type==="Keyword")}function op(e,t,n){let r=Xb.call(e,t);return r===null?!1:r.some(n)}var Qb=$(()=>{"use strict"});function Jb(e){return"node"in e?e.node:Jb(e.match[0])}function Zb(e){return"node"in e?e.node:Zb(e.match[e.match.length-1])}function sp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=Jb(a),c=Zb(a);e.syntax.walk(t,function(l,d,f){if(l===u){let p=new Vn;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:f,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var e0=$(()=>{"use strict";ps()});function ap(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function t0(e){return!!e&&ap(e.offset)&&ap(e.line)&&ap(e.column)}function oP(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(Cs.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(!t0(r.loc.start))i+=".start";else if(!t0(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 Vn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Cs.call(t,i)&&Cs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function n0(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<"+(n0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function iP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Cs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=n0(s,e+"."+i)}return{docs:o,check:oP(e,r)}}function r0(e){let t={};if(e.node){for(let n in e.node)if(Cs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=iP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Cs,o0=$(()=>{"use strict";ps();({hasOwnProperty:Cs}=Object.prototype)});function lp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:pi(e[o].syntax,{compact:t}));return r}function sP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:pi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&lp(i.descriptors,t,n)};return r}function aP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function lP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function br(e,t,n){return{matched:e,iterations:n,error:t,...ip}}function yi(e,t,n,r){let o=_b(n,e.syntax),i;return aP(o)?br(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=rp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=rp(o,t.match,e),!i.match)?br(null,new ab(i.reason,t.syntax,n,i),i.iterations):br(i.match,null,i.iterations))}var Ts,i0=$(()=>{"use strict";lb();sl();al();wb();vb();Ju();$b();ep();Kb();Qb();e0();o0();Ts=class{constructor(t,n,r){if(this.cssWideKeywords=gi,this.syntax=n,this.generic=!1,this.units={...ul},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||r0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(ul))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(Sb(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=ks(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=ks(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ss(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:ks(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=lP(a)?ks({...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 di("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&&!yi(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=ol(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 di("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new di("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return br(null,r);let o=this.getAtrule(t);return o.prelude?yi(this,o.prelude,n||"",!1):br(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return br(null,o);let i=this.getAtrule(t),s=ol(n);return yi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?br(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Pu(t).custom)return br(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?br(null,r):yi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?yi(this,r,n,!1):br(null,new di("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?br(null,new di("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),yi(this,t,n,!1))}findValueFragments(t,n,r,o){return sp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return sp(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=ol(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=Pu(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&&Qu(d.syntax,function(f){if(f.type!=="Type"&&f.type!=="Property")return;let p=f.type==="Type"?u.types:u.properties,g=f.type==="Type"?o:i;hasOwnProperty.call(p,f.name)?n(u,f.name,g,p[f.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(f.name,f.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:lp(this.types,!n,t),properties:lp(this.properties,!n,t),atrules:sP(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 cP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function up(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?cP(i,n):i};return r}function Is(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]=up(e[r],o);break;case"atrule":case"pseudo":n[r]=up(e[r],o,["parse"]);break;case"node":n[r]=up(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var s0=$(()=>{"use strict"});function a0(e){let t=vy(e),n=ob(e),r=Xy(e),{fromPlainObject:o,toPlainObject:i}=Jy(n),s={lexer:null,createLexer:a=>new Ts(a,s,s.lexer.structure),tokenize:lo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Is({},e);return a0(typeof a=="function"?a(u):Is(u,a))}};return s.lexer=new Ts({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var l0,c0=$(()=>{"use strict";nr();ky();Qy();Zy();ib();i0();s0();l0=e=>a0(Is({},e))});var u0,p0=$(()=>{"use strict";u0={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 fp={};ye(fp,{generate:()=>fP,name:()=>pP,parse:()=>dp,structure:()=>dP});function yl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Lr||r===Gn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)_t(this.charCodeAt(n))||this.error("Integer is expected",n)}function bi(e){return yl.call(this,0,e)}function po(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case xl:n="N is expected";break;case Gn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function pp(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Lr,e)||this.isDelim(Gn,e)){t=this.isDelim(Lr,e)?Lr:Gn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),bi.call(this,Oo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Lr&&n!==Gn&&this.error("Number sign is expected")),bi.call(this,t!==0),t===Gn?"-"+this.consume(10):this.consume(10)}function dp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)bi.call(this,uP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Gn))switch(t="-1",po.call(this,1,xl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=pp.call(this);break;case 3:po.call(this,2,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,2,Gn),yl.call(this,3,Oo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Lr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Lr)&&(r=1,this.next()),po.call(this,0,xl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=pp.call(this);break;case 2:po.call(this,1,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,1,Gn),yl.call(this,2,Oo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Lr||r===Gn,i=this.tokenStart+o;for(;i<this.tokenEnd&&_t(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),po.call(this,i-this.tokenStart,xl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=pp.call(this)):(po.call(this,i-this.tokenStart+1,Gn),i+2===this.tokenEnd?(this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10)):(yl.call(this,i-this.tokenStart+2,Oo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Lr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Lr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function fP(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 Lr,Gn,xl,Oo,uP,pP,dP,gp=$(()=>{"use strict";nr();Lr=43,Gn=45,xl=110,Oo=!0,uP=!1;pP="AnPlusB",dP={a:[String,null],b:[String,null]}});var hp={};ye(hp,{generate:()=>yP,name:()=>mP,parse:()=>mp,structure:()=>xP,walkContext:()=>hP});function d0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function gP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function mp(e=!1){let t=this.tokenStart,n,r,o=null,i=null;switch(this.eat(3),n=this.substrToCursor(t+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,n,e),d0):o=d0.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?i=this.atrule[r].block.call(this,e):i=this.Block(gP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function yP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var mP,hP,xP,xp=$(()=>{"use strict";mP="Atrule",hP="atrule",xP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var bp={};ye(bp,{generate:()=>vP,name:()=>bP,parse:()=>yp,structure:()=>wP,walkContext:()=>SP});function yp(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 vP(e){this.children(e)}var bP,SP,wP,Sp=$(()=>{"use strict";bP="AtrulePrelude",SP="atrulePrelude",wP={children:[[]]}});var kp={};ye(kp,{generate:()=>PP,name:()=>EP,parse:()=>vp,structure:()=>AP});function IP(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(f0)?(t=!0,this.next()):this.isDelim(wp)||this.eat(1),this.isDelim(wp)?this.charCodeAt(this.tokenStart+1)!==bl?(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 FP(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==bl&&t!==TP&&t!==CP&&t!==kP&&t!==f0&&t!==wp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==bl&&(this.isDelim(bl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function vp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=IP.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=FP.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 PP(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 kP,f0,bl,CP,wp,TP,EP,AP,Cp=$(()=>{"use strict";kP=36,f0=42,bl=61,CP=94,wp=124,TP=126;EP="AttributeSelector",AP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Ip={};ye(Ip,{generate:()=>zP,name:()=>BP,parse:()=>Tp,structure:()=>RP,walkContext:()=>DP});function h0(){return this.Raw(null,!0)}function g0(){return this.parseWithFallback(this.Rule,h0)}function m0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function MP(){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 Tp(e){let t=e?MP:g0,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),h0));break;default:e&&this.isDelim(LP)?r.push(g0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function zP(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var LP,BP,DP,RP,Fp=$(()=>{"use strict";LP=38;BP="Block",DP="block",RP={children:[["Atrule","Rule","Declaration"]]}});var Ap={};ye(Ap,{generate:()=>_P,name:()=>NP,parse:()=>Ep,structure:()=>OP});function Ep(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 _P(e){this.token(9,"["),this.children(e),this.token(9,"]")}var NP,OP,Pp=$(()=>{"use strict";NP="Brackets",OP={children:[[]]}});var Mp={};ye(Mp,{generate:()=>jP,name:()=>$P,parse:()=>Lp,structure:()=>UP});function Lp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function jP(){this.token(15,"-->")}var $P,UP,Bp=$(()=>{"use strict";$P="CDC",UP=[]});var Rp={};ye(Rp,{generate:()=>VP,name:()=>HP,parse:()=>Dp,structure:()=>WP});function Dp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function VP(){this.token(14,"<!--")}var HP,WP,zp=$(()=>{"use strict";HP="CDO",WP=[]});var Op={};ye(Op,{generate:()=>KP,name:()=>qP,parse:()=>Np,structure:()=>YP});function Np(){return this.eatDelim(GP),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function KP(e){this.token(9,"."),this.token(1,e.name)}var GP,qP,YP,_p=$(()=>{"use strict";GP=46,qP="ClassSelector",YP={name:String}});var Up={};ye(Up,{generate:()=>t2,name:()=>ZP,parse:()=>$p,structure:()=>e2});function $p(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case QP:case XP:case JP:this.next();break;case x0:this.next(),this.eatIdent("deep"),this.eatDelim(x0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function t2(e){this.tokenize(e.name)}var XP,x0,QP,JP,ZP,e2,jp=$(()=>{"use strict";XP=43,x0=47,QP=62,JP=126,ZP="Combinator",e2={name:String}});var Wp={};ye(Wp,{generate:()=>s2,name:()=>o2,parse:()=>Hp,structure:()=>i2});function Hp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===n2&&this.charCodeAt(t-1)===r2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function s2(e){this.token(25,"/*"+e.value+"*/")}var n2,r2,o2,i2,Vp=$(()=>{"use strict";n2=42,r2=47,o2="Comment",i2={value:String}});var qp={};ye(qp,{generate:()=>p2,name:()=>l2,parse:()=>Gp,structure:()=>c2});function y0(e){return this.lookupTypeNonSC(1)===1&&a2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function Gp(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 p2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var a2,l2,c2,u2,Yp=$(()=>{"use strict";a2=new Set([16,22,0]),l2="Condition",c2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};u2={media:y0,container:y0,supports(){return this.SupportsDeclaration()}}});var Xp={};ye(Xp,{generate:()=>k2,name:()=>S2,parse:()=>Kp,structure:()=>v2,walkContext:()=>w2});function x2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function b2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(S0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Kp(){let e=this.tokenStart,t=this.tokenIndex,n=C2.call(this),r=il(n),o=r?this.parseCustomProperty:this.parseValue,i=r?y2:x2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(b2,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(S0)&&(s=T2.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 k2(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 C2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case m2:case f2:case h2:case d2:case g2:this.next();break;case b0:this.next(),this.isDelim(b0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function T2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var S0,d2,f2,g2,m2,h2,b0,S2,w2,v2,Qp=$(()=>{"use strict";sl();S0=33,d2=35,f2=36,g2=38,m2=42,h2=43,b0=47;S2="Declaration",w2="declaration",v2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var ed={};ye(ed,{generate:()=>A2,name:()=>F2,parse:()=>Zp,structure:()=>E2});function Jp(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Zp(){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),Jp));break;default:this.isDelim(I2)?e.push(this.parseWithFallback(this.Rule,Jp)):e.push(this.parseWithFallback(this.Declaration,Jp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function A2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var I2,F2,E2,td=$(()=>{"use strict";I2=38;F2="DeclarationList",E2={children:[["Declaration","Atrule","Rule"]]}});var rd={};ye(rd,{generate:()=>M2,name:()=>P2,parse:()=>nd,structure:()=>L2});function nd(){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 M2(e){this.token(12,e.value+e.unit)}var P2,L2,od=$(()=>{"use strict";P2="Dimension",L2={value:String,unit:String}});var sd={};ye(sd,{generate:()=>z2,name:()=>D2,parse:()=>id,structure:()=>R2});function id(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(B2)&&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 z2(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var B2,D2,R2,ad=$(()=>{"use strict";B2=47,D2="Feature",R2={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var cd={};ye(cd,{generate:()=>$2,name:()=>N2,parse:()=>ld,structure:()=>O2});function _2(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function ld(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=_2.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 $2(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var N2,O2,ud=$(()=>{"use strict";N2="FeatureFunction",O2={kind:String,feature:String,value:["Declaration","Selector"]}});var fd={};ye(fd,{generate:()=>V2,name:()=>H2,parse:()=>dd,structure:()=>W2});function pd(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(w0,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(w0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function k0(e){if(this.skipSC(),this.isDelim(U2)||this.isDelim(j2)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(v0)?(this.next(),t+"="):t}if(this.isDelim(v0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function dd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=pd.call(this),r=k0.call(this,n.type==="Identifier"),o=pd.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=k0.call(this),s=pd.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 V2(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 w0,U2,v0,j2,H2,W2,gd=$(()=>{"use strict";w0=47,U2=60,v0=61,j2=62,H2="FeatureRange",W2={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 hd={};ye(hd,{generate:()=>K2,name:()=>G2,parse:()=>md,structure:()=>Y2,walkContext:()=>q2});function md(e,t){let n=this.tokenStart,r=this.consumeFunctionName(),o=r.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:i}}function K2(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var G2,q2,Y2,xd=$(()=>{"use strict";G2="Function",q2="function",Y2={name:String,children:[[]]}});var bd={};ye(bd,{generate:()=>J2,name:()=>X2,parse:()=>yd,structure:()=>Q2});function yd(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 J2(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var X2,Q2,Sd=$(()=>{"use strict";X2="GeneralEnclosed",Q2={kind:String,function:[String,null],children:[[]]}});var vd={};ye(vd,{generate:()=>nL,name:()=>eL,parse:()=>wd,structure:()=>tL,xxx:()=>Z2});function wd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function nL(e){this.token(4,"#"+e.value)}var Z2,eL,tL,kd=$(()=>{"use strict";Z2="XXX",eL="Hash",tL={value:String}});var Td={};ye(Td,{generate:()=>iL,name:()=>rL,parse:()=>Cd,structure:()=>oL});function Cd(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function iL(e){this.token(1,e.name)}var rL,oL,Id=$(()=>{"use strict";rL="Identifier",oL={name:String}});var Ed={};ye(Ed,{generate:()=>lL,name:()=>sL,parse:()=>Fd,structure:()=>aL});function Fd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function lL(e){this.token(9,"#"+e.name)}var sL,aL,Ad=$(()=>{"use strict";sL="IdSelector",aL={name:String}});var Ld={};ye(Ld,{generate:()=>dL,name:()=>uL,parse:()=>Pd,structure:()=>pL});function Pd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(cL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function dL(e){this.tokenize(e.name)}var cL,uL,pL,Md=$(()=>{"use strict";cL=46,uL="Layer",pL={name:String}});var Dd={};ye(Dd,{generate:()=>mL,name:()=>fL,parse:()=>Bd,structure:()=>gL});function Bd(){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 mL(e){this.children(e,()=>this.token(18,","))}var fL,gL,Rd=$(()=>{"use strict";fL="LayerList",gL={children:[["Layer"]]}});var Nd={};ye(Nd,{generate:()=>yL,name:()=>hL,parse:()=>zd,structure:()=>xL});function zd(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function 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 hL,xL,Od=$(()=>{"use strict";hL="MediaQuery",xL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var $d={};ye($d,{generate:()=>wL,name:()=>bL,parse:()=>_d,structure:()=>SL});function _d(){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 wL(e){this.children(e,()=>this.token(18,","))}var bL,SL,Ud=$(()=>{"use strict";bL="MediaQueryList",SL={children:[["MediaQuery"]]}});var Hd={};ye(Hd,{generate:()=>TL,name:()=>kL,parse:()=>jd,structure:()=>CL});function jd(){let e=this.tokenStart;return this.eatDelim(vL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function TL(){this.token(9,"&")}var vL,kL,CL,Wd=$(()=>{"use strict";vL=38,kL="NestingSelector",CL={}});var Gd={};ye(Gd,{generate:()=>EL,name:()=>IL,parse:()=>Vd,structure:()=>FL});function Vd(){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 EL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var IL,FL,qd=$(()=>{"use strict";IL="Nth",FL={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Kd={};ye(Kd,{generate:()=>LL,name:()=>AL,parse:()=>Yd,structure:()=>PL});function Yd(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function LL(e){this.token(10,e.value)}var AL,PL,Xd=$(()=>{"use strict";AL="Number",PL={value:String}});var Jd={};ye(Jd,{generate:()=>DL,name:()=>ML,parse:()=>Qd,structure:()=>BL});function Qd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function DL(e){this.tokenize(e.value)}var ML,BL,Zd=$(()=>{"use strict";ML="Operator",BL={value:String}});var tf={};ye(tf,{generate:()=>NL,name:()=>RL,parse:()=>ef,structure:()=>zL});function ef(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 NL(e){this.token(21,"("),this.children(e),this.token(22,")")}var RL,zL,nf=$(()=>{"use strict";RL="Parentheses",zL={children:[[]]}});var of={};ye(of,{generate:()=>$L,name:()=>OL,parse:()=>rf,structure:()=>_L});function rf(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function $L(e){this.token(11,e.value+"%")}var OL,_L,sf=$(()=>{"use strict";OL="Percentage",_L={value:String}});var lf={};ye(lf,{generate:()=>WL,name:()=>UL,parse:()=>af,structure:()=>HL,walkContext:()=>jL});function af(){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 WL(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var UL,jL,HL,cf=$(()=>{"use strict";UL="PseudoClassSelector",jL="function",HL={name:String,children:[["Raw"],null]}});var pf={};ye(pf,{generate:()=>YL,name:()=>VL,parse:()=>uf,structure:()=>qL,walkContext:()=>GL});function uf(){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 YL(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 VL,GL,qL,df=$(()=>{"use strict";VL="PseudoElementSelector",GL="function",qL={name:String,children:[["Raw"],null]}});var gf={};ye(gf,{generate:()=>QL,name:()=>KL,parse:()=>ff,structure:()=>XL});function T0(){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 ff(){let e=this.tokenStart,t=T0.call(this),n=null;return this.skipSC(),this.isDelim(C0)&&(this.eatDelim(C0),n=T0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function QL(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var C0,KL,XL,mf=$(()=>{"use strict";C0=47;KL="Ratio",XL={left:["Number","Function"],right:["Number","Function",null]}});var xf={};ye(xf,{generate:()=>tM,name:()=>ZL,parse:()=>hf,structure:()=>eM});function JL(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function hf(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=JL.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function tM(e){this.tokenize(e.value)}var ZL,eM,yf=$(()=>{"use strict";ZL="Raw",eM={value:String}});var Sf={};ye(Sf,{generate:()=>sM,name:()=>rM,parse:()=>bf,structure:()=>iM,walkContext:()=>oM});function I0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function nM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function bf(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(nM,I0):n=I0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function sM(e){this.node(e.prelude),this.node(e.block)}var rM,oM,iM,wf=$(()=>{"use strict";rM="Rule",oM="rule",iM={prelude:["SelectorList","Raw"],block:["Block"]}});var kf={};ye(kf,{generate:()=>cM,name:()=>aM,parse:()=>vf,structure:()=>lM});function vf(){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 cM(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 aM,lM,Cf=$(()=>{"use strict";aM="Scope",lM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var If={};ye(If,{generate:()=>dM,name:()=>uM,parse:()=>Tf,structure:()=>pM});function Tf(){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 dM(e){this.children(e)}var uM,pM,Ff=$(()=>{"use strict";uM="Selector",pM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Af={};ye(Af,{generate:()=>hM,name:()=>fM,parse:()=>Ef,structure:()=>mM,walkContext:()=>gM});function Ef(){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 hM(e){this.children(e,()=>this.token(18,","))}var fM,gM,mM,Pf=$(()=>{"use strict";fM="SelectorList",gM="selector",mM={children:[["Selector","Raw"]]}});function Sl(e){let t=e.length,n=e.charCodeAt(0),r=n===F0||n===E0?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===Lf){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),An(Lf,a)){let u=s-1,c=Ur(e,u);s=c-1,i+=Ha(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function A0(e,t){let n=t?"'":'"',r=t?E0:F0,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===Lf?(o+="\\"+e.charAt(s),i=!1):(i&&(Pn(a)||Ar(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Lf,F0,E0,wl=$(()=>{"use strict";nr();Lf=92,F0=34,E0=39});var Bf={};ye(Bf,{generate:()=>bM,name:()=>xM,parse:()=>Mf,structure:()=>yM});function Mf(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Sl(this.consume(5))}}function bM(e){this.token(5,A0(e.value))}var xM,yM,Df=$(()=>{"use strict";wl();xM="String",yM={value:String}});var zf={};ye(zf,{generate:()=>CM,name:()=>wM,parse:()=>Rf,structure:()=>kM,walkContext:()=>vM});function L0(){return this.Raw(null,!1)}function Rf(){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)!==SM){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,L0);break;default:n=this.parseWithFallback(this.Rule,L0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function CM(e){this.children(e)}var SM,wM,vM,kM,Nf=$(()=>{"use strict";SM=33;wM="StyleSheet",vM="stylesheet",kM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var _f={};ye(_f,{generate:()=>FM,name:()=>TM,parse:()=>Of,structure:()=>IM});function Of(){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 FM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var TM,IM,$f=$(()=>{"use strict";TM="SupportsDeclaration",IM={declaration:"Declaration"}});var Hf={};ye(Hf,{generate:()=>LM,name:()=>AM,parse:()=>jf,structure:()=>PM});function Uf(){this.tokenType!==1&&this.isDelim(EM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function jf(){let e=this.tokenStart;return this.isDelim(M0)?(this.next(),Uf.call(this)):(Uf.call(this),this.isDelim(M0)&&(this.next(),Uf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function LM(e){this.tokenize(e.name)}var EM,M0,AM,PM,Wf=$(()=>{"use strict";EM=42,M0=124;AM="TypeSelector",PM={name:String}});var qf={};ye(qf,{generate:()=>zM,name:()=>DM,parse:()=>Gf,structure:()=>RM});function Fs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===D0&&t&&n!==0)return Fs.call(this,e+n+1,!1),-1;Pn(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 vl(e){let t=0;for(;this.isDelim(Vf);)++t>e&&this.error("Too many question marks"),this.next()}function MM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===B0?"Plus sign":"Hyphen minus")+" is expected")}function BM(){let e=0;switch(this.tokenType){case 10:if(e=Fs.call(this,1,!0),this.isDelim(Vf)){vl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){MM.call(this,D0),Fs.call(this,1,!1);break}break;case 12:e=Fs.call(this,1,!0),e>0&&vl.call(this,6-e);break;default:if(this.eatDelim(B0),this.tokenType===1){e=Fs.call(this,0,!0),e>0&&vl.call(this,6-e);break}if(this.isDelim(Vf)){this.next(),vl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function Gf(){let e=this.tokenStart;return this.eatIdent("u"),BM.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function zM(e){this.tokenize(e.value)}var B0,D0,Vf,DM,RM,Yf=$(()=>{"use strict";nr();B0=43,D0=45,Vf=63;DM="UnicodeRange",RM={value:String}});function z0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===R0?t-2:t-1,o="";for(;n<r&&Ar(e.charCodeAt(n));)n++;for(;n<r&&Ar(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Kf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),An(Kf,s)){let a=i-1,u=Ur(e,a);i=u-1,o+=Ha(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function N0(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===NM||o===Kf||o===OM||o===_M||o===$M||o===R0?(t+="\\"+e.charAt(r),n=!1):(n&&Pn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var NM,Kf,OM,_M,$M,R0,Xf=$(()=>{"use strict";nr();NM=32,Kf=92,OM=34,_M=39,$M=40,R0=41});var Jf={};ye(Jf,{generate:()=>HM,name:()=>UM,parse:()=>Qf,structure:()=>jM});function Qf(){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=Sl(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 HM(e){this.token(7,N0(e.value))}var UM,jM,Zf=$(()=>{"use strict";Xf();wl();UM="Url",jM={value:String}});var tg={};ye(tg,{generate:()=>GM,name:()=>WM,parse:()=>eg,structure:()=>VM});function eg(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function GM(e){this.children(e)}var WM,VM,ng=$(()=>{"use strict";WM="Value",VM={children:[[]]}});var og={};ye(og,{generate:()=>XM,name:()=>YM,parse:()=>rg,structure:()=>KM});function rg(){return this.eat(13),qM}function XM(e){this.token(13,e.value)}var qM,YM,KM,ig=$(()=>{"use strict";qM=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),YM="WhiteSpace",KM={value:String}});var Es={};ye(Es,{AnPlusB:()=>fp,Atrule:()=>hp,AtrulePrelude:()=>bp,AttributeSelector:()=>kp,Block:()=>Ip,Brackets:()=>Ap,CDC:()=>Mp,CDO:()=>Rp,ClassSelector:()=>Op,Combinator:()=>Up,Comment:()=>Wp,Condition:()=>qp,Declaration:()=>Xp,DeclarationList:()=>ed,Dimension:()=>rd,Feature:()=>sd,FeatureFunction:()=>cd,FeatureRange:()=>fd,Function:()=>hd,GeneralEnclosed:()=>bd,Hash:()=>vd,IdSelector:()=>Ed,Identifier:()=>Td,Layer:()=>Ld,LayerList:()=>Dd,MediaQuery:()=>Nd,MediaQueryList:()=>$d,NestingSelector:()=>Hd,Nth:()=>Gd,Number:()=>Kd,Operator:()=>Jd,Parentheses:()=>tf,Percentage:()=>of,PseudoClassSelector:()=>lf,PseudoElementSelector:()=>pf,Ratio:()=>gf,Raw:()=>xf,Rule:()=>Sf,Scope:()=>kf,Selector:()=>If,SelectorList:()=>Af,String:()=>Bf,StyleSheet:()=>zf,SupportsDeclaration:()=>_f,TypeSelector:()=>Hf,UnicodeRange:()=>qf,Url:()=>Jf,Value:()=>tg,WhiteSpace:()=>og});var sg=$(()=>{"use strict";gp();xp();Sp();Cp();Fp();Pp();Bp();zp();_p();jp();Vp();Yp();Qp();td();od();ad();ud();gd();xd();Sd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();nf();sf();cf();df();mf();yf();wf();Cf();Ff();Pf();Df();Nf();$f();Wf();Yf();Zf();ng();ig()});var _0,$0=$(()=>{"use strict";al();p0();sg();_0={generic:!0,cssWideKeywords:gi,...u0,node:Es}});function As(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,tB)&&this.cmpChar(this.tokenStart+1,U0)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===eB||t===JM||t===U0||t===ZM)return this.Operator();t===QM&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var QM,JM,U0,ZM,eB,tB,ag=$(()=>{"use strict";QM=35,JM=42,U0=43,ZM=45,eB=47,tB=117});var j0,H0=$(()=>{"use strict";ag();j0={getNode:As}});function uB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function pB(){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)===W0&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case iB:case aB:case cB:case sB:return this.Combinator();case W0:return this.ClassSelector();case oB:case lB:return this.TypeSelector();case nB:return this.IdSelector();case rB:return this.NestingSelector()}break}}}var nB,rB,oB,iB,sB,W0,aB,lB,cB,V0,G0=$(()=>{"use strict";nB=35,rB=38,oB=42,iB=43,sB=47,W0=46,aB=62,lB=124,cB=126;V0={onWhiteSpace:uB,getNode:pB}});function q0(){return this.createSingleNodeList(this.Raw(null,!1))}var Y0=$(()=>{"use strict"});function K0(){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 X0=$(()=>{"use strict"});function Q0(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var J0,Z0=$(()=>{"use strict";ag();Y0();X0();J0={getNode:As,onWhiteSpace(e,t){Q0(e)&&(e.value=" "+e.value),Q0(t.last)&&(t.last.value+=" ")},expression:q0,var:K0}});var lg={};ye(lg,{AtrulePrelude:()=>j0,Selector:()=>V0,Value:()=>J0});var eS=$(()=>{"use strict";H0();G0();Z0()});var dB,tS,nS=$(()=>{"use strict";dB=new Set(["none","and","not","or"]),tS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);dB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var rS,oS=$(()=>{"use strict";rS={parse:{prelude:null,block(){return this.Block(!0)}}}});function cg(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 iS,sS,aS=$(()=>{"use strict";iS={layer(){this.skipSC();let e=this.createList(),t=cg.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=cg.call(this,this.Declaration,()=>cg.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},sS={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,iS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,iS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var lS,cS=$(()=>{"use strict";lS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var uS,pS=$(()=>{"use strict";uS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var dS,fS=$(()=>{"use strict";dS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var gS,mS=$(()=>{"use strict";gS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var hS,xS=$(()=>{"use strict";hS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var yS,bS=$(()=>{"use strict";yS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var SS,wS=$(()=>{"use strict";SS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var vS,kS=$(()=>{"use strict";nS();oS();aS();cS();pS();fS();mS();xS();bS();wS();vS={container:tS,"font-face":rS,import:sS,layer:lS,media:uS,nest:dS,page:gS,scope:hS,"starting-style":yS,supports:SS}});function CS(){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 TS=$(()=>{"use strict"});var _o,ug,fB,gB,kl,IS,FS=$(()=>{"use strict";TS();_o={parse(){return this.createSingleNodeList(this.SelectorList())}},ug={parse(){return this.createSingleNodeList(this.Selector())}},fB={parse(){return this.createSingleNodeList(this.Identifier())}},gB={parse:CS},kl={parse(){return this.createSingleNodeList(this.Nth())}},IS={dir:fB,has:_o,lang:gB,matches:_o,is:_o,"-moz-any":_o,"-webkit-any":_o,where:_o,not:_o,"nth-child":kl,"nth-last-child":kl,"nth-last-of-type":kl,"nth-of-type":kl,slotted:ug,host:ug,"host-context":ug}});var pg={};ye(pg,{AnPlusB:()=>dp,Atrule:()=>mp,AtrulePrelude:()=>yp,AttributeSelector:()=>vp,Block:()=>Tp,Brackets:()=>Ep,CDC:()=>Lp,CDO:()=>Dp,ClassSelector:()=>Np,Combinator:()=>$p,Comment:()=>Hp,Condition:()=>Gp,Declaration:()=>Kp,DeclarationList:()=>Zp,Dimension:()=>nd,Feature:()=>id,FeatureFunction:()=>ld,FeatureRange:()=>dd,Function:()=>md,GeneralEnclosed:()=>yd,Hash:()=>wd,IdSelector:()=>Fd,Identifier:()=>Cd,Layer:()=>Pd,LayerList:()=>Bd,MediaQuery:()=>zd,MediaQueryList:()=>_d,NestingSelector:()=>jd,Nth:()=>Vd,Number:()=>Yd,Operator:()=>Qd,Parentheses:()=>ef,Percentage:()=>rf,PseudoClassSelector:()=>af,PseudoElementSelector:()=>uf,Ratio:()=>ff,Raw:()=>hf,Rule:()=>bf,Scope:()=>vf,Selector:()=>Tf,SelectorList:()=>Ef,String:()=>Mf,StyleSheet:()=>Rf,SupportsDeclaration:()=>Of,TypeSelector:()=>jf,UnicodeRange:()=>Gf,Url:()=>Qf,Value:()=>eg,WhiteSpace:()=>rg});var ES=$(()=>{"use strict";gp();xp();Sp();Cp();Fp();Pp();Bp();zp();_p();jp();Vp();Yp();Qp();td();od();ad();ud();gd();xd();Sd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();nf();sf();cf();df();mf();yf();wf();Cf();Ff();Pf();Df();Nf();$f();Wf();Yf();Zf();ng();ig()});var AS,PS=$(()=>{"use strict";eS();kS();FS();ES();AS={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:lg,atrule:vS,pseudo:IS,node:pg}});var LS,MS=$(()=>{"use strict";sg();LS={node:Es}});var BS,DS=$(()=>{"use strict";c0();$0();PS();MS();BS=l0({..._0,...AS,...LS})});var RS=$(()=>{"use strict"});var zS=$(()=>{"use strict"});var tq,NS,nq,rq,oq,OS,iq,sq,aq,lq,cq,uq,_S=$(()=>{"use strict";DS();RS();Ju();sl();zS();wl();Xf();({tokenize:tq,parse:NS,generate:nq,lexer:rq,createLexer:oq,walk:OS,find:iq,findLast:sq,findAll:aq,toPlainObject:lq,fromPlainObject:cq,fork:uq}=BS)});function yB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function US(e){try{let t=NS(e.trim(),{context:"value"}),n=[];return OS(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 bB(e,t){let n=yB(e);if(!xB.has(n))return t;let r=US(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 $S(e,t){let n=t.trim();if(!n)return"";let r=bB(e,n);return US(r).map(i=>i==="0"?"0px":i).join(" ")}function jS(e,t,n){let r=$S(e,t),o=$S(e,n);return r!==""&&o!==""&&r===o}var xB,HS=$(()=>{"use strict";_S();xB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function SB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function wB(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 WS(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=wB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return SB(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 $o(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 f=WS(r),p=WS(o);return!!(f===p||n&&jS(n,r,o))}var dg=$(()=>{"use strict";HS()});function IB(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 VS(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 FB(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 EB(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&&IB(n)||VS(r)||VS(o)||n&&FB(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<qS:a<GS}return r.includes("%")||o.includes("%")?a<1:!1}function AB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(TB.some(s=>t.includes(s))||!kB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!$o(o,i,e.property))}function PB(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 LB(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)<YS}function MB(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(!CB.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]))>vB)}function BB(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 Ps(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($o(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(LB(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${YS}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(EB(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")?qS:GS}px)`,dismissedBy:"post-ai-validation"}}return BB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:AB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:MB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:PB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var GS,qS,YS,vB,kB,CB,TB,KS=$(()=>{"use strict";dg();GS=.5,qS=2,YS=2,vB=5,kB=["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"],CB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],TB=["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 Si(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var XS=$(()=>{"use strict"});var QS=$(()=>{"use strict"});var JS=$(()=>{"use strict"});var fg=$(()=>{"use strict";dg();KS();XS();QS();JS()});var jB,HB,Fq,gg=$(()=>{"use strict";jB=["flex","inline-flex"],HB=["grid","inline-grid"],Fq=[...jB,...HB]});var ew=$(()=>{"use strict";fg();gg()});var tw=$(()=>{"use strict"});var Ls=$(()=>{"use strict";sy();fg();gg();ew();tw()});function VB(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function qn(e){try{let t=e.map(VB),n=JSON.stringify(t,GB);sessionStorage.setItem(mg,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function hg(){try{let e=sessionStorage.getItem(mg);if(!e)return[];let t=JSON.parse(e,qB);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function nw(){try{let e=hg();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&&(qn(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function rw(){try{sessionStorage.removeItem(mg),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function GB(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function qB(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var mg,xg=$(()=>{"use strict";De();mg="uicopilot_review_history"});import YB,{createContext as KB,useContext as XB,useReducer as QB,useMemo as ow,useRef as JB,useEffect as ZB}from"react";function eD(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],qn(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=[...e.reviewHistory,...r];return qn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=[...e.reviewHistory,t.payload];return qn(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 qn(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 qn(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 qn(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 qn(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{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,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:o)});return qn(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{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,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:o)});return qn(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=Si(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return qn(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 qn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return rw(),{...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 bg({children:e}){let[t,n]=QB(eD,iD),r=JB(t);ZB(()=>{r.current=t},[t]);let o=ow(()=>({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=ow(()=>({...t,...o}),[t,o]);return YB.createElement(iw.Provider,{value:i},e)}function ie(){let e=XB(iw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var tD,nD,yg,rD,oD,iD,iw,Sg=$(()=>{"use strict";Ls();xg();De();tD=()=>{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},nD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},yg={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},rD=()=>{if(typeof localStorage>"u")return yg;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return yg;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 yg},oD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},iD={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:hg(),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:oD(),roleOverride:nD(),featureFlags:rD(),reviewAllConcurrency:tD(),hoveredIssueId:null},iw=KB(null)});import Ms,{useMemo as sD}from"react";function vg({children:e}){return Ms.createElement(ru,null,Ms.createElement(iu,null,Ms.createElement(au,null,Ms.createElement(bg,null,Ms.createElement(aD,null),e))))}function sw(e){let t=we(),n=Ze(),r=rt(),o=ie(),i=sD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function aD(){return wg=sw(),null}var wg,mt,aw=$(()=>{"use strict";ou();su();lu();Sg();wg=null,mt=Object.assign(sw,{getState:()=>{if(!wg)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return wg}})});var ve=$(()=>{"use strict";aw();ou();su();lu();Sg()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||lD).replace(/\/$/,"")}var lD,lw,je=$(()=>{"use strict";lD="https://app.uicopilot.dev",lw=3.6});async function oe(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 pt=$(()=>{"use strict"});import{useEffect as zs,useState as Tl,useRef as JD,useCallback as Cg}from"react";import{addons as Tg}from"storybook/manager-api";async function ZD(e,t,n){let r=`${e}:${t}`,o=Ig.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await oe(`${Tw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Ig.delete(r)});return Ig.set(r,i),i}function eR(e,t,n){try{sessionStorage.setItem(`${Il}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function tR(e,t){try{let n=sessionStorage.getItem(`${Il}${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(`${Il}${e}`)}catch{}return null}function nR(e){try{let t=sessionStorage.getItem(`${Il}${e}`);if(!t)return null;let n=JSON.parse(t);if(n.imageUrl&&Date.now()-n.timestamp<300*1e3)return n.imageUrl}catch{}return null}var ww,vw,kw,Cw,Ci,Tw,ir,Fg,Ig,Il,Iw,Uo,Ns=$(()=>{"use strict";ve();Eg();De();je();pt();ww="storyArgsUpdated",vw="storyRendered",kw="forceRemount",Cw=null,Ci=()=>Cw,Tw=q(),ir=new Map,Fg=null,Ig=new Map;Il="uicopilot-figma-image-";Iw=(e,t,n)=>{Fg=t;let r=ir.get(e);r?r.figmaImageUrl=n:ir.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Uo=()=>{let[e,t]=Tl(!1),[n,r]=Tl(!1),[o,i]=Tl(!1),[s,a]=Tl(null),u=JD(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ie(),d=Cg(()=>{let z=mt.getState().currentStoryId;z&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",z),ir.delete(z),u.current=null,i(!0),l())},[l]),f=Cg(()=>{let z=mt.getState().currentStoryId;if(z){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",z);let _=ir.get(z);_&&(_.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=we(),{selectedProjectId:g}=Ze(),{currentStoryId:S,currentMapping:C}=rt(),{setStorybookImageUrl:F,setFigmaImageUrl:k}=ie();zs(()=>{if(!S||mt.getState().figmaImageUrl)return;let _=nR(S);_&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",S),k(_))},[S,k]),zs(()=>{(async()=>{if(!p||!g||!S){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}let _=mt.getState();if(_.storybookImageUrl&&_.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded from persisted review, skipping capture"),u.current=S;return}let M=C?.figmaNodeId??null;if(M!==Fg){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",S);let I=ir.get(S);I&&(I.figmaImageUrl=null),Fg=M,u.current=null}let B=C?.figmaNodeId;if(B&&!ir.get(S)?.figmaImageUrl){let I=tR(S,B);if(I){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",S),k(I);let v=ir.get(S);v?v.figmaImageUrl=I:ir.set(S,{storybookImageUrl:null,figmaImageUrl:I})}}let m=ir.get(S),x=m&&m.storybookImageUrl&&m.figmaImageUrl,b=m&&m.storybookImageUrl&&!m.figmaImageUrl,E=m&&!m.storybookImageUrl&&m.figmaImageUrl;if(x){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",S),F(m.storybookImageUrl),k(m.figmaImageUrl),u.current=S;return}let h=b&&C?.figmaNodeId;h&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",S),F(m.storybookImageUrl));let T=E;if(T&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",S),k(m.figmaImageUrl)),u.current===S&&C?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{a(null),h?r(!0):(T||(t(!0),r(!0)),i(!0)),u.current=S;let I=T?m.figmaImageUrl:null,v;if(T)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(B){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",B);let P=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await ZD(g,B,p);P=D.imageUrl||null;let N=D.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${N}:`,P?"success":"not found")}catch(D){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(P)if(P.includes(".azureedge.net")||P.includes(".blob.core.windows.net")||P.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),I=P,k(P);let N=new Image;N.crossOrigin="anonymous",await new Promise(w=>{N.onload=()=>{v={width:N.naturalWidth,height:N.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),w()},N.onerror=()=>w(),N.src=P})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let N=`${Tw}/api/proxy/image?url=${encodeURIComponent(P)}`,w=await oe(N);if(w.ok){let j=await w.blob(),G=new FileReader,L=await new Promise((ee,re)=>{G.onloadend=()=>ee(G.result),G.onerror=re,G.readAsDataURL(j)});I=L,k(L),y.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let K=new Image;await new Promise(ee=>{K.onload=()=>{v={width:K.naturalWidth,height:K.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),ee()},K.onerror=()=>ee(),K.src=L})}else I=P,k(P),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(N){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",N),I=P,k(P)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",B),k(null);I&&B&&eR(S,B,I),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),k(null),r(!1);let A=m?.storybookImageUrl||null;if(A)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",S);let P=await Fl({storyId:S,sessionToken:p||void 0,...v&&{figmaWidth:v.width,figmaHeight:v.height}});P?(A=P,F(P),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",v||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}ir.set(S,{storybookImageUrl:A,figmaImageUrl:I}),y.debug("[useReviewScreenshots] Screenshots cached for story:",S)}catch(I){y.error("[useReviewScreenshots] Error loading screenshots:",I),a(I instanceof Error?I.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})()},[p,g,S,C?.figmaNodeId,c]),zs(()=>{let z=Tg.getChannel(),_=null,M=B=>{Cw=B.args,y.debug("[useReviewScreenshots] Args updated for story:",B.storyId,"args:",B.args),_&&clearTimeout(_),_=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return z.on(ww,M),()=>{z.off(ww,M),_&&clearTimeout(_)}},[d]),zs(()=>{let z=Tg.getChannel(),_=!1,M=null,B=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),_=!0,i(!0)},m=()=>{_&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),M&&clearTimeout(M),M=setTimeout(()=>{_=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return z.on(kw,B),z.on(vw,m),()=>{z.off(kw,B),z.off(vw,m),M&&clearTimeout(M)}},[f]),zs(()=>{let z=Tg.getChannel(),_=async M=>{if(!M?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let B=mt.getState().currentStoryId,m=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M.snapshot,storyId:B})});if(m.ok){let x=await m.json();if(x.screenshot){F(x.screenshot);let b=mt.getState().currentStoryId;if(b){let E=ir.get(b);E?E.storybookImageUrl=x.screenshot:ir.set(b,{storybookImageUrl:x.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await m.text())}catch(B){y.error("[useReviewScreenshots] Snapshot screenshot error:",B)}finally{i(!1)}};return z.on("UICOPILOT/STORY_DOM_MUTATED",_),()=>{z.off("UICOPILOT/STORY_DOM_MUTATED",_)}},[]);let R=Cg((z,_,M)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Iw(z,_,M),k(M),r(!1),u.current=z},[k]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:f,setFigmaImageDirect:R}}});function oR(){return!q().startsWith("http://localhost")}function iR(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 Fw(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=iR(o,t,n);return r.set(o,i),i})}async function sR(){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=Fw(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 f of Array.from(l.cssRules))d+=f.cssText+`
|
|
13
|
-
`;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let f=s.createElement("style");f.textContent=Fw(d,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function aR(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 lR(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 oe(`${rR}/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 cR(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 uR(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=Ci();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=cR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=aR(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 pR(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 Fl(e){let t=e?.storyId||dR();if(t){let n=Ag.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Ew(t,e).finally(()=>{Ag.delete(t)});return Ag.set(t,r),r}return Ew(void 0,e)}async function Ew(e,t){try{if(e){let n=await pR(e);if(n)return n}if(!oR()){let n=uR(t?.storyId);return await lR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await sR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function dR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var rR,Ag,Eg=$(()=>{"use strict";je();Ns();De();pt();rR=q();Ag=new Map});function vn(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 Dn(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 Os(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Aw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let C=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let k=t.fonts.check(`${F} ${C} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:k,fontWeight:F,fontSize:C,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(R=>({family:R.family,status:R.status}))}),k)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(C=>C.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],f=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,g="unknown",S=new Map;for(let C of f){s.font=`${c} ${u} ${a} "${C}", monospace`;let F=s.measureText(o).width;if(S.set(C,F),F!==p){s.font=`${c} ${u} ${a} "${C}"`;let k=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let R=s.measureText(o).width;if(Math.abs(k-R)<.1){g=C;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:g,declaredFonts:l,fontWidths:Array.from(S.entries()),isIframe:t!==document}),g}var _s=$(()=>{"use strict";De()});function Ti(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 Pg(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:vn(n.color),backgroundColor:vn(n.backgroundColor),borderColor:vn(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:Aw(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 Lg(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 El=$(()=>{"use strict";De();_s()});function fR(e){let t=[],n=new Set,r=Pw.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(Pw.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function gR(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:Ti(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Os(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:vn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function mR(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 hR(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,f=vn(n.borderColor),p=s?`${l} ${d} ${f}`:"none";return{selector:Ti(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:vn(n.backgroundColor),gap:n.gap}}function $s(){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=mR(r,2),i=o.map(hR).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=fR(r);s=a.map(gR),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:Pg(r),declared:Lg(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Pw,Lw=$(()=>{"use strict";De();_s();El();Pw=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Mg(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 yR(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function bR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=vn(n.backgroundColor);Dn("backgroundColor",o)||(r.backgroundColor=o);let i=yR(n.borderWidth,n.borderStyle,vn(n.borderColor));i&&(r.border=i),Dn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Dn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Dn("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 C=0;C<e.attributes.length;C++){let F=e.attributes[C];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let k=F.name.replace(/-([a-z])/g,(z,_)=>_.toUpperCase()),R=F.value.startsWith("rgb")?vn(F.value):F.value;k==="d"&&R.length>100?r[k]=R.substring(0,100)+"...":r[k]=R}let p=n.getPropertyValue("fill"),g=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?vn(p):p),g&&g!=="none"&&(r.stroke=g.startsWith("rgb")?vn(g):g),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let C=e.getBoundingClientRect();C.width>0&&(r.width=`${Math.round(C.width*100)/100}px`),C.height>0&&(r.height=`${Math.round(C.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=xR.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Os(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=vn(n.color),Dn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Dn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Mg(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Dn("padding",d)||(r.padding=d);let f=Mg(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Dn("margin",f)||(r.margin=f),Dn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Dn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Dn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Dn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Mw(e){let t=1;for(let n of e.children)t+=Mw(n);return t}function Bw(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 S of Array.from(o.childNodes))if(S.nodeType===Node.TEXT_NODE){let C=S.textContent?.trim();if(C){d=C.length>50?C.substring(0,50)+"...":C;break}}let f=s;c?f=`${s}#${c}`:u&&(f=Ti(s,u));let p=bR(o),g=[];if(i<t){let S=Array.from(o.children);for(let C of S){let F=C.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let R=(C.ownerDocument.defaultView||window).getComputedStyle(C);R.display==="none"||R.visibility==="hidden"||g.push(n(C,i+1))}}return{selector:f,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:g}}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:Mw(r)}),r}function Bg(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=Bw(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 xR,Dw=$(()=>{"use strict";De();_s();El();xR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Dg=$(()=>{"use strict";_s();El();Lw();Dw()});var sv=Jn((eX,iv)=>{"use strict";iv.exports={compareTwoStrings:ov,findBestMatch:WR};function ov(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 WR(e,t){if(!VR(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=ov(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 VR(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var QC=Jn((Xoe,XC)=>{"use strict";var GC=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,N4=/\n/g,O4=/^\s*/,_4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$4=/^:\s*/,U4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,j4=/^[;\s]*/,H4=/^\s+|\s+$/g,W4=`
|
|
14
|
-
`,qC="/",YC="*",Qo="",V4="comment",G4="declaration";function q4(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(g){var S=g.match(N4);S&&(n+=S.length);var C=g.lastIndexOf(W4);r=~C?g.length-C:r+g.length}function i(){var g={line:n,column:r};return function(S){return S.position=new s(g),c(),S}}function s(g){this.start=g,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(g){var S=new Error(t.source+":"+n+":"+r+": "+g);if(S.reason=g,S.filename=t.source,S.line=n,S.column=r,S.source=e,!t.silent)throw S}function u(g){var S=g.exec(e);if(S){var C=S[0];return o(C),e=e.slice(C.length),S}}function c(){u(O4)}function l(g){var S;for(g=g||[];S=d();)S!==!1&&g.push(S);return g}function d(){var g=i();if(!(qC!=e.charAt(0)||YC!=e.charAt(1))){for(var S=2;Qo!=e.charAt(S)&&(YC!=e.charAt(S)||qC!=e.charAt(S+1));)++S;if(S+=2,Qo===e.charAt(S-1))return a("End of comment missing");var C=e.slice(2,S-2);return r+=2,o(C),e=e.slice(S),r+=2,g({type:V4,comment:C})}}function f(){var g=i(),S=u(_4);if(S){if(d(),!u($4))return a("property missing ':'");var C=u(U4),F=g({type:G4,property:KC(S[0].replace(GC,Qo)),value:C?KC(C[0].replace(GC,Qo)):Qo});return u(j4),F}}function p(){var g=[];l(g);for(var S;S=f();)S!==!1&&(g.push(S),l(g));return g}return c(),p()}function KC(e){return e?e.replace(H4,Qo):Qo}XC.exports=q4});var JC=Jn(oa=>{"use strict";var Y4=oa&&oa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oa,"__esModule",{value:!0});oa.default=X4;var K4=Y4(QC());function X4(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,K4.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=Jn(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.camelCase=void 0;var Q4=/^--[a-zA-Z0-9_-]+$/,J4=/-([a-z])/g,Z4=/^[^-]+$/,eU=/^-(webkit|moz|ms|o|khtml)-/,tU=/^-(ms)-/,nU=function(e){return!e||Z4.test(e)||Q4.test(e)},rU=function(e,t){return t.toUpperCase()},ZC=function(e,t){return"".concat(t,"-")},oU=function(e,t){return t===void 0&&(t={}),nU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(tU,ZC):e=e.replace(eU,ZC),e.replace(J4,rU))};pc.camelCase=oU});var n1=Jn((hh,t1)=>{"use strict";var iU=hh&&hh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},sU=iU(JC()),aU=e1();function mh(e,t){var n={};return!e||typeof e!="string"||(0,sU.default)(e,function(r,o){r&&o&&(n[(0,aU.camelCase)(r,t)]=o)}),n}mh.default=mh;t1.exports=mh});var AT=Jn((Tue,ET)=>{"use strict";var Dc=Object.prototype.hasOwnProperty,FT=Object.prototype.toString,wT=Object.defineProperty,vT=Object.getOwnPropertyDescriptor,kT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):FT.call(t)==="[object Array]"},CT=function(t){if(!t||FT.call(t)!=="[object Object]")return!1;var n=Dc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Dc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Dc.call(t,o)},TT=function(t,n){wT&&n.name==="__proto__"?wT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},IT=function(t,n){if(n==="__proto__")if(Dc.call(t,n)){if(vT)return vT(t,n).value}else return;return t[n]};ET.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=IT(a,n),o=IT(t,n),a!==o&&(l&&o&&(CT(o)||(i=kT(o)))?(i?(i=!1,s=r&&kT(r)?r:[]):s=r&&CT(r)?r:{},TT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&TT(a,{name:n,newValue:o}));return a}});import Fa from"react";import{addons as Kc,types as Ux,experimental_getStatusStore as mF}from"storybook/manager-api";import{AddonPanel as I8}from"storybook/internal/components";import Mt,{useState as VW,useEffect as GW}from"react";import{styled as fr}from"storybook/theming";import Xx from"react";import{styled as At}from"storybook/theming";var le="#ea580c",Jc="#c2410c",La="#ff6b35";var Wx=At.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),Vx=At.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),ts=At.div({marginBottom:"20px"}),ns=At.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})),rs=At.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`}})),En=At.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"}})),Gx=At(En)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),Ma=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"}}),er=At.button(({theme:e})=>({...Ma(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),en=At.button(({theme:e})=>({...Ma(e),backgroundColor:le,color:e.color.inverseText,boxShadow:`0 2px 4px ${le}4d`,"&:hover:not(:disabled)":{backgroundColor:Jc,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${le}66`}})),Er=At.button(({theme:e})=>({...Ma(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),qx=At.button(({theme:e})=>({...Ma(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),wn=At.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"}})),Zc=At.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"}})),io=At.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=At(rs)(({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"})),D8=At.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Yx=At.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})),R8=At.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})),eu=At.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})),z8=At.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%)"}}})),Kx=At.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}}),N8=At.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),O8=At.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),_8=At.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var tu=({header:e,children:t,footer:n})=>Xx.createElement(Wx,null,e,Xx.createElement(Vx,null,t),n);import CF from"react";import{styled as TF}from"storybook/theming";var IF=TF.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})),nu=({toolbar:e})=>CF.createElement(IF,null,e);import K8 from"react";import{styled as Ba}from"storybook/theming";var J8=Ba.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})),Z8=Ba.div({display:"flex",flex:1}),eV=Ba(io)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),tV=Ba.div({display:"flex",gap:"8px",alignItems:"center"});import pn,{useState as hw,useCallback as xw,useEffect as yw}from"react";import{styled as fo}from"storybook/theming";import Re,{useEffect as cw}from"react";import{styled as at}from"storybook/theming";ve();je();De();pt();var uw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),pw=at.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})),cD=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),uD=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),pD=at.div({display:"flex",flexDirection:"column",gap:"4px"}),dD=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),fD=at.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=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),mD=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),hD=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),xD=at.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"})),yD=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${le} 100%)`,transition:"width 0.3s ease"})),bD=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),SD=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),wD=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:le,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),vD=at.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}})),kD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),CD=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),TD=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),ID=at.div({display:"flex",gap:"8px"}),dw=at(wn)({fontSize:"18px"}),FD=at.div({padding:"20px 16px"}),ED=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),AD=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),PD=at.div({fontSize:"28px",fontWeight:700}),LD=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),MD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),BD=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),DD=at.div({display:"flex",alignItems:"center",gap:"8px"}),RD=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),zD=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:le,color:e.color.inverseText})),ND=at.button(({theme:e})=>({background:"none",border:"none",color:le,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),OD=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),_D=at.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"?le:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),$D=30*1e3,fw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ie(),a=s.showCosts,u=r,c=!r&&t,l=async(g=!1)=>{if(!t)return;let S=o&&Date.now()-o<$D;if(!(!g&&S&&r))try{let C=q(),F=await oe(`${C}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let k=await F.json();i(k)}}catch(C){y.error("Failed to fetch usage:",C)}};cw(()=>{l()},[t]),cw(()=>{let g=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[t]);let d=()=>{n(),e()},f=()=>{let g=q();window.open(`${g}/pricing`,"_blank")},p=()=>{let g=q();window.open(`${g}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let g=Math.floor(u?.creditBalance??0),C=Math.max(g,10),F=Math.max(0,C-g),k=C>0?g/C*100:0;return Re.createElement(Re.Fragment,null,Re.createElement(uw,{onClick:e}),Re.createElement(pw,{onClick:R=>R.stopPropagation(),style:{width:"320px"}},Re.createElement(vD,{onClick:e,title:"Close"},"\xD7"),Re.createElement(cD,null,Re.createElement(uD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement(pD,null,Re.createElement(dD,null,"UI Review"),Re.createElement(fD,null,(u?.plan||"BETA").toUpperCase()))),Re.createElement(gD,null,Re.createElement(mD,null,"Credits"),Re.createElement(hD,null,g," left")),Re.createElement(xD,null,Re.createElement(yD,{percent:k})),Re.createElement(bD,null,F," used \xB7 ",g," remaining"),Re.createElement(SD,null),Re.createElement(wD,{onClick:p},"Get free credits \u2192")))}return Re.createElement(Re.Fragment,null,Re.createElement(uw,{onClick:e}),Re.createElement(pw,{onClick:g=>g.stopPropagation()},Re.createElement(kD,null,Re.createElement(CD,null,Re.createElement(TD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement("span",null,u?.email||"Loading...")),Re.createElement(ID,null,Re.createElement(dw,{onClick:d,title:"Sign out"},"\u2192"),Re.createElement(dw,{onClick:e,title:"Close"},"\xD7"))),Re.createElement(FD,null,c?Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Re.createElement(Re.Fragment,null,Re.createElement(ED,null,Re.createElement(AD,null,"Credit Balance"),Re.createElement(PD,null,"$",(u?.creditBalance??0).toFixed(2)),Re.createElement(LD,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Re.createElement(MD,null,Re.createElement(BD,null,Re.createElement(DD,null,Re.createElement(RD,null,"Current Plan"),Re.createElement(zD,null,u?.plan||"Free")),Re.createElement(ND,{onClick:f},"View detail >")),Re.createElement(OD,null,"~$0.02-0.05 per review depending on complexity"),Re.createElement(_D,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ve();import wi from"react";import{styled as gw}from"storybook/theming";je();ve();pt();De();var UD=gw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),jD=gw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),HD={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}},mw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ie(),{sessionToken:o}=we();return e!=="admin"?null:wi.createElement(UD,null,wi.createElement(jD,null,"View as:"),wi.createElement(Gx,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&oe(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=HD[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},wi.createElement("option",{value:"admin"},"Admin"),wi.createElement("option",{value:"beta"},"Beta Tester")),t&&wi.createElement(Kx,{variant:"warning"},"Previewing as ",t))};ve();je();pt();var WD=fo.div({display:"flex",alignItems:"center"}),vi=fo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),VD=fo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),GD=fo.div({position:"relative"}),qD=fo.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`}})),bw=fo.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)"}})),YD=fo.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)"}}}),KD=fo.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}})),XD=30*1e3,kg=({onOpenSettings:e})=>{let[t,n]=hw(!1),[r,o]=hw(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=we(),{userRole:c,roleOverride:l,featureFlags:d}=ie(),f=l??c;yw(()=>{(async()=>{if(!(!u||s&&Date.now()-s<XD&&i)){o(!0);try{let R=q(),z=await oe(`${R}/api/addon/account`,{headers:{Authorization:`Bearer ${u}`}});if(z.ok){let _=await z.json();a(_)}}catch(R){console.error("Failed to fetch balance:",R)}finally{o(!1)}}})()},[u,s,i,a]),yw(()=>{let F=()=>{document.visibilityState==="visible"&&t&&n(!1)},k=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",F),window.addEventListener("focus",k),()=>{document.removeEventListener("visibilitychange",F),window.removeEventListener("focus",k)}},[t]);let p=xw(()=>{n(!0)},[]),g=xw(()=>{n(!1)},[]),S=i?.creditBalance??0,C=S<2&&!r;return pn.createElement(WD,null,e&&pn.createElement(vi,null,pn.createElement(KD,{onClick:e,title:"Settings"},pn.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),u&&c==="admin"&&f==="admin"&&pn.createElement(vi,null,pn.createElement(mw,null)),pn.createElement(vi,null,pn.createElement(VD,null,"v","0.5.5")),u&&d.showCosts&&pn.createElement(vi,null,pn.createElement(bw,{onClick:p,isLow:C,title:r?"Loading...":i?C?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},r?pn.createElement(YD,null):i?`$${S.toFixed(2)}`:"...")),u&&!d.showCosts&&i&&pn.createElement(vi,null,pn.createElement(bw,{onClick:p,isLow:Math.floor(S)<=3,title:`${Math.floor(S)} review credits remaining \u2014 click to manage`},"\u26A1 ",Math.floor(S))),pn.createElement(vi,null,pn.createElement(GD,null,pn.createElement(qD,{title:"Account & Usage",onClick:p},i?.email?i.email[0].toUpperCase():"?"),t&&pn.createElement(fw,{onClose:g}))))};import Et from"react";import{styled as cr}from"storybook/theming";import Lt from"react";ve();De();je();pt();import{useCallback as ki,useRef as Sw,useEffect as QD}from"react";var go=q();y.debug("[useAuth] Module loaded, APP_URL:",go);var Bs=()=>{let e=Sw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:f,setUserCode:p,setVerificationUri:g,setPollingInterval:S,setAuthError:C,resetAuth:F}=we(),k=Sw(null),R=ki(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let x;try{x=await oe(`${go}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let D=A instanceof Error&&A.message.includes("timed out")?`Cannot reach UI Copilot server at ${go}. Is the dashboard running?`:`Connection failed: ${go} is not responding.`;C(D),y.error("[useAuth]",D);return}if(!x.ok)throw new Error("Failed to create poll code");let{poll_code:b}=await x.json();y.debug("[useAuth] Got poll_code:",b.substring(0,15)+"...");let E=600,h=700,T=window.screenX+(window.outerWidth-E)/2,I=window.screenY+(window.outerHeight-h)/2;window.open(`${go}/addon/auth?poll_code=${b}`,"figma-auth",`width=${E},height=${h},left=${T},top=${I}`),y.debug("[useAuth] Starting OAuth poll for token..."),k.current&&clearInterval(k.current);let v=async()=>{try{let P=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:b})})).json();P.status==="authorized"&&P.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),k.current&&(clearInterval(k.current),k.current=null),localStorage.setItem("uicopilot_session_token",P.session_token),c(P.session_token)):P.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),k.current&&(clearInterval(k.current),k.current=null))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};k.current=setInterval(v,2e3),setTimeout(v,1e3)}catch(x){y.error("[useAuth] OAuth flow error:",x)}},[c]),z=ki(async()=>{try{let x=await fetch(`${go}/api/addon/auth/device`,{method:"POST"});if(!x.ok)throw new Error("Failed to start device code flow");let b=await x.json();f(b.device_code),p(b.user_code),g(b.verification_uri),window.open(b.verification_uri,"_blank"),_(b.device_code,b.interval*1e3)}catch(x){throw y.error("[useAuth] Device code flow error:",x),x}},[f,p,g]),_=ki((x,b)=>{y.debug("[useAuth] Starting polling. Device code:",x,"Interval:",b),e.current&&clearInterval(e.current);let E=async()=>{try{let T=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:x})})).json();T.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null),localStorage.setItem("uicopilot_session_token",T.session_token),c(T.session_token)):(T.status==="expired"||T.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null))}catch(h){y.error("[useAuth] Polling error:",h)}};e.current=setInterval(E,b),S(b)},[f,p,g,c,S]),M=ki(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null),S(null)},[f,p,g,S]),B=ki(x=>{l(x),localStorage.setItem("uicopilot_api_key",x)},[l]),m=ki(()=>{F(),e.current&&(clearInterval(e.current),e.current=null)},[F]);return QD(()=>()=>{e.current&&clearInterval(e.current),k.current&&clearInterval(k.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setAuthMethod:d,startOAuth:R,startDeviceCode:z,cancelDeviceCode:M,saveApiKey:B,logout:m}};ve();De();je();pt();import{useCallback as Cl}from"react";var Ds=q(),qr=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Ze(),{sessionToken:a}=we(),u=Cl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Ds}/api/projects`);let f=await oe(`${Ds}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(f.ok){let p=await f.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",f.status,f.statusText)}catch(f){y.error("[useProjects] Error fetching projects:",f)}finally{i(!1)}},[a,r,i]),c=Cl(async f=>{if(!a)throw new Error("Not authenticated");let p=await oe(`${Ds}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)});if(!p.ok)throw new Error("Failed to create project");let g=await p.json();return await u(),g.project},[a,u]),l=Cl(async(f,p)=>{if(!a)throw new Error("Not authenticated");let g={};if(p.name!==void 0&&(g.name=p.name),p.description!==void 0&&(g.description=p.description),p.figmaFileUrl!==void 0&&(g.figmaFileId=p.figmaFileUrl||void 0),!(await oe(`${Ds}/api/projects/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=Cl(async f=>{if(!a)throw new Error("Not authenticated");if(!(await oe(`${Ds}/api/projects/${f}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===f&&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}};ve();var Rs=()=>{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}=rt();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)}};ve();Eg();Dg();import{useCallback as Vs,useRef as zl}from"react";De();function Al(){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 Pl=BigInt(4294967295),Rw=BigInt(32);function SR(e,t=!1){return t?{h:Number(e&Pl),l:Number(e>>Rw&Pl)}:{h:Number(e>>Rw&Pl)|0,l:Number(e&Pl)|0}}function zw(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}=SR(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Nw=(e,t,n)=>e<<n|t>>>32-n,Ow=(e,t,n)=>t<<n|e>>>32-n,_w=(e,t,n)=>t<<n-32|e>>>64-n,$w=(e,t,n)=>e<<n-32|t>>>64-n;function wR(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rg(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Ll(e,t,n=""){let r=wR(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 zg(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 Uw(e,t){Ll(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 jw(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ng(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var vR=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function kR(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function CR(e){for(let t=0;t<e.length;t++)e[t]=kR(e[t]);return e}var Og=vR?e=>e:CR;function Hw(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 Ww=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var TR=BigInt(0),Us=BigInt(1),IR=BigInt(2),FR=BigInt(7),ER=BigInt(256),AR=BigInt(113),qw=[],Yw=[],Kw=[];for(let e=0,t=Us,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],qw.push(2*(5*r+n)),Yw.push((e+1)*(e+2)/2%64);let o=TR;for(let i=0;i<7;i++)t=(t<<Us^(t>>FR)*AR)%ER,t&IR&&(o^=Us<<(Us<<BigInt(i))-Us);Kw.push(o)}var Xw=zw(Kw,!0),PR=Xw[0],LR=Xw[1],Vw=(e,t,n)=>n>32?_w(e,t,n):Nw(e,t,n),Gw=(e,t,n)=>n>32?$w(e,t,n):Ow(e,t,n);function MR(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=Vw(c,l,1)^n[a],f=Gw(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Yw[s],u=Vw(o,i,a),c=Gw(o,i,a),l=qw[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]^=PR[r],e[1]^=LR[r]}Ng(n)}var _g=class e{constructor(t,n,r,o=!1,i=24){Zn(this,"state");Zn(this,"pos",0);Zn(this,"posOut",0);Zn(this,"finished",!1);Zn(this,"state32");Zn(this,"destroyed",!1);Zn(this,"blockLen");Zn(this,"suffix");Zn(this,"outputLen");Zn(this,"enableXOF",!1);Zn(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Rg(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=jw(this.state)}clone(){return this._cloneInto()}keccak(){Og(this.state32),MR(this.state32,this.rounds),Og(this.state32),this.posOut=0,this.pos=0}update(t){zg(this),Ll(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){zg(this,!1),Ll(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 Rg(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Uw(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,Ng(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}},BR=(e,t,n,r={})=>Hw(()=>new _g(t,e,n),r);var Qw=BR(6,72,64,Ww(10));var DR=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,$g=Math.ceil,ar=Math.floor,Rn="[BigNumber Error] ",Jw=Rn+"Number primitive has more than 15 significant digits: ",Sr=1e14,He=14,Ug=9007199254740991,jg=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],mo=1e7,rn=1e9;function Zw(e){var t,n,r,o=k.prototype={constructor:k,toString:null,valueOf:null},i=new k(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,f=!1,p=1,g=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function k(m,x){var b,E,h,T,I,v,A,P,D=this;if(!(D instanceof k))return new k(m,x);if(x==null){if(m&&m._isBigNumber===!0){D.s=m.s,!m.c||m.e>d?D.c=D.e=null:m.e<l?D.c=[D.e=0]:(D.e=m.e,D.c=m.c.slice());return}if((v=typeof m=="number")&&m*0==0){if(D.s=1/m<0?(m=-m,-1):1,m===~~m){for(T=0,I=m;I>=10;I/=10,T++);T>d?D.c=D.e=null:(D.e=T,D.c=[m]);return}P=String(m)}else{if(!DR.test(P=String(m)))return r(D,P,v);D.s=P.charCodeAt(0)==45?(P=P.slice(1),-1):1}(T=P.indexOf("."))>-1&&(P=P.replace(".","")),(I=P.search(/e/i))>0?(T<0&&(T=I),T+=+P.slice(I+1),P=P.substring(0,I)):T<0&&(T=P.length)}else{if(Dt(x,2,C.length,"Base"),x==10&&F)return D=new k(m),M(D,s+D.e+1,a);if(P=String(m),v=typeof m=="number"){if(m*0!=0)return r(D,P,v,x);if(D.s=1/m<0?(P=P.slice(1),-1):1,k.DEBUG&&P.replace(/^0\.0*|\./,"").length>15)throw Error(Jw+m)}else D.s=P.charCodeAt(0)===45?(P=P.slice(1),-1):1;for(b=C.slice(0,x),T=I=0,A=P.length;I<A;I++)if(b.indexOf(E=P.charAt(I))<0){if(E=="."){if(I>T){T=A;continue}}else if(!h&&(P==P.toUpperCase()&&(P=P.toLowerCase())||P==P.toLowerCase()&&(P=P.toUpperCase()))){h=!0,I=-1,T=0;continue}return r(D,String(m),v,x)}v=!1,P=n(P,x,10,D.s),(T=P.indexOf("."))>-1?P=P.replace(".",""):T=P.length}for(I=0;P.charCodeAt(I)===48;I++);for(A=P.length;P.charCodeAt(--A)===48;);if(P=P.slice(I,++A)){if(A-=I,v&&k.DEBUG&&A>15&&(m>Ug||m!==ar(m)))throw Error(Jw+D.s*m);if((T=T-I-1)>d)D.c=D.e=null;else if(T<l)D.c=[D.e=0];else{if(D.e=T,D.c=[],I=(T+1)%He,T<0&&(I+=He),I<A){for(I&&D.c.push(+P.slice(0,I)),A-=He;I<A;)D.c.push(+P.slice(I,I+=He));I=He-(P=P.slice(I)).length}else I-=A;for(;I--;P+="0");D.c.push(+P)}}else D.c=[D.e=0]}k.clone=Zw,k.ROUND_UP=0,k.ROUND_DOWN=1,k.ROUND_CEIL=2,k.ROUND_FLOOR=3,k.ROUND_HALF_UP=4,k.ROUND_HALF_DOWN=5,k.ROUND_HALF_EVEN=6,k.ROUND_HALF_CEIL=7,k.ROUND_HALF_FLOOR=8,k.EUCLID=9,k.config=k.set=function(m){var x,b;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(x="DECIMAL_PLACES")&&(b=m[x],Dt(b,0,rn,x),s=b),m.hasOwnProperty(x="ROUNDING_MODE")&&(b=m[x],Dt(b,0,8,x),a=b),m.hasOwnProperty(x="EXPONENTIAL_AT")&&(b=m[x],b&&b.pop?(Dt(b[0],-rn,0,x),Dt(b[1],0,rn,x),u=b[0],c=b[1]):(Dt(b,-rn,rn,x),u=-(c=b<0?-b:b))),m.hasOwnProperty(x="RANGE"))if(b=m[x],b&&b.pop)Dt(b[0],-rn,-1,x),Dt(b[1],1,rn,x),l=b[0],d=b[1];else if(Dt(b,-rn,rn,x),b)l=-(d=b<0?-b:b);else throw Error(Rn+x+" cannot be zero: "+b);if(m.hasOwnProperty(x="CRYPTO"))if(b=m[x],b===!!b)if(b)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=b;else throw f=!b,Error(Rn+"crypto unavailable");else f=b;else throw Error(Rn+x+" not true or false: "+b);if(m.hasOwnProperty(x="MODULO_MODE")&&(b=m[x],Dt(b,0,9,x),p=b),m.hasOwnProperty(x="POW_PRECISION")&&(b=m[x],Dt(b,0,rn,x),g=b),m.hasOwnProperty(x="FORMAT"))if(b=m[x],typeof b=="object")S=b;else throw Error(Rn+x+" not an object: "+b);if(m.hasOwnProperty(x="ALPHABET"))if(b=m[x],typeof b=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(b))F=b.slice(0,10)=="0123456789",C=b;else throw Error(Rn+x+" invalid: "+b)}else throw Error(Rn+"Object expected: "+m);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:g,FORMAT:S,ALPHABET:C}},k.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!k.DEBUG)return!0;var x,b,E=m.c,h=m.e,T=m.s;e:if({}.toString.call(E)=="[object Array]"){if((T===1||T===-1)&&h>=-rn&&h<=rn&&h===ar(h)){if(E[0]===0){if(h===0&&E.length===1)return!0;break e}if(x=(h+1)%He,x<1&&(x+=He),String(E[0]).length==x){for(x=0;x<E.length;x++)if(b=E[x],b<0||b>=Sr||b!==ar(b))break e;if(b!==0)return!0}}}else if(E===null&&h===null&&(T===null||T===1||T===-1))return!0;throw Error(Rn+"Invalid BigNumber: "+m)},k.maximum=k.max=function(){return z(arguments,-1)},k.minimum=k.min=function(){return z(arguments,1)},k.random=(function(){var m=9007199254740992,x=Math.random()*m&2097151?function(){return ar(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(b){var E,h,T,I,v,A=0,P=[],D=new k(i);if(b==null?b=s:Dt(b,0,rn),I=$g(b/He),f)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(I*=2));A<I;)v=E[A]*131072+(E[A+1]>>>11),v>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),E[A]=h[0],E[A+1]=h[1]):(P.push(v%1e14),A+=2);A=I/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(I*=7);A<I;)v=(E[A]&31)*281474976710656+E[A+1]*1099511627776+E[A+2]*4294967296+E[A+3]*16777216+(E[A+4]<<16)+(E[A+5]<<8)+E[A+6],v>=9e15?crypto.randomBytes(7).copy(E,A):(P.push(v%1e14),A+=7);A=I/7}else throw f=!1,Error(Rn+"crypto unavailable");if(!f)for(;A<I;)v=x(),v<9e15&&(P[A++]=v%1e14);for(I=P[--A],b%=He,I&&b&&(v=jg[He-b],P[A]=ar(I/v)*v);P[A]===0;P.pop(),A--);if(A<0)P=[T=0];else{for(T=-1;P[0]===0;P.splice(0,1),T-=He);for(A=1,v=P[0];v>=10;v/=10,A++);A<He&&(T-=He-A)}return D.e=T,D.c=P,D}})(),k.sum=function(){for(var m=1,x=arguments,b=new k(x[0]);m<x.length;)b=b.plus(x[m++]);return b},n=(function(){var m="0123456789";function x(b,E,h,T){for(var I,v=[0],A,P=0,D=b.length;P<D;){for(A=v.length;A--;v[A]*=E);for(v[0]+=T.indexOf(b.charAt(P++)),I=0;I<v.length;I++)v[I]>h-1&&(v[I+1]==null&&(v[I+1]=0),v[I+1]+=v[I]/h|0,v[I]%=h)}return v.reverse()}return function(b,E,h,T,I){var v,A,P,D,N,w,j,G,L=b.indexOf("."),K=s,ee=a;for(L>=0&&(D=g,g=0,b=b.replace(".",""),G=new k(E),w=G.pow(b.length-L),g=D,G.c=x(Yr(sr(w.c),w.e,"0"),10,h,m),G.e=G.c.length),j=x(b,E,h,I?(v=C,m):(v=m,C)),P=D=j.length;j[--D]==0;j.pop());if(!j[0])return v.charAt(0);if(L<0?--P:(w.c=j,w.e=P,w.s=T,w=t(w,G,K,ee,h),j=w.c,N=w.r,P=w.e),A=P+K+1,L=j[A],D=h/2,N=N||A<0||j[A+1]!=null,N=ee<4?(L!=null||N)&&(ee==0||ee==(w.s<0?3:2)):L>D||L==D&&(ee==4||N||ee==6&&j[A-1]&1||ee==(w.s<0?8:7)),A<1||!j[0])b=N?Yr(v.charAt(1),-K,v.charAt(0)):v.charAt(0);else{if(j.length=A,N)for(--h;++j[--A]>h;)j[A]=0,A||(++P,j=[1].concat(j));for(D=j.length;!j[--D];);for(L=0,b="";L<=D;b+=v.charAt(j[L++]));b=Yr(b,P,v.charAt(0))}return b}})(),t=(function(){function m(E,h,T){var I,v,A,P,D=0,N=E.length,w=h%mo,j=h/mo|0;for(E=E.slice();N--;)A=E[N]%mo,P=E[N]/mo|0,I=j*A+P*w,v=w*A+I%mo*mo+D,D=(v/T|0)+(I/mo|0)+j*P,E[N]=v%T;return D&&(E=[D].concat(E)),E}function x(E,h,T,I){var v,A;if(T!=I)A=T>I?1:-1;else for(v=A=0;v<T;v++)if(E[v]!=h[v]){A=E[v]>h[v]?1:-1;break}return A}function b(E,h,T,I){for(var v=0;T--;)E[T]-=v,v=E[T]<h[T]?1:0,E[T]=v*I+E[T]-h[T];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,h,T,I,v){var A,P,D,N,w,j,G,L,K,ee,re,de,ae,qe,tt,se,pe,Ie=E.s==h.s?1:-1,ze=E.c,me=h.c;if(!ze||!ze[0]||!me||!me[0])return new k(!E.s||!h.s||(ze?me&&ze[0]==me[0]:!me)?NaN:ze&&ze[0]==0||!me?Ie*0:Ie/0);for(L=new k(Ie),K=L.c=[],P=E.e-h.e,Ie=T+P+1,v||(v=Sr,P=lr(E.e/He)-lr(h.e/He),Ie=Ie/He|0),D=0;me[D]==(ze[D]||0);D++);if(me[D]>(ze[D]||0)&&P--,Ie<0)K.push(1),N=!0;else{for(qe=ze.length,se=me.length,D=0,Ie+=2,w=ar(v/(me[0]+1)),w>1&&(me=m(me,w,v),ze=m(ze,w,v),se=me.length,qe=ze.length),ae=se,ee=ze.slice(0,se),re=ee.length;re<se;ee[re++]=0);pe=me.slice(),pe=[0].concat(pe),tt=me[0],me[1]>=v/2&&tt++;do{if(w=0,A=x(me,ee,se,re),A<0){if(de=ee[0],se!=re&&(de=de*v+(ee[1]||0)),w=ar(de/tt),w>1)for(w>=v&&(w=v-1),j=m(me,w,v),G=j.length,re=ee.length;x(j,ee,G,re)==1;)w--,b(j,se<G?pe:me,G,v),G=j.length,A=1;else w==0&&(A=w=1),j=me.slice(),G=j.length;if(G<re&&(j=[0].concat(j)),b(ee,j,re,v),re=ee.length,A==-1)for(;x(me,ee,se,re)<1;)w++,b(ee,se<re?pe:me,re,v),re=ee.length}else A===0&&(w++,ee=[0]);K[D++]=w,ee[0]?ee[re++]=ze[ae]||0:(ee=[ze[ae]],re=1)}while((ae++<qe||ee[0]!=null)&&Ie--);N=ee[0]!=null,K[0]||K.splice(0,1)}if(v==Sr){for(D=1,Ie=K[0];Ie>=10;Ie/=10,D++);M(L,T+(L.e=D+P*He-1)+1,I,N)}else L.e=P,L.r=+N;return L}})();function R(m,x,b,E){var h,T,I,v,A;if(b==null?b=a:Dt(b,0,8),!m.c)return m.toString();if(h=m.c[0],I=m.e,x==null)A=sr(m.c),A=E==1||E==2&&(I<=u||I>=c)?Bl(A,I):Yr(A,I,"0");else if(m=M(new k(m),x,b),T=m.e,A=sr(m.c),v=A.length,E==1||E==2&&(x<=T||T<=u)){for(;v<x;A+="0",v++);A=Bl(A,T)}else if(x-=I+(E===2&&T>I),A=Yr(A,T,"0"),T+1>v){if(--x>0)for(A+=".";x--;A+="0");}else if(x+=T-v,x>0)for(T+1==v&&(A+=".");x--;A+="0");return m.s<0&&h?"-"+A:A}function z(m,x){for(var b,E,h=1,T=new k(m[0]);h<m.length;h++)E=new k(m[h]),(!E.s||(b=jo(T,E))===x||b===0&&T.s===x)&&(T=E);return T}function _(m,x,b){for(var E=1,h=x.length;!x[--h];x.pop());for(h=x[0];h>=10;h/=10,E++);return(b=E+b*He-1)>d?m.c=m.e=null:b<l?m.c=[m.e=0]:(m.e=b,m.c=x),m}r=(function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,b=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,I,v,A){var P,D=v?I:I.replace(h,"");if(E.test(D))T.s=isNaN(D)?null:D<0?-1:1;else{if(!v&&(D=D.replace(m,function(N,w,j){return P=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==P?w:N}),A&&(P=A,D=D.replace(x,"$1").replace(b,"0.$1")),I!=D))return new k(D,P);if(k.DEBUG)throw Error(Rn+"Not a"+(A?" base "+A:"")+" number: "+I);T.s=null}T.c=T.e=null}})();function M(m,x,b,E){var h,T,I,v,A,P,D,N=m.c,w=jg;if(N){e:{for(h=1,v=N[0];v>=10;v/=10,h++);if(T=x-h,T<0)T+=He,I=x,A=N[P=0],D=ar(A/w[h-I-1]%10);else if(P=$g((T+1)/He),P>=N.length)if(E){for(;N.length<=P;N.push(0));A=D=0,h=1,T%=He,I=T-He+1}else break e;else{for(A=v=N[P],h=1;v>=10;v/=10,h++);T%=He,I=T-He+h,D=I<0?0:ar(A/w[h-I-1]%10)}if(E=E||x<0||N[P+1]!=null||(I<0?A:A%w[h-I-1]),E=b<4?(D||E)&&(b==0||b==(m.s<0?3:2)):D>5||D==5&&(b==4||E||b==6&&(T>0?I>0?A/w[h-I]:0:N[P-1])%10&1||b==(m.s<0?8:7)),x<1||!N[0])return N.length=0,E?(x-=m.e+1,N[0]=w[(He-x%He)%He],m.e=-x||0):N[0]=m.e=0,m;if(T==0?(N.length=P,v=1,P--):(N.length=P+1,v=w[He-T],N[P]=I>0?ar(A/w[h-I]%w[I])*v:0),E)for(;;)if(P==0){for(T=1,I=N[0];I>=10;I/=10,T++);for(I=N[0]+=v,v=1;I>=10;I/=10,v++);T!=v&&(m.e++,N[0]==Sr&&(N[0]=1));break}else{if(N[P]+=v,N[P]!=Sr)break;N[P--]=0,v=1}for(T=N.length;N[--T]===0;N.pop());}m.e>d?m.c=m.e=null:m.e<l&&(m.c=[m.e=0])}return m}function B(m){var x,b=m.e;return b===null?m.toString():(x=sr(m.c),x=b<=u||b>=c?Bl(x,b):Yr(x,b,"0"),m.s<0?"-"+x:x)}return o.absoluteValue=o.abs=function(){var m=new k(this);return m.s<0&&(m.s=1),m},o.comparedTo=function(m,x){return jo(this,new k(m,x))},o.decimalPlaces=o.dp=function(m,x){var b,E,h,T=this;if(m!=null)return Dt(m,0,rn),x==null?x=a:Dt(x,0,8),M(new k(T),m+T.e+1,x);if(!(b=T.c))return null;if(E=((h=b.length-1)-lr(this.e/He))*He,h=b[h])for(;h%10==0;h/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(m,x){return t(this,new k(m,x),s,a)},o.dividedToIntegerBy=o.idiv=function(m,x){return t(this,new k(m,x),0,1)},o.exponentiatedBy=o.pow=function(m,x){var b,E,h,T,I,v,A,P,D,N=this;if(m=new k(m),m.c&&!m.isInteger())throw Error(Rn+"Exponent not an integer: "+B(m));if(x!=null&&(x=new k(x)),v=m.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!m.c||!m.c[0])return D=new k(Math.pow(+B(N),v?m.s*(2-Ml(m)):+B(m))),x?D.mod(x):D;if(A=m.s<0,x){if(x.c?!x.c[0]:!x.s)return new k(NaN);E=!A&&N.isInteger()&&x.isInteger(),E&&(N=N.mod(x))}else{if(m.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||v&&N.c[1]>=24e7:N.c[0]<8e13||v&&N.c[0]<=9999975e7)))return T=N.s<0&&Ml(m)?-0:0,N.e>-1&&(T=1/T),new k(A?1/T:T);g&&(T=$g(g/He+2))}for(v?(b=new k(.5),A&&(m.s=1),P=Ml(m)):(h=Math.abs(+B(m)),P=h%2),D=new k(i);;){if(P){if(D=D.times(N),!D.c)break;T?D.c.length>T&&(D.c.length=T):E&&(D=D.mod(x))}if(h){if(h=ar(h/2),h===0)break;P=h%2}else if(m=m.times(b),M(m,m.e+1,1),m.e>14)P=Ml(m);else{if(h=+B(m),h===0)break;P=h%2}N=N.times(N),T?N.c&&N.c.length>T&&(N.c.length=T):E&&(N=N.mod(x))}return E?D:(A&&(D=i.div(D)),x?D.mod(x):T?M(D,g,a,I):D)},o.integerValue=function(m){var x=new k(this);return m==null?m=a:Dt(m,0,8),M(x,x.e+1,m)},o.isEqualTo=o.eq=function(m,x){return jo(this,new k(m,x))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(m,x){return jo(this,new k(m,x))>0},o.isGreaterThanOrEqualTo=o.gte=function(m,x){return(x=jo(this,new k(m,x)))===1||x===0},o.isInteger=function(){return!!this.c&&lr(this.e/He)>this.c.length-2},o.isLessThan=o.lt=function(m,x){return jo(this,new k(m,x))<0},o.isLessThanOrEqualTo=o.lte=function(m,x){return(x=jo(this,new k(m,x)))===-1||x===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(m,x){var b,E,h,T,I=this,v=I.s;if(m=new k(m,x),x=m.s,!v||!x)return new k(NaN);if(v!=x)return m.s=-x,I.plus(m);var A=I.e/He,P=m.e/He,D=I.c,N=m.c;if(!A||!P){if(!D||!N)return D?(m.s=-x,m):new k(N?I:NaN);if(!D[0]||!N[0])return N[0]?(m.s=-x,m):new k(D[0]?I:a==3?-0:0)}if(A=lr(A),P=lr(P),D=D.slice(),v=A-P){for((T=v<0)?(v=-v,h=D):(P=A,h=N),h.reverse(),x=v;x--;h.push(0));h.reverse()}else for(E=(T=(v=D.length)<(x=N.length))?v:x,v=x=0;x<E;x++)if(D[x]!=N[x]){T=D[x]<N[x];break}if(T&&(h=D,D=N,N=h,m.s=-m.s),x=(E=N.length)-(b=D.length),x>0)for(;x--;D[b++]=0);for(x=Sr-1;E>v;){if(D[--E]<N[E]){for(b=E;b&&!D[--b];D[b]=x);--D[b],D[E]+=Sr}D[E]-=N[E]}for(;D[0]==0;D.splice(0,1),--P);return D[0]?_(m,D,P):(m.s=a==3?-1:1,m.c=[m.e=0],m)},o.modulo=o.mod=function(m,x){var b,E,h=this;return m=new k(m,x),!h.c||!m.s||m.c&&!m.c[0]?new k(NaN):!m.c||h.c&&!h.c[0]?new k(h):(p==9?(E=m.s,m.s=1,b=t(h,m,0,3),m.s=E,b.s*=E):b=t(h,m,0,p),m=h.minus(b.times(m)),!m.c[0]&&p==1&&(m.s=h.s),m)},o.multipliedBy=o.times=function(m,x){var b,E,h,T,I,v,A,P,D,N,w,j,G,L,K,ee=this,re=ee.c,de=(m=new k(m,x)).c;if(!re||!de||!re[0]||!de[0])return!ee.s||!m.s||re&&!re[0]&&!de||de&&!de[0]&&!re?m.c=m.e=m.s=null:(m.s*=ee.s,!re||!de?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(E=lr(ee.e/He)+lr(m.e/He),m.s*=ee.s,A=re.length,N=de.length,A<N&&(G=re,re=de,de=G,h=A,A=N,N=h),h=A+N,G=[];h--;G.push(0));for(L=Sr,K=mo,h=N;--h>=0;){for(b=0,w=de[h]%K,j=de[h]/K|0,I=A,T=h+I;T>h;)P=re[--I]%K,D=re[I]/K|0,v=j*P+D*w,P=w*P+v%K*K+G[T]+b,b=(P/L|0)+(v/K|0)+j*D,G[T--]=P%L;G[T]=b}return b?++E:G.splice(0,1),_(m,G,E)},o.negated=function(){var m=new k(this);return m.s=-m.s||null,m},o.plus=function(m,x){var b,E=this,h=E.s;if(m=new k(m,x),x=m.s,!h||!x)return new k(NaN);if(h!=x)return m.s=-x,E.minus(m);var T=E.e/He,I=m.e/He,v=E.c,A=m.c;if(!T||!I){if(!v||!A)return new k(h/0);if(!v[0]||!A[0])return A[0]?m:new k(v[0]?E:h*0)}if(T=lr(T),I=lr(I),v=v.slice(),h=T-I){for(h>0?(I=T,b=A):(h=-h,b=v),b.reverse();h--;b.push(0));b.reverse()}for(h=v.length,x=A.length,h-x<0&&(b=A,A=v,v=b,x=h),h=0;x;)h=(v[--x]=v[x]+A[x]+h)/Sr|0,v[x]=Sr===v[x]?0:v[x]%Sr;return h&&(v=[h].concat(v),++I),_(m,v,I)},o.precision=o.sd=function(m,x){var b,E,h,T=this;if(m!=null&&m!==!!m)return Dt(m,1,rn),x==null?x=a:Dt(x,0,8),M(new k(T),m,x);if(!(b=T.c))return null;if(h=b.length-1,E=h*He+1,h=b[h]){for(;h%10==0;h/=10,E--);for(h=b[0];h>=10;h/=10,E++);}return m&&T.e+1>E&&(E=T.e+1),E},o.shiftedBy=function(m){return Dt(m,-Ug,Ug),this.times("1e"+m)},o.squareRoot=o.sqrt=function(){var m,x,b,E,h,T=this,I=T.c,v=T.s,A=T.e,P=s+4,D=new k("0.5");if(v!==1||!I||!I[0])return new k(!v||v<0&&(!I||I[0])?NaN:I?T:1/0);if(v=Math.sqrt(+B(T)),v==0||v==1/0?(x=sr(I),(x.length+A)%2==0&&(x+="0"),v=Math.sqrt(+x),A=lr((A+1)/2)-(A<0||A%2),v==1/0?x="5e"+A:(x=v.toExponential(),x=x.slice(0,x.indexOf("e")+1)+A),b=new k(x)):b=new k(v+""),b.c[0]){for(A=b.e,v=A+P,v<3&&(v=0);;)if(h=b,b=D.times(h.plus(t(T,h,P,1))),sr(h.c).slice(0,v)===(x=sr(b.c)).slice(0,v))if(b.e<A&&--v,x=x.slice(v-3,v+1),x=="9999"||!E&&x=="4999"){if(!E&&(M(h,h.e+s+2,0),h.times(h).eq(T))){b=h;break}P+=4,v+=4,E=1}else{(!+x||!+x.slice(1)&&x.charAt(0)=="5")&&(M(b,b.e+s+2,1),m=!b.times(b).eq(T));break}}return M(b,b.e+s+1,a,m)},o.toExponential=function(m,x){return m!=null&&(Dt(m,0,rn),m++),R(this,m,x,1)},o.toFixed=function(m,x){return m!=null&&(Dt(m,0,rn),m=m+this.e+1),R(this,m,x)},o.toFormat=function(m,x,b){var E,h=this;if(b==null)m!=null&&x&&typeof x=="object"?(b=x,x=null):m&&typeof m=="object"?(b=m,m=x=null):b=S;else if(typeof b!="object")throw Error(Rn+"Argument not an object: "+b);if(E=h.toFixed(m,x),h.c){var T,I=E.split("."),v=+b.groupSize,A=+b.secondaryGroupSize,P=b.groupSeparator||"",D=I[0],N=I[1],w=h.s<0,j=w?D.slice(1):D,G=j.length;if(A&&(T=v,v=A,A=T,G-=T),v>0&&G>0){for(T=G%v||v,D=j.substr(0,T);T<G;T+=v)D+=P+j.substr(T,v);A>0&&(D+=P+j.slice(T)),w&&(D="-"+D)}E=N?D+(b.decimalSeparator||"")+((A=+b.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(b.fractionGroupSeparator||"")):N):D}return(b.prefix||"")+E+(b.suffix||"")},o.toFraction=function(m){var x,b,E,h,T,I,v,A,P,D,N,w,j=this,G=j.c;if(m!=null&&(v=new k(m),!v.isInteger()&&(v.c||v.s!==1)||v.lt(i)))throw Error(Rn+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+B(v));if(!G)return new k(j);for(x=new k(i),P=b=new k(i),E=A=new k(i),w=sr(G),T=x.e=w.length-j.e-1,x.c[0]=jg[(I=T%He)<0?He+I:I],m=!m||v.comparedTo(x)>0?T>0?x:P:v,I=d,d=1/0,v=new k(w),A.c[0]=0;D=t(v,x,0,1),h=b.plus(D.times(E)),h.comparedTo(m)!=1;)b=E,E=h,P=A.plus(D.times(h=P)),A=h,x=v.minus(D.times(h=x)),v=h;return h=t(m.minus(b),E,0,1),A=A.plus(h.times(P)),b=b.plus(h.times(E)),A.s=P.s=j.s,T=T*2,N=t(P,E,T,a).minus(j).abs().comparedTo(t(A,b,T,a).minus(j).abs())<1?[P,E]:[A,b],d=I,N},o.toNumber=function(){return+B(this)},o.toPrecision=function(m,x){return m!=null&&Dt(m,1,rn),R(this,m,x,2)},o.toString=function(m){var x,b=this,E=b.s,h=b.e;return h===null?E?(x="Infinity",E<0&&(x="-"+x)):x="NaN":(m==null?x=h<=u||h>=c?Bl(sr(b.c),h):Yr(sr(b.c),h,"0"):m===10&&F?(b=M(new k(b),s+h+1,a),x=Yr(sr(b.c),b.e,"0")):(Dt(m,2,C.length,"Base"),x=n(Yr(sr(b.c),h,"0"),10,m,E,!0)),E<0&&b.c[0]&&(x="-"+x)),x},o.valueOf=o.toJSON=function(){return B(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&k.set(e),k}function lr(e){var t=e|0;return e>0||e===t?t:t-1}function sr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=He-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function jo(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 Dt(e,t,n,r){if(e<t||e>n||e!==ar(e))throw Error(Rn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Ml(e){var t=e.c.length-1;return lr(e.e/He)==t&&e.c[t]%2!=0}function Bl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Yr(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 RR=Zw(),ev=RR;var zR=24,js=32,NR=()=>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,Wg=NR(),Hg=(e=4,t=Wg)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function OR(e){let t=new ev(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var nv=(e="")=>{let t=new TextEncoder;return OR(Qw(t.encode(e))).toString(36).slice(1)},tv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),_R=e=>tv[Math.floor(e()*tv.length)],$R=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=Wg}={})=>{let n=Object.keys(e).toString(),r=n.length?n+Hg(js,t):Hg(js,t);return nv(r).substring(0,js)},UR=e=>()=>e++,jR=476782367,rv=({random:e=Wg,counter:t=UR(Math.floor(e()*jR)),length:n=zR,fingerprint:r=$R({random:e})}={})=>{if(n>js)throw new Error(`Length must be between 2 and ${js}. Received: ${n}`);return function(){let i=_R(e),s=Date.now().toString(36),a=t().toString(36),u=Hg(n,e),c=`${s+u+a+r}`;return`${i+nv(c).substring(1,n)}`}},ho=HR(rv);function HR(e){let t;return()=>(t||(t=e()),t())}var GR=Pa(sv());Ls();De();var Dl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function qR(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function Vg(e,t){let n=[],r=e.split(`
|
|
15
|
-
`);for(let s=0;s<r.length;s++){let a=qR(r[s]),u=
|
|
16
|
-
`)}else r.push(i)}return n.description=r.join(" ").trim(),n}De();var Hs=null,av=0,XR=3e4;async function QR(){let e=Date.now();if(Hs&&e-av<XR)return Hs;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 Hs=n.entries||n.stories||{},av=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Hs).length),Hs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ws(e){try{let n=(await QR())[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 Gg(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function JR(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 qg(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):JR(e.type,t)}De();function ZR(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 ez(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 tz(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 nz(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 Yg(e){if(!e||e.length===0)return[];let t=e.filter(i=>!tz(i)),n=[],r=[];for(let i of t){let s=ZR(i),a=ez(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(nz(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}De();je();import{addons as Rl}from"storybook/manager-api";var Kg="uireview/badge",Ii={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function rz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function oz(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 iz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Fi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function cv(e){if(Fi())try{Rl.getChannel().emit(Ii.REVIEW_START,{storyId:e})}catch{}}function xo(e,t){if(Fi())try{Rl.getChannel().emit(Ii.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function uv(e){if(Fi())try{Rl.getChannel().emit(Ii.REVIEW_ERROR,{storyId:e})}catch{}}function lv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}function pv(e){let t=Rl.getChannel(),n=o=>i=>{Fi()&&o(i)};t.on(Ii.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:Kg,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Ii.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:rz(i),typeId:Kg,storyId:o,title:iz(i),description:oz(i)}])})),t.on(Ii.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:Kg,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Fi();r||lv(e),setInterval(()=>{let o=Fi();o!==r&&(r=o,o||lv(e))},1500)}var Xg=q(),Qg=180;function yo(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 Jg=()=>{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:f,setReviewResults:p,setShowReviewMenu:g,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:_,setStreamingStatus:M,setFullPrompt:B,setFullResponse:m,setFigmaImageUrl:x,storybookImageUrl:b,setStorybookImageUrl:E,setFigmaDimensions:h,setMultiModelResults:T,updateMultiModelStreamingMessages:I,setModelCompleted:v,setActiveModelId:A,resetReview:P,addReview:D,setReviewDetailTab:N,includeTextComparison:w,usePromptCache:j,setApplyFixesResult:G,featureFlags:L}=ie(),{sessionToken:K,usageData:ee,setUsageData:re}=we(),{selectedProjectId:de}=Ze(),{currentStoryId:ae,currentStoryName:qe}=rt(),tt=zl(ee);tt.current=ee;let se=zl(null),pe=zl(null),Ie=zl({}),ze=Vs((Ge,lt)=>{k({role:Ge,content:lt})},[k]),me=Vs((Ge,lt)=>{_(Ge),M(lt)},[_,M]),Nt=Vs(async Ge=>{let{isIteration:lt=!1,parentReviewId:nt=null}=Ge||{};if(!K)throw new Error("Not authenticated");if(!de)throw new Error("No project selected");if(!ae||!qe)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let ne=Date.now();try{d(!0),f(null),p(null),N("issues"),G(null),ae&&L.enableReviewBadges&&cv(ae),pe.current&&clearTimeout(pe.current),pe.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${Qg}s timeout`),se.current&&se.current.abort(),k({role:"system",content:`Review auto-stopped after ${Qg} seconds timeout.`})},Qg*1e3),B(""),m(""),C(!0),F(!1),z(),me(0,"Starting review..."),me(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await Al(),y.debug("[Review] Iframe reloaded, styles should be fresh"),me(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[W,Ae,ge]=await Promise.all([Fl({sessionToken:K||void 0}),Promise.resolve($s()),Promise.resolve(Bg())]);if(W&&W!==b&&(E(W),y.debug("[Review] Storybook screenshot captured and set")),!Ae)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:H,textElementStyles:Pe,nestedElementStyles:Ne}=Ae;ge?y.debug("[Review] DOM tree extracted:",{selector:ge.selector,childrenCount:ge.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")),me(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:ae,name:qe});let xt=mt.getState().currentMapping?.figmaNodeId??null,Un=mt.getState().figmaImageUrl;if(xt&&(y.debug("[Review] Using Figma node ID from store:",xt),Un&&(me(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!xt)try{let Xe=await fetch(`${Xg}/api/mappings?projectId=${de}&storyId=${ae}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`}});if(Xe.ok){let Bt=await Xe.json();Bt.mapping?.figmaNodeId?(xt=Bt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",xt)):y.debug("[Review] No mapping found for story:",ae)}else y.debug("[Review] Failed to fetch mapping:",Xe.status)}catch(Xe){y.error("[Review] Error fetching mapping:",Xe)}if(xt&&!Un){me(65,"Fetching Figma design...");try{let Xe=await fetch(`${Xg}/api/figma/frames?projectId=${de}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`}});if(Xe.ok){let Ot=(await Xe.json()).thumbnails?.[xt];Ot?(x(Ot),y.debug("[Review] Figma thumbnail fetched and displayed:",Ot)):y.warn("[Review] No thumbnail found for node:",xt)}else y.warn("[Review] Failed to fetch Figma frames:",Xe.status)}catch(Xe){y.error("[Review] Error fetching Figma frames:",Xe)}}if(!xt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');me(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let Qn={projectId:de,storyId:ae,storyName:qe,storybookScreenshot:W,computedStyles:O,declaredStyles:U,textElementStyles:Pe,nestedElementStyles:Ne,componentMarkup:H,domTree:ge,figmaNodeId:xt,figmaImageUrl:Un||void 0,aiModels:l,includeTextComparison:w,usePromptCache:j,parentReviewId:lt?nt:void 0,isIteration:lt};y.debug("[Review] Request payload:",{...Qn,storybookScreenshot:W?`${W.substring(0,50)}...`:null,domTree:ge?{selector:ge.selector,childrenCount:ge.children.length}:null}),se.current=new AbortController;let In=await fetch(`${Xg}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`},body:JSON.stringify(Qn),signal:se.current.signal});if(y.debug("[Review] Response status:",In.status,In.statusText),!In.ok){let Xe=await In.json();if(y.error("[Review] API error response:",Xe),In.status===429){let Bt=Xe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Bt} seconds before trying again.`)}if(In.status===402){if(Xe.code==="INSUFFICIENT_CREDITS"){let Bt=Xe.details?.required??1,Ot=Xe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Bt} credit(s) but you have ${Ot}. Visit Settings to add more.`)}throw Xe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Xe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Xe.message||"Payment required")}throw In.status===401&&Xe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Xe.error||Xe.message||"Review request failed")}let oo=In.body?.getReader(),bn=new TextDecoder,Ir="",Zt="",Oe=null,Qc=null,jx=l.length>1,Bo={},Zi={},A8={};if(!oo)throw new Error("Response body is not readable");let Hx=mt.getState().streamingMessages.length;for(ze("assistant","");;){let{done:Xe,value:Bt}=await oo.read();if(Xe)break;Ir+=bn.decode(Bt,{stream:!0});let Ot=Ir.split(`
|
|
17
|
-
`);Ir=Ot.pop()||"";for(let jn of Ot)if(jn.startsWith("data: ")){let ln=jn.slice(6);if(ln==="[DONE]")continue;try{let
|
|
12
|
+
--`+new Array((n||t.length)+1).join("-")+"^"})}var Cb=$(()=>{"use strict";Xa()});var vA,kA,CA,TA,IA,Tb,dl,Ib=$(()=>{"use strict";Cb();vA=9,kA=10,CA=12,TA=13,IA=32,Tb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),dl=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&&Tb[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!==TA&&n!==kA&&n!==CA&&n!==IA&&n!==vA)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 kb(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||Tb[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 Mb(e){let t=null,n=null;return e.eat(ml),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Yu?(e.pos++,e.skipWs(),e.charCode()!==Vu&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(Vu),{min:Number(t),max:n?Number(n):0}}function BA(e){let t=null,n=!1;switch(e.charCode()){case zb:e.pos++,t={min:0,max:0};break;case qu:e.pos++,t={min:1,max:0};break;case gl:e.pos++,t={min:0,max:1};break;case Gu:e.pos++,n=!0,e.charCode()===ml?t=Mb(e):e.charCode()===gl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case ml:t=Mb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Gr(e,t){let n=BA(e);return n!==null?(n.term=t,e.charCode()===Gu&&e.charCodeAt(e.pos-1)===qu||e.charCode()===gl&&e.charCodeAt(e.pos-1)===Vu?Gr(e,n):n):t}function Hu(e){let t=e.peek();return t===""?null:Gr(e,{type:"Token",value:t})}function DA(e){let t;return e.eat(Ku),e.eat(fl),t=e.scanWord(),e.eat(fl),e.eat(Wu),Gr(e,{type:"Property",name:t})}function RA(e){let t=null,n=null,r=1;return e.eat(bs),e.charCode()===Eb&&(e.peek(),r=-1),r==-1&&e.charCode()===Pb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Yu),e.skipWs(),e.charCode()===Pb?e.peek():(r=1,e.charCode()===Eb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(hi),{type:"Range",min:t,max:n}}function zA(e){let t,n=null;if(e.eat(Ku),t=e.scanWord(),t==="boolean-expr"){e.eat(bs);let r=hl(e,hi);return e.eat(hi),e.eat(Wu),Gr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Db&&e.nextCharCode()===Rb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===bs&&(e.skipWs(),n=RA(e)),e.eat(Wu),Gr(e,{type:"Type",name:t,opts:n})}function NA(e){let t=e.scanWord();return e.charCode()===Db?(e.pos++,{type:"Function",name:t}):Gr(e,{type:"Keyword",name:t})}function OA(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)=>Lb[o]-Lb[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 hl(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?hl(e,Rb):$A(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:OA(r,n)||" ",disallowEmpty:!1,explicit:!1}}function _A(e){let t;return e.eat(bs),t=hl(e,hi),e.eat(hi),t.explicit=!0,e.charCode()===Bb&&(e.pos++,t.disallowEmpty=!0),t}function $A(e){let t=e.charCode();switch(t){case hi:break;case bs:return Gr(e,_A(e));case Ku:return e.nextCharCode()===fl?DA(e):zA(e);case Ab:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Ab?2:1))};case Fb:return e.pos++,e.eat(Fb),{type:"Combinator",value:"&&"};case Yu:return e.pos++,{type:"Comma"};case fl:return Gr(e,{type:"String",value:e.scanString()});case LA:case FA:case EA:case PA:case AA:return{type:"Spaces",value:e.scanSpaces()};case MA:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Hu(e);case zb:case qu:case gl:case Gu:case Bb:break;case ml:if(t=e.nextCharCode(),t<48||t>57)return Hu(e);break;default:return e.isNameCharCode(t)?NA(e):Hu(e)}}function Ss(e){let t=new dl(e),n=hl(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var FA,EA,AA,PA,LA,Bb,Gu,Fb,fl,Db,Rb,zb,qu,Yu,Eb,Ku,Wu,gl,MA,bs,hi,ml,Ab,Vu,Pb,Lb,Xu=$(()=>{"use strict";Ib();FA=9,EA=10,AA=12,PA=13,LA=32,Bb=33,Gu=35,Fb=38,fl=39,Db=40,Rb=41,zb=42,qu=43,Yu=44,Eb=45,Ku=60,Wu=62,gl=63,MA=64,bs=91,hi=93,ml=123,Ab=124,Vu=125,Pb=8734,Lb={" ":1,"&&":2,"||":3,"|":4}});function Nb(e){return typeof e=="function"?e:ws}function Qu(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=ws,i=ws;if(typeof t=="function"?o=t:t&&(o=Nb(t.enter),i=Nb(t.leave)),o===ws&&i===ws)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var ws,Ob=$(()=>{"use strict";ws=function(){}});var Ju=$(()=>{"use strict";Au();Xu();Ob()});function HA(e){let t=[];return lo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function _b(e,t){return typeof e=="string"?HA(e):t.generate(e,jA)}var jA,$b=$(()=>{"use strict";nr();jA={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 xn(e,t,n){return t===ut&&n===yt||e===ut&&t===ut&&n===ut?e:(e.type==="If"&&e.else===yt&&t===ut&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function jb(e){return e.length>2&&e.charCodeAt(e.length-2)===WA&&e.charCodeAt(e.length-1)===VA}function Ub(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&jb(e.name)}function uo(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function vs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=vs(e.match,t,n),e.then=vs(e.then,t,n),e.else=vs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Zu(e,t,n){switch(e){case" ":{let r=ut;for(let o=t.length-1;o>=0;o--){let i=t[o];r=xn(i,r,yt)}return r}case"|":{let r=yt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(Ub(s)&&(o===null&&i>0&&Ub(t[i-1])&&(o=Object.create(null),r=xn({type:"Enum",map:o},ut,r)),o!==null)){let a=(jb(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=xn(s,ut,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=yt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Zu(e,t.filter(function(a){return a!==i}),!1):s=ut,r=xn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?ut:yt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Zu(e,t.filter(function(a){return a!==i}),!0):s=ut,r=xn(i,s,r)}return r}}}function GA(e){let t=ut,n=xi(e.term);if(e.max===0)n=xn(n,xl,yt),t=xn(n,null,yt),t.then=xn(ut,ut,t),e.comma&&(t.then.else=xn({type:"Comma",syntax:e},t,yt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,yt)),t=xn(n,xn(ut,ut,t),yt);if(e.min===0)t=xn(ut,ut,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,yt)),t=xn(n,t,yt);return t}function xi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Zu(e.combinator,e.terms.map(xi),!1);return e.disallowEmpty&&(t=xn(t,xl,yt)),t}case"Multiplier":return GA(e);case"Boolean":{let t=xi(e.term),n=xi(uo([uo([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),uo([{type:"Type",name:"!boolean-group"},uo([{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=xi(uo([{type:"Type",name:"!term"},uo([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return vs(r,{"!term":t,"!self":n}),vs(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 ks(e,t){return typeof e=="string"&&(e=Ss(e)),{type:"MatchGraph",match:xi(e),syntax:t||null,source:e}}var ut,yt,xl,WA,VA,ep=$(()=>{"use strict";Xu();ut={type:"Match"},yt={type:"Mismatch"},xl={type:"DisallowEmpty"},WA=40,VA=41});function JA(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function tp(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 ZA(e){return e.type!==9?!1:e.value!=="?"}function Gb(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||ZA(e)}function qb(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function eP(e,t,n){function r(){do C++,F=C<e.length?e[C]:null;while(F!==null&&(F.type===13||F.type===25))}function o(O){let L=C+O;return L<e.length?e[L]:null}function i(O,L){return{nextState:O,matchStack:R,syntaxStack:p,thenStack:f,tokenIndex:C,prev:L}}function s(O){f={nextState:O,matchStack:R,syntaxStack:p,prev:f}}function a(O){d=i(O,d)}function u(){R={type:YA,syntax:t.syntax,token:F,prev:R},r(),m=null,C>z&&(z=C)}function c(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},R={type:np,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===np?R=R.prev:R={type:Yb,syntax:p.syntax,token:R.token,prev:R},p=p.prev}let p=null,f=null,d=null,m=null,w=0,k=null,F=null,C=-1,z=0,R={type:qA,syntax:null,token:null,prev:null};for(r();k===null&&++w<Vb;)switch(t.type){case"Match":if(f===null){if(F!==null&&(C!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=yt;break}k=Wb;break}if(t=f.nextState,t===xl)if(f.matchStack===R){t=yt;break}else t=ut;for(;f.syntaxStack!==p;)l();f=f.prev;break;case"Mismatch":if(m!==null&&m!==!1)(d===null||C>d.tokenIndex)&&(d=m,m=!1);else if(d===null){k=KA;break}t=d.nextState,f=d.thenStack,p=d.syntaxStack,R=d.matchStack,C=d.tokenIndex,F=C<e.length?e[C]:null,d=d.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==yt&&a(t.else),t.then!==ut&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let B=t.syntax.terms;if(t.index===B.length){if(t.mask===0||t.syntax.all){t=yt;break}t=ut;break}if(t.mask===(1<<B.length)-1){t=ut;break}for(;t.index<B.length;t.index++){let g=1<<t.index;if((t.mask&g)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|g}),t=B[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let B=F.value.toLowerCase();if(B.indexOf("\\")!==-1&&(B=B.replace(/\\[09].*$/,"")),Hb.call(t.map,B)){t=t.map[B];break}}t=yt;break;case"Generic":{let B=p!==null?p.opts:null,g=C+Math.floor(t.fn(F,o,B));if(!isNaN(g)&&g>C){for(;C<g;)u();t=ut}else t=yt;break}case"Type":case"Property":{let B=t.type==="Type"?"types":"properties",g=Hb.call(n,B)?n[B][t.name]:null;if(!g||!g.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(m!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){m===null&&(m=i(t,d)),t=yt;break}c(),t=g.matchRef||g.match;break}case"Keyword":{let B=t.name;if(F!==null){let g=F.value;if(g.indexOf("\\")!==-1&&(g=g.replace(/\\[09].*$/,"")),tp(g,B)){u(),t=ut;break}}t=yt;break}case"AtKeyword":case"Function":if(F!==null&&tp(F.value,t.name)){u(),t=ut;break}t=yt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=ut;break}t=yt;break;case"Comma":F!==null&&F.type===18?Gb(R.token)?t=yt:(u(),t=qb(F)?yt:ut):t=Gb(R.token)||qb(F)?ut:yt;break;case"String":let O="",L=C;for(;L<e.length&&O.length<t.value.length;L++)O+=e[L].value;if(tp(O,t.value)){for(;C<L;)u();t=ut}else t=yt;break;default:throw new Error("Unknown node type: "+t.type)}switch(QA+=w,k){case null:console.warn("[csstree-match] BREAK after "+Vb+" iterations"),k=XA,R=null;break;case Wb:for(;p!==null;)l();break;default:R=null}return{tokens:e,reason:k,iterations:w,match:R,longestMatch:z}}function rp(e,t,n){let r=eP(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=JA(o).prev;o!==null;){switch(o.type){case np:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Yb: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 Hb,qA,YA,np,Yb,Wb,KA,XA,Vb,QA,Kb=$(()=>{"use strict";ep();({hasOwnProperty:Hb}=Object.prototype),qA=0,YA=1,np=2,Yb=3,Wb="Match",KA="Mismatch",XA="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Vb=15e3,QA=0});var ip={};xe(ip,{getTrace:()=>Xb,isKeyword:()=>rP,isProperty:()=>nP,isType:()=>tP});function Xb(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 tP(e,t){return op(this,e,n=>n.type==="Type"&&n.name===t)}function nP(e,t){return op(this,e,n=>n.type==="Property"&&n.name===t)}function rP(e){return op(this,e,t=>t.type==="Keyword")}function op(e,t,n){let r=Xb.call(e,t);return r===null?!1:r.some(n)}var Qb=$(()=>{"use strict"});function Jb(e){return"node"in e?e.node:Jb(e.match[0])}function Zb(e){return"node"in e?e.node:Zb(e.match[e.match.length-1])}function sp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=Jb(a),c=Zb(a);e.syntax.walk(t,function(l,p,f){if(l===u){let d=new Vn;do{if(d.appendData(p.data),p.data===c)break;p=p.next}while(p!==null);s.push({parent:f,nodes:d})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var e0=$(()=>{"use strict";ps()});function ap(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function t0(e){return!!e&&ap(e.offset)&&ap(e.line)&&ap(e.column)}function oP(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(Cs.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(!t0(r.loc.start))i+=".start";else if(!t0(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 Vn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Cs.call(t,i)&&Cs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function n0(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<"+(n0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function iP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Cs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=n0(s,e+"."+i)}return{docs:o,check:oP(e,r)}}function r0(e){let t={};if(e.node){for(let n in e.node)if(Cs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=iP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Cs,o0=$(()=>{"use strict";ps();({hasOwnProperty:Cs}=Object.prototype)});function lp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:pi(e[o].syntax,{compact:t}));return r}function sP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:pi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&lp(i.descriptors,t,n)};return r}function aP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function lP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function br(e,t,n){return{matched:e,iterations:n,error:t,...ip}}function yi(e,t,n,r){let o=_b(n,e.syntax),i;return aP(o)?br(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=rp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=rp(o,t.match,e),!i.match)?br(null,new ab(i.reason,t.syntax,n,i),i.iterations):br(i.match,null,i.iterations))}var Ts,i0=$(()=>{"use strict";lb();al();ll();wb();vb();Ju();$b();ep();Kb();Qb();e0();o0();Ts=class{constructor(t,n,r){if(this.cssWideKeywords=gi,this.syntax=n,this.generic=!1,this.units={...pl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||r0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(pl))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(Sb(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=ks(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=ks(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ss(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:ks(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=lP(a)?ks({...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 di("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&&!yi(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=il(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 di("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new di("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return br(null,r);let o=this.getAtrule(t);return o.prelude?yi(this,o.prelude,n||"",!1):br(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return br(null,o);let i=this.getAtrule(t),s=il(n);return yi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?br(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Pu(t).custom)return br(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?br(null,r):yi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?yi(this,r,n,!1):br(null,new di("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?br(null,new di("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),yi(this,t,n,!1))}findValueFragments(t,n,r,o){return sp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return sp(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=il(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=Pu(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&&Qu(p.syntax,function(f){if(f.type!=="Type"&&f.type!=="Property")return;let d=f.type==="Type"?u.types:u.properties,m=f.type==="Type"?o:i;hasOwnProperty.call(d,f.name)?n(u,f.name,m,d[f.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(f.name,f.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:lp(this.types,!n,t),properties:lp(this.properties,!n,t),atrules:sP(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 cP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function up(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?cP(i,n):i};return r}function Is(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]=up(e[r],o);break;case"atrule":case"pseudo":n[r]=up(e[r],o,["parse"]);break;case"node":n[r]=up(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var s0=$(()=>{"use strict"});function a0(e){let t=vy(e),n=ob(e),r=Xy(e),{fromPlainObject:o,toPlainObject:i}=Jy(n),s={lexer:null,createLexer:a=>new Ts(a,s,s.lexer.structure),tokenize:lo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Is({},e);return a0(typeof a=="function"?a(u):Is(u,a))}};return s.lexer=new Ts({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var l0,c0=$(()=>{"use strict";nr();ky();Qy();Zy();ib();i0();s0();l0=e=>a0(Is({},e))});var u0,p0=$(()=>{"use strict";u0={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 fp={};xe(fp,{generate:()=>fP,name:()=>pP,parse:()=>dp,structure:()=>dP});function bl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Lr||r===Gn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)_t(this.charCodeAt(n))||this.error("Integer is expected",n)}function bi(e){return bl.call(this,0,e)}function po(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case yl:n="N is expected";break;case Gn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function pp(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Lr,e)||this.isDelim(Gn,e)){t=this.isDelim(Lr,e)?Lr:Gn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),bi.call(this,Oo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Lr&&n!==Gn&&this.error("Number sign is expected")),bi.call(this,t!==0),t===Gn?"-"+this.consume(10):this.consume(10)}function dp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)bi.call(this,uP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Gn))switch(t="-1",po.call(this,1,yl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=pp.call(this);break;case 3:po.call(this,2,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,2,Gn),bl.call(this,3,Oo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Lr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Lr)&&(r=1,this.next()),po.call(this,0,yl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=pp.call(this);break;case 2:po.call(this,1,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,1,Gn),bl.call(this,2,Oo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Lr||r===Gn,i=this.tokenStart+o;for(;i<this.tokenEnd&&_t(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),po.call(this,i-this.tokenStart,yl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=pp.call(this)):(po.call(this,i-this.tokenStart+1,Gn),i+2===this.tokenEnd?(this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10)):(bl.call(this,i-this.tokenStart+2,Oo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Lr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Lr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function fP(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 Lr,Gn,yl,Oo,uP,pP,dP,gp=$(()=>{"use strict";nr();Lr=43,Gn=45,yl=110,Oo=!0,uP=!1;pP="AnPlusB",dP={a:[String,null],b:[String,null]}});var hp={};xe(hp,{generate:()=>yP,name:()=>mP,parse:()=>mp,structure:()=>xP,walkContext:()=>hP});function d0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function gP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function mp(e=!1){let t=this.tokenStart,n,r,o=null,i=null;switch(this.eat(3),n=this.substrToCursor(t+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,n,e),d0):o=d0.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?i=this.atrule[r].block.call(this,e):i=this.Block(gP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function yP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var mP,hP,xP,xp=$(()=>{"use strict";mP="Atrule",hP="atrule",xP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var bp={};xe(bp,{generate:()=>vP,name:()=>bP,parse:()=>yp,structure:()=>wP,walkContext:()=>SP});function yp(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 vP(e){this.children(e)}var bP,SP,wP,Sp=$(()=>{"use strict";bP="AtrulePrelude",SP="atrulePrelude",wP={children:[[]]}});var kp={};xe(kp,{generate:()=>PP,name:()=>EP,parse:()=>vp,structure:()=>AP});function IP(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(f0)?(t=!0,this.next()):this.isDelim(wp)||this.eat(1),this.isDelim(wp)?this.charCodeAt(this.tokenStart+1)!==Sl?(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 FP(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Sl&&t!==TP&&t!==CP&&t!==kP&&t!==f0&&t!==wp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Sl&&(this.isDelim(Sl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function vp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=IP.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=FP.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 PP(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 kP,f0,Sl,CP,wp,TP,EP,AP,Cp=$(()=>{"use strict";kP=36,f0=42,Sl=61,CP=94,wp=124,TP=126;EP="AttributeSelector",AP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Ip={};xe(Ip,{generate:()=>zP,name:()=>BP,parse:()=>Tp,structure:()=>RP,walkContext:()=>DP});function h0(){return this.Raw(null,!0)}function g0(){return this.parseWithFallback(this.Rule,h0)}function m0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function MP(){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 Tp(e){let t=e?MP:g0,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),h0));break;default:e&&this.isDelim(LP)?r.push(g0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function zP(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var LP,BP,DP,RP,Fp=$(()=>{"use strict";LP=38;BP="Block",DP="block",RP={children:[["Atrule","Rule","Declaration"]]}});var Ap={};xe(Ap,{generate:()=>_P,name:()=>NP,parse:()=>Ep,structure:()=>OP});function Ep(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 _P(e){this.token(9,"["),this.children(e),this.token(9,"]")}var NP,OP,Pp=$(()=>{"use strict";NP="Brackets",OP={children:[[]]}});var Mp={};xe(Mp,{generate:()=>jP,name:()=>$P,parse:()=>Lp,structure:()=>UP});function Lp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function jP(){this.token(15,"-->")}var $P,UP,Bp=$(()=>{"use strict";$P="CDC",UP=[]});var Rp={};xe(Rp,{generate:()=>VP,name:()=>HP,parse:()=>Dp,structure:()=>WP});function Dp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function VP(){this.token(14,"<!--")}var HP,WP,zp=$(()=>{"use strict";HP="CDO",WP=[]});var Op={};xe(Op,{generate:()=>KP,name:()=>qP,parse:()=>Np,structure:()=>YP});function Np(){return this.eatDelim(GP),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function KP(e){this.token(9,"."),this.token(1,e.name)}var GP,qP,YP,_p=$(()=>{"use strict";GP=46,qP="ClassSelector",YP={name:String}});var Up={};xe(Up,{generate:()=>t2,name:()=>ZP,parse:()=>$p,structure:()=>e2});function $p(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case QP:case XP:case JP:this.next();break;case x0:this.next(),this.eatIdent("deep"),this.eatDelim(x0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function t2(e){this.tokenize(e.name)}var XP,x0,QP,JP,ZP,e2,jp=$(()=>{"use strict";XP=43,x0=47,QP=62,JP=126,ZP="Combinator",e2={name:String}});var Wp={};xe(Wp,{generate:()=>s2,name:()=>o2,parse:()=>Hp,structure:()=>i2});function Hp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===n2&&this.charCodeAt(t-1)===r2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function s2(e){this.token(25,"/*"+e.value+"*/")}var n2,r2,o2,i2,Vp=$(()=>{"use strict";n2=42,r2=47,o2="Comment",i2={value:String}});var qp={};xe(qp,{generate:()=>p2,name:()=>l2,parse:()=>Gp,structure:()=>c2});function y0(e){return this.lookupTypeNonSC(1)===1&&a2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function Gp(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 p2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var a2,l2,c2,u2,Yp=$(()=>{"use strict";a2=new Set([16,22,0]),l2="Condition",c2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};u2={media:y0,container:y0,supports(){return this.SupportsDeclaration()}}});var Xp={};xe(Xp,{generate:()=>k2,name:()=>S2,parse:()=>Kp,structure:()=>v2,walkContext:()=>w2});function x2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function b2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(S0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Kp(){let e=this.tokenStart,t=this.tokenIndex,n=C2.call(this),r=sl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?y2:x2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(b2,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(S0)&&(s=T2.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 k2(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 C2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case m2:case f2:case h2:case d2:case g2:this.next();break;case b0:this.next(),this.isDelim(b0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function T2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var S0,d2,f2,g2,m2,h2,b0,S2,w2,v2,Qp=$(()=>{"use strict";al();S0=33,d2=35,f2=36,g2=38,m2=42,h2=43,b0=47;S2="Declaration",w2="declaration",v2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var ed={};xe(ed,{generate:()=>A2,name:()=>F2,parse:()=>Zp,structure:()=>E2});function Jp(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Zp(){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),Jp));break;default:this.isDelim(I2)?e.push(this.parseWithFallback(this.Rule,Jp)):e.push(this.parseWithFallback(this.Declaration,Jp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function A2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var I2,F2,E2,td=$(()=>{"use strict";I2=38;F2="DeclarationList",E2={children:[["Declaration","Atrule","Rule"]]}});var rd={};xe(rd,{generate:()=>M2,name:()=>P2,parse:()=>nd,structure:()=>L2});function nd(){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 M2(e){this.token(12,e.value+e.unit)}var P2,L2,od=$(()=>{"use strict";P2="Dimension",L2={value:String,unit:String}});var sd={};xe(sd,{generate:()=>z2,name:()=>D2,parse:()=>id,structure:()=>R2});function id(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(B2)&&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 z2(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var B2,D2,R2,ad=$(()=>{"use strict";B2=47,D2="Feature",R2={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var cd={};xe(cd,{generate:()=>$2,name:()=>N2,parse:()=>ld,structure:()=>O2});function _2(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function ld(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=_2.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 $2(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var N2,O2,ud=$(()=>{"use strict";N2="FeatureFunction",O2={kind:String,feature:String,value:["Declaration","Selector"]}});var fd={};xe(fd,{generate:()=>V2,name:()=>H2,parse:()=>dd,structure:()=>W2});function pd(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(w0,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(w0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function k0(e){if(this.skipSC(),this.isDelim(U2)||this.isDelim(j2)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(v0)?(this.next(),t+"="):t}if(this.isDelim(v0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function dd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=pd.call(this),r=k0.call(this,n.type==="Identifier"),o=pd.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=k0.call(this),s=pd.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 V2(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 w0,U2,v0,j2,H2,W2,gd=$(()=>{"use strict";w0=47,U2=60,v0=61,j2=62,H2="FeatureRange",W2={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 hd={};xe(hd,{generate:()=>K2,name:()=>G2,parse:()=>md,structure:()=>Y2,walkContext:()=>q2});function md(e,t){let n=this.tokenStart,r=this.consumeFunctionName(),o=r.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:i}}function K2(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var G2,q2,Y2,xd=$(()=>{"use strict";G2="Function",q2="function",Y2={name:String,children:[[]]}});var bd={};xe(bd,{generate:()=>J2,name:()=>X2,parse:()=>yd,structure:()=>Q2});function yd(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 J2(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var X2,Q2,Sd=$(()=>{"use strict";X2="GeneralEnclosed",Q2={kind:String,function:[String,null],children:[[]]}});var vd={};xe(vd,{generate:()=>nL,name:()=>eL,parse:()=>wd,structure:()=>tL,xxx:()=>Z2});function wd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function nL(e){this.token(4,"#"+e.value)}var Z2,eL,tL,kd=$(()=>{"use strict";Z2="XXX",eL="Hash",tL={value:String}});var Td={};xe(Td,{generate:()=>iL,name:()=>rL,parse:()=>Cd,structure:()=>oL});function Cd(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function iL(e){this.token(1,e.name)}var rL,oL,Id=$(()=>{"use strict";rL="Identifier",oL={name:String}});var Ed={};xe(Ed,{generate:()=>lL,name:()=>sL,parse:()=>Fd,structure:()=>aL});function Fd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function lL(e){this.token(9,"#"+e.name)}var sL,aL,Ad=$(()=>{"use strict";sL="IdSelector",aL={name:String}});var Ld={};xe(Ld,{generate:()=>dL,name:()=>uL,parse:()=>Pd,structure:()=>pL});function Pd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(cL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function dL(e){this.tokenize(e.name)}var cL,uL,pL,Md=$(()=>{"use strict";cL=46,uL="Layer",pL={name:String}});var Dd={};xe(Dd,{generate:()=>mL,name:()=>fL,parse:()=>Bd,structure:()=>gL});function Bd(){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 mL(e){this.children(e,()=>this.token(18,","))}var fL,gL,Rd=$(()=>{"use strict";fL="LayerList",gL={children:[["Layer"]]}});var Nd={};xe(Nd,{generate:()=>yL,name:()=>hL,parse:()=>zd,structure:()=>xL});function zd(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function 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 hL,xL,Od=$(()=>{"use strict";hL="MediaQuery",xL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var $d={};xe($d,{generate:()=>wL,name:()=>bL,parse:()=>_d,structure:()=>SL});function _d(){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 wL(e){this.children(e,()=>this.token(18,","))}var bL,SL,Ud=$(()=>{"use strict";bL="MediaQueryList",SL={children:[["MediaQuery"]]}});var Hd={};xe(Hd,{generate:()=>TL,name:()=>kL,parse:()=>jd,structure:()=>CL});function jd(){let e=this.tokenStart;return this.eatDelim(vL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function TL(){this.token(9,"&")}var vL,kL,CL,Wd=$(()=>{"use strict";vL=38,kL="NestingSelector",CL={}});var Gd={};xe(Gd,{generate:()=>EL,name:()=>IL,parse:()=>Vd,structure:()=>FL});function Vd(){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 EL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var IL,FL,qd=$(()=>{"use strict";IL="Nth",FL={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Kd={};xe(Kd,{generate:()=>LL,name:()=>AL,parse:()=>Yd,structure:()=>PL});function Yd(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function LL(e){this.token(10,e.value)}var AL,PL,Xd=$(()=>{"use strict";AL="Number",PL={value:String}});var Jd={};xe(Jd,{generate:()=>DL,name:()=>ML,parse:()=>Qd,structure:()=>BL});function Qd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function DL(e){this.tokenize(e.value)}var ML,BL,Zd=$(()=>{"use strict";ML="Operator",BL={value:String}});var tf={};xe(tf,{generate:()=>NL,name:()=>RL,parse:()=>ef,structure:()=>zL});function ef(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 NL(e){this.token(21,"("),this.children(e),this.token(22,")")}var RL,zL,nf=$(()=>{"use strict";RL="Parentheses",zL={children:[[]]}});var of={};xe(of,{generate:()=>$L,name:()=>OL,parse:()=>rf,structure:()=>_L});function rf(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function $L(e){this.token(11,e.value+"%")}var OL,_L,sf=$(()=>{"use strict";OL="Percentage",_L={value:String}});var lf={};xe(lf,{generate:()=>WL,name:()=>UL,parse:()=>af,structure:()=>HL,walkContext:()=>jL});function af(){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 WL(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var UL,jL,HL,cf=$(()=>{"use strict";UL="PseudoClassSelector",jL="function",HL={name:String,children:[["Raw"],null]}});var pf={};xe(pf,{generate:()=>YL,name:()=>VL,parse:()=>uf,structure:()=>qL,walkContext:()=>GL});function uf(){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 YL(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 VL,GL,qL,df=$(()=>{"use strict";VL="PseudoElementSelector",GL="function",qL={name:String,children:[["Raw"],null]}});var gf={};xe(gf,{generate:()=>QL,name:()=>KL,parse:()=>ff,structure:()=>XL});function T0(){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 ff(){let e=this.tokenStart,t=T0.call(this),n=null;return this.skipSC(),this.isDelim(C0)&&(this.eatDelim(C0),n=T0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function QL(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var C0,KL,XL,mf=$(()=>{"use strict";C0=47;KL="Ratio",XL={left:["Number","Function"],right:["Number","Function",null]}});var xf={};xe(xf,{generate:()=>tM,name:()=>ZL,parse:()=>hf,structure:()=>eM});function JL(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function hf(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=JL.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function tM(e){this.tokenize(e.value)}var ZL,eM,yf=$(()=>{"use strict";ZL="Raw",eM={value:String}});var Sf={};xe(Sf,{generate:()=>sM,name:()=>rM,parse:()=>bf,structure:()=>iM,walkContext:()=>oM});function I0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function nM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function bf(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(nM,I0):n=I0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function sM(e){this.node(e.prelude),this.node(e.block)}var rM,oM,iM,wf=$(()=>{"use strict";rM="Rule",oM="rule",iM={prelude:["SelectorList","Raw"],block:["Block"]}});var kf={};xe(kf,{generate:()=>cM,name:()=>aM,parse:()=>vf,structure:()=>lM});function vf(){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 cM(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 aM,lM,Cf=$(()=>{"use strict";aM="Scope",lM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var If={};xe(If,{generate:()=>dM,name:()=>uM,parse:()=>Tf,structure:()=>pM});function Tf(){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 dM(e){this.children(e)}var uM,pM,Ff=$(()=>{"use strict";uM="Selector",pM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Af={};xe(Af,{generate:()=>hM,name:()=>fM,parse:()=>Ef,structure:()=>mM,walkContext:()=>gM});function Ef(){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 hM(e){this.children(e,()=>this.token(18,","))}var fM,gM,mM,Pf=$(()=>{"use strict";fM="SelectorList",gM="selector",mM={children:[["Selector","Raw"]]}});function wl(e){let t=e.length,n=e.charCodeAt(0),r=n===F0||n===E0?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===Lf){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),An(Lf,a)){let u=s-1,c=Ur(e,u);s=c-1,i+=Wa(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function A0(e,t){let n=t?"'":'"',r=t?E0:F0,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===Lf?(o+="\\"+e.charAt(s),i=!1):(i&&(Pn(a)||Ar(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Lf,F0,E0,vl=$(()=>{"use strict";nr();Lf=92,F0=34,E0=39});var Bf={};xe(Bf,{generate:()=>bM,name:()=>xM,parse:()=>Mf,structure:()=>yM});function Mf(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:wl(this.consume(5))}}function bM(e){this.token(5,A0(e.value))}var xM,yM,Df=$(()=>{"use strict";vl();xM="String",yM={value:String}});var zf={};xe(zf,{generate:()=>CM,name:()=>wM,parse:()=>Rf,structure:()=>kM,walkContext:()=>vM});function L0(){return this.Raw(null,!1)}function Rf(){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)!==SM){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,L0);break;default:n=this.parseWithFallback(this.Rule,L0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function CM(e){this.children(e)}var SM,wM,vM,kM,Nf=$(()=>{"use strict";SM=33;wM="StyleSheet",vM="stylesheet",kM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var _f={};xe(_f,{generate:()=>FM,name:()=>TM,parse:()=>Of,structure:()=>IM});function Of(){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 FM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var TM,IM,$f=$(()=>{"use strict";TM="SupportsDeclaration",IM={declaration:"Declaration"}});var Hf={};xe(Hf,{generate:()=>LM,name:()=>AM,parse:()=>jf,structure:()=>PM});function Uf(){this.tokenType!==1&&this.isDelim(EM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function jf(){let e=this.tokenStart;return this.isDelim(M0)?(this.next(),Uf.call(this)):(Uf.call(this),this.isDelim(M0)&&(this.next(),Uf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function LM(e){this.tokenize(e.name)}var EM,M0,AM,PM,Wf=$(()=>{"use strict";EM=42,M0=124;AM="TypeSelector",PM={name:String}});var qf={};xe(qf,{generate:()=>zM,name:()=>DM,parse:()=>Gf,structure:()=>RM});function Fs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===D0&&t&&n!==0)return Fs.call(this,e+n+1,!1),-1;Pn(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 kl(e){let t=0;for(;this.isDelim(Vf);)++t>e&&this.error("Too many question marks"),this.next()}function MM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===B0?"Plus sign":"Hyphen minus")+" is expected")}function BM(){let e=0;switch(this.tokenType){case 10:if(e=Fs.call(this,1,!0),this.isDelim(Vf)){kl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){MM.call(this,D0),Fs.call(this,1,!1);break}break;case 12:e=Fs.call(this,1,!0),e>0&&kl.call(this,6-e);break;default:if(this.eatDelim(B0),this.tokenType===1){e=Fs.call(this,0,!0),e>0&&kl.call(this,6-e);break}if(this.isDelim(Vf)){this.next(),kl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function Gf(){let e=this.tokenStart;return this.eatIdent("u"),BM.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function zM(e){this.tokenize(e.value)}var B0,D0,Vf,DM,RM,Yf=$(()=>{"use strict";nr();B0=43,D0=45,Vf=63;DM="UnicodeRange",RM={value:String}});function z0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===R0?t-2:t-1,o="";for(;n<r&&Ar(e.charCodeAt(n));)n++;for(;n<r&&Ar(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Kf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),An(Kf,s)){let a=i-1,u=Ur(e,a);i=u-1,o+=Wa(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function N0(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===NM||o===Kf||o===OM||o===_M||o===$M||o===R0?(t+="\\"+e.charAt(r),n=!1):(n&&Pn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var NM,Kf,OM,_M,$M,R0,Xf=$(()=>{"use strict";nr();NM=32,Kf=92,OM=34,_M=39,$M=40,R0=41});var Jf={};xe(Jf,{generate:()=>HM,name:()=>UM,parse:()=>Qf,structure:()=>jM});function Qf(){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=wl(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 HM(e){this.token(7,N0(e.value))}var UM,jM,Zf=$(()=>{"use strict";Xf();vl();UM="Url",jM={value:String}});var tg={};xe(tg,{generate:()=>GM,name:()=>WM,parse:()=>eg,structure:()=>VM});function eg(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function GM(e){this.children(e)}var WM,VM,ng=$(()=>{"use strict";WM="Value",VM={children:[[]]}});var og={};xe(og,{generate:()=>XM,name:()=>YM,parse:()=>rg,structure:()=>KM});function rg(){return this.eat(13),qM}function XM(e){this.token(13,e.value)}var qM,YM,KM,ig=$(()=>{"use strict";qM=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),YM="WhiteSpace",KM={value:String}});var Es={};xe(Es,{AnPlusB:()=>fp,Atrule:()=>hp,AtrulePrelude:()=>bp,AttributeSelector:()=>kp,Block:()=>Ip,Brackets:()=>Ap,CDC:()=>Mp,CDO:()=>Rp,ClassSelector:()=>Op,Combinator:()=>Up,Comment:()=>Wp,Condition:()=>qp,Declaration:()=>Xp,DeclarationList:()=>ed,Dimension:()=>rd,Feature:()=>sd,FeatureFunction:()=>cd,FeatureRange:()=>fd,Function:()=>hd,GeneralEnclosed:()=>bd,Hash:()=>vd,IdSelector:()=>Ed,Identifier:()=>Td,Layer:()=>Ld,LayerList:()=>Dd,MediaQuery:()=>Nd,MediaQueryList:()=>$d,NestingSelector:()=>Hd,Nth:()=>Gd,Number:()=>Kd,Operator:()=>Jd,Parentheses:()=>tf,Percentage:()=>of,PseudoClassSelector:()=>lf,PseudoElementSelector:()=>pf,Ratio:()=>gf,Raw:()=>xf,Rule:()=>Sf,Scope:()=>kf,Selector:()=>If,SelectorList:()=>Af,String:()=>Bf,StyleSheet:()=>zf,SupportsDeclaration:()=>_f,TypeSelector:()=>Hf,UnicodeRange:()=>qf,Url:()=>Jf,Value:()=>tg,WhiteSpace:()=>og});var sg=$(()=>{"use strict";gp();xp();Sp();Cp();Fp();Pp();Bp();zp();_p();jp();Vp();Yp();Qp();td();od();ad();ud();gd();xd();Sd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();nf();sf();cf();df();mf();yf();wf();Cf();Ff();Pf();Df();Nf();$f();Wf();Yf();Zf();ng();ig()});var _0,$0=$(()=>{"use strict";ll();p0();sg();_0={generic:!0,cssWideKeywords:gi,...u0,node:Es}});function As(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,tB)&&this.cmpChar(this.tokenStart+1,U0)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===eB||t===JM||t===U0||t===ZM)return this.Operator();t===QM&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var QM,JM,U0,ZM,eB,tB,ag=$(()=>{"use strict";QM=35,JM=42,U0=43,ZM=45,eB=47,tB=117});var j0,H0=$(()=>{"use strict";ag();j0={getNode:As}});function uB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function pB(){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)===W0&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case iB:case aB:case cB:case sB:return this.Combinator();case W0:return this.ClassSelector();case oB:case lB:return this.TypeSelector();case nB:return this.IdSelector();case rB:return this.NestingSelector()}break}}}var nB,rB,oB,iB,sB,W0,aB,lB,cB,V0,G0=$(()=>{"use strict";nB=35,rB=38,oB=42,iB=43,sB=47,W0=46,aB=62,lB=124,cB=126;V0={onWhiteSpace:uB,getNode:pB}});function q0(){return this.createSingleNodeList(this.Raw(null,!1))}var Y0=$(()=>{"use strict"});function K0(){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 X0=$(()=>{"use strict"});function Q0(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var J0,Z0=$(()=>{"use strict";ag();Y0();X0();J0={getNode:As,onWhiteSpace(e,t){Q0(e)&&(e.value=" "+e.value),Q0(t.last)&&(t.last.value+=" ")},expression:q0,var:K0}});var lg={};xe(lg,{AtrulePrelude:()=>j0,Selector:()=>V0,Value:()=>J0});var eS=$(()=>{"use strict";H0();G0();Z0()});var dB,tS,nS=$(()=>{"use strict";dB=new Set(["none","and","not","or"]),tS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);dB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var rS,oS=$(()=>{"use strict";rS={parse:{prelude:null,block(){return this.Block(!0)}}}});function cg(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 iS,sS,aS=$(()=>{"use strict";iS={layer(){this.skipSC();let e=this.createList(),t=cg.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=cg.call(this,this.Declaration,()=>cg.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},sS={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,iS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,iS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var lS,cS=$(()=>{"use strict";lS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var uS,pS=$(()=>{"use strict";uS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var dS,fS=$(()=>{"use strict";dS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var gS,mS=$(()=>{"use strict";gS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var hS,xS=$(()=>{"use strict";hS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var yS,bS=$(()=>{"use strict";yS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var SS,wS=$(()=>{"use strict";SS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var vS,kS=$(()=>{"use strict";nS();oS();aS();cS();pS();fS();mS();xS();bS();wS();vS={container:tS,"font-face":rS,import:sS,layer:lS,media:uS,nest:dS,page:gS,scope:hS,"starting-style":yS,supports:SS}});function CS(){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 TS=$(()=>{"use strict"});var _o,ug,fB,gB,Cl,IS,FS=$(()=>{"use strict";TS();_o={parse(){return this.createSingleNodeList(this.SelectorList())}},ug={parse(){return this.createSingleNodeList(this.Selector())}},fB={parse(){return this.createSingleNodeList(this.Identifier())}},gB={parse:CS},Cl={parse(){return this.createSingleNodeList(this.Nth())}},IS={dir:fB,has:_o,lang:gB,matches:_o,is:_o,"-moz-any":_o,"-webkit-any":_o,where:_o,not:_o,"nth-child":Cl,"nth-last-child":Cl,"nth-last-of-type":Cl,"nth-of-type":Cl,slotted:ug,host:ug,"host-context":ug}});var pg={};xe(pg,{AnPlusB:()=>dp,Atrule:()=>mp,AtrulePrelude:()=>yp,AttributeSelector:()=>vp,Block:()=>Tp,Brackets:()=>Ep,CDC:()=>Lp,CDO:()=>Dp,ClassSelector:()=>Np,Combinator:()=>$p,Comment:()=>Hp,Condition:()=>Gp,Declaration:()=>Kp,DeclarationList:()=>Zp,Dimension:()=>nd,Feature:()=>id,FeatureFunction:()=>ld,FeatureRange:()=>dd,Function:()=>md,GeneralEnclosed:()=>yd,Hash:()=>wd,IdSelector:()=>Fd,Identifier:()=>Cd,Layer:()=>Pd,LayerList:()=>Bd,MediaQuery:()=>zd,MediaQueryList:()=>_d,NestingSelector:()=>jd,Nth:()=>Vd,Number:()=>Yd,Operator:()=>Qd,Parentheses:()=>ef,Percentage:()=>rf,PseudoClassSelector:()=>af,PseudoElementSelector:()=>uf,Ratio:()=>ff,Raw:()=>hf,Rule:()=>bf,Scope:()=>vf,Selector:()=>Tf,SelectorList:()=>Ef,String:()=>Mf,StyleSheet:()=>Rf,SupportsDeclaration:()=>Of,TypeSelector:()=>jf,UnicodeRange:()=>Gf,Url:()=>Qf,Value:()=>eg,WhiteSpace:()=>rg});var ES=$(()=>{"use strict";gp();xp();Sp();Cp();Fp();Pp();Bp();zp();_p();jp();Vp();Yp();Qp();td();od();ad();ud();gd();xd();Sd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();nf();sf();cf();df();mf();yf();wf();Cf();Ff();Pf();Df();Nf();$f();Wf();Yf();Zf();ng();ig()});var AS,PS=$(()=>{"use strict";eS();kS();FS();ES();AS={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:lg,atrule:vS,pseudo:IS,node:pg}});var LS,MS=$(()=>{"use strict";sg();LS={node:Es}});var BS,DS=$(()=>{"use strict";c0();$0();PS();MS();BS=l0({..._0,...AS,...LS})});var RS=$(()=>{"use strict"});var zS=$(()=>{"use strict"});var tq,NS,nq,rq,oq,OS,iq,sq,aq,lq,cq,uq,_S=$(()=>{"use strict";DS();RS();Ju();al();zS();vl();Xf();({tokenize:tq,parse:NS,generate:nq,lexer:rq,createLexer:oq,walk:OS,find:iq,findLast:sq,findAll:aq,toPlainObject:lq,fromPlainObject:cq,fork:uq}=BS)});function yB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function US(e){try{let t=NS(e.trim(),{context:"value"}),n=[];return OS(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 bB(e,t){let n=yB(e);if(!xB.has(n))return t;let r=US(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 $S(e,t){let n=t.trim();if(!n)return"";let r=bB(e,n);return US(r).map(i=>i==="0"?"0px":i).join(" ")}function jS(e,t,n){let r=$S(e,t),o=$S(e,n);return r!==""&&o!==""&&r===o}var xB,HS=$(()=>{"use strict";_S();xB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function SB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function wB(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 WS(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=wB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return SB(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 $o(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 f=WS(r),d=WS(o);return!!(f===d||n&&jS(n,r,o))}var dg=$(()=>{"use strict";HS()});function IB(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 VS(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 FB(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 EB(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&&IB(n)||VS(r)||VS(o)||n&&FB(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<qS:a<GS}return r.includes("%")||o.includes("%")?a<1:!1}function AB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(TB.some(s=>t.includes(s))||!kB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!$o(o,i,e.property))}function PB(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 LB(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)<YS}function MB(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(!CB.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]))>vB)}function BB(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 Ps(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($o(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(LB(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${YS}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(EB(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")?qS:GS}px)`,dismissedBy:"post-ai-validation"}}return BB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:AB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:MB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:PB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var GS,qS,YS,vB,kB,CB,TB,KS=$(()=>{"use strict";dg();GS=.5,qS=2,YS=2,vB=5,kB=["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"],CB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],TB=["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 Si(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var XS=$(()=>{"use strict"});var QS=$(()=>{"use strict"});var JS=$(()=>{"use strict"});var fg=$(()=>{"use strict";dg();KS();XS();QS();JS()});var jB,HB,Fq,gg=$(()=>{"use strict";jB=["flex","inline-flex"],HB=["grid","inline-grid"],Fq=[...jB,...HB]});var ew=$(()=>{"use strict";fg();gg()});var tw=$(()=>{"use strict"});var Ls=$(()=>{"use strict";sy();fg();gg();ew();tw()});function VB(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function qn(e){try{let t=e.map(VB),n=JSON.stringify(t,GB);sessionStorage.setItem(mg,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function hg(){try{let e=sessionStorage.getItem(mg);if(!e)return[];let t=JSON.parse(e,qB);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function nw(){try{let e=hg();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&&(qn(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function rw(){try{sessionStorage.removeItem(mg),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function GB(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function qB(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var mg,xg=$(()=>{"use strict";De();mg="uicopilot_review_history"});import YB,{createContext as KB,useContext as XB,useReducer as QB,useMemo as ow,useRef as JB,useEffect as ZB}from"react";function eD(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],qn(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=[...e.reviewHistory,...r];return qn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=[...e.reviewHistory,t.payload];return qn(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 qn(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 qn(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 qn(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 qn(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{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,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:o)});return qn(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{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,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:o)});return qn(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=Si(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return qn(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 qn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return rw(),{...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 bg({children:e}){let[t,n]=QB(eD,iD),r=JB(t);ZB(()=>{r.current=t},[t]);let o=ow(()=>({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=ow(()=>({...t,...o}),[t,o]);return YB.createElement(iw.Provider,{value:i},e)}function se(){let e=XB(iw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var tD,nD,yg,rD,oD,iD,iw,Sg=$(()=>{"use strict";Ls();xg();De();tD=()=>{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},nD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},yg={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},rD=()=>{if(typeof localStorage>"u")return yg;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return yg;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 yg},oD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},iD={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:hg(),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:oD(),roleOverride:nD(),featureFlags:rD(),reviewAllConcurrency:tD(),hoveredIssueId:null},iw=KB(null)});import Ms,{useMemo as sD}from"react";function vg({children:e}){return Ms.createElement(ru,null,Ms.createElement(iu,null,Ms.createElement(au,null,Ms.createElement(bg,null,Ms.createElement(aD,null),e))))}function sw(e){let t=Se(),n=Ze(),r=rt(),o=se(),i=sD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function aD(){return wg=sw(),null}var wg,mt,aw=$(()=>{"use strict";ou();su();lu();Sg();wg=null,mt=Object.assign(sw,{getState:()=>{if(!wg)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return wg}})});var we=$(()=>{"use strict";aw();ou();su();lu();Sg()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||lD).replace(/\/$/,"")}var lD,lw,Ue=$(()=>{"use strict";lD="https://app.uicopilot.dev",lw=3.6});async function ie(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 pt=$(()=>{"use strict"});import{useEffect as zs,useState as Il,useRef as JD,useCallback as Cg}from"react";import{addons as Tg}from"storybook/manager-api";async function ZD(e,t,n){let r=`${e}:${t}`,o=Ig.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ie(`${Tw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Ig.delete(r)});return Ig.set(r,i),i}function eR(e,t,n){try{sessionStorage.setItem(`${Fl}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function tR(e,t){try{let n=sessionStorage.getItem(`${Fl}${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(`${Fl}${e}`)}catch{}return null}function nR(e){try{let t=sessionStorage.getItem(`${Fl}${e}`);if(!t)return null;let n=JSON.parse(t);if(n.imageUrl&&Date.now()-n.timestamp<300*1e3)return n.imageUrl}catch{}return null}var ww,vw,kw,Cw,Ci,Tw,ir,Fg,Ig,Fl,Iw,Uo,Ns=$(()=>{"use strict";we();Eg();De();Ue();pt();ww="storyArgsUpdated",vw="storyRendered",kw="forceRemount",Cw=null,Ci=()=>Cw,Tw=q(),ir=new Map,Fg=null,Ig=new Map;Fl="uicopilot-figma-image-";Iw=(e,t,n)=>{Fg=t;let r=ir.get(e);r?r.figmaImageUrl=n:ir.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Uo=()=>{let[e,t]=Il(!1),[n,r]=Il(!1),[o,i]=Il(!1),[s,a]=Il(null),u=JD(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=se(),p=Cg(()=>{let R=mt.getState().currentStoryId;R&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",R),ir.delete(R),u.current=null,i(!0),l())},[l]),f=Cg(()=>{let R=mt.getState().currentStoryId;if(R){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",R);let O=ir.get(R);O&&(O.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:d}=Se(),{selectedProjectId:m}=Ze(),{currentStoryId:w,currentMapping:k}=rt(),{setStorybookImageUrl:F,setFigmaImageUrl:C}=se();zs(()=>{if(!w||mt.getState().figmaImageUrl)return;let O=nR(w);O&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",w),C(O))},[w,C]),zs(()=>{(async()=>{if(!d||!m||!w){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}let O=mt.getState();if(O.storybookImageUrl&&O.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded from persisted review, skipping capture"),u.current=w;return}let L=k?.figmaNodeId??null;if(L!==Fg){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",w);let I=ir.get(w);I&&(I.figmaImageUrl=null),Fg=L,u.current=null}let B=k?.figmaNodeId;if(B&&!ir.get(w)?.figmaImageUrl){let I=tR(w,B);if(I){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",w),C(I);let v=ir.get(w);v?v.figmaImageUrl=I:ir.set(w,{storybookImageUrl:null,figmaImageUrl:I})}}let g=ir.get(w),x=g&&g.storybookImageUrl&&g.figmaImageUrl,b=g&&g.storybookImageUrl&&!g.figmaImageUrl,E=g&&!g.storybookImageUrl&&g.figmaImageUrl;if(x){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",w),F(g.storybookImageUrl),C(g.figmaImageUrl),u.current=w;return}let h=b&&k?.figmaNodeId;h&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",w),F(g.storybookImageUrl));let T=E;if(T&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",w),C(g.figmaImageUrl)),u.current===w&&k?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{a(null),h?r(!0):(T||(t(!0),r(!0)),i(!0)),u.current=w;let I=T?g.figmaImageUrl:null,v;if(T)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(B){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",B);let P=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await ZD(m,B,d);P=D.imageUrl||null;let N=D.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${N}:`,P?"success":"not found")}catch(D){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(P)if(P.includes(".azureedge.net")||P.includes(".blob.core.windows.net")||P.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),I=P,C(P);let N=new Image;N.crossOrigin="anonymous",await new Promise(S=>{N.onload=()=>{v={width:N.naturalWidth,height:N.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),S()},N.onerror=()=>S(),N.src=P})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let N=`${Tw}/api/proxy/image?url=${encodeURIComponent(P)}`,S=await ie(N);if(S.ok){let j=await S.blob(),G=new FileReader,M=await new Promise((Z,oe)=>{G.onloadend=()=>Z(G.result),G.onerror=oe,G.readAsDataURL(j)});I=M,C(M),y.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let J=new Image;await new Promise(Z=>{J.onload=()=>{v={width:J.naturalWidth,height:J.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),Z()},J.onerror=()=>Z(),J.src=M})}else I=P,C(P),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(N){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",N),I=P,C(P)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",B),C(null);I&&B&&eR(w,B,I),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),C(null),r(!1);let A=g?.storybookImageUrl||null;if(A)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",w);let P=await El({storyId:w,sessionToken:d||void 0,...v&&{figmaWidth:v.width,figmaHeight:v.height}});P?(A=P,F(P),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",v||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}ir.set(w,{storybookImageUrl:A,figmaImageUrl:I}),y.debug("[useReviewScreenshots] Screenshots cached for story:",w)}catch(I){y.error("[useReviewScreenshots] Error loading screenshots:",I),a(I instanceof Error?I.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})()},[d,m,w,k?.figmaNodeId,c]),zs(()=>{let R=Tg.getChannel(),O=null,L=B=>{Cw=B.args,y.debug("[useReviewScreenshots] Args updated for story:",B.storyId,"args:",B.args),O&&clearTimeout(O),O=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return R.on(ww,L),()=>{R.off(ww,L),O&&clearTimeout(O)}},[p]),zs(()=>{let R=Tg.getChannel(),O=!1,L=null,B=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),O=!0,i(!0)},g=()=>{O&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),L&&clearTimeout(L),L=setTimeout(()=>{O=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return R.on(kw,B),R.on(vw,g),()=>{R.off(kw,B),R.off(vw,g),L&&clearTimeout(L)}},[f]),zs(()=>{let R=Tg.getChannel(),O=async L=>{if(!L?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let B=mt.getState().currentStoryId,g=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L.snapshot,storyId:B})});if(g.ok){let x=await g.json();if(x.screenshot){F(x.screenshot);let b=mt.getState().currentStoryId;if(b){let E=ir.get(b);E?E.storybookImageUrl=x.screenshot:ir.set(b,{storybookImageUrl:x.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await g.text())}catch(B){y.error("[useReviewScreenshots] Snapshot screenshot error:",B)}finally{i(!1)}};return R.on("UICOPILOT/STORY_DOM_MUTATED",O),()=>{R.off("UICOPILOT/STORY_DOM_MUTATED",O)}},[]);let z=Cg((R,O,L)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Iw(R,O,L),C(L),r(!1),u.current=R},[C]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:p,refreshStorybookOnly:f,setFigmaImageDirect:z}}});function oR(){return!q().startsWith("http://localhost")}function iR(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 Fw(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=iR(o,t,n);return r.set(o,i),i})}async function sR(){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=Fw(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 f of Array.from(l.cssRules))p+=f.cssText+`
|
|
13
|
+
`;if(/(?:color|oklch|oklab|lab|lch)\(/.test(p)){let f=s.createElement("style");f.textContent=Fw(p,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function aR(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 lR(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 ie(`${rR}/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 cR(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 uR(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=Ci();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=cR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=aR(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 pR(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 El(e){let t=e?.storyId||dR();if(t){let n=Ag.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Ew(t,e).finally(()=>{Ag.delete(t)});return Ag.set(t,r),r}return Ew(void 0,e)}async function Ew(e,t){try{if(e){let n=await pR(e);if(n)return n}if(!oR()){let n=uR(t?.storyId);return await lR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await sR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function dR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var rR,Ag,Eg=$(()=>{"use strict";Ue();Ns();De();pt();rR=q();Ag=new Map});function vn(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 Dn(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 Os(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Aw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let k=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let C=t.fonts.check(`${F} ${k} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:C,fontWeight:F,fontSize:k,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(z=>({family:z.family,status:z.status}))}),C)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(k=>k.trim().replace(/['"]/g,"")),p=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],f=[...new Set([...l,...p])];s.font=`${c} ${u} ${a} monospace`;let d=s.measureText(o).width,m="unknown",w=new Map;for(let k of f){s.font=`${c} ${u} ${a} "${k}", monospace`;let F=s.measureText(o).width;if(w.set(k,F),F!==d){s.font=`${c} ${u} ${a} "${k}"`;let C=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let z=s.measureText(o).width;if(Math.abs(C-z)<.1){m=k;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:m,declaredFonts:l,fontWidths:Array.from(w.entries()),isIframe:t!==document}),m}var _s=$(()=>{"use strict";De()});function Ti(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 Pg(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:vn(n.color),backgroundColor:vn(n.backgroundColor),borderColor:vn(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:Aw(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 Lg(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 Al=$(()=>{"use strict";De();_s()});function fR(e){let t=[],n=new Set,r=Pw.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(Pw.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function gR(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:Ti(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Os(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:vn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function mR(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 hR(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,f=vn(n.borderColor),d=s?`${l} ${p} ${f}`:"none";return{selector:Ti(r,i),className:i,border:d,borderRadius:n.borderRadius,backgroundColor:vn(n.backgroundColor),gap:n.gap}}function $s(){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=mR(r,2),i=o.map(hR).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=fR(r);s=a.map(gR),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:Pg(r),declared:Lg(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Pw,Lw=$(()=>{"use strict";De();_s();Al();Pw=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Mg(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 yR(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function bR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=vn(n.backgroundColor);Dn("backgroundColor",o)||(r.backgroundColor=o);let i=yR(n.borderWidth,n.borderStyle,vn(n.borderColor));i&&(r.border=i),Dn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Dn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Dn("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 k=0;k<e.attributes.length;k++){let F=e.attributes[k];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let C=F.name.replace(/-([a-z])/g,(R,O)=>O.toUpperCase()),z=F.value.startsWith("rgb")?vn(F.value):F.value;C==="d"&&z.length>100?r[C]=z.substring(0,100)+"...":r[C]=z}let d=n.getPropertyValue("fill"),m=n.getPropertyValue("stroke");if(d&&d!=="none"&&(r.fill=d.startsWith("rgb")?vn(d):d),m&&m!=="none"&&(r.stroke=m.startsWith("rgb")?vn(m):m),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let k=e.getBoundingClientRect();k.width>0&&(r.width=`${Math.round(k.width*100)/100}px`),k.height>0&&(r.height=`${Math.round(k.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=xR.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Os(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=vn(n.color),Dn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Dn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let p=Mg(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Dn("padding",p)||(r.padding=p);let f=Mg(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Dn("margin",f)||(r.margin=f),Dn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Dn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Dn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Dn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Mw(e){let t=1;for(let n of e.children)t+=Mw(n);return t}function Bw(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 w of Array.from(o.childNodes))if(w.nodeType===Node.TEXT_NODE){let k=w.textContent?.trim();if(k){p=k.length>50?k.substring(0,50)+"...":k;break}}let f=s;c?f=`${s}#${c}`:u&&(f=Ti(s,u));let d=bR(o),m=[];if(i<t){let w=Array.from(o.children);for(let k of w){let F=k.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let z=(k.ownerDocument.defaultView||window).getComputedStyle(k);z.display==="none"||z.visibility==="hidden"||m.push(n(k,i+1))}}return{selector:f,tagName:s,className:u,id:c,role:l,textContent:p,styles:d,children:m}}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:Mw(r)}),r}function Bg(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=Bw(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 xR,Dw=$(()=>{"use strict";De();_s();Al();xR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Dg=$(()=>{"use strict";_s();Al();Lw();Dw()});var sv=Jn((eX,iv)=>{"use strict";iv.exports={compareTwoStrings:ov,findBestMatch:WR};function ov(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 WR(e,t){if(!VR(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=ov(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 VR(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var QC=Jn((Xoe,XC)=>{"use strict";var GC=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,N4=/\n/g,O4=/^\s*/,_4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$4=/^:\s*/,U4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,j4=/^[;\s]*/,H4=/^\s+|\s+$/g,W4=`
|
|
14
|
+
`,qC="/",YC="*",Qo="",V4="comment",G4="declaration";function q4(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(m){var w=m.match(N4);w&&(n+=w.length);var k=m.lastIndexOf(W4);r=~k?m.length-k:r+m.length}function i(){var m={line:n,column:r};return function(w){return w.position=new s(m),c(),w}}function s(m){this.start=m,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(m){var w=new Error(t.source+":"+n+":"+r+": "+m);if(w.reason=m,w.filename=t.source,w.line=n,w.column=r,w.source=e,!t.silent)throw w}function u(m){var w=m.exec(e);if(w){var k=w[0];return o(k),e=e.slice(k.length),w}}function c(){u(O4)}function l(m){var w;for(m=m||[];w=p();)w!==!1&&m.push(w);return m}function p(){var m=i();if(!(qC!=e.charAt(0)||YC!=e.charAt(1))){for(var w=2;Qo!=e.charAt(w)&&(YC!=e.charAt(w)||qC!=e.charAt(w+1));)++w;if(w+=2,Qo===e.charAt(w-1))return a("End of comment missing");var k=e.slice(2,w-2);return r+=2,o(k),e=e.slice(w),r+=2,m({type:V4,comment:k})}}function f(){var m=i(),w=u(_4);if(w){if(p(),!u($4))return a("property missing ':'");var k=u(U4),F=m({type:G4,property:KC(w[0].replace(GC,Qo)),value:k?KC(k[0].replace(GC,Qo)):Qo});return u(j4),F}}function d(){var m=[];l(m);for(var w;w=f();)w!==!1&&(m.push(w),l(m));return m}return c(),d()}function KC(e){return e?e.replace(H4,Qo):Qo}XC.exports=q4});var JC=Jn(ia=>{"use strict";var Y4=ia&&ia.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ia,"__esModule",{value:!0});ia.default=X4;var K4=Y4(QC());function X4(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,K4.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=Jn(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.camelCase=void 0;var Q4=/^--[a-zA-Z0-9_-]+$/,J4=/-([a-z])/g,Z4=/^[^-]+$/,eU=/^-(webkit|moz|ms|o|khtml)-/,tU=/^-(ms)-/,nU=function(e){return!e||Z4.test(e)||Q4.test(e)},rU=function(e,t){return t.toUpperCase()},ZC=function(e,t){return"".concat(t,"-")},oU=function(e,t){return t===void 0&&(t={}),nU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(tU,ZC):e=e.replace(eU,ZC),e.replace(J4,rU))};pc.camelCase=oU});var n1=Jn((hh,t1)=>{"use strict";var iU=hh&&hh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},sU=iU(JC()),aU=e1();function mh(e,t){var n={};return!e||typeof e!="string"||(0,sU.default)(e,function(r,o){r&&o&&(n[(0,aU.camelCase)(r,t)]=o)}),n}mh.default=mh;t1.exports=mh});var AT=Jn((Tue,ET)=>{"use strict";var Dc=Object.prototype.hasOwnProperty,FT=Object.prototype.toString,wT=Object.defineProperty,vT=Object.getOwnPropertyDescriptor,kT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):FT.call(t)==="[object Array]"},CT=function(t){if(!t||FT.call(t)!=="[object Object]")return!1;var n=Dc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Dc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Dc.call(t,o)},TT=function(t,n){wT&&n.name==="__proto__"?wT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},IT=function(t,n){if(n==="__proto__")if(Dc.call(t,n)){if(vT)return vT(t,n).value}else return;return t[n]};ET.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=IT(a,n),o=IT(t,n),a!==o&&(l&&o&&(CT(o)||(i=kT(o)))?(i?(i=!1,s=r&&kT(r)?r:[]):s=r&&CT(r)?r:{},TT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&TT(a,{name:n,newValue:o}));return a}});import Ea from"react";import{addons as Kc,types as Ux,experimental_getStatusStore as mF}from"storybook/manager-api";import{AddonPanel as I8}from"storybook/internal/components";import Bt,{useState as VW,useEffect as GW}from"react";import{styled as fr}from"storybook/theming";import Xx from"react";import{styled as Pt}from"storybook/theming";var le="#ea580c",Jc="#c2410c",Ma="#ff6b35";var Wx=Pt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),Vx=Pt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),ts=Pt.div({marginBottom:"20px"}),ns=Pt.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})),rs=Pt.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`}})),En=Pt.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"}})),Gx=Pt(En)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),Ba=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"}}),er=Pt.button(({theme:e})=>({...Ba(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),en=Pt.button(({theme:e})=>({...Ba(e),backgroundColor:le,color:e.color.inverseText,boxShadow:`0 2px 4px ${le}4d`,"&:hover:not(:disabled)":{backgroundColor:Jc,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${le}66`}})),Er=Pt.button(({theme:e})=>({...Ba(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),qx=Pt.button(({theme:e})=>({...Ba(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),wn=Pt.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"}})),Zc=Pt.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"}})),io=Pt.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=Pt(rs)(({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"})),D8=Pt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Yx=Pt.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})),R8=Pt.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})),eu=Pt.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})),z8=Pt.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%)"}}})),Kx=Pt.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}}),N8=Pt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),O8=Pt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),_8=Pt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var tu=({header:e,children:t,footer:n})=>Xx.createElement(Wx,null,e,Xx.createElement(Vx,null,t),n);import CF from"react";import{styled as TF}from"storybook/theming";var IF=TF.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})),nu=({toolbar:e})=>CF.createElement(IF,null,e);import K8 from"react";import{styled as Da}from"storybook/theming";var J8=Da.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})),Z8=Da.div({display:"flex",flex:1}),eV=Da(io)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),tV=Da.div({display:"flex",gap:"8px",alignItems:"center"});import pn,{useState as hw,useCallback as xw,useEffect as yw}from"react";import{styled as fo}from"storybook/theming";import Re,{useEffect as cw}from"react";import{styled as at}from"storybook/theming";we();Ue();De();pt();var uw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),pw=at.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})),cD=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),uD=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),pD=at.div({display:"flex",flexDirection:"column",gap:"4px"}),dD=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),fD=at.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=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),mD=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),hD=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),xD=at.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"})),yD=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${le} 100%)`,transition:"width 0.3s ease"})),bD=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),SD=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),wD=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:le,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),vD=at.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}})),kD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),CD=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),TD=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),ID=at.div({display:"flex",gap:"8px"}),dw=at(wn)({fontSize:"18px"}),FD=at.div({padding:"20px 16px"}),ED=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),AD=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),PD=at.div({fontSize:"28px",fontWeight:700}),LD=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),MD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),BD=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),DD=at.div({display:"flex",alignItems:"center",gap:"8px"}),RD=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),zD=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:le,color:e.color.inverseText})),ND=at.button(({theme:e})=>({background:"none",border:"none",color:le,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),OD=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),_D=at.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"?le:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),$D=30*1e3,fw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=Se(),{featureFlags:s}=se(),a=s.showCosts,u=r,c=!r&&t,l=async(m=!1)=>{if(!t)return;let w=o&&Date.now()-o<$D;if(!(!m&&w&&r))try{let k=q(),F=await ie(`${k}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let C=await F.json();i(C)}}catch(k){y.error("Failed to fetch usage:",k)}};cw(()=>{l()},[t]),cw(()=>{let m=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[t]);let p=()=>{n(),e()},f=()=>{let m=q();window.open(`${m}/pricing`,"_blank")},d=()=>{let m=q();window.open(`${m}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let m=Math.floor(u?.creditBalance??0),k=Math.max(m,10),F=Math.max(0,k-m),C=k>0?m/k*100:0;return Re.createElement(Re.Fragment,null,Re.createElement(uw,{onClick:e}),Re.createElement(pw,{onClick:z=>z.stopPropagation(),style:{width:"320px"}},Re.createElement(vD,{onClick:e,title:"Close"},"\xD7"),Re.createElement(cD,null,Re.createElement(uD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement(pD,null,Re.createElement(dD,null,"UI Review"),Re.createElement(fD,null,(u?.plan||"BETA").toUpperCase()))),Re.createElement(gD,null,Re.createElement(mD,null,"Credits"),Re.createElement(hD,null,m," left")),Re.createElement(xD,null,Re.createElement(yD,{percent:C})),Re.createElement(bD,null,F," used \xB7 ",m," remaining"),Re.createElement(SD,null),Re.createElement(wD,{onClick:d},"Get free credits \u2192")))}return Re.createElement(Re.Fragment,null,Re.createElement(uw,{onClick:e}),Re.createElement(pw,{onClick:m=>m.stopPropagation()},Re.createElement(kD,null,Re.createElement(CD,null,Re.createElement(TD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement("span",null,u?.email||"Loading...")),Re.createElement(ID,null,Re.createElement(dw,{onClick:p,title:"Sign out"},"\u2192"),Re.createElement(dw,{onClick:e,title:"Close"},"\xD7"))),Re.createElement(FD,null,c?Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Re.createElement(Re.Fragment,null,Re.createElement(ED,null,Re.createElement(AD,null,"Credit Balance"),Re.createElement(PD,null,"$",(u?.creditBalance??0).toFixed(2)),Re.createElement(LD,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Re.createElement(MD,null,Re.createElement(BD,null,Re.createElement(DD,null,Re.createElement(RD,null,"Current Plan"),Re.createElement(zD,null,u?.plan||"Free")),Re.createElement(ND,{onClick:f},"View detail >")),Re.createElement(OD,null,"~$0.02-0.05 per review depending on complexity"),Re.createElement(_D,{onClick:d,style:{marginTop:"16px"}},"Add Credits"))):Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};we();import wi from"react";import{styled as gw}from"storybook/theming";Ue();we();pt();De();var UD=gw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),jD=gw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),HD={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}},mw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=se(),{sessionToken:o}=Se();return e!=="admin"?null:wi.createElement(UD,null,wi.createElement(jD,null,"View as:"),wi.createElement(Gx,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ie(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=HD[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},wi.createElement("option",{value:"admin"},"Admin"),wi.createElement("option",{value:"beta"},"Beta Tester")),t&&wi.createElement(Kx,{variant:"warning"},"Previewing as ",t))};we();Ue();pt();var WD=fo.div({display:"flex",alignItems:"center"}),vi=fo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),VD=fo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),GD=fo.div({position:"relative"}),qD=fo.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`}})),bw=fo.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)"}})),YD=fo.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)"}}}),KD=fo.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}})),XD=30*1e3,kg=({onOpenSettings:e})=>{let[t,n]=hw(!1),[r,o]=hw(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=Se(),{userRole:c,roleOverride:l,featureFlags:p}=se(),f=l??c;yw(()=>{(async()=>{if(!(!u||s&&Date.now()-s<XD&&i)){o(!0);try{let z=q(),R=await ie(`${z}/api/addon/account`,{headers:{Authorization:`Bearer ${u}`}});if(R.ok){let O=await R.json();a(O)}}catch(z){console.error("Failed to fetch balance:",z)}finally{o(!1)}}})()},[u,s,i,a]),yw(()=>{let F=()=>{document.visibilityState==="visible"&&t&&n(!1)},C=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",F),window.addEventListener("focus",C),()=>{document.removeEventListener("visibilitychange",F),window.removeEventListener("focus",C)}},[t]);let d=xw(()=>{n(!0)},[]),m=xw(()=>{n(!1)},[]),w=i?.creditBalance??0,k=w<2&&!r;return pn.createElement(WD,null,e&&pn.createElement(vi,null,pn.createElement(KD,{onClick:e,title:"Settings"},pn.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),u&&c==="admin"&&f==="admin"&&pn.createElement(vi,null,pn.createElement(mw,null)),pn.createElement(vi,null,pn.createElement(VD,null,"v","0.5.6")),u&&p.showCosts&&pn.createElement(vi,null,pn.createElement(bw,{onClick:d,isLow:k,title:r?"Loading...":i?k?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},r?pn.createElement(YD,null):i?`$${w.toFixed(2)}`:"...")),u&&!p.showCosts&&i&&pn.createElement(vi,null,pn.createElement(bw,{onClick:d,isLow:Math.floor(w)<=3,title:`${Math.floor(w)} review credits remaining \u2014 click to manage`},"\u26A1 ",Math.floor(w))),pn.createElement(vi,null,pn.createElement(GD,null,pn.createElement(qD,{title:"Account & Usage",onClick:d},i?.email?i.email[0].toUpperCase():"?"),t&&pn.createElement(fw,{onClose:m}))))};import At from"react";import{styled as cr}from"storybook/theming";import Mt from"react";we();De();Ue();pt();import{useCallback as ki,useRef as Sw,useEffect as QD}from"react";var go=q();y.debug("[useAuth] Module loaded, APP_URL:",go);var Bs=()=>{let e=Sw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:p,setDeviceCode:f,setUserCode:d,setVerificationUri:m,setPollingInterval:w,setAuthError:k,resetAuth:F}=Se(),C=Sw(null),z=ki(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let x;try{x=await ie(`${go}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let D=A instanceof Error&&A.message.includes("timed out")?`Cannot reach UI Copilot server at ${go}. Is the dashboard running?`:`Connection failed: ${go} is not responding.`;k(D),y.error("[useAuth]",D);return}if(!x.ok)throw new Error("Failed to create poll code");let{poll_code:b}=await x.json();y.debug("[useAuth] Got poll_code:",b.substring(0,15)+"...");let E=600,h=700,T=window.screenX+(window.outerWidth-E)/2,I=window.screenY+(window.outerHeight-h)/2;window.open(`${go}/addon/auth?poll_code=${b}`,"figma-auth",`width=${E},height=${h},left=${T},top=${I}`),y.debug("[useAuth] Starting OAuth poll for token..."),C.current&&clearInterval(C.current);let v=async()=>{try{let P=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:b})})).json();P.status==="authorized"&&P.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),C.current&&(clearInterval(C.current),C.current=null),localStorage.setItem("uicopilot_session_token",P.session_token),c(P.session_token)):P.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),C.current&&(clearInterval(C.current),C.current=null))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};C.current=setInterval(v,2e3),setTimeout(v,1e3)}catch(x){y.error("[useAuth] OAuth flow error:",x)}},[c]),R=ki(async()=>{try{let x=await fetch(`${go}/api/addon/auth/device`,{method:"POST"});if(!x.ok)throw new Error("Failed to start device code flow");let b=await x.json();f(b.device_code),d(b.user_code),m(b.verification_uri),window.open(b.verification_uri,"_blank"),O(b.device_code,b.interval*1e3)}catch(x){throw y.error("[useAuth] Device code flow error:",x),x}},[f,d,m]),O=ki((x,b)=>{y.debug("[useAuth] Starting polling. Device code:",x,"Interval:",b),e.current&&clearInterval(e.current);let E=async()=>{try{let T=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:x})})).json();T.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null),localStorage.setItem("uicopilot_session_token",T.session_token),c(T.session_token)):(T.status==="expired"||T.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null))}catch(h){y.error("[useAuth] Polling error:",h)}};e.current=setInterval(E,b),w(b)},[f,d,m,c,w]),L=ki(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null),w(null)},[f,d,m,w]),B=ki(x=>{l(x),localStorage.setItem("uicopilot_api_key",x)},[l]),g=ki(()=>{F(),e.current&&(clearInterval(e.current),e.current=null)},[F]);return QD(()=>()=>{e.current&&clearInterval(e.current),C.current&&clearInterval(C.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setAuthMethod:p,startOAuth:z,startDeviceCode:R,cancelDeviceCode:L,saveApiKey:B,logout:g}};we();De();Ue();pt();import{useCallback as Tl}from"react";var Ds=q(),qr=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Ze(),{sessionToken:a}=Se(),u=Tl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Ds}/api/projects`);let f=await ie(`${Ds}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(f.ok){let d=await f.json();y.debug("[useProjects] Projects:",d.projects),r(d.projects||[])}else y.error("[useProjects] Failed to fetch projects:",f.status,f.statusText)}catch(f){y.error("[useProjects] Error fetching projects:",f)}finally{i(!1)}},[a,r,i]),c=Tl(async f=>{if(!a)throw new Error("Not authenticated");let d=await ie(`${Ds}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)});if(!d.ok)throw new Error("Failed to create project");let m=await d.json();return await u(),m.project},[a,u]),l=Tl(async(f,d)=>{if(!a)throw new Error("Not authenticated");let m={};if(d.name!==void 0&&(m.name=d.name),d.description!==void 0&&(m.description=d.description),d.figmaFileUrl!==void 0&&(m.figmaFileId=d.figmaFileUrl||void 0),!(await ie(`${Ds}/api/projects/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(m)})).ok)throw new Error("Failed to update project");await u()},[a,u]),p=Tl(async f=>{if(!a)throw new Error("Not authenticated");if(!(await ie(`${Ds}/api/projects/${f}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===f&&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}};we();var Rs=()=>{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}=rt();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)}};we();Eg();Dg();import{useCallback as Vs,useRef as Nl}from"react";De();function Pl(){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 Ll=BigInt(4294967295),Rw=BigInt(32);function SR(e,t=!1){return t?{h:Number(e&Ll),l:Number(e>>Rw&Ll)}:{h:Number(e>>Rw&Ll)|0,l:Number(e&Ll)|0}}function zw(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}=SR(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Nw=(e,t,n)=>e<<n|t>>>32-n,Ow=(e,t,n)=>t<<n|e>>>32-n,_w=(e,t,n)=>t<<n-32|e>>>64-n,$w=(e,t,n)=>e<<n-32|t>>>64-n;function wR(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rg(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Ml(e,t,n=""){let r=wR(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 zg(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 Uw(e,t){Ml(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 jw(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ng(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var vR=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function kR(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function CR(e){for(let t=0;t<e.length;t++)e[t]=kR(e[t]);return e}var Og=vR?e=>e:CR;function Hw(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 Ww=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var TR=BigInt(0),Us=BigInt(1),IR=BigInt(2),FR=BigInt(7),ER=BigInt(256),AR=BigInt(113),qw=[],Yw=[],Kw=[];for(let e=0,t=Us,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],qw.push(2*(5*r+n)),Yw.push((e+1)*(e+2)/2%64);let o=TR;for(let i=0;i<7;i++)t=(t<<Us^(t>>FR)*AR)%ER,t&IR&&(o^=Us<<(Us<<BigInt(i))-Us);Kw.push(o)}var Xw=zw(Kw,!0),PR=Xw[0],LR=Xw[1],Vw=(e,t,n)=>n>32?_w(e,t,n):Nw(e,t,n),Gw=(e,t,n)=>n>32?$w(e,t,n):Ow(e,t,n);function MR(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=Vw(c,l,1)^n[a],f=Gw(c,l,1)^n[a+1];for(let d=0;d<50;d+=10)e[s+d]^=p,e[s+d+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Yw[s],u=Vw(o,i,a),c=Gw(o,i,a),l=qw[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]^=PR[r],e[1]^=LR[r]}Ng(n)}var _g=class e{constructor(t,n,r,o=!1,i=24){Zn(this,"state");Zn(this,"pos",0);Zn(this,"posOut",0);Zn(this,"finished",!1);Zn(this,"state32");Zn(this,"destroyed",!1);Zn(this,"blockLen");Zn(this,"suffix");Zn(this,"outputLen");Zn(this,"enableXOF",!1);Zn(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Rg(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=jw(this.state)}clone(){return this._cloneInto()}keccak(){Og(this.state32),MR(this.state32,this.rounds),Og(this.state32),this.posOut=0,this.pos=0}update(t){zg(this),Ml(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){zg(this,!1),Ml(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 Rg(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Uw(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,Ng(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}},BR=(e,t,n,r={})=>Hw(()=>new _g(t,e,n),r);var Qw=BR(6,72,64,Ww(10));var DR=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,$g=Math.ceil,ar=Math.floor,Rn="[BigNumber Error] ",Jw=Rn+"Number primitive has more than 15 significant digits: ",Sr=1e14,je=14,Ug=9007199254740991,jg=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],mo=1e7,rn=1e9;function Zw(e){var t,n,r,o=C.prototype={constructor:C,toString:null,valueOf:null},i=new C(1),s=20,a=4,u=-7,c=21,l=-1e7,p=1e7,f=!1,d=1,m=0,w={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},k="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function C(g,x){var b,E,h,T,I,v,A,P,D=this;if(!(D instanceof C))return new C(g,x);if(x==null){if(g&&g._isBigNumber===!0){D.s=g.s,!g.c||g.e>p?D.c=D.e=null:g.e<l?D.c=[D.e=0]:(D.e=g.e,D.c=g.c.slice());return}if((v=typeof g=="number")&&g*0==0){if(D.s=1/g<0?(g=-g,-1):1,g===~~g){for(T=0,I=g;I>=10;I/=10,T++);T>p?D.c=D.e=null:(D.e=T,D.c=[g]);return}P=String(g)}else{if(!DR.test(P=String(g)))return r(D,P,v);D.s=P.charCodeAt(0)==45?(P=P.slice(1),-1):1}(T=P.indexOf("."))>-1&&(P=P.replace(".","")),(I=P.search(/e/i))>0?(T<0&&(T=I),T+=+P.slice(I+1),P=P.substring(0,I)):T<0&&(T=P.length)}else{if(Rt(x,2,k.length,"Base"),x==10&&F)return D=new C(g),L(D,s+D.e+1,a);if(P=String(g),v=typeof g=="number"){if(g*0!=0)return r(D,P,v,x);if(D.s=1/g<0?(P=P.slice(1),-1):1,C.DEBUG&&P.replace(/^0\.0*|\./,"").length>15)throw Error(Jw+g)}else D.s=P.charCodeAt(0)===45?(P=P.slice(1),-1):1;for(b=k.slice(0,x),T=I=0,A=P.length;I<A;I++)if(b.indexOf(E=P.charAt(I))<0){if(E=="."){if(I>T){T=A;continue}}else if(!h&&(P==P.toUpperCase()&&(P=P.toLowerCase())||P==P.toLowerCase()&&(P=P.toUpperCase()))){h=!0,I=-1,T=0;continue}return r(D,String(g),v,x)}v=!1,P=n(P,x,10,D.s),(T=P.indexOf("."))>-1?P=P.replace(".",""):T=P.length}for(I=0;P.charCodeAt(I)===48;I++);for(A=P.length;P.charCodeAt(--A)===48;);if(P=P.slice(I,++A)){if(A-=I,v&&C.DEBUG&&A>15&&(g>Ug||g!==ar(g)))throw Error(Jw+D.s*g);if((T=T-I-1)>p)D.c=D.e=null;else if(T<l)D.c=[D.e=0];else{if(D.e=T,D.c=[],I=(T+1)%je,T<0&&(I+=je),I<A){for(I&&D.c.push(+P.slice(0,I)),A-=je;I<A;)D.c.push(+P.slice(I,I+=je));I=je-(P=P.slice(I)).length}else I-=A;for(;I--;P+="0");D.c.push(+P)}}else D.c=[D.e=0]}C.clone=Zw,C.ROUND_UP=0,C.ROUND_DOWN=1,C.ROUND_CEIL=2,C.ROUND_FLOOR=3,C.ROUND_HALF_UP=4,C.ROUND_HALF_DOWN=5,C.ROUND_HALF_EVEN=6,C.ROUND_HALF_CEIL=7,C.ROUND_HALF_FLOOR=8,C.EUCLID=9,C.config=C.set=function(g){var x,b;if(g!=null)if(typeof g=="object"){if(g.hasOwnProperty(x="DECIMAL_PLACES")&&(b=g[x],Rt(b,0,rn,x),s=b),g.hasOwnProperty(x="ROUNDING_MODE")&&(b=g[x],Rt(b,0,8,x),a=b),g.hasOwnProperty(x="EXPONENTIAL_AT")&&(b=g[x],b&&b.pop?(Rt(b[0],-rn,0,x),Rt(b[1],0,rn,x),u=b[0],c=b[1]):(Rt(b,-rn,rn,x),u=-(c=b<0?-b:b))),g.hasOwnProperty(x="RANGE"))if(b=g[x],b&&b.pop)Rt(b[0],-rn,-1,x),Rt(b[1],1,rn,x),l=b[0],p=b[1];else if(Rt(b,-rn,rn,x),b)l=-(p=b<0?-b:b);else throw Error(Rn+x+" cannot be zero: "+b);if(g.hasOwnProperty(x="CRYPTO"))if(b=g[x],b===!!b)if(b)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=b;else throw f=!b,Error(Rn+"crypto unavailable");else f=b;else throw Error(Rn+x+" not true or false: "+b);if(g.hasOwnProperty(x="MODULO_MODE")&&(b=g[x],Rt(b,0,9,x),d=b),g.hasOwnProperty(x="POW_PRECISION")&&(b=g[x],Rt(b,0,rn,x),m=b),g.hasOwnProperty(x="FORMAT"))if(b=g[x],typeof b=="object")w=b;else throw Error(Rn+x+" not an object: "+b);if(g.hasOwnProperty(x="ALPHABET"))if(b=g[x],typeof b=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(b))F=b.slice(0,10)=="0123456789",k=b;else throw Error(Rn+x+" invalid: "+b)}else throw Error(Rn+"Object expected: "+g);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,p],CRYPTO:f,MODULO_MODE:d,POW_PRECISION:m,FORMAT:w,ALPHABET:k}},C.isBigNumber=function(g){if(!g||g._isBigNumber!==!0)return!1;if(!C.DEBUG)return!0;var x,b,E=g.c,h=g.e,T=g.s;e:if({}.toString.call(E)=="[object Array]"){if((T===1||T===-1)&&h>=-rn&&h<=rn&&h===ar(h)){if(E[0]===0){if(h===0&&E.length===1)return!0;break e}if(x=(h+1)%je,x<1&&(x+=je),String(E[0]).length==x){for(x=0;x<E.length;x++)if(b=E[x],b<0||b>=Sr||b!==ar(b))break e;if(b!==0)return!0}}}else if(E===null&&h===null&&(T===null||T===1||T===-1))return!0;throw Error(Rn+"Invalid BigNumber: "+g)},C.maximum=C.max=function(){return R(arguments,-1)},C.minimum=C.min=function(){return R(arguments,1)},C.random=(function(){var g=9007199254740992,x=Math.random()*g&2097151?function(){return ar(Math.random()*g)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(b){var E,h,T,I,v,A=0,P=[],D=new C(i);if(b==null?b=s:Rt(b,0,rn),I=$g(b/je),f)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(I*=2));A<I;)v=E[A]*131072+(E[A+1]>>>11),v>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),E[A]=h[0],E[A+1]=h[1]):(P.push(v%1e14),A+=2);A=I/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(I*=7);A<I;)v=(E[A]&31)*281474976710656+E[A+1]*1099511627776+E[A+2]*4294967296+E[A+3]*16777216+(E[A+4]<<16)+(E[A+5]<<8)+E[A+6],v>=9e15?crypto.randomBytes(7).copy(E,A):(P.push(v%1e14),A+=7);A=I/7}else throw f=!1,Error(Rn+"crypto unavailable");if(!f)for(;A<I;)v=x(),v<9e15&&(P[A++]=v%1e14);for(I=P[--A],b%=je,I&&b&&(v=jg[je-b],P[A]=ar(I/v)*v);P[A]===0;P.pop(),A--);if(A<0)P=[T=0];else{for(T=-1;P[0]===0;P.splice(0,1),T-=je);for(A=1,v=P[0];v>=10;v/=10,A++);A<je&&(T-=je-A)}return D.e=T,D.c=P,D}})(),C.sum=function(){for(var g=1,x=arguments,b=new C(x[0]);g<x.length;)b=b.plus(x[g++]);return b},n=(function(){var g="0123456789";function x(b,E,h,T){for(var I,v=[0],A,P=0,D=b.length;P<D;){for(A=v.length;A--;v[A]*=E);for(v[0]+=T.indexOf(b.charAt(P++)),I=0;I<v.length;I++)v[I]>h-1&&(v[I+1]==null&&(v[I+1]=0),v[I+1]+=v[I]/h|0,v[I]%=h)}return v.reverse()}return function(b,E,h,T,I){var v,A,P,D,N,S,j,G,M=b.indexOf("."),J=s,Z=a;for(M>=0&&(D=m,m=0,b=b.replace(".",""),G=new C(E),S=G.pow(b.length-M),m=D,G.c=x(Yr(sr(S.c),S.e,"0"),10,h,g),G.e=G.c.length),j=x(b,E,h,I?(v=k,g):(v=g,k)),P=D=j.length;j[--D]==0;j.pop());if(!j[0])return v.charAt(0);if(M<0?--P:(S.c=j,S.e=P,S.s=T,S=t(S,G,J,Z,h),j=S.c,N=S.r,P=S.e),A=P+J+1,M=j[A],D=h/2,N=N||A<0||j[A+1]!=null,N=Z<4?(M!=null||N)&&(Z==0||Z==(S.s<0?3:2)):M>D||M==D&&(Z==4||N||Z==6&&j[A-1]&1||Z==(S.s<0?8:7)),A<1||!j[0])b=N?Yr(v.charAt(1),-J,v.charAt(0)):v.charAt(0);else{if(j.length=A,N)for(--h;++j[--A]>h;)j[A]=0,A||(++P,j=[1].concat(j));for(D=j.length;!j[--D];);for(M=0,b="";M<=D;b+=v.charAt(j[M++]));b=Yr(b,P,v.charAt(0))}return b}})(),t=(function(){function g(E,h,T){var I,v,A,P,D=0,N=E.length,S=h%mo,j=h/mo|0;for(E=E.slice();N--;)A=E[N]%mo,P=E[N]/mo|0,I=j*A+P*S,v=S*A+I%mo*mo+D,D=(v/T|0)+(I/mo|0)+j*P,E[N]=v%T;return D&&(E=[D].concat(E)),E}function x(E,h,T,I){var v,A;if(T!=I)A=T>I?1:-1;else for(v=A=0;v<T;v++)if(E[v]!=h[v]){A=E[v]>h[v]?1:-1;break}return A}function b(E,h,T,I){for(var v=0;T--;)E[T]-=v,v=E[T]<h[T]?1:0,E[T]=v*I+E[T]-h[T];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,h,T,I,v){var A,P,D,N,S,j,G,M,J,Z,oe,pe,ae,qe,tt,Ve,te,Be=E.s==h.s?1:-1,Le=E.c,de=h.c;if(!Le||!Le[0]||!de||!de[0])return new C(!E.s||!h.s||(Le?de&&Le[0]==de[0]:!de)?NaN:Le&&Le[0]==0||!de?Be*0:Be/0);for(M=new C(Be),J=M.c=[],P=E.e-h.e,Be=T+P+1,v||(v=Sr,P=lr(E.e/je)-lr(h.e/je),Be=Be/je|0),D=0;de[D]==(Le[D]||0);D++);if(de[D]>(Le[D]||0)&&P--,Be<0)J.push(1),N=!0;else{for(qe=Le.length,Ve=de.length,D=0,Be+=2,S=ar(v/(de[0]+1)),S>1&&(de=g(de,S,v),Le=g(Le,S,v),Ve=de.length,qe=Le.length),ae=Ve,Z=Le.slice(0,Ve),oe=Z.length;oe<Ve;Z[oe++]=0);te=de.slice(),te=[0].concat(te),tt=de[0],de[1]>=v/2&&tt++;do{if(S=0,A=x(de,Z,Ve,oe),A<0){if(pe=Z[0],Ve!=oe&&(pe=pe*v+(Z[1]||0)),S=ar(pe/tt),S>1)for(S>=v&&(S=v-1),j=g(de,S,v),G=j.length,oe=Z.length;x(j,Z,G,oe)==1;)S--,b(j,Ve<G?te:de,G,v),G=j.length,A=1;else S==0&&(A=S=1),j=de.slice(),G=j.length;if(G<oe&&(j=[0].concat(j)),b(Z,j,oe,v),oe=Z.length,A==-1)for(;x(de,Z,Ve,oe)<1;)S++,b(Z,Ve<oe?te:de,oe,v),oe=Z.length}else A===0&&(S++,Z=[0]);J[D++]=S,Z[0]?Z[oe++]=Le[ae]||0:(Z=[Le[ae]],oe=1)}while((ae++<qe||Z[0]!=null)&&Be--);N=Z[0]!=null,J[0]||J.splice(0,1)}if(v==Sr){for(D=1,Be=J[0];Be>=10;Be/=10,D++);L(M,T+(M.e=D+P*je-1)+1,I,N)}else M.e=P,M.r=+N;return M}})();function z(g,x,b,E){var h,T,I,v,A;if(b==null?b=a:Rt(b,0,8),!g.c)return g.toString();if(h=g.c[0],I=g.e,x==null)A=sr(g.c),A=E==1||E==2&&(I<=u||I>=c)?Dl(A,I):Yr(A,I,"0");else if(g=L(new C(g),x,b),T=g.e,A=sr(g.c),v=A.length,E==1||E==2&&(x<=T||T<=u)){for(;v<x;A+="0",v++);A=Dl(A,T)}else if(x-=I+(E===2&&T>I),A=Yr(A,T,"0"),T+1>v){if(--x>0)for(A+=".";x--;A+="0");}else if(x+=T-v,x>0)for(T+1==v&&(A+=".");x--;A+="0");return g.s<0&&h?"-"+A:A}function R(g,x){for(var b,E,h=1,T=new C(g[0]);h<g.length;h++)E=new C(g[h]),(!E.s||(b=jo(T,E))===x||b===0&&T.s===x)&&(T=E);return T}function O(g,x,b){for(var E=1,h=x.length;!x[--h];x.pop());for(h=x[0];h>=10;h/=10,E++);return(b=E+b*je-1)>p?g.c=g.e=null:b<l?g.c=[g.e=0]:(g.e=b,g.c=x),g}r=(function(){var g=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,b=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,I,v,A){var P,D=v?I:I.replace(h,"");if(E.test(D))T.s=isNaN(D)?null:D<0?-1:1;else{if(!v&&(D=D.replace(g,function(N,S,j){return P=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==P?S:N}),A&&(P=A,D=D.replace(x,"$1").replace(b,"0.$1")),I!=D))return new C(D,P);if(C.DEBUG)throw Error(Rn+"Not a"+(A?" base "+A:"")+" number: "+I);T.s=null}T.c=T.e=null}})();function L(g,x,b,E){var h,T,I,v,A,P,D,N=g.c,S=jg;if(N){e:{for(h=1,v=N[0];v>=10;v/=10,h++);if(T=x-h,T<0)T+=je,I=x,A=N[P=0],D=ar(A/S[h-I-1]%10);else if(P=$g((T+1)/je),P>=N.length)if(E){for(;N.length<=P;N.push(0));A=D=0,h=1,T%=je,I=T-je+1}else break e;else{for(A=v=N[P],h=1;v>=10;v/=10,h++);T%=je,I=T-je+h,D=I<0?0:ar(A/S[h-I-1]%10)}if(E=E||x<0||N[P+1]!=null||(I<0?A:A%S[h-I-1]),E=b<4?(D||E)&&(b==0||b==(g.s<0?3:2)):D>5||D==5&&(b==4||E||b==6&&(T>0?I>0?A/S[h-I]:0:N[P-1])%10&1||b==(g.s<0?8:7)),x<1||!N[0])return N.length=0,E?(x-=g.e+1,N[0]=S[(je-x%je)%je],g.e=-x||0):N[0]=g.e=0,g;if(T==0?(N.length=P,v=1,P--):(N.length=P+1,v=S[je-T],N[P]=I>0?ar(A/S[h-I]%S[I])*v:0),E)for(;;)if(P==0){for(T=1,I=N[0];I>=10;I/=10,T++);for(I=N[0]+=v,v=1;I>=10;I/=10,v++);T!=v&&(g.e++,N[0]==Sr&&(N[0]=1));break}else{if(N[P]+=v,N[P]!=Sr)break;N[P--]=0,v=1}for(T=N.length;N[--T]===0;N.pop());}g.e>p?g.c=g.e=null:g.e<l&&(g.c=[g.e=0])}return g}function B(g){var x,b=g.e;return b===null?g.toString():(x=sr(g.c),x=b<=u||b>=c?Dl(x,b):Yr(x,b,"0"),g.s<0?"-"+x:x)}return o.absoluteValue=o.abs=function(){var g=new C(this);return g.s<0&&(g.s=1),g},o.comparedTo=function(g,x){return jo(this,new C(g,x))},o.decimalPlaces=o.dp=function(g,x){var b,E,h,T=this;if(g!=null)return Rt(g,0,rn),x==null?x=a:Rt(x,0,8),L(new C(T),g+T.e+1,x);if(!(b=T.c))return null;if(E=((h=b.length-1)-lr(this.e/je))*je,h=b[h])for(;h%10==0;h/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(g,x){return t(this,new C(g,x),s,a)},o.dividedToIntegerBy=o.idiv=function(g,x){return t(this,new C(g,x),0,1)},o.exponentiatedBy=o.pow=function(g,x){var b,E,h,T,I,v,A,P,D,N=this;if(g=new C(g),g.c&&!g.isInteger())throw Error(Rn+"Exponent not an integer: "+B(g));if(x!=null&&(x=new C(x)),v=g.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!g.c||!g.c[0])return D=new C(Math.pow(+B(N),v?g.s*(2-Bl(g)):+B(g))),x?D.mod(x):D;if(A=g.s<0,x){if(x.c?!x.c[0]:!x.s)return new C(NaN);E=!A&&N.isInteger()&&x.isInteger(),E&&(N=N.mod(x))}else{if(g.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||v&&N.c[1]>=24e7:N.c[0]<8e13||v&&N.c[0]<=9999975e7)))return T=N.s<0&&Bl(g)?-0:0,N.e>-1&&(T=1/T),new C(A?1/T:T);m&&(T=$g(m/je+2))}for(v?(b=new C(.5),A&&(g.s=1),P=Bl(g)):(h=Math.abs(+B(g)),P=h%2),D=new C(i);;){if(P){if(D=D.times(N),!D.c)break;T?D.c.length>T&&(D.c.length=T):E&&(D=D.mod(x))}if(h){if(h=ar(h/2),h===0)break;P=h%2}else if(g=g.times(b),L(g,g.e+1,1),g.e>14)P=Bl(g);else{if(h=+B(g),h===0)break;P=h%2}N=N.times(N),T?N.c&&N.c.length>T&&(N.c.length=T):E&&(N=N.mod(x))}return E?D:(A&&(D=i.div(D)),x?D.mod(x):T?L(D,m,a,I):D)},o.integerValue=function(g){var x=new C(this);return g==null?g=a:Rt(g,0,8),L(x,x.e+1,g)},o.isEqualTo=o.eq=function(g,x){return jo(this,new C(g,x))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(g,x){return jo(this,new C(g,x))>0},o.isGreaterThanOrEqualTo=o.gte=function(g,x){return(x=jo(this,new C(g,x)))===1||x===0},o.isInteger=function(){return!!this.c&&lr(this.e/je)>this.c.length-2},o.isLessThan=o.lt=function(g,x){return jo(this,new C(g,x))<0},o.isLessThanOrEqualTo=o.lte=function(g,x){return(x=jo(this,new C(g,x)))===-1||x===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(g,x){var b,E,h,T,I=this,v=I.s;if(g=new C(g,x),x=g.s,!v||!x)return new C(NaN);if(v!=x)return g.s=-x,I.plus(g);var A=I.e/je,P=g.e/je,D=I.c,N=g.c;if(!A||!P){if(!D||!N)return D?(g.s=-x,g):new C(N?I:NaN);if(!D[0]||!N[0])return N[0]?(g.s=-x,g):new C(D[0]?I:a==3?-0:0)}if(A=lr(A),P=lr(P),D=D.slice(),v=A-P){for((T=v<0)?(v=-v,h=D):(P=A,h=N),h.reverse(),x=v;x--;h.push(0));h.reverse()}else for(E=(T=(v=D.length)<(x=N.length))?v:x,v=x=0;x<E;x++)if(D[x]!=N[x]){T=D[x]<N[x];break}if(T&&(h=D,D=N,N=h,g.s=-g.s),x=(E=N.length)-(b=D.length),x>0)for(;x--;D[b++]=0);for(x=Sr-1;E>v;){if(D[--E]<N[E]){for(b=E;b&&!D[--b];D[b]=x);--D[b],D[E]+=Sr}D[E]-=N[E]}for(;D[0]==0;D.splice(0,1),--P);return D[0]?O(g,D,P):(g.s=a==3?-1:1,g.c=[g.e=0],g)},o.modulo=o.mod=function(g,x){var b,E,h=this;return g=new C(g,x),!h.c||!g.s||g.c&&!g.c[0]?new C(NaN):!g.c||h.c&&!h.c[0]?new C(h):(d==9?(E=g.s,g.s=1,b=t(h,g,0,3),g.s=E,b.s*=E):b=t(h,g,0,d),g=h.minus(b.times(g)),!g.c[0]&&d==1&&(g.s=h.s),g)},o.multipliedBy=o.times=function(g,x){var b,E,h,T,I,v,A,P,D,N,S,j,G,M,J,Z=this,oe=Z.c,pe=(g=new C(g,x)).c;if(!oe||!pe||!oe[0]||!pe[0])return!Z.s||!g.s||oe&&!oe[0]&&!pe||pe&&!pe[0]&&!oe?g.c=g.e=g.s=null:(g.s*=Z.s,!oe||!pe?g.c=g.e=null:(g.c=[0],g.e=0)),g;for(E=lr(Z.e/je)+lr(g.e/je),g.s*=Z.s,A=oe.length,N=pe.length,A<N&&(G=oe,oe=pe,pe=G,h=A,A=N,N=h),h=A+N,G=[];h--;G.push(0));for(M=Sr,J=mo,h=N;--h>=0;){for(b=0,S=pe[h]%J,j=pe[h]/J|0,I=A,T=h+I;T>h;)P=oe[--I]%J,D=oe[I]/J|0,v=j*P+D*S,P=S*P+v%J*J+G[T]+b,b=(P/M|0)+(v/J|0)+j*D,G[T--]=P%M;G[T]=b}return b?++E:G.splice(0,1),O(g,G,E)},o.negated=function(){var g=new C(this);return g.s=-g.s||null,g},o.plus=function(g,x){var b,E=this,h=E.s;if(g=new C(g,x),x=g.s,!h||!x)return new C(NaN);if(h!=x)return g.s=-x,E.minus(g);var T=E.e/je,I=g.e/je,v=E.c,A=g.c;if(!T||!I){if(!v||!A)return new C(h/0);if(!v[0]||!A[0])return A[0]?g:new C(v[0]?E:h*0)}if(T=lr(T),I=lr(I),v=v.slice(),h=T-I){for(h>0?(I=T,b=A):(h=-h,b=v),b.reverse();h--;b.push(0));b.reverse()}for(h=v.length,x=A.length,h-x<0&&(b=A,A=v,v=b,x=h),h=0;x;)h=(v[--x]=v[x]+A[x]+h)/Sr|0,v[x]=Sr===v[x]?0:v[x]%Sr;return h&&(v=[h].concat(v),++I),O(g,v,I)},o.precision=o.sd=function(g,x){var b,E,h,T=this;if(g!=null&&g!==!!g)return Rt(g,1,rn),x==null?x=a:Rt(x,0,8),L(new C(T),g,x);if(!(b=T.c))return null;if(h=b.length-1,E=h*je+1,h=b[h]){for(;h%10==0;h/=10,E--);for(h=b[0];h>=10;h/=10,E++);}return g&&T.e+1>E&&(E=T.e+1),E},o.shiftedBy=function(g){return Rt(g,-Ug,Ug),this.times("1e"+g)},o.squareRoot=o.sqrt=function(){var g,x,b,E,h,T=this,I=T.c,v=T.s,A=T.e,P=s+4,D=new C("0.5");if(v!==1||!I||!I[0])return new C(!v||v<0&&(!I||I[0])?NaN:I?T:1/0);if(v=Math.sqrt(+B(T)),v==0||v==1/0?(x=sr(I),(x.length+A)%2==0&&(x+="0"),v=Math.sqrt(+x),A=lr((A+1)/2)-(A<0||A%2),v==1/0?x="5e"+A:(x=v.toExponential(),x=x.slice(0,x.indexOf("e")+1)+A),b=new C(x)):b=new C(v+""),b.c[0]){for(A=b.e,v=A+P,v<3&&(v=0);;)if(h=b,b=D.times(h.plus(t(T,h,P,1))),sr(h.c).slice(0,v)===(x=sr(b.c)).slice(0,v))if(b.e<A&&--v,x=x.slice(v-3,v+1),x=="9999"||!E&&x=="4999"){if(!E&&(L(h,h.e+s+2,0),h.times(h).eq(T))){b=h;break}P+=4,v+=4,E=1}else{(!+x||!+x.slice(1)&&x.charAt(0)=="5")&&(L(b,b.e+s+2,1),g=!b.times(b).eq(T));break}}return L(b,b.e+s+1,a,g)},o.toExponential=function(g,x){return g!=null&&(Rt(g,0,rn),g++),z(this,g,x,1)},o.toFixed=function(g,x){return g!=null&&(Rt(g,0,rn),g=g+this.e+1),z(this,g,x)},o.toFormat=function(g,x,b){var E,h=this;if(b==null)g!=null&&x&&typeof x=="object"?(b=x,x=null):g&&typeof g=="object"?(b=g,g=x=null):b=w;else if(typeof b!="object")throw Error(Rn+"Argument not an object: "+b);if(E=h.toFixed(g,x),h.c){var T,I=E.split("."),v=+b.groupSize,A=+b.secondaryGroupSize,P=b.groupSeparator||"",D=I[0],N=I[1],S=h.s<0,j=S?D.slice(1):D,G=j.length;if(A&&(T=v,v=A,A=T,G-=T),v>0&&G>0){for(T=G%v||v,D=j.substr(0,T);T<G;T+=v)D+=P+j.substr(T,v);A>0&&(D+=P+j.slice(T)),S&&(D="-"+D)}E=N?D+(b.decimalSeparator||"")+((A=+b.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(b.fractionGroupSeparator||"")):N):D}return(b.prefix||"")+E+(b.suffix||"")},o.toFraction=function(g){var x,b,E,h,T,I,v,A,P,D,N,S,j=this,G=j.c;if(g!=null&&(v=new C(g),!v.isInteger()&&(v.c||v.s!==1)||v.lt(i)))throw Error(Rn+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+B(v));if(!G)return new C(j);for(x=new C(i),P=b=new C(i),E=A=new C(i),S=sr(G),T=x.e=S.length-j.e-1,x.c[0]=jg[(I=T%je)<0?je+I:I],g=!g||v.comparedTo(x)>0?T>0?x:P:v,I=p,p=1/0,v=new C(S),A.c[0]=0;D=t(v,x,0,1),h=b.plus(D.times(E)),h.comparedTo(g)!=1;)b=E,E=h,P=A.plus(D.times(h=P)),A=h,x=v.minus(D.times(h=x)),v=h;return h=t(g.minus(b),E,0,1),A=A.plus(h.times(P)),b=b.plus(h.times(E)),A.s=P.s=j.s,T=T*2,N=t(P,E,T,a).minus(j).abs().comparedTo(t(A,b,T,a).minus(j).abs())<1?[P,E]:[A,b],p=I,N},o.toNumber=function(){return+B(this)},o.toPrecision=function(g,x){return g!=null&&Rt(g,1,rn),z(this,g,x,2)},o.toString=function(g){var x,b=this,E=b.s,h=b.e;return h===null?E?(x="Infinity",E<0&&(x="-"+x)):x="NaN":(g==null?x=h<=u||h>=c?Dl(sr(b.c),h):Yr(sr(b.c),h,"0"):g===10&&F?(b=L(new C(b),s+h+1,a),x=Yr(sr(b.c),b.e,"0")):(Rt(g,2,k.length,"Base"),x=n(Yr(sr(b.c),h,"0"),10,g,E,!0)),E<0&&b.c[0]&&(x="-"+x)),x},o.valueOf=o.toJSON=function(){return B(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&C.set(e),C}function lr(e){var t=e|0;return e>0||e===t?t:t-1}function sr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=je-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function jo(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 Rt(e,t,n,r){if(e<t||e>n||e!==ar(e))throw Error(Rn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Bl(e){var t=e.c.length-1;return lr(e.e/je)==t&&e.c[t]%2!=0}function Dl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Yr(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 RR=Zw(),ev=RR;var zR=24,js=32,NR=()=>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,Wg=NR(),Hg=(e=4,t=Wg)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function OR(e){let t=new ev(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var nv=(e="")=>{let t=new TextEncoder;return OR(Qw(t.encode(e))).toString(36).slice(1)},tv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),_R=e=>tv[Math.floor(e()*tv.length)],$R=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=Wg}={})=>{let n=Object.keys(e).toString(),r=n.length?n+Hg(js,t):Hg(js,t);return nv(r).substring(0,js)},UR=e=>()=>e++,jR=476782367,rv=({random:e=Wg,counter:t=UR(Math.floor(e()*jR)),length:n=zR,fingerprint:r=$R({random:e})}={})=>{if(n>js)throw new Error(`Length must be between 2 and ${js}. Received: ${n}`);return function(){let i=_R(e),s=Date.now().toString(36),a=t().toString(36),u=Hg(n,e),c=`${s+u+a+r}`;return`${i+nv(c).substring(1,n)}`}},ho=HR(rv);function HR(e){let t;return()=>(t||(t=e()),t())}var GR=La(sv());Ls();De();var Rl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function qR(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function Vg(e,t){let n=[],r=e.split(`
|
|
15
|
+
`);for(let s=0;s<r.length;s++){let a=qR(r[s]),u=Rl.exec(a);if(u){let[,c,l,,p]=u,f=YR(l),d=KR(r,s+1),m={id:ho(),reviewId:t,type:c.trim(),severity:f,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(m)}Rl.lastIndex=0}return n.map(s=>{let a=Ps(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 YR(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function KR(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||Rl.test(i)){Rl.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}De();var Hs=null,av=0,XR=3e4;async function QR(){let e=Date.now();if(Hs&&e-av<XR)return Hs;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 Hs=n.entries||n.stories||{},av=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Hs).length),Hs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ws(e){try{let n=(await QR())[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 Gg(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function JR(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 qg(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):JR(e.type,t)}De();function ZR(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 ez(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 tz(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 nz(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 Yg(e){if(!e||e.length===0)return[];let t=e.filter(i=>!tz(i)),n=[],r=[];for(let i of t){let s=ZR(i),a=ez(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(nz(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}De();Ue();import{addons as zl}from"storybook/manager-api";var Kg="uireview/badge",Ii={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function rz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function oz(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 iz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Fi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function cv(e){if(Fi())try{zl.getChannel().emit(Ii.REVIEW_START,{storyId:e})}catch{}}function xo(e,t){if(Fi())try{zl.getChannel().emit(Ii.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function uv(e){if(Fi())try{zl.getChannel().emit(Ii.REVIEW_ERROR,{storyId:e})}catch{}}function lv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}function pv(e){let t=zl.getChannel(),n=o=>i=>{Fi()&&o(i)};t.on(Ii.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:Kg,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Ii.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:rz(i),typeId:Kg,storyId:o,title:iz(i),description:oz(i)}])})),t.on(Ii.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:Kg,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Fi();r||lv(e),setInterval(()=>{let o=Fi();o!==r&&(r=o,o||lv(e))},1500)}var Xg=q(),Qg=180;function yo(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 Jg=()=>{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:f,setReviewResults:d,setShowReviewMenu:m,setSeverityFilter:w,setShowStreamingPanel:k,setStreamingPanelCollapsed:F,addStreamingMessage:C,updateStreamingMessage:z,clearStreamingMessages:R,setStreamingProgress:O,setStreamingStatus:L,setFullPrompt:B,setFullResponse:g,setFigmaImageUrl:x,storybookImageUrl:b,setStorybookImageUrl:E,setFigmaDimensions:h,setMultiModelResults:T,updateMultiModelStreamingMessages:I,setModelCompleted:v,setActiveModelId:A,resetReview:P,addReview:D,setReviewDetailTab:N,includeTextComparison:S,usePromptCache:j,setApplyFixesResult:G,featureFlags:M}=se(),{sessionToken:J,usageData:Z,setUsageData:oe}=Se(),{selectedProjectId:pe}=Ze(),{currentStoryId:ae,currentStoryName:qe}=rt(),tt=Nl(Z);tt.current=Z;let Ve=Nl(null),te=Nl(null),Be=Nl({}),Le=Vs((Ge,lt)=>{C({role:Ge,content:lt})},[C]),de=Vs((Ge,lt)=>{O(Ge),L(lt)},[O,L]),Et=Vs(async Ge=>{let{isIteration:lt=!1,parentReviewId:nt=null}=Ge||{};if(!J)throw new Error("Not authenticated");if(!pe)throw new Error("No project selected");if(!ae||!qe)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let re=Date.now();try{p(!0),f(null),d(null),N("issues"),G(null),ae&&M.enableReviewBadges&&cv(ae),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${Qg}s timeout`),Ve.current&&Ve.current.abort(),C({role:"system",content:`Review auto-stopped after ${Qg} seconds timeout.`})},Qg*1e3),B(""),g(""),k(!0),F(!1),R(),de(0,"Starting review..."),de(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await Pl(),y.debug("[Review] Iframe reloaded, styles should be fresh"),de(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[W,Fe,me]=await Promise.all([El({sessionToken:J||void 0}),Promise.resolve($s()),Promise.resolve(Bg())]);if(W&&W!==b&&(E(W),y.debug("[Review] Storybook screenshot captured and set")),!Fe)throw new Error("Failed to extract styles from component");let{computed:_,declared:U,markup:H,textElementStyles:Ee,nestedElementStyles:ze}=Fe;me?y.debug("[Review] DOM tree extracted:",{selector:me.selector,childrenCount:me.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")),de(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:ae,name:qe});let xt=mt.getState().currentMapping?.figmaNodeId??null,Un=mt.getState().figmaImageUrl;if(xt&&(y.debug("[Review] Using Figma node ID from store:",xt),Un&&(de(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!xt)try{let Xe=await fetch(`${Xg}/api/mappings?projectId=${pe}&storyId=${ae}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${J}`}});if(Xe.ok){let Dt=await Xe.json();Dt.mapping?.figmaNodeId?(xt=Dt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",xt)):y.debug("[Review] No mapping found for story:",ae)}else y.debug("[Review] Failed to fetch mapping:",Xe.status)}catch(Xe){y.error("[Review] Error fetching mapping:",Xe)}if(xt&&!Un){de(65,"Fetching Figma design...");try{let Xe=await fetch(`${Xg}/api/figma/frames?projectId=${pe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${J}`}});if(Xe.ok){let Ot=(await Xe.json()).thumbnails?.[xt];Ot?(x(Ot),y.debug("[Review] Figma thumbnail fetched and displayed:",Ot)):y.warn("[Review] No thumbnail found for node:",xt)}else y.warn("[Review] Failed to fetch Figma frames:",Xe.status)}catch(Xe){y.error("[Review] Error fetching Figma frames:",Xe)}}if(!xt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');de(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let Qn={projectId:pe,storyId:ae,storyName:qe,storybookScreenshot:W,computedStyles:_,declaredStyles:U,textElementStyles:Ee,nestedElementStyles:ze,componentMarkup:H,domTree:me,figmaNodeId:xt,figmaImageUrl:Un||void 0,aiModels:l,includeTextComparison:S,usePromptCache:j,parentReviewId:lt?nt:void 0,isIteration:lt};y.debug("[Review] Request payload:",{...Qn,storybookScreenshot:W?`${W.substring(0,50)}...`:null,domTree:me?{selector:me.selector,childrenCount:me.children.length}:null}),Ve.current=new AbortController;let In=await fetch(`${Xg}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${J}`},body:JSON.stringify(Qn),signal:Ve.current.signal});if(y.debug("[Review] Response status:",In.status,In.statusText),!In.ok){let Xe=await In.json();if(y.error("[Review] API error response:",Xe),In.status===429){let Dt=Xe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Dt} seconds before trying again.`)}if(In.status===402){if(Xe.code==="INSUFFICIENT_CREDITS"){let Dt=Xe.details?.required??1,Ot=Xe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Dt} credit(s) but you have ${Ot}. Visit Settings to add more.`)}throw Xe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Xe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Xe.message||"Payment required")}throw In.status===401&&Xe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Xe.error||Xe.message||"Review request failed")}let oo=In.body?.getReader(),bn=new TextDecoder,Ir="",Zt="",Ne=null,Qc=null,jx=l.length>1,Bo={},Zi={},A8={};if(!oo)throw new Error("Response body is not readable");let Hx=mt.getState().streamingMessages.length;for(Le("assistant","");;){let{done:Xe,value:Dt}=await oo.read();if(Xe)break;Ir+=bn.decode(Dt,{stream:!0});let Ot=Ir.split(`
|
|
17
|
+
`);Ir=Ot.pop()||"";for(let jn of Ot)if(jn.startsWith("data: ")){let ln=jn.slice(6);if(ln==="[DONE]")continue;try{let ne=JSON.parse(ln);if(ne.type!=="text"&&ne.type!=="content"&&y.debug("[Review] SSE Event received:",ne.type),ne.type==="prompt")ne.prompt&&(B(ne.prompt),y.debug("[Review] Prompt received early"));else if(ne.type==="model_started")y.debug("[Review] Model started:",ne.modelId),Bo[ne.modelId]||(Bo[ne.modelId]="",Zi[ne.modelId]=[{role:"assistant",content:""}]);else if(ne.type==="text"||ne.type==="content")if(jx&&ne.modelId){Bo[ne.modelId]||(Bo[ne.modelId]="",Zi[ne.modelId]=[{role:"assistant",content:""}]),Bo[ne.modelId]+=ne.content,Zi[ne.modelId][0].content=Bo[ne.modelId],I(ne.modelId,Zi[ne.modelId]);let Gt=Object.entries(Bo).map(([cn,st])=>`[${cn}]
|
|
18
18
|
${st}`).join(`
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
`);
|
|
22
|
+
`);z(Hx,Gt)}else Zt+=ne.content,z(Hx,Zt);else if(ne.type==="model_completed")y.debug("[Review] Model completed:",ne.modelId,ne.complianceScore),v(ne.modelId);else if(ne.type==="figma_image")ne.url&&(x(ne.url),y.debug("[Review] Figma image URL received:",ne.url));else if(ne.type==="figma_dimensions")ne.width&&ne.height&&(h({width:ne.width,height:ne.height}),y.debug("[Review] Figma dimensions received:",ne.width,"x",ne.height));else if(ne.type==="complete"||ne.type==="result")Ne=ne,y.debug("[Review] Final result received! Type:",ne.type),y.debug("[Review] Final result issues count:",ne.issues?.length||0),y.debug("[Review] Final result score:",ne.validation?.complianceScore),ne.remainingCredits!=null&&tt.current&&oe({...tt.current,creditBalance:ne.remainingCredits,reviewCredits:Math.floor(ne.remainingCredits)});else if(ne.type==="all_complete")Ne=ne,y.debug("[Review] Multi-model results received:",Object.keys(ne.byModel)),ne.remainingCredits!=null&&tt.current&&oe({...tt.current,creditBalance:ne.remainingCredits,reviewCredits:Math.floor(ne.remainingCredits)});else if(ne.type==="error"||ne.type==="model_error"){let Gt=new Error(ne.message||ne.error||"Streaming error");throw Gt.isServerError=!0,Gt}}catch(ne){if(ne.isServerError)throw ne;let Gt=ne instanceof Error?{message:ne.message,name:ne.name,stack:ne.stack}:String(ne);y.error("[Review] Error parsing SSE data:",Gt),y.error("[Review] Failed to parse data:",ln.substring(0,200)+(ln.length>200?"...":"")),Qc=ne instanceof Error?ne:new Error(String(ne))}}}if(de(100,"Review complete!"),!Ne&&Qc&&(y.error("[Review] No final result received. Last parse error:",Qc),y.error("[Review] Streaming text available:",Zt.length,"chars")),jx&&Ne?.type==="all_complete"){let Xe=Object.keys(Ne.byModel).reduce((Ot,jn)=>{let ln=Ne.byModel[jn];return Ot[jn]={...ln,fullResponse:ln.response||ln.fullResponse||"",fullPrompt:ln.prompt||ln.fullPrompt||"",streamingMessages:Zi[jn]||[]},Ot},{}),Dt=Object.keys(Ne.byModel)[0];T({byModel:Xe,activeModelId:Dt}),Xe[Dt]?.fullPrompt&&B(Xe[Dt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys(Ne.byModel));try{let Ot=ho(),jn=Ne.byModel?.[Dt]?.issues,ln=jn&&jn.length>0,ne=ln?jn.map(ge=>({id:ho(),reviewId:Ot,dbId:ge.dbId,type:ge.type,severity:ge.severity,title:ge.description,description:ge.description,property:ge.property,expected:yo(ge.expected),actual:yo(ge.actual),currentValue:yo(ge.actual),suggestedValue:yo(ge.expected),source:ge.source||"computed-styles",suggestedFix:ge.suggestedFix,file:ge.file,domElement:ge.domElement,figmaElement:ge.figmaElement,fixTarget:ge.fixTarget,fixRequired:ge.fixRequired,detectedBy:ge.detectedBy,dismissed:ge.dismissed??!1,dismissReason:ge.dismissReason,dismissedAt:ge.dismissed?new Date:void 0,_unreliable:ge._unreliable,_validationError:ge._validationError,figmaContext:ge.figmaContext,relatedTo:Array.isArray(ge.relatedTo)?ge.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Vg(Xe[Dt]?.fullResponse||"",Ot);y.debug("[Review] Multi-model issues source:",ln?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",ne.length,"issues");let Gt=ne.filter(ge=>ge.dismissed).length;Gt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Gt,"false positive issues"),Le("system",`
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
\u2705 ${Gt} issue${Gt>1?"s were":" was"} auto-dismissed as false positive${Gt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let cn=
|
|
26
|
+
\u2705 ${Gt} issue${Gt>1?"s were":" was"} auto-dismissed as false positive${Gt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let cn=Be.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Be.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=ne.map(ge=>({...ge,file:ge.file||Gg(ge.fixTarget,cn)||qg(ge,cn)}));if(st=Yg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!S){let ge=st.length;st=st.filter(Sn=>Sn.property?.toLowerCase()!=="textcontent"&&!Sn.description?.toLowerCase().includes("text content")),ge!==st.length&&y.debug("[Review] Filtered out",ge-st.length,"textContent issues (toggle OFF)")}let Fr=Ne.validation?.complianceScore??Xe[Dt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:Dt,validationScore:Ne.validation?.complianceScore,modelScore:Xe[Dt]?.complianceScore,multiModelScore:Fr}),Fr==null){let Sn=(Xe[Dt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Fr=Sn?parseInt(Sn[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",Fr)}let Fn;lt&&nt&&(Fn=(mt.getState().reviewHistory.find(Sn=>Sn.id===nt)?.iterationNumber||0)+1);let es={id:Ot,componentId:ae,storyId:ae,modelId:Dt,parentReviewId:lt&&nt||void 0,iterationNumber:Fn,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Un||void 0,complianceScore:Fr,visualSimilarity:Ne.visualSimilarity,issuesCount:st.filter(ge=>!ge.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-re,costUsd:Ne.costUsd,inputTokens:Ne.inputTokens,outputTokens:Ne.outputTokens,cacheCreationTokens:Ne.cacheCreationTokens,cacheReadTokens:Ne.cacheReadTokens};if(y.debug("[Review] Multi-model token data:",{costUsd:Ne.costUsd,inputTokens:Ne.inputTokens,outputTokens:Ne.outputTokens,cacheCreationTokens:Ne.cacheCreationTokens,cacheReadTokens:Ne.cacheReadTokens,reviewTokens:es.inputTokens}),D(es),ae&&M.enableReviewBadges){let ge=st.filter(Sn=>!Sn.dismissed);xo(ae,{score:Fr??100,issueCount:ge.length,criticalCount:ge.filter(Sn=>Sn.severity==="critical").length,majorCount:ge.filter(Sn=>Sn.severity==="major").length,minorCount:ge.filter(Sn=>Sn.severity==="minor").length})}N("issues");let Aa=st.filter(ge=>!ge.dismissed).length;y.debug("[Review] Created multi-model review with",Aa,"active issues,",st.length-Aa,"dismissed");let be=xt||mt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",st.filter(ge=>!ge.dismissed).length,"Dismissed:",st.filter(ge=>ge.dismissed).length)}catch(Ot){y.error("[Review] Failed to parse issues from multi-model response:",Ot)}}else if(Ne){Ne.prompt&&B(Ne.prompt),(Ne.response||Zt)&&g(Ne.response||Zt),Ne.figmaImageUrl&&x(Ne.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Xe=ho(),Dt=Ne.response||Zt,Ot=Ne.issues,jn=Ot&&Ot.length>0,ln=jn?Ot.map(be=>({id:ho(),reviewId:Xe,dbId:be.dbId,type:be.type,severity:be.severity,title:be.description,description:be.description,property:be.property,expected:yo(be.expected),actual:yo(be.actual),currentValue:yo(be.actual),suggestedValue:yo(be.expected),source:be.source||"computed-styles",suggestedFix:be.suggestedFix,file:be.file,domElement:be.domElement,figmaElement:be.figmaElement,fixTarget:be.fixTarget,fixRequired:be.fixRequired,detectedBy:be.detectedBy,dismissed:be.dismissed??!1,dismissReason:be.dismissReason,dismissedAt:be.dismissed?new Date:void 0,_unreliable:be._unreliable,_validationError:be._validationError,figmaContext:be.figmaContext,relatedTo:Array.isArray(be.relatedTo)?be.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Vg(Dt,Xe);y.debug("[Review] Issues source:",jn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",ln.length,"issues");let ne=ln.filter(be=>be.dismissed).length;ne>0&&(y.debug("[Review] Auto-dismissed:",ne,"false positive issues"),Le("system",`
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
\u2705 ${te} issue${te>1?"s were":" was"} auto-dismissed as false positive${te>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Gt=Oe.complianceScore??Oe.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Oe.complianceScore,validationScore:Oe.validation?.complianceScore,parsedScore:Gt}),Gt==null){let Se=Bt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Gt=Se?parseInt(Se[1],10):void 0,y.debug("[Review] Parsed score from response:",Gt)}let cn=Ie.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Ie.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=ln.map(Se=>({...Se,file:Se.file||Gg(Se.fixTarget,cn)||qg(Se,cn)}));if(st=Yg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!w){let Se=st.length;st=st.filter(fe=>fe.property?.toLowerCase()!=="textcontent"&&!fe.description?.toLowerCase().includes("text content")),Se!==st.length&&y.debug("[Review] Filtered out",Se-st.length,"textContent issues (toggle OFF)")}let Fr;lt&&nt&&(Fr=(mt.getState().reviewHistory.find(fe=>fe.id===nt)?.iterationNumber||0)+1);let Fn={id:Xe,componentId:ae,storyId:ae,modelId:l[0],parentReviewId:lt&&nt||void 0,iterationNumber:Fr,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Un||void 0,complianceScore:Gt,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(Se=>!Se.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ne,costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens,variantMismatch:Oe.variantMismatch,storybookVariant:Oe.storybookVariant,figmaVariant:Oe.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:Fn.id,storyId:Fn.storyId,issueCount:Fn.issues?.length,complianceScore:Fn.complianceScore,createdAt:Fn.createdAt?.toISOString(),inputTokens:Fn.inputTokens,outputTokens:Fn.outputTokens,costUsd:Fn.costUsd,cacheCreationTokens:Fn.cacheCreationTokens,cacheReadTokens:Fn.cacheReadTokens}),D(Fn),y.debug("[useAIReview] addReview called successfully"),ae&&L.enableReviewBadges){let Se=st.filter(fe=>!fe.dismissed);xo(ae,{score:Gt??100,issueCount:Se.length,criticalCount:Se.filter(fe=>fe.severity==="critical").length,majorCount:Se.filter(fe=>fe.severity==="major").length,minorCount:Se.filter(fe=>fe.severity==="minor").length})}N("issues");let es=st.filter(Se=>!Se.dismissed).length;y.debug("[Review] Created review with",es,"active issues,",st.length-es,"dismissed");let Ea=xt||mt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:xt,effectiveFigmaNodeIdSingle:Ea,hasSessionToken:!!K,selectedProjectId:de,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(Se=>!Se.dismissed).length,"Dismissed:",st.filter(Se=>Se.dismissed).length)}catch(Xe){y.error("[Review] Failed to parse issues:",Xe)}}else throw Zt?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",Zt.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(W){if(W instanceof Error&&W.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),me(0,"Review cancelled");return}y.error("[useAIReview] Review error:",W);let Ae=W instanceof Error?W.message:"Review failed";throw f(Ae),ae&&L.enableReviewBadges&&uv(ae),me(0,`Error: ${Ae}`),W}finally{d(!1),se.current=null,pe.current&&(clearTimeout(pe.current),pe.current=null),re(null)}},[e,K,de,ae,qe,l,d,f,p,T,I,v,A,C,F,z,ze,me,R,E,x,B,m,re]),he=Vs(()=>n?.issues?o==="all"?n.issues:n.issues.filter(Ge=>Ge.severity===o):[],[n,o]),vt=Vs(()=>{se.current&&(y.debug("[useAIReview] Cancelling review..."),se.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Nt,cancelReview:vt,setShowReviewMenu:g,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:_,setStreamingStatus:M,resetReview:P,getFilteredIssues:he}};ve();De();je();import{useCallback as FX}from"react";var LX=q();ve();De();import{useEffect as dv,useRef as fv}from"react";import{useStorybookApi as sz,useStorybookState as az,addons as lz}from"storybook/manager-api";var gv="storyArgsUpdated",Zg=()=>{let e=sz(),t=az(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=rt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ie(),l=fv(null),d=fv(0);return dv(()=>{let f=t.storyId;if(f){l.current!==f&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",f),s(f),l.current=f,d.current=Date.now()),o(f);let p=e.getData(f),g=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||f;i(g),y.debug("[useCurrentStory] Current story:",{storyId:f,fullName:g})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),dv(()=>{let f=lz.getChannel(),p=null,g=S=>{if(S.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:C,isValidating:F}=mt.getState();if(C||F){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 f.on(gv,g),()=>{f.off(gv,g),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ve();je();pt();import{useCallback as mv}from"react";import{addons as hv}from"storybook/manager-api";var xv=q(),Ho=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=rt(),{sessionToken:o}=we(),{selectedProjectId:i}=Ze(),s=mv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await oe(`${xv}/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{hv.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=mv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await oe(`${xv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{hv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Ns();ve();import{useCallback as em,useEffect as yv,useRef as cz}from"react";import{useChannel as uz,addons as bv}from"storybook/manager-api";De();var pz=3e4,dz="forceRemount";function fz(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 gz(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 mz="UICOPILOT/APPLY_FIXES",hz="UICOPILOT/FIX_STARTED",xz="UICOPILOT/FIX_COMPLETED",yz="UICOPILOT/FIX_FAILED",bz="UICOPILOT/ALL_FIXES_APPLIED",tm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ie(),c=cz(null),l=em(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);yv(()=>()=>l(),[l]),yv(()=>{let g=bv.getChannel(),S=()=>{mt.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 g.on("channelWSDisconnect",S),()=>g.off("channelWSDisconnect",S)},[l,o,i]);let d=uz({[hz]:({issueId:g})=>{y.debug(`[useApplyFixes] Fix started for issue: ${g}`),a(g,{status:"applying"})},[xz]:({issueId:g,result:S})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${g}`,S),s(g,"applied"),a(g,{status:"applied"})},[yz]:({issueId:g,error:S})=>{y.error(`[useApplyFixes] Fix failed for issue: ${g}`,S),s(g,"failed",S),a(g,{status:"failed",error:S})},[bz]:async({summary:g})=>{if(y.debug("[useApplyFixes] All fixes applied:",g),l(),o(!1),i({succeeded:g.succeeded,failed:g.failed,total:g.total}),g.failed>0?y.warn(`Applied ${g.succeeded}/${g.total} fixes. ${g.failed} failed.`):y.debug(`Successfully applied all ${g.total} fixes!`),g.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{bv.getChannel().emit(dz,{storyId:mt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(S){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",S)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Al(),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")}}),f=em(g=>{let S=[],C=[],F=[];for(let k of g){let R=k.currentValue||k.actual||"",z=k.suggestedValue||k.expected||"";if(R&&z&&fz(R,z)){S.push(k);continue}if(gz(k)){C.push(k);continue}let _=k.generatedFix?.filePath||k.file||"";if(!_){y.warn(`[useApplyFixes] Skipping issue ${k.id} - no target file path`);continue}let M=_.toLowerCase().split(".").pop()||"",B=["tsx","jsx","ts","js"].includes(M)?"component":"css";F.push({...k,targetFilePath:_,targetFileType:B})}return{actionable:F,negligible:S,designTokens:C}},[]);return{applyFixes:em(g=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(g.length===0){y.warn("[useApplyFixes] No issues to fix");return}let S=f(g);if(S.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${S.negligible.length} negligible issue(s)`),S.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${S.designTokens.length} design token suggestion(s)`),S.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let C=S.actionable.filter(R=>R.targetFileType==="css"),F=S.actionable.filter(R=>R.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),C.length>0){let R=[...new Set(C.map(z=>z.targetFilePath))];y.debug(` - ${C.length} CSS issue(s) in: ${R.join(", ")}`)}if(F.length>0){let R=[...new Set(F.map(z=>z.targetFilePath))];y.debug(` - ${F.length} component issue(s) in: ${R.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:S.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{mt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:S.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},pz),d(mz,{issues:S.actionable,storybookRoot:n||void 0})},[d,r,o,i,f,n,l]),isApplying:r}};ve();je();import{useState as JX}from"react";var tQ=q();ve();import{useState as Wo}from"react";je();De();pt();var Sz=q();async function Nl(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 oe(`${Sz}/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 Sv(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=>Nl(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"}}Ls();Dg();Ns();De();je();var wz=["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"],vz=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],kz=q();function nm(){let[e,t]=Wo(!1),[n,r]=Wo(null),[o,i]=Wo(null),[s,a]=Wo(null),[u,c]=Wo(null),[l,d]=Wo(null),[f,p]=Wo(null),{sessionToken:g}=we(),{selectedProjectId:S}=Ze(),{currentStoryId:C,currentStoryName:F}=rt(),{workspacePath:k,updateIssueGeneratedFix:R,batchUpdateIssueGeneratedFixes:z,includeComponentIssues:_,dismissIssue:M,recalculateScore:B,addStreamingMessage:m}=ie();return{generateBatchFixes:async b=>{if(!g){r("Not authenticated");return}if(!S){r("No project selected");return}if(!C){r("No story selected");return}if(b.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:b.length,completed:0});let E=b.map(h=>({issueId:h.id,generatedFix:{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"",status:"generating"}}));z(E);try{y.debug("[useBatchGenerateFixes] Generating fixes for",b.length,"issues");let h=null;try{let w=$s();w?.computed&&(h=w.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(w){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",w)}let T=null;try{T=await Ws(C),T&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",T)}catch(w){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",w)}let I=await fetch(`${kz}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:S,storyId:C,workspacePath:k,includeComponentIssues:_,computedStyles:h,storyFilePaths:T,reviewContext:{storyName:F||void 0,variantArgs:Ci()||void 0},issues:b.map(w=>({id:w.id,dbId:w.dbId,title:w.title,description:w.description,property:w.property,currentValue:w.currentValue,suggestedValue:w.suggestedValue,file:w.file,lineNumber:w.lineNumber,severity:w.severity,type:w.type,fixTarget:w.fixTarget,domElement:w.domElement,figmaContext:w.figmaContext,suggestedFix:w.suggestedFix}))})});if(!I.ok){let w=await I.json().catch(()=>({}));throw new Error(w.error||"Batch fix generation failed")}let v=await I.json();if(!v.success)throw new Error(v.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",v.result.fixes.length,"fixes"),v.result.storybookRoot&&(p(v.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",v.result.storybookRoot)),v.result.selfReview&&(d(v.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",v.result.selfReview)),v.result.partialFailure){let{failedBatches:w,errors:j}=v.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${w.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${w.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:b.length,completed:v.result.fixes.length});let A=new Set(v.result.fixes.map(w=>w.issueId)),P=b.filter(w=>!A.has(w.id));P.length>0&&(y.warn(`[useBatchGenerateFixes] ${P.length} issues not returned by API, marking as failed`),P.forEach(w=>{R(w.id,{code:"",diffPreview:"",filePath:w.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),v.timing&&(i({durationSec:v.timing.durationSec,issueCount:v.timing.issueCount,avgPerIssueSec:v.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${v.timing.durationSec}s for ${v.timing.issueCount} issues`)),v.result?.usage&&(c({inputTokens:v.result.usage.inputTokens||0,outputTokens:v.result.usage.outputTokens||0,costUsd:v.result.usage.costUsd||0,modelId:v.result.usage.modelId||"unknown",provider:v.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${v.result.usage.inputTokens} in, ${v.result.usage.outputTokens} out, $${v.result.usage.costUsd?.toFixed(4)}`));let D=[],N=[];if(v.result.fixes.forEach(w=>{let j=w.noChangesNeeded===!0;if(!j){let K=(w.fixStrategy||"").toLowerCase(),ee=(w.generatedCode||"").toLowerCase(),re=(w.diffPreview||"").toLowerCase(),de=wz.some(qe=>K.includes(qe.toLowerCase())||K.replace(/[-_]/g,"").includes(qe.replace(/[-_]/g,""))),ae=vz.some(qe=>ee.includes(qe)||re.includes(qe));j=de||ae}let G=b.find(K=>K.id===w.issueId);if(j&&G){let K=G.suggestedValue,ee=G.currentValue;K&&ee&&!$o(K,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${K}", actual="${ee}"), NOT auto-dismissing issue ${w.issueId}`),j=!1)}let L=G?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${w.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:L,detectedBy:G?.detectedBy,noChangesNeeded:w.noChangesNeeded,fixStrategy:w.fixStrategy,title:G?.title?.substring(0,50)}),L&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${w.issueId} (detectedBy: ${G?.detectedBy})`),j=!1),j){let K=`Auto-dismissed: ${w.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${w.issueId} - noChangesNeeded: ${w.noChangesNeeded}, strategy: "${w.fixStrategy}"`),M(w.issueId,K),D.push({localId:w.issueId,dbId:G?.dbId,dismissReason:K}),N.push({issueId:w.issueId,generatedFix:{code:w.generatedCode||"",diffPreview:w.diffPreview||"",filePath:w.filePath,confidence:w.confidence,strategy:w.fixStrategy,status:"ready",error:void 0,noChangesExplanation:w.noChangesExplanation}})}else{let K=w.error||w.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:w.issueId,generatedFix:{code:w.generatedCode,diffPreview:w.diffPreview,filePath:w.filePath,confidence:w.confidence,strategy:w.fixStrategy,status:K,error:w.error,noChangesExplanation:w.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),z(N)),D.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${D.length} false positive(s), recalculating score`),B(),g){let j=D.filter(G=>G.dbId).map(G=>({dbId:G.dbId,dismissed:!0,dismissReason:G.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Sv(j,g).then(G=>{G.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${G.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",G.error)}).catch(G=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",G)}))}let w=D.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${D.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;m({role:"system",content:w})}y.debug("[useBatchGenerateFixes] Updated",v.result.fixes.length,"issues with fixes")}catch(h){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",h),r(h?.message||"Failed to generate batch fixes");let T=b.map(I=>({issueId:I.id,generatedFix:{code:"",diffPreview:"",filePath:I.file||"",confidence:0,strategy:"",status:"failed",error:h?.message||"Failed to generate fix"}}));z(T)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:f}}ve();De();je();pt();import{useState as rm,useCallback as om}from"react";var Cz=q();function im(){let[e,t]=rm([]),[n,r]=rm(!1),[o,i]=rm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Ze(),{currentStoryId:u}=rt(),{setReviewResults:c}=ie(),l=om(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let g=await oe(`${Cz}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!g.ok){let C=await g.json().catch(()=>({}));throw new Error(C.error||"Failed to fetch reviews")}let S=await g.json();if(!S.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",S.reviews.length,"reviews for:",u),t(S.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=om(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let g=[];if(typeof p.models=="string")try{g=JSON.parse(p.models)}catch(k){y.error("[useReviewHistory] Failed to parse models:",k),g=["claude-sonnet-4-20250514"]}else g=p.models;let S=p.issues.map(k=>({id:k.id,reviewId:p.id,type:k.type,severity:k.severity,title:k.description,description:k.description,file:void 0,lineNumber:void 0,property:k.property,currentValue:k.actual,suggestedValue:k.expected,suggestedCode:k.suggestedFix||void 0,status:k.status,dismissed:k.dismissed||!1,dismissReason:k.dismissReason,dismissedBy:k.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(k.createdAt)})),C=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,F=p.storyId||"";if(c({id:p.id,componentId:"",storyId:F,modelId:g[0]||"claude-sonnet-4-5-20250929",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:S,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:C}),F){let k=p.issues.filter(M=>!M.dismissed),R=k.filter(M=>M.severity==="critical").length,z=k.filter(M=>M.severity==="major").length,_=k.filter(M=>M.severity==="minor").length;xo(F,{score:p.complianceScore,issueCount:k.length,criticalCount:R,majorCount:z,minorCount:_})}},[c]),f=om(p=>{let g=e.find(S=>S.id===p);if(!g){y.error("[useReviewHistory] Review not found:",p);return}d(g)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:f}}ve();De();import{useEffect as Tz,useState as Iz,useRef as Ol}from"react";import{useChannel as Fz}from"storybook/manager-api";var Ez="UICOPILOT/WORKSPACE_PATH",wv="UICOPILOT/REQUEST_WORKSPACE_PATH",Az=3e3,Pz=500,Lz=5,sm=()=>{let[e,t]=Iz({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ie(),r=Ol(!1),o=Ol(null),i=Ol(0),s=Ol(null),a=Fz({[Ez]:({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 Tz(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(wv,{}),s.current=setInterval(()=>{!r.current&&i.current<Lz&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(wv,{}))},Pz),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}))}},Az),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},am=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}};ve();je();import{useEffect as Mz,useRef as Bz}from"react";var MQ=q(),Dz=new Set;function lm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Ze(),n=Bz(!1);Mz(()=>{t&&Dz.add(t)},[e,t])}ve();import{useCallback as Rz,useState as vv}from"react";function cm(){let[e,t]=vv(!1),[n,r]=vv(null),{currentStoryId:o}=rt(),{currentReviewId:i}=ie();return{exportPDF:Rz(async()=>{if(!i){r("No review to export");return}t(!0),r(null);try{let[{default:a},{jsPDF:u}]=await Promise.all([import("html2canvas"),import("jspdf")]),c=document.querySelector('[data-testid="issues-panel"]')||document.querySelector(".issues-list-container")||document.querySelector('[class*="IssuesList"]');if(c)await kv(a,u,c,o);else{let l=document.querySelector("#storybook-panel-root")||document.querySelector('[id*="panel-tab-content"]')||document.querySelector(".sb-show-main");if(!l)throw new Error("Could not find panel to export");await kv(a,u,l,o)}}catch(a){console.error("[useExportPDF] Export failed:",a),r(a instanceof Error?a.message:"Failed to export PDF")}finally{t(!1)}},[i,o]),isExporting:e,error:n}}async function kv(e,t,n,r){let o=await e(n,{backgroundColor:"#ffffff",scale:2,logging:!1,useCORS:!0,allowTaint:!0}),i=o.toDataURL("image/png"),s=o.width,a=o.height,u=210,c=297,l=10,d=u-l*2,f=d/(s/2),p=a/2*f,g=new t({orientation:(p>c-l*2,"portrait"),unit:"mm",format:"a4"});g.setFillColor("#0ea5e9"),g.rect(0,0,u,20,"F"),g.setTextColor("#ffffff"),g.setFontSize(14),g.setFont("helvetica","bold"),g.text("Design Review Report",l,13);let S=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});g.setFontSize(10),g.setFont("helvetica","normal"),g.text(S,u-l,13,{align:"right"});let C=r?zz(r):"Component Review";g.setTextColor("#1f2937"),g.setFontSize(16),g.setFont("helvetica","bold"),g.text(C,l,30);let F=38,k=c-F-15;if(p<=k)g.addImage(i,"PNG",l,F,d,p);else{let _=p,M=0,B=!0;for(;_>0;){B||g.addPage();let m=B?F:l,x=B?k:c-l*2-10,b=Math.min(_,x),E=b/f*2,h=document.createElement("canvas");h.width=s,h.height=E;let T=h.getContext("2d");if(T){T.drawImage(o,0,M,s,E,0,0,s,E);let I=h.toDataURL("image/png");g.addImage(I,"PNG",l,m,d,b)}M+=E,_-=b,B=!1}}let R=g.getNumberOfPages();for(let _=1;_<=R;_++)g.setPage(_),g.setDrawColor("#e5e7eb"),g.setLineWidth(.3),g.line(l,c-12,u-l,c-12),g.setTextColor("#6b7280"),g.setFontSize(8),g.setFont("helvetica","normal"),g.text("Generated by UI Copilot",l,c-7),g.text(`Page ${_} of ${R}`,u-l,c-7,{align:"right"});let z=`design-review-${(r||"report").replace(/[^a-zA-Z0-9]/g,"-")}.pdf`;g.save(z)}function zz(e){let t=e.replace(/^(example|stories)-/i,""),[n,r]=t.split("--"),o=n.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),i=r?r.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null;return i?`${o} / ${i}`:o}import{useState as Vo,useMemo as Dv,useCallback as Ai}from"react";je();De();pt();import{useState as Kr,useEffect as _l,useRef as Ei,useCallback as um}from"react";var Nz=300;function Cv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=Kr([]),[u,c]=Kr({}),[l,d]=Kr(0),[f,p]=Kr([]),[g,S]=Kr(new Set),[C,F]=Kr(!1),[k,R]=Kr(!1),[z,_]=Kr(null),M=Ei(1),B=Ei(null),m=Ei(null),[x,b]=Kr(0),E=Ei(!1),h=Ei({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});h.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let T=um(async(D,N,w=!1)=>{let{projectId:j,typeFilter:G,search:L,figmaPage:K,limit:ee}=h.current;if(!j||!G)return;B.current&&B.current.abort();let re=new AbortController;B.current=re,N?R(!0):F(!0),_(null);try{let de=q(),ae=localStorage.getItem("uicopilot_session_token");if(!ae)throw new Error("Not authenticated. Please connect to UI Copilot first.");let qe=new URLSearchParams({projectId:j,page:String(D),limit:String(ee)});G&&qe.append("type",G),K&&qe.append("figmaPage",K),L.trim()&&qe.append("search",L.trim()),w&&qe.append("refresh","true");let tt=await fetch(`${de}/api/figma/frames?${qe.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`},signal:re.signal});if(!tt.ok){let me=await tt.json();throw new Error(me.error||"Failed to fetch frames")}let se=await tt.json(),pe=se.frames||[],Ie=se.thumbnails||{},ze=tt.headers.get("X-Cache-Status");if(pe.length===0&&D===1&&!N&&!w&&!E.current&&ze!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),E.current=!0,await T(1,!1,!0);return}N?(a(me=>[...me,...pe]),c(me=>({...me,...Ie}))):(a(pe),c(Ie)),d(se.total||pe.length),se.pages&&p(se.pages),se.cacheDiff?.added&&S(new Set(se.cacheDiff.added)),M.current=D}catch(de){if(de instanceof DOMException&&de.name==="AbortError")return;let ae=de instanceof Error?de.message:"Failed to fetch Figma frames.";_(ae),y.error("Error fetching frames:",de)}finally{re.signal.aborted||(F(!1),R(!1))}},[]);_l(()=>{if(!i||!e||!t)return;E.current=!1,m.current&&clearTimeout(m.current);let D=n.trim()?Nz:0;return m.current=setTimeout(()=>{M.current=1,T(1,!1)},D),()=>{m.current&&clearTimeout(m.current)}},[e,t,n,r,i,x,T]);let I=Ei(new Set);_l(()=>{if(s.length===0)return;let D={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(D[N.id]=N.thumbnailCdnUrl);Object.keys(D).length>0&&c(N=>({...N,...D}))},[s]),_l(()=>{if(s.length===0)return;let D=s.filter(w=>!w.thumbnailCdnUrl&&!u[w.id]&&!I.current.has(w.id)).map(w=>w.id);if(D.length===0)return;D.forEach(w=>I.current.add(w)),(async()=>{try{let{projectId:w}=h.current,j=q(),G=localStorage.getItem("uicopilot_session_token");if(!G||!w)return;let L=await oe(`${j}/api/figma/frames?projectId=${w}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(L.ok){let K=await L.json();K.thumbnails&&Object.keys(K.thumbnails).length>0&&c(ee=>({...ee,...K.thumbnails}))}}catch(w){D.forEach(j=>I.current.delete(j)),y.error("Failed to fetch frame thumbnails:",w)}})()},[s,u]),_l(()=>()=>{B.current&&B.current.abort(),m.current&&clearTimeout(m.current)},[]);let v=um(async()=>{let D=M.current+1;await T(D,!0)},[T]),A=um(()=>{E.current=!1,M.current=1,a([]),c({}),b(D=>D+1)},[]),P=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:g,isLoading:C,loadingMore:k,hasMore:P,loadMore:v,refresh:A,error:z}}je();De();pt();import{useState as $l,useCallback as Ul,useRef as Oz}from"react";function Tv({projectId:e}){let[t,n]=$l({}),[r,o]=$l({}),[i,s]=$l(new Set),[a,u]=$l(new Set),c=Oz({}),l=Ul(async g=>{if(!(!e||i.has(g))){s(S=>new Set(S).add(g));try{let S=q(),C=localStorage.getItem("uicopilot_session_token"),F=await oe(`${S}/api/figma/variants?projectId=${e}&componentSetId=${g}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`}});if(F.ok){let k=await F.json();if(k.variants){n(z=>({...z,[g]:k.variants}));let R={};for(let z of k.variants)z.thumbnailCdnUrl&&(R[z.id]=z.thumbnailCdnUrl);o(z=>({...z,[g]:{...z[g]||{},...R}})),c.current[g]||(c.current[g]=new Set),Object.keys(R).forEach(z=>c.current[g].add(z))}else o(R=>({...R,[g]:R[g]||{}}))}else o(k=>({...k,[g]:{}}))}catch(S){y.error("Failed to fetch variant metadata:",S),o(C=>({...C,[g]:{}}))}finally{s(S=>{let C=new Set(S);return C.delete(g),C})}}},[e,i]),d=Ul(async(g,S)=>{if(!e||S.length===0)return;c.current[g]||(c.current[g]=new Set);let C=r[g]||{},F=S.filter(k=>!c.current[g].has(k)&&!C[k]);if(F.length!==0){F.forEach(k=>c.current[g].add(k)),u(k=>new Set(k).add(g));try{let k=q(),R=localStorage.getItem("uicopilot_session_token"),z=await oe(`${k}/api/figma/variants?projectId=${e}&componentSetId=${g}&thumbnailIds=${F.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(z.ok){let _=await z.json();_.thumbnails&&Object.keys(_.thumbnails).length>0&&o(M=>({...M,[g]:{...M[g]||{},..._.thumbnails}}))}}catch(k){y.error("Failed to fetch variant thumbnails:",k),F.forEach(R=>c.current[g]?.delete(R))}finally{u(k=>{let R=new Set(k);return R.delete(g),R})}}},[e]),f=Ul(g=>{o(S=>{let C={...S};return delete C[g],C}),n(S=>{let C={...S};return delete C[g],C}),delete c.current[g]},[]),p=Ul(()=>{o({}),n({}),c.current={}},[]);return{variantChildren:t,variantThumbnails:r,loadingVariants:i,loadingThumbnails:a,fetchVariants:l,fetchVariantThumbnails:d,clearVariantsForSet:f,clearAllVariants:p}}je();Ns();ve();De();pt();import{useState as Iv,useEffect as Fv,useRef as Ev,useCallback as pm}from"react";function Av({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Iv(null),[i,s]=Iv(!1),a=Ev(null),u=Ev(new Set),c=pm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let f=Ci();if(!f||Object.keys(f).length===0)return;let p=mt.getState().currentStoryId||"",g=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,S=>S.toUpperCase());a.current=e,s(!0),o(null);try{let S=q(),C=localStorage.getItem("uicopilot_session_token"),F=await oe(`${S}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({storyName:g,storyId:p,storyArgs:f,availableFilters:t.map(k=>({property:k.property,values:k.values}))})});if(F.ok){let k=await F.json();k.confidence>0&&Object.keys(k.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",k),o(k))}}catch(S){y.error("[useFilterSuggestion] Error:",S)}finally{s(!1)}},[e,t,n]);Fv(()=>{c()},[c]),Fv(()=>{e||(o(null),a.current=null)},[e]);let l=pm(()=>{},[]),d=pm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Pv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Lv(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 Mv(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 Bv(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 Gs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=Vo(!0),[i,s]=Vo(!1),[a,u]=Vo(!1),[c,l]=Vo(""),[d,f]=Vo(""),[p,g]=Vo([]),[S,C]=Vo(new Set),F=Ai(se=>{l(se),p.length>0&&g([]),S.size>0&&C(new Set)},[p.length,S.size]),k=Pv(r,i,a),{frames:R,thumbnails:z,totalFrames:_,availablePages:M,recentlyAdded:B,isLoading:m,loadingMore:x,hasMore:b,loadMore:E,refresh:h,error:T}=Cv({projectId:e,typeFilter:k,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!k}),{variantChildren:I,variantThumbnails:v,loadingVariants:A,loadingThumbnails:P,fetchVariants:D,fetchVariantThumbnails:N,clearVariantsForSet:w,clearAllVariants:j}=Tv({projectId:e}),G=Dv(()=>{let se=Lv(I),pe=Mv(R),Ie={};for(let ze of[...se,...pe])Ie[ze.property]||(Ie[ze.property]=new Set),ze.values.forEach(me=>Ie[ze.property].add(me));return Object.entries(Ie).map(([ze,me])=>({property:ze,values:Array.from(me).sort()}))},[I,R]),L=S.size===1?Array.from(S)[0]:null,K=Av({expandedSetId:L,availableFilters:G,filtersReady:G.length>0}),ee=Ai(()=>{if(!K.suggestion)return;let{suggestedFilters:se}=K.suggestion,pe=Object.entries(se).map(([Ie,ze])=>({property:Ie,value:ze}));g(pe),K.dismissSuggestion()},[K.suggestion]),re=Dv(()=>p.some(se=>se.value)?R.filter(se=>Bv(se,p,I[se.id])):R,[R,p,I]),de=Ai((se,pe)=>{pe.stopPropagation();let Ie=!S.has(se);C(ze=>{let me=new Set(ze);return me.has(se)?me.delete(se):me.add(se),me}),Ie&&!I[se]&&!A.has(se)&&D(se)},[S,I,A,D]),ae=Ai((se,pe)=>{let Ie=pe===""?null:pe;g(ze=>ze.find(Nt=>Nt.property===se)?ze.map(Nt=>Nt.property===se?{...Nt,value:Ie}:Nt):[...ze,{property:se,value:Ie}])},[]),qe=Ai(()=>{g([])},[]),tt=Ai(se=>{let pe=R.find(Ie=>Ie.id===se);if(pe?.thumbnailCdnUrl)return pe.thumbnailCdnUrl;if(z[se])return z[se];for(let Ie of Object.values(v))if(Ie[se])return Ie[se]},[z,v]);return{frames:R,filteredFrames:re,thumbnails:z,totalFrames:_,isLoading:m,loadingMore:x,hasMore:b,error:T,loadMore:E,refresh:h,search:c,setSearch:F,figmaPage:d,setFigmaPage:f,availablePages:M,recentlyAdded:B,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:G,handleFilterChange:ae,clearFilters:qe,expandedSets:S,toggleExpanded:de,variantChildren:I,variantThumbnails:v,loadingVariants:A,loadingThumbnails:P,fetchVariantThumbnails:N,resolveThumbnail:tt,filterSuggestion:K.suggestion,filterSuggestionLoading:K.isLoading,applySuggestedFilters:ee,dismissFilterSuggestion:K.dismissSuggestion}}ve();import{useEffect as Mr,useCallback as Hz,useState as Wz,useRef as Vz}from"react";import{useChannel as Gz}from"storybook/manager-api";function bo(e){return e.status===401||e.status===403}var kn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function Rv(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 console.error("UI Copilot: Error parsing Figma URL:",t),null}}De();je();je();pt();var _z=q();async function dm(e){let t=await oe(`${_z}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(bo(t))throw new kn(t.status);return t.ok?(await t.json()).projects||[]:[]}je();pt();var $z=q();async function fm(e,t,n){let r=await oe(`${$z}/api/mappings?projectId=${t}&storyId=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(r))throw new kn(r.status);return r.ok&&(await r.json()).mapping||null}je();pt();var Uz=q();async function gm(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 oe(`${Uz}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(s))throw new kn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}je();pt();var jz=q();async function mm(e,t){let n=await oe(`${jz}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(n))throw new kn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function qz(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 Yz=q(),Kz="UICOPILOT/WORKSPACE_PATH",Xz="UICOPILOT/REQUEST_WORKSPACE_PATH",hm=!1;function xm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Ze(),{currentStoryId:l,mappingsRefreshKey:d,setFigmaFileUrl:f,setCurrentMapping:p,setMappingSource:g,setLoadingMapping:S}=rt(),{setReviewResults:C,setReviewDetailTab:F,setStorybookImageUrl:k,setFigmaImageUrl:R,setFullPrompt:z,setFullResponse:_,bulkAddReviews:M}=ie(),[B,m]=Wz([]),x=Vz(null);Mr(()=>{let h=T=>{T.origin.startsWith(Yz)&&T.data?.type==="UICOPILOT_AUTH_SUCCESS"&&T.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(T.data.token))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[t]);let b=Gz({[Kz]:h=>{y.debug("[useDataInit] Received workspace path:",h.path),c(h.path)}});Mr(()=>{b(Xz)},[b]),Mr(()=>{if(!e)return;let h=!1;return(async()=>{try{u(!0);let I=await dm(e);h||(s(I),n(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch projects:",I)}finally{h||u(!1)}})(),()=>{h=!0}},[e,s,u]),Mr(()=>{if(!i||r.length===0)return;let h=r.find(T=>T.storybookRoot===i);h&&o!==h.id&&(y.debug("[useDataInit] Auto-selecting project:",h.name),a(h.id))},[i,r,o,a]),Mr(()=>{if(!o||r.length===0)return;let h=r.find(I=>I.id===o),T=h?.figmaFileId;if(h&&typeof T=="string"&&T){let I=T,v=I.includes("figma.com")&&Rv(I)?.fileKey||I;f(`https://www.figma.com/file/${v}`)}},[o,r,f]),Mr(()=>!e||!o||hm?void 0:(hm=!0,(async()=>{try{let T=await mm(e,o);for(let[I,v]of Object.entries(T))xo(I,{score:v.score,issueCount:v.issueCount,criticalCount:v.criticalCount,majorCount:v.majorCount,minorCount:v.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(T).length,"stories")}catch(T){T instanceof kn&&n(T.message),y.error("[useDataInit] Failed to fetch review statuses:",T)}})(),()=>{hm=!1}),[e,o]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{S(!0);let I=await fm(e,o,l);if(h)return;I?(p(I),g("database")):(p(null),g(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch mapping:",I)}finally{h||S(!1)}})(),()=>{h=!0}},[e,o,l,d,p,g,S]),Mr(()=>{m([]),x.current=null},[l]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{let I=await gm(e,o,l,10,!0);if(!h){m(I);let v=I.map(A=>qz(A)).filter(Boolean);v.length>0&&M(v)}}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{h=!0}},[e,o,l]);let E=Hz(h=>{y.debug("[useDataInit] Applying review:",h.id,"with",h.issues.length,"issues");let T=[];if(typeof h.models=="string")try{T=JSON.parse(h.models)}catch{T=["claude-sonnet-4-20250514"]}else T=h.models;let I=h.issues.map(P=>({id:P.id,reviewId:h.id,type:P.type,severity:P.severity,title:P.description,description:P.description,file:void 0,lineNumber:void 0,property:P.property,currentValue:P.actual,suggestedValue:P.expected,suggestedCode:P.suggestedFix||void 0,status:P.status,dismissed:P.dismissed||!1,dismissReason:P.dismissReason,dismissedBy:P.dismissedBy,figmaContext:P.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(P.createdAt)})),v=h.completedAt&&h.createdAt?new Date(h.completedAt).getTime()-new Date(h.createdAt).getTime():void 0,A=h.storyId||"";if(C({id:h.id,componentId:"",storyId:A,modelId:T[0]||"claude-sonnet-4-5-20250929",complianceScore:h.complianceScore,issuesCount:h.issuesCount,issues:I,createdAt:new Date(h.createdAt),timestamp:new Date(h.createdAt).toISOString(),costUsd:h.costUsd,inputTokens:h.inputTokens,outputTokens:h.outputTokens,reviewDurationMs:v}),h.storybookScreenshot&&(k(h.storybookScreenshot),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),h.figmaScreenshot&&(R(h.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot")),h.aiPrompt&&(z(h.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),h.aiResponse&&(_(h.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),A){let P=h.issues.filter(j=>!j.dismissed),D=P.filter(j=>j.severity==="critical").length,N=P.filter(j=>j.severity==="major").length,w=P.filter(j=>j.severity==="minor").length;xo(A,{score:h.complianceScore,issueCount:P.length,criticalCount:D,majorCount:N,minorCount:w})}},[C,k,R,z,_]);Mr(()=>{if(B.length>0&&l&&x.current!==l){let h=B[0];h&&h.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",h.id,"for:",l),x.current=l,E(h),F("issues"))}},[B,l,E,F])}import{styled as qs}from"storybook/theming";var Qz=qs.div({display:"flex",gap:"10px",marginTop:"8px"}),zv=qs.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Jz=qs.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"})),Zz=qs.div({display:"flex",alignItems:"center",gap:"8px"}),eN=qs(er)(({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"})),Nv=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o}=Bs();return Lt.createElement(Lt.Fragment,null,Lt.createElement(ts,null,Lt.createElement(ns,null,"Authentication Method"),Lt.createElement(Qz,null,Lt.createElement(zv,null,Lt.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),Lt.createElement(zv,null,Lt.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&Lt.createElement(ts,null,Lt.createElement(ns,null,"Connect to UI Copilot"),e?Lt.createElement(Jz,null,Lt.createElement(Zz,null,Lt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),Lt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),Lt.createElement(eN,{onClick:o},"Disconnect")):Lt.createElement("div",null,Lt.createElement(eu,{style:{marginBottom:"12px"}},"Connect to UI Copilot to manage projects and integrations. This will open a browser window for authentication."),Lt.createElement(er,{onClick:r},"\u{1F517} Connect to UI Copilot"))),t==="apikey"&&Lt.createElement(ts,null,Lt.createElement(ns,null,"API Key"),Lt.createElement(eu,{style:{marginBottom:"12px"}},"Enter your UI Copilot API key below."),Lt.createElement(rs,{type:"password",placeholder:"Enter API key",disabled:!0}),Lt.createElement(er,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import Yt,{useState as ym}from"react";ve();import{styled as wr}from"storybook/theming";var tN=wr.div({marginBottom:"30px"}),nN=wr.div({display:"flex",gap:"8px",alignItems:"center"}),rN=wr(En)({flex:1}),oN=wr(en)({padding:"8px 12px",whiteSpace:"nowrap"}),iN=wr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),bm=wr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Sm=wr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),wm=wr(rs)({fontSize:"13px",padding:"6px 8px"}),sN=wr.div({display:"flex",gap:"8px",marginTop:"12px"}),Ov=wr(en)({fontSize:"12px",padding:"6px 12px"}),aN=wr(Ov)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),_v=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o}=qr(),{currentStorybookPath:i}=Ze(),[s,a]=ym(!1),[u,c]=ym(!1),[l,d]=ym({name:"",storybookRoot:"",figmaFileUrl:""}),f=C=>{n(C||null),a(!1)},p=()=>{if(a(!0),i){let C=i.replace(/\/+$/,"").split("/").pop()||"";d({storybookRoot:i,name:C,figmaFileUrl:""})}},g=async()=>{if(l.name.trim())try{c(!0);let C;if(l.figmaFileUrl.trim()){let k=l.figmaFileUrl.trim(),R=k.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);C=R?R[1]:k}let F=await o({name:l.name.trim(),storybookRoot:l.storybookRoot.trim()||void 0,figmaFileId:C});n(F.id),a(!1),d({name:"",storybookRoot:"",figmaFileUrl:""})}catch(C){console.error("Failed to create project:",C)}finally{c(!1)}},S=C=>{d(F=>{let k={...F,storybookRoot:C};if(!F.name&&C){let R=C.replace(/\/+$/,"").split("/").pop()||"";k.name=R}return k})};return Yt.createElement(tN,null,Yt.createElement(Yx,null,"Project"),Yt.createElement(nN,null,Yt.createElement(rN,{value:t||"",onChange:C=>f(C.target.value),disabled:r||s},Yt.createElement("option",{value:""},"-- Select a project --"),e.map(C=>Yt.createElement("option",{key:C.id,value:C.id},C.name))),Yt.createElement(oN,{onClick:p,disabled:r,type:"button"},"+ New")),s&&Yt.createElement(iN,null,Yt.createElement(bm,null,Yt.createElement(Sm,null,"Storybook Path (for fix generation)"),Yt.createElement(wm,{type:"text",placeholder:"/path/to/your/storybook",value:l.storybookRoot,onChange:C=>S(C.target.value)})),Yt.createElement(bm,null,Yt.createElement(Sm,null,"Project Name *"),Yt.createElement(wm,{type:"text",placeholder:"my-storybook",value:l.name,onChange:C=>{let F=C.target.value;d(k=>({...k,name:F}))}})),Yt.createElement(bm,null,Yt.createElement(Sm,null,"Figma File URL (for design comparison)"),Yt.createElement(wm,{type:"text",placeholder:"https://www.figma.com/file/...",value:l.figmaFileUrl,onChange:C=>{let F=C.target.value;d(k=>({...k,figmaFileUrl:F}))}})),Yt.createElement(sN,null,Yt.createElement(Ov,{onClick:g,disabled:u||!l.name.trim()},u?"Creating...":"Create"),Yt.createElement(aN,{onClick:()=>{a(!1),d({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import bt,{useState as Jm,useCallback as bC,useEffect as b$}from"react";import{styled as vr}from"storybook/theming";import So,{useState as km,useEffect as IN,useCallback as Uv}from"react";import{styled as Go}from"storybook/theming";ve();je();pt();ve();je();pt();import Ut,{useState as vm}from"react";import{styled as zn,keyframes as lN}from"storybook/theming";var cN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},uN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",pN=zn.div({position:"relative",display:"inline-flex"}),dN=lN`
|
|
30
|
+
\u2705 ${ne} issue${ne>1?"s were":" was"} auto-dismissed as false positive${ne>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Gt=Ne.complianceScore??Ne.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Ne.complianceScore,validationScore:Ne.validation?.complianceScore,parsedScore:Gt}),Gt==null){let be=Dt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Gt=be?parseInt(be[1],10):void 0,y.debug("[Review] Parsed score from response:",Gt)}let cn=Be.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Be.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=ln.map(be=>({...be,file:be.file||Gg(be.fixTarget,cn)||qg(be,cn)}));if(st=Yg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!S){let be=st.length;st=st.filter(ge=>ge.property?.toLowerCase()!=="textcontent"&&!ge.description?.toLowerCase().includes("text content")),be!==st.length&&y.debug("[Review] Filtered out",be-st.length,"textContent issues (toggle OFF)")}let Fr;lt&&nt&&(Fr=(mt.getState().reviewHistory.find(ge=>ge.id===nt)?.iterationNumber||0)+1);let Fn={id:Xe,componentId:ae,storyId:ae,modelId:l[0],parentReviewId:lt&&nt||void 0,iterationNumber:Fr,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Un||void 0,complianceScore:Gt,visualSimilarity:Ne.visualSimilarity,issuesCount:st.filter(be=>!be.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-re,costUsd:Ne.costUsd,inputTokens:Ne.inputTokens,outputTokens:Ne.outputTokens,cacheCreationTokens:Ne.cacheCreationTokens,cacheReadTokens:Ne.cacheReadTokens,variantMismatch:Ne.variantMismatch,storybookVariant:Ne.storybookVariant,figmaVariant:Ne.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:Fn.id,storyId:Fn.storyId,issueCount:Fn.issues?.length,complianceScore:Fn.complianceScore,createdAt:Fn.createdAt?.toISOString(),inputTokens:Fn.inputTokens,outputTokens:Fn.outputTokens,costUsd:Fn.costUsd,cacheCreationTokens:Fn.cacheCreationTokens,cacheReadTokens:Fn.cacheReadTokens}),D(Fn),y.debug("[useAIReview] addReview called successfully"),ae&&M.enableReviewBadges){let be=st.filter(ge=>!ge.dismissed);xo(ae,{score:Gt??100,issueCount:be.length,criticalCount:be.filter(ge=>ge.severity==="critical").length,majorCount:be.filter(ge=>ge.severity==="major").length,minorCount:be.filter(ge=>ge.severity==="minor").length})}N("issues");let es=st.filter(be=>!be.dismissed).length;y.debug("[Review] Created review with",es,"active issues,",st.length-es,"dismissed");let Aa=xt||mt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:xt,effectiveFigmaNodeIdSingle:Aa,hasSessionToken:!!J,selectedProjectId:pe,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(be=>!be.dismissed).length,"Dismissed:",st.filter(be=>be.dismissed).length)}catch(Xe){y.error("[Review] Failed to parse issues:",Xe)}}else throw Zt?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",Zt.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(W){if(W instanceof Error&&W.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),de(0,"Review cancelled");return}y.error("[useAIReview] Review error:",W);let Fe=W instanceof Error?W.message:"Review failed";throw f(Fe),ae&&M.enableReviewBadges&&uv(ae),de(0,`Error: ${Fe}`),W}finally{p(!1),Ve.current=null,te.current&&(clearTimeout(te.current),te.current=null),oe(null)}},[e,J,pe,ae,qe,l,p,f,d,T,I,v,A,k,F,R,Le,de,z,E,x,B,g,oe]),fe=Vs(()=>n?.issues?o==="all"?n.issues:n.issues.filter(Ge=>Ge.severity===o):[],[n,o]),vt=Vs(()=>{Ve.current&&(y.debug("[useAIReview] Cancelling review..."),Ve.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Et,cancelReview:vt,setShowReviewMenu:m,setSeverityFilter:w,setShowStreamingPanel:k,setStreamingPanelCollapsed:F,addStreamingMessage:C,updateStreamingMessage:z,clearStreamingMessages:R,setStreamingProgress:O,setStreamingStatus:L,resetReview:P,getFilteredIssues:fe}};we();De();Ue();import{useCallback as FX}from"react";var LX=q();we();De();import{useEffect as dv,useRef as fv}from"react";import{useStorybookApi as sz,useStorybookState as az,addons as lz}from"storybook/manager-api";var gv="storyArgsUpdated",Zg=()=>{let e=sz(),t=az(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=rt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=se(),l=fv(null),p=fv(0);return dv(()=>{let f=t.storyId;if(f){l.current!==f&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",f),s(f),l.current=f,p.current=Date.now()),o(f);let d=e.getData(f),m=d?.name&&d.name!=="default"?`${d.title} / ${d.name}`:d?.title||f;i(m),y.debug("[useCurrentStory] Current story:",{storyId:f,fullName:m})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),dv(()=>{let f=lz.getChannel(),d=null,m=w=>{if(w.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:k,isValidating:F}=mt.getState();if(k||F){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 f.on(gv,m),()=>{f.off(gv,m),d&&clearTimeout(d)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};we();Ue();pt();import{useCallback as mv}from"react";import{addons as hv}from"storybook/manager-api";var xv=q(),Ho=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=rt(),{sessionToken:o}=Se(),{selectedProjectId:i}=Ze(),s=mv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ie(`${xv}/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{hv.getChannel().emit("uireview/mappings-changed")}catch{}return p.mapping},[o,i,r]),a=mv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ie(`${xv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{hv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Ns();we();import{useCallback as em,useEffect as yv,useRef as cz}from"react";import{useChannel as uz,addons as bv}from"storybook/manager-api";De();var pz=3e4,dz="forceRemount";function fz(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 gz(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 mz="UICOPILOT/APPLY_FIXES",hz="UICOPILOT/FIX_STARTED",xz="UICOPILOT/FIX_COMPLETED",yz="UICOPILOT/FIX_FAILED",bz="UICOPILOT/ALL_FIXES_APPLIED",tm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=se(),c=cz(null),l=em(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);yv(()=>()=>l(),[l]),yv(()=>{let m=bv.getChannel(),w=()=>{mt.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 m.on("channelWSDisconnect",w),()=>m.off("channelWSDisconnect",w)},[l,o,i]);let p=uz({[hz]:({issueId:m})=>{y.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[xz]:({issueId:m,result:w})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${m}`,w),s(m,"applied"),a(m,{status:"applied"})},[yz]:({issueId:m,error:w})=>{y.error(`[useApplyFixes] Fix failed for issue: ${m}`,w),s(m,"failed",w),a(m,{status:"failed",error:w})},[bz]:async({summary:m})=>{if(y.debug("[useApplyFixes] All fixes applied:",m),l(),o(!1),i({succeeded:m.succeeded,failed:m.failed,total:m.total}),m.failed>0?y.warn(`Applied ${m.succeeded}/${m.total} fixes. ${m.failed} failed.`):y.debug(`Successfully applied all ${m.total} fixes!`),m.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{bv.getChannel().emit(dz,{storyId:mt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(w){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",w)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Pl(),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")}}),f=em(m=>{let w=[],k=[],F=[];for(let C of m){let z=C.currentValue||C.actual||"",R=C.suggestedValue||C.expected||"";if(z&&R&&fz(z,R)){w.push(C);continue}if(gz(C)){k.push(C);continue}let O=C.generatedFix?.filePath||C.file||"";if(!O){y.warn(`[useApplyFixes] Skipping issue ${C.id} - no target file path`);continue}let L=O.toLowerCase().split(".").pop()||"",B=["tsx","jsx","ts","js"].includes(L)?"component":"css";F.push({...C,targetFilePath:O,targetFileType:B})}return{actionable:F,negligible:w,designTokens:k}},[]);return{applyFixes:em(m=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(m.length===0){y.warn("[useApplyFixes] No issues to fix");return}let w=f(m);if(w.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${w.negligible.length} negligible issue(s)`),w.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${w.designTokens.length} design token suggestion(s)`),w.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let k=w.actionable.filter(z=>z.targetFileType==="css"),F=w.actionable.filter(z=>z.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),k.length>0){let z=[...new Set(k.map(R=>R.targetFilePath))];y.debug(` - ${k.length} CSS issue(s) in: ${z.join(", ")}`)}if(F.length>0){let z=[...new Set(F.map(R=>R.targetFilePath))];y.debug(` - ${F.length} component issue(s) in: ${z.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:w.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{mt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:w.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},pz),p(mz,{issues:w.actionable,storybookRoot:n||void 0})},[p,r,o,i,f,n,l]),isApplying:r}};we();Ue();import{useState as JX}from"react";var tQ=q();we();import{useState as Wo}from"react";Ue();De();pt();var Sz=q();async function Ol(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 ie(`${Sz}/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 Sv(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=>Ol(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"}}Ls();Dg();Ns();De();Ue();var wz=["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"],vz=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],kz=q();function nm(){let[e,t]=Wo(!1),[n,r]=Wo(null),[o,i]=Wo(null),[s,a]=Wo(null),[u,c]=Wo(null),[l,p]=Wo(null),[f,d]=Wo(null),{sessionToken:m}=Se(),{selectedProjectId:w}=Ze(),{currentStoryId:k,currentStoryName:F}=rt(),{workspacePath:C,updateIssueGeneratedFix:z,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:O,dismissIssue:L,recalculateScore:B,addStreamingMessage:g}=se();return{generateBatchFixes:async b=>{if(!m){r("Not authenticated");return}if(!w){r("No project selected");return}if(!k){r("No story selected");return}if(b.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),p(null),a({total:b.length,completed:0});let E=b.map(h=>({issueId:h.id,generatedFix:{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"",status:"generating"}}));R(E);try{y.debug("[useBatchGenerateFixes] Generating fixes for",b.length,"issues");let h=null;try{let S=$s();S?.computed&&(h=S.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(S){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",S)}let T=null;try{T=await Ws(k),T&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",T)}catch(S){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",S)}let I=await fetch(`${kz}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:w,storyId:k,workspacePath:C,includeComponentIssues:O,computedStyles:h,storyFilePaths:T,reviewContext:{storyName:F||void 0,variantArgs:Ci()||void 0},issues:b.map(S=>({id:S.id,dbId:S.dbId,title:S.title,description:S.description,property:S.property,currentValue:S.currentValue,suggestedValue:S.suggestedValue,file:S.file,lineNumber:S.lineNumber,severity:S.severity,type:S.type,fixTarget:S.fixTarget,domElement:S.domElement,figmaContext:S.figmaContext,suggestedFix:S.suggestedFix}))})});if(!I.ok){let S=await I.json().catch(()=>({}));throw new Error(S.error||"Batch fix generation failed")}let v=await I.json();if(!v.success)throw new Error(v.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",v.result.fixes.length,"fixes"),v.result.storybookRoot&&(d(v.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",v.result.storybookRoot)),v.result.selfReview&&(p(v.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",v.result.selfReview)),v.result.partialFailure){let{failedBatches:S,errors:j}=v.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${S.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${S.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:b.length,completed:v.result.fixes.length});let A=new Set(v.result.fixes.map(S=>S.issueId)),P=b.filter(S=>!A.has(S.id));P.length>0&&(y.warn(`[useBatchGenerateFixes] ${P.length} issues not returned by API, marking as failed`),P.forEach(S=>{z(S.id,{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),v.timing&&(i({durationSec:v.timing.durationSec,issueCount:v.timing.issueCount,avgPerIssueSec:v.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${v.timing.durationSec}s for ${v.timing.issueCount} issues`)),v.result?.usage&&(c({inputTokens:v.result.usage.inputTokens||0,outputTokens:v.result.usage.outputTokens||0,costUsd:v.result.usage.costUsd||0,modelId:v.result.usage.modelId||"unknown",provider:v.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${v.result.usage.inputTokens} in, ${v.result.usage.outputTokens} out, $${v.result.usage.costUsd?.toFixed(4)}`));let D=[],N=[];if(v.result.fixes.forEach(S=>{let j=S.noChangesNeeded===!0;if(!j){let J=(S.fixStrategy||"").toLowerCase(),Z=(S.generatedCode||"").toLowerCase(),oe=(S.diffPreview||"").toLowerCase(),pe=wz.some(qe=>J.includes(qe.toLowerCase())||J.replace(/[-_]/g,"").includes(qe.replace(/[-_]/g,""))),ae=vz.some(qe=>Z.includes(qe)||oe.includes(qe));j=pe||ae}let G=b.find(J=>J.id===S.issueId);if(j&&G){let J=G.suggestedValue,Z=G.currentValue;J&&Z&&!$o(J,Z)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${J}", actual="${Z}"), NOT auto-dismissing issue ${S.issueId}`),j=!1)}let M=G?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${S.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:M,detectedBy:G?.detectedBy,noChangesNeeded:S.noChangesNeeded,fixStrategy:S.fixStrategy,title:G?.title?.substring(0,50)}),M&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${S.issueId} (detectedBy: ${G?.detectedBy})`),j=!1),j){let J=`Auto-dismissed: ${S.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${S.issueId} - noChangesNeeded: ${S.noChangesNeeded}, strategy: "${S.fixStrategy}"`),L(S.issueId,J),D.push({localId:S.issueId,dbId:G?.dbId,dismissReason:J}),N.push({issueId:S.issueId,generatedFix:{code:S.generatedCode||"",diffPreview:S.diffPreview||"",filePath:S.filePath,confidence:S.confidence,strategy:S.fixStrategy,status:"ready",error:void 0,noChangesExplanation:S.noChangesExplanation}})}else{let J=S.error||S.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:S.issueId,generatedFix:{code:S.generatedCode,diffPreview:S.diffPreview,filePath:S.filePath,confidence:S.confidence,strategy:S.fixStrategy,status:J,error:S.error,noChangesExplanation:S.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),D.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${D.length} false positive(s), recalculating score`),B(),m){let j=D.filter(G=>G.dbId).map(G=>({dbId:G.dbId,dismissed:!0,dismissReason:G.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Sv(j,m).then(G=>{G.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${G.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",G.error)}).catch(G=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",G)}))}let S=D.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${D.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;g({role:"system",content:S})}y.debug("[useBatchGenerateFixes] Updated",v.result.fixes.length,"issues with fixes")}catch(h){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",h),r(h?.message||"Failed to generate batch fixes");let T=b.map(I=>({issueId:I.id,generatedFix:{code:"",diffPreview:"",filePath:I.file||"",confidence:0,strategy:"",status:"failed",error:h?.message||"Failed to generate fix"}}));R(T)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:f}}we();De();Ue();pt();import{useState as rm,useCallback as om}from"react";var Cz=q();function im(){let[e,t]=rm([]),[n,r]=rm(!1),[o,i]=rm(null),{sessionToken:s}=Se(),{selectedProjectId:a}=Ze(),{currentStoryId:u}=rt(),{setReviewResults:c}=se(),l=om(async()=>{if(!(!s||!a)){r(!0),i(null);try{let d=new URLSearchParams({projectId:a,limit:"10"});u&&d.append("storyId",u);let m=await ie(`${Cz}/api/reviews/list?${d.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!m.ok){let k=await m.json().catch(()=>({}));throw new Error(k.error||"Failed to fetch reviews")}let w=await m.json();if(!w.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",w.reviews.length,"reviews for:",u),t(w.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=om(d=>{y.debug("[useReviewHistory] Applying review:",d.id,"with",d.issues.length,"issues");let m=[];if(typeof d.models=="string")try{m=JSON.parse(d.models)}catch(C){y.error("[useReviewHistory] Failed to parse models:",C),m=["claude-sonnet-4-20250514"]}else m=d.models;let w=d.issues.map(C=>({id:C.id,reviewId:d.id,type:C.type,severity:C.severity,title:C.description,description:C.description,file:void 0,lineNumber:void 0,property:C.property,currentValue:C.actual,suggestedValue:C.expected,suggestedCode:C.suggestedFix||void 0,status:C.status,dismissed:C.dismissed||!1,dismissReason:C.dismissReason,dismissedBy:C.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(C.createdAt)})),k=d.completedAt&&d.createdAt?new Date(d.completedAt).getTime()-new Date(d.createdAt).getTime():void 0,F=d.storyId||"";if(c({id:d.id,componentId:"",storyId:F,modelId:m[0]||"claude-sonnet-4-5-20250929",complianceScore:d.complianceScore,issuesCount:d.issuesCount,issues:w,createdAt:new Date(d.createdAt),timestamp:new Date(d.createdAt).toISOString(),costUsd:d.costUsd,inputTokens:d.inputTokens,outputTokens:d.outputTokens,reviewDurationMs:k}),F){let C=d.issues.filter(L=>!L.dismissed),z=C.filter(L=>L.severity==="critical").length,R=C.filter(L=>L.severity==="major").length,O=C.filter(L=>L.severity==="minor").length;xo(F,{score:d.complianceScore,issueCount:C.length,criticalCount:z,majorCount:R,minorCount:O})}},[c]),f=om(d=>{let m=e.find(w=>w.id===d);if(!m){y.error("[useReviewHistory] Review not found:",d);return}p(m)},[e,p]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:f}}we();De();import{useEffect as Tz,useState as Iz,useRef as _l}from"react";import{useChannel as Fz}from"storybook/manager-api";var Ez="UICOPILOT/WORKSPACE_PATH",wv="UICOPILOT/REQUEST_WORKSPACE_PATH",Az=3e3,Pz=500,Lz=5,sm=()=>{let[e,t]=Iz({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=se(),r=_l(!1),o=_l(null),i=_l(0),s=_l(null),a=Fz({[Ez]:({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 Tz(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(wv,{}),s.current=setInterval(()=>{!r.current&&i.current<Lz&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(wv,{}))},Pz),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}))}},Az),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},am=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}};we();Ue();import{useEffect as Mz,useRef as Bz}from"react";var MQ=q(),Dz=new Set;function lm(){let{sessionToken:e}=Se(),{selectedProjectId:t}=Ze(),n=Bz(!1);Mz(()=>{t&&Dz.add(t)},[e,t])}we();import{useCallback as Rz,useState as vv}from"react";function cm(){let[e,t]=vv(!1),[n,r]=vv(null),{currentStoryId:o}=rt(),{currentReviewId:i}=se();return{exportPDF:Rz(async()=>{if(!i){r("No review to export");return}t(!0),r(null);try{let[{default:a},{jsPDF:u}]=await Promise.all([import("html2canvas"),import("jspdf")]),c=document.querySelector('[data-testid="issues-panel"]')||document.querySelector(".issues-list-container")||document.querySelector('[class*="IssuesList"]');if(c)await kv(a,u,c,o);else{let l=document.querySelector("#storybook-panel-root")||document.querySelector('[id*="panel-tab-content"]')||document.querySelector(".sb-show-main");if(!l)throw new Error("Could not find panel to export");await kv(a,u,l,o)}}catch(a){console.error("[useExportPDF] Export failed:",a),r(a instanceof Error?a.message:"Failed to export PDF")}finally{t(!1)}},[i,o]),isExporting:e,error:n}}async function kv(e,t,n,r){let o=await e(n,{backgroundColor:"#ffffff",scale:2,logging:!1,useCORS:!0,allowTaint:!0}),i=o.toDataURL("image/png"),s=o.width,a=o.height,u=210,c=297,l=10,p=u-l*2,f=p/(s/2),d=a/2*f,m=new t({orientation:(d>c-l*2,"portrait"),unit:"mm",format:"a4"});m.setFillColor("#0ea5e9"),m.rect(0,0,u,20,"F"),m.setTextColor("#ffffff"),m.setFontSize(14),m.setFont("helvetica","bold"),m.text("Design Review Report",l,13);let w=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});m.setFontSize(10),m.setFont("helvetica","normal"),m.text(w,u-l,13,{align:"right"});let k=r?zz(r):"Component Review";m.setTextColor("#1f2937"),m.setFontSize(16),m.setFont("helvetica","bold"),m.text(k,l,30);let F=38,C=c-F-15;if(d<=C)m.addImage(i,"PNG",l,F,p,d);else{let O=d,L=0,B=!0;for(;O>0;){B||m.addPage();let g=B?F:l,x=B?C:c-l*2-10,b=Math.min(O,x),E=b/f*2,h=document.createElement("canvas");h.width=s,h.height=E;let T=h.getContext("2d");if(T){T.drawImage(o,0,L,s,E,0,0,s,E);let I=h.toDataURL("image/png");m.addImage(I,"PNG",l,g,p,b)}L+=E,O-=b,B=!1}}let z=m.getNumberOfPages();for(let O=1;O<=z;O++)m.setPage(O),m.setDrawColor("#e5e7eb"),m.setLineWidth(.3),m.line(l,c-12,u-l,c-12),m.setTextColor("#6b7280"),m.setFontSize(8),m.setFont("helvetica","normal"),m.text("Generated by UI Copilot",l,c-7),m.text(`Page ${O} of ${z}`,u-l,c-7,{align:"right"});let R=`design-review-${(r||"report").replace(/[^a-zA-Z0-9]/g,"-")}.pdf`;m.save(R)}function zz(e){let t=e.replace(/^(example|stories)-/i,""),[n,r]=t.split("--"),o=n.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),i=r?r.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null;return i?`${o} / ${i}`:o}import{useState as Vo,useMemo as Dv,useCallback as Ai}from"react";Ue();De();pt();import{useState as Kr,useEffect as $l,useRef as Ei,useCallback as um}from"react";var Nz=300;function Cv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=Kr([]),[u,c]=Kr({}),[l,p]=Kr(0),[f,d]=Kr([]),[m,w]=Kr(new Set),[k,F]=Kr(!1),[C,z]=Kr(!1),[R,O]=Kr(null),L=Ei(1),B=Ei(null),g=Ei(null),[x,b]=Kr(0),E=Ei(!1),h=Ei({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});h.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let T=um(async(D,N,S=!1)=>{let{projectId:j,typeFilter:G,search:M,figmaPage:J,limit:Z}=h.current;if(!j||!G)return;B.current&&B.current.abort();let oe=new AbortController;B.current=oe,N?z(!0):F(!0),O(null);try{let pe=q(),ae=localStorage.getItem("uicopilot_session_token");if(!ae)throw new Error("Not authenticated. Please connect to UI Copilot first.");let qe=new URLSearchParams({projectId:j,page:String(D),limit:String(Z)});G&&qe.append("type",G),J&&qe.append("figmaPage",J),M.trim()&&qe.append("search",M.trim()),S&&qe.append("refresh","true");let tt=await fetch(`${pe}/api/figma/frames?${qe.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`},signal:oe.signal});if(!tt.ok){let de=await tt.json();throw new Error(de.error||"Failed to fetch frames")}let Ve=await tt.json(),te=Ve.frames||[],Be=Ve.thumbnails||{},Le=tt.headers.get("X-Cache-Status");if(te.length===0&&D===1&&!N&&!S&&!E.current&&Le!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),E.current=!0,await T(1,!1,!0);return}N?(a(de=>[...de,...te]),c(de=>({...de,...Be}))):(a(te),c(Be)),p(Ve.total||te.length),Ve.pages&&d(Ve.pages),Ve.cacheDiff?.added&&w(new Set(Ve.cacheDiff.added)),L.current=D}catch(pe){if(pe instanceof DOMException&&pe.name==="AbortError")return;let ae=pe instanceof Error?pe.message:"Failed to fetch Figma frames.";O(ae),y.error("Error fetching frames:",pe)}finally{oe.signal.aborted||(F(!1),z(!1))}},[]);$l(()=>{if(!i||!e||!t)return;E.current=!1,g.current&&clearTimeout(g.current);let D=n.trim()?Nz:0;return g.current=setTimeout(()=>{L.current=1,T(1,!1)},D),()=>{g.current&&clearTimeout(g.current)}},[e,t,n,r,i,x,T]);let I=Ei(new Set);$l(()=>{if(s.length===0)return;let D={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(D[N.id]=N.thumbnailCdnUrl);Object.keys(D).length>0&&c(N=>({...N,...D}))},[s]),$l(()=>{if(s.length===0)return;let D=s.filter(S=>!S.thumbnailCdnUrl&&!u[S.id]&&!I.current.has(S.id)).map(S=>S.id);if(D.length===0)return;D.forEach(S=>I.current.add(S)),(async()=>{try{let{projectId:S}=h.current,j=q(),G=localStorage.getItem("uicopilot_session_token");if(!G||!S)return;let M=await ie(`${j}/api/figma/frames?projectId=${S}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(M.ok){let J=await M.json();J.thumbnails&&Object.keys(J.thumbnails).length>0&&c(Z=>({...Z,...J.thumbnails}))}}catch(S){D.forEach(j=>I.current.delete(j)),y.error("Failed to fetch frame thumbnails:",S)}})()},[s,u]),$l(()=>()=>{B.current&&B.current.abort(),g.current&&clearTimeout(g.current)},[]);let v=um(async()=>{let D=L.current+1;await T(D,!0)},[T]),A=um(()=>{E.current=!1,L.current=1,a([]),c({}),b(D=>D+1)},[]),P=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:m,isLoading:k,loadingMore:C,hasMore:P,loadMore:v,refresh:A,error:R}}Ue();De();pt();import{useState as Gs,useCallback as Ul,useRef as Oz}from"react";function Tv({projectId:e}){let[t,n]=Gs({}),[r,o]=Gs({}),[i,s]=Gs(new Set),[a,u]=Gs(new Set),[c,l]=Gs({}),p=Oz({}),f=Ul(async k=>{if(!(!e||i.has(k))){s(F=>new Set(F).add(k));try{let F=q(),C=localStorage.getItem("uicopilot_session_token"),z=await ie(`${F}/api/figma/variants?projectId=${e}&componentSetId=${k}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`}});if(z.ok){let R=await z.json();if(R.variants){n(L=>({...L,[k]:R.variants}));let O={};for(let L of R.variants)L.thumbnailCdnUrl&&(O[L.id]=L.thumbnailCdnUrl);o(L=>({...L,[k]:{...L[k]||{},...O}})),p.current[k]||(p.current[k]=new Set),Object.keys(O).forEach(L=>p.current[k].add(L))}else o(O=>({...O,[k]:O[k]||{}}))}else o(R=>({...R,[k]:{}}))}catch(F){y.error("Failed to fetch variant metadata:",F),o(C=>({...C,[k]:{}}))}finally{s(F=>{let C=new Set(F);return C.delete(k),C})}}},[e,i]),d=Ul(async(k,F)=>{if(!e||F.length===0)return;p.current[k]||(p.current[k]=new Set);let C=r[k]||{},z=F.filter(R=>!p.current[k].has(R)&&!C[R]);if(z.length!==0){z.forEach(R=>p.current[k].add(R)),u(R=>new Set(R).add(k));try{let R=q(),O=localStorage.getItem("uicopilot_session_token"),L=await ie(`${R}/api/figma/variants?projectId=${e}&componentSetId=${k}&thumbnailIds=${z.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${O}`}});if(L.ok){let B=await L.json();B.thumbnails&&Object.keys(B.thumbnails).length>0&&o(g=>({...g,[k]:{...g[k]||{},...B.thumbnails}})),Array.isArray(B.failed)&&B.failed.length>0&&l(g=>{let x=new Set(g[k]||[]);for(let b of B.failed)x.add(b);return{...g,[k]:x}})}}catch(R){y.error("Failed to fetch variant thumbnails:",R),z.forEach(O=>p.current[k]?.delete(O))}finally{u(R=>{let O=new Set(R);return O.delete(k),O})}}},[e]),m=Ul(k=>{o(F=>{let C={...F};return delete C[k],C}),n(F=>{let C={...F};return delete C[k],C}),l(F=>{let C={...F};return delete C[k],C}),delete p.current[k]},[]),w=Ul(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,fetchVariants:f,fetchVariantThumbnails:d,clearVariantsForSet:m,clearAllVariants:w}}Ue();Ns();we();De();pt();import{useState as Iv,useEffect as Fv,useRef as Ev,useCallback as pm}from"react";function Av({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Iv(null),[i,s]=Iv(!1),a=Ev(null),u=Ev(new Set),c=pm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let f=Ci();if(!f||Object.keys(f).length===0)return;let d=mt.getState().currentStoryId||"",m=d.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,w=>w.toUpperCase());a.current=e,s(!0),o(null);try{let w=q(),k=localStorage.getItem("uicopilot_session_token"),F=await ie(`${w}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:JSON.stringify({storyName:m,storyId:d,storyArgs:f,availableFilters:t.map(C=>({property:C.property,values:C.values}))})});if(F.ok){let C=await F.json();C.confidence>0&&Object.keys(C.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",C),o(C))}}catch(w){y.error("[useFilterSuggestion] Error:",w)}finally{s(!1)}},[e,t,n]);Fv(()=>{c()},[c]),Fv(()=>{e||(o(null),a.current=null)},[e]);let l=pm(()=>{},[]),p=pm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:p}}function Pv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Lv(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 Mv(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 Bv(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 qs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=Vo(!0),[i,s]=Vo(!1),[a,u]=Vo(!1),[c,l]=Vo(""),[p,f]=Vo(""),[d,m]=Vo([]),[w,k]=Vo(new Set),F=Ai(te=>{l(te),d.length>0&&m([]),w.size>0&&k(new Set)},[d.length,w.size]),C=Pv(r,i,a),{frames:z,thumbnails:R,totalFrames:O,availablePages:L,recentlyAdded:B,isLoading:g,loadingMore:x,hasMore:b,loadMore:E,refresh:h,error:T}=Cv({projectId:e,typeFilter:C,search:c,figmaPage:p||void 0,limit:t,enabled:n&&!!C}),{variantChildren:I,variantThumbnails:v,variantFailed:A,loadingVariants:P,loadingThumbnails:D,fetchVariants:N,fetchVariantThumbnails:S,clearVariantsForSet:j,clearAllVariants:G}=Tv({projectId:e}),M=Dv(()=>{let te=Lv(I),Be=Mv(z),Le={};for(let de of[...te,...Be])Le[de.property]||(Le[de.property]=new Set),de.values.forEach(Et=>Le[de.property].add(Et));return Object.entries(Le).map(([de,Et])=>({property:de,values:Array.from(Et).sort()}))},[I,z]),J=w.size===1?Array.from(w)[0]:null,Z=Av({expandedSetId:J,availableFilters:M,filtersReady:M.length>0}),oe=Ai(()=>{if(!Z.suggestion)return;let{suggestedFilters:te}=Z.suggestion,Be=Object.entries(te).map(([Le,de])=>({property:Le,value:de}));m(Be),Z.dismissSuggestion()},[Z.suggestion]),pe=Dv(()=>d.some(te=>te.value)?z.filter(te=>Bv(te,d,I[te.id])):z,[z,d,I]),ae=Ai((te,Be)=>{Be.stopPropagation();let Le=!w.has(te);k(de=>{let Et=new Set(de);return Et.has(te)?Et.delete(te):Et.add(te),Et}),Le&&!I[te]&&!P.has(te)&&N(te)},[w,I,P,N]),qe=Ai((te,Be)=>{let Le=Be===""?null:Be;m(de=>de.find(fe=>fe.property===te)?de.map(fe=>fe.property===te?{...fe,value:Le}:fe):[...de,{property:te,value:Le}])},[]),tt=Ai(()=>{m([])},[]),Ve=Ai(te=>{let Be=z.find(Le=>Le.id===te);if(Be?.thumbnailCdnUrl)return Be.thumbnailCdnUrl;if(R[te])return R[te];for(let Le of Object.values(v))if(Le[te])return Le[te]},[R,v]);return{frames:z,filteredFrames:pe,thumbnails:R,totalFrames:O,isLoading:g,loadingMore:x,hasMore:b,error:T,loadMore:E,refresh:h,search:c,setSearch:F,figmaPage:p,setFigmaPage:f,availablePages:L,recentlyAdded:B,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:d,availableFilters:M,handleFilterChange:qe,clearFilters:tt,expandedSets:w,toggleExpanded:ae,variantChildren:I,variantThumbnails:v,variantFailed:A,loadingVariants:P,loadingThumbnails:D,fetchVariantThumbnails:S,resolveThumbnail:Ve,filterSuggestion:Z.suggestion,filterSuggestionLoading:Z.isLoading,applySuggestedFilters:oe,dismissFilterSuggestion:Z.dismissSuggestion}}we();import{useEffect as Mr,useCallback as Hz,useState as Wz,useRef as Vz}from"react";import{useChannel as Gz}from"storybook/manager-api";function bo(e){return e.status===401||e.status===403}var kn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function Rv(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 console.error("UI Copilot: Error parsing Figma URL:",t),null}}De();Ue();Ue();pt();var _z=q();async function dm(e){let t=await ie(`${_z}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(bo(t))throw new kn(t.status);return t.ok?(await t.json()).projects||[]:[]}Ue();pt();var $z=q();async function fm(e,t,n){let r=await ie(`${$z}/api/mappings?projectId=${t}&storyId=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(r))throw new kn(r.status);return r.ok&&(await r.json()).mapping||null}Ue();pt();var Uz=q();async function gm(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 ie(`${Uz}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(s))throw new kn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}Ue();pt();var jz=q();async function mm(e,t){let n=await ie(`${jz}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(n))throw new kn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function qz(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 Yz=q(),Kz="UICOPILOT/WORKSPACE_PATH",Xz="UICOPILOT/REQUEST_WORKSPACE_PATH",hm=!1;function xm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=Se(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Ze(),{currentStoryId:l,mappingsRefreshKey:p,setFigmaFileUrl:f,setCurrentMapping:d,setMappingSource:m,setLoadingMapping:w}=rt(),{setReviewResults:k,setReviewDetailTab:F,setStorybookImageUrl:C,setFigmaImageUrl:z,setFullPrompt:R,setFullResponse:O,bulkAddReviews:L}=se(),[B,g]=Wz([]),x=Vz(null);Mr(()=>{let h=T=>{T.origin.startsWith(Yz)&&T.data?.type==="UICOPILOT_AUTH_SUCCESS"&&T.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(T.data.token))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[t]);let b=Gz({[Kz]:h=>{y.debug("[useDataInit] Received workspace path:",h.path),c(h.path)}});Mr(()=>{b(Xz)},[b]),Mr(()=>{if(!e)return;let h=!1;return(async()=>{try{u(!0);let I=await dm(e);h||(s(I),n(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch projects:",I)}finally{h||u(!1)}})(),()=>{h=!0}},[e,s,u]),Mr(()=>{if(!i||r.length===0)return;let h=r.find(T=>T.storybookRoot===i);h&&o!==h.id&&(y.debug("[useDataInit] Auto-selecting project:",h.name),a(h.id))},[i,r,o,a]),Mr(()=>{if(!o||r.length===0)return;let h=r.find(I=>I.id===o),T=h?.figmaFileId;if(h&&typeof T=="string"&&T){let I=T,v=I.includes("figma.com")&&Rv(I)?.fileKey||I;f(`https://www.figma.com/file/${v}`)}},[o,r,f]),Mr(()=>!e||!o||hm?void 0:(hm=!0,(async()=>{try{let T=await mm(e,o);for(let[I,v]of Object.entries(T))xo(I,{score:v.score,issueCount:v.issueCount,criticalCount:v.criticalCount,majorCount:v.majorCount,minorCount:v.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(T).length,"stories")}catch(T){T instanceof kn&&n(T.message),y.error("[useDataInit] Failed to fetch review statuses:",T)}})(),()=>{hm=!1}),[e,o]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{w(!0);let I=await fm(e,o,l);if(h)return;I?(d(I),m("database")):(d(null),m(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch mapping:",I)}finally{h||w(!1)}})(),()=>{h=!0}},[e,o,l,p,d,m,w]),Mr(()=>{g([]),x.current=null},[l]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{let I=await gm(e,o,l,10,!0);if(!h){g(I);let v=I.map(A=>qz(A)).filter(Boolean);v.length>0&&L(v)}}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{h=!0}},[e,o,l]);let E=Hz(h=>{y.debug("[useDataInit] Applying review:",h.id,"with",h.issues.length,"issues");let T=[];if(typeof h.models=="string")try{T=JSON.parse(h.models)}catch{T=["claude-sonnet-4-20250514"]}else T=h.models;let I=h.issues.map(P=>({id:P.id,reviewId:h.id,type:P.type,severity:P.severity,title:P.description,description:P.description,file:void 0,lineNumber:void 0,property:P.property,currentValue:P.actual,suggestedValue:P.expected,suggestedCode:P.suggestedFix||void 0,status:P.status,dismissed:P.dismissed||!1,dismissReason:P.dismissReason,dismissedBy:P.dismissedBy,figmaContext:P.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(P.createdAt)})),v=h.completedAt&&h.createdAt?new Date(h.completedAt).getTime()-new Date(h.createdAt).getTime():void 0,A=h.storyId||"";if(k({id:h.id,componentId:"",storyId:A,modelId:T[0]||"claude-sonnet-4-5-20250929",complianceScore:h.complianceScore,issuesCount:h.issuesCount,issues:I,createdAt:new Date(h.createdAt),timestamp:new Date(h.createdAt).toISOString(),costUsd:h.costUsd,inputTokens:h.inputTokens,outputTokens:h.outputTokens,reviewDurationMs:v}),h.storybookScreenshot&&(C(h.storybookScreenshot),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),h.figmaScreenshot&&(z(h.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot")),h.aiPrompt&&(R(h.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),h.aiResponse&&(O(h.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),A){let P=h.issues.filter(j=>!j.dismissed),D=P.filter(j=>j.severity==="critical").length,N=P.filter(j=>j.severity==="major").length,S=P.filter(j=>j.severity==="minor").length;xo(A,{score:h.complianceScore,issueCount:P.length,criticalCount:D,majorCount:N,minorCount:S})}},[k,C,z,R,O]);Mr(()=>{if(B.length>0&&l&&x.current!==l){let h=B[0];h&&h.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",h.id,"for:",l),x.current=l,E(h),F("issues"))}},[B,l,E,F])}import{styled as Ys}from"storybook/theming";var Qz=Ys.div({display:"flex",gap:"10px",marginTop:"8px"}),zv=Ys.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Jz=Ys.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"})),Zz=Ys.div({display:"flex",alignItems:"center",gap:"8px"}),eN=Ys(er)(({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"})),Nv=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o}=Bs();return Mt.createElement(Mt.Fragment,null,Mt.createElement(ts,null,Mt.createElement(ns,null,"Authentication Method"),Mt.createElement(Qz,null,Mt.createElement(zv,null,Mt.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),Mt.createElement(zv,null,Mt.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&Mt.createElement(ts,null,Mt.createElement(ns,null,"Connect to UI Copilot"),e?Mt.createElement(Jz,null,Mt.createElement(Zz,null,Mt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),Mt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),Mt.createElement(eN,{onClick:o},"Disconnect")):Mt.createElement("div",null,Mt.createElement(eu,{style:{marginBottom:"12px"}},"Connect to UI Copilot to manage projects and integrations. This will open a browser window for authentication."),Mt.createElement(er,{onClick:r},"\u{1F517} Connect to UI Copilot"))),t==="apikey"&&Mt.createElement(ts,null,Mt.createElement(ns,null,"API Key"),Mt.createElement(eu,{style:{marginBottom:"12px"}},"Enter your UI Copilot API key below."),Mt.createElement(rs,{type:"password",placeholder:"Enter API key",disabled:!0}),Mt.createElement(er,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import Yt,{useState as ym}from"react";we();import{styled as wr}from"storybook/theming";var tN=wr.div({marginBottom:"30px"}),nN=wr.div({display:"flex",gap:"8px",alignItems:"center"}),rN=wr(En)({flex:1}),oN=wr(en)({padding:"8px 12px",whiteSpace:"nowrap"}),iN=wr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),bm=wr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Sm=wr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),wm=wr(rs)({fontSize:"13px",padding:"6px 8px"}),sN=wr.div({display:"flex",gap:"8px",marginTop:"12px"}),Ov=wr(en)({fontSize:"12px",padding:"6px 12px"}),aN=wr(Ov)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),_v=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o}=qr(),{currentStorybookPath:i}=Ze(),[s,a]=ym(!1),[u,c]=ym(!1),[l,p]=ym({name:"",storybookRoot:"",figmaFileUrl:""}),f=k=>{n(k||null),a(!1)},d=()=>{if(a(!0),i){let k=i.replace(/\/+$/,"").split("/").pop()||"";p({storybookRoot:i,name:k,figmaFileUrl:""})}},m=async()=>{if(l.name.trim())try{c(!0);let k;if(l.figmaFileUrl.trim()){let C=l.figmaFileUrl.trim(),z=C.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);k=z?z[1]:C}let F=await o({name:l.name.trim(),storybookRoot:l.storybookRoot.trim()||void 0,figmaFileId:k});n(F.id),a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}catch(k){console.error("Failed to create project:",k)}finally{c(!1)}},w=k=>{p(F=>{let C={...F,storybookRoot:k};if(!F.name&&k){let z=k.replace(/\/+$/,"").split("/").pop()||"";C.name=z}return C})};return Yt.createElement(tN,null,Yt.createElement(Yx,null,"Project"),Yt.createElement(nN,null,Yt.createElement(rN,{value:t||"",onChange:k=>f(k.target.value),disabled:r||s},Yt.createElement("option",{value:""},"-- Select a project --"),e.map(k=>Yt.createElement("option",{key:k.id,value:k.id},k.name))),Yt.createElement(oN,{onClick:d,disabled:r,type:"button"},"+ New")),s&&Yt.createElement(iN,null,Yt.createElement(bm,null,Yt.createElement(Sm,null,"Storybook Path (for fix generation)"),Yt.createElement(wm,{type:"text",placeholder:"/path/to/your/storybook",value:l.storybookRoot,onChange:k=>w(k.target.value)})),Yt.createElement(bm,null,Yt.createElement(Sm,null,"Project Name *"),Yt.createElement(wm,{type:"text",placeholder:"my-storybook",value:l.name,onChange:k=>{let F=k.target.value;p(C=>({...C,name:F}))}})),Yt.createElement(bm,null,Yt.createElement(Sm,null,"Figma File URL (for design comparison)"),Yt.createElement(wm,{type:"text",placeholder:"https://www.figma.com/file/...",value:l.figmaFileUrl,onChange:k=>{let F=k.target.value;p(C=>({...C,figmaFileUrl:F}))}})),Yt.createElement(sN,null,Yt.createElement(Ov,{onClick:m,disabled:u||!l.name.trim()},u?"Creating...":"Create"),Yt.createElement(aN,{onClick:()=>{a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import bt,{useState as Jm,useCallback as bC,useEffect as b$}from"react";import{styled as vr}from"storybook/theming";import So,{useState as km,useEffect as IN,useCallback as Uv}from"react";import{styled as Go}from"storybook/theming";we();Ue();pt();we();Ue();pt();import Ut,{useState as vm}from"react";import{styled as zn,keyframes as lN}from"storybook/theming";var cN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},uN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",pN=zn.div({position:"relative",display:"inline-flex"}),dN=lN`
|
|
31
31
|
0% { transform: rotate(0deg); }
|
|
32
32
|
100% { transform: rotate(360deg); }
|
|
33
33
|
`,fN=zn.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}}}),gN=zn.span`
|
|
@@ -38,10 +38,10 @@ ${st}`).join(`
|
|
|
38
38
|
border-top-color: #fff;
|
|
39
39
|
border-radius: 50%;
|
|
40
40
|
animation: ${dN} 0.8s linear infinite;
|
|
41
|
-
`,mN=zn.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})),hN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),xN=zn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),yN=zn.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()}}),bN=zn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),SN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),wN=zn.span({display:"flex",alignItems:"center",gap:"4px"}),vN=zn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),kN=zn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),CN=zn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),TN=zn.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"}})),$v=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Ze(),[n,r]=vm(!1),[o,i]=vm(!1),[s,a]=vm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=q(),l=localStorage.getItem("uicopilot_session_token"),d=await oe(`${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 f=await d.json();a(f),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Ut.createElement(pN,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Ut.createElement(fN,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Ut.createElement(Ut.Fragment,null,Ut.createElement(gN,null)," Checking..."):s?Ut.createElement(Ut.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Ut.createElement(Ut.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Ut.createElement(mN,null,Ut.createElement(hN,null,Ut.createElement(xN,null,"Figma Design Quality"),Ut.createElement(yN,{score:s.score},Math.round(s.score),"%")),Ut.createElement(bN,null,Object.entries(s.categories).map(([c,l])=>Ut.createElement(SN,{key:c},Ut.createElement(wN,null,Ut.createElement(vN,{status:l.status},uN(l.status)),cN[c]||c),Ut.createElement(kN,null,l.score)))),s.summary&&Ut.createElement(CN,null,s.summary),s.recommendations?.length>0&&Ut.createElement(TN,null,s.recommendations.slice(0,2).map((c,l)=>Ut.createElement("li",{key:l},c))))):null};var FN=Go.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),EN=Go.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),AN=Go.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),PN=Go.div({display:"flex",gap:"8px",alignItems:"center"}),LN=Go.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:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight}})),MN=Go(en)({whiteSpace:"nowrap"}),BN=Go.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),jv=()=>{let{selectedProjectId:e,projects:t}=Ze(),{sessionToken:n}=we(),{updateProject:r}=qr(),o=t.find(S=>S.id===e),[i,s]=km(""),[a,u]=km(!1),[c,l]=km(null),d=o?.figmaFileUrl||o?.figmaFileId||"";IN(()=>{s(d),l(null)},[o?.id,d]);let f=i!==d,p=Uv(async()=>{if(!(!e||!f))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let S=q();try{await oe(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}oe(`${S}/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(S){l({type:"error",message:S instanceof Error?S.message:"Failed to save"})}finally{u(!1)}},[e,i,f,r]),g=Uv(S=>{S.key==="Enter"&&f&&!a&&p()},[f,a,p]);return e?So.createElement(FN,null,So.createElement(EN,null,So.createElement(AN,null,"Figma File URL"),So.createElement($v,{figmaFileUrl:d})),So.createElement(PN,null,So.createElement(LN,{type:"text",value:i,onChange:S=>s(S.target.value),onKeyDown:g,placeholder:"https://www.figma.com/file/..."}),So.createElement(MN,{onClick:p,disabled:!f||a},a?"Saving...":"Save")),c&&So.createElement(BN,{variant:c.type},c.message)):null};import kt,{useState as nc,useEffect as X_}from"react";import{styled as Yn}from"storybook/theming";ve();je();import Je,{useState as Bi,useEffect as w_,useCallback as Co}from"react";import{styled as Jt}from"storybook/theming";je();je();De();import X,{useState as Li,useEffect as Ak,useMemo as zm,useCallback as Pk}from"react";import{styled as Ye}from"storybook/theming";pt();import Me,{useState as Ek,useEffect as DN,memo as RN}from"react";import{styled as xe}from"storybook/theming";var Hv=xe.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}),Wv=xe.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}`})),Vv=xe.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),Gv=xe.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),qv=xe(wn)({fontSize:"20px",padding:"4px 8px"}),Yv=xe.div({flex:1,overflow:"auto",padding:"20px"}),Kv=xe(so)({fontSize:"14px",marginBottom:"16px"}),Cm=xe.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Xv=xe.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:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Tm=xe.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"})),Qv=xe.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"})),Jv=xe.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),Ys=xe.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})),Im=xe.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Ks=xe.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Fm=xe.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Em=xe.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Am=xe.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Pm=xe.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Zv=xe.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),jl=xe.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),ek=xe.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),tk=xe.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),nk=xe.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:le}})),rk=xe.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,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:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),ok=xe.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:le,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),ik=xe.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),OZ=xe.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"})),sk=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),ak=xe.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%"}}})),Lm=xe.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"}})),lk=xe.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})),ck=xe.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),uk=xe.span(({theme:e})=>({color:e.color.defaultText})),Hl=xe.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%"}}})),pk=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),dk=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),fk=xe.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),gk=xe(En)({flex:1,width:"auto"}),mk=xe.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),hk=xe.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"})),xk=xe.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),yk=xe.span(({theme:e})=>({color:e.color.defaultText})),bk=xe.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}})),Sk=xe.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}})),wk=xe.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),Wl=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),Xs=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Pi=xe(En)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),Vl=xe.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`}})),vk=xe.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),kk=xe.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:le,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),Ck=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Mm=xe.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?le: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:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Bm=xe.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?le:e.appBorderColor}`,backgroundColor:t?le:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),Tk=xe.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),Ik=xe.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:le,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:le,opacity:t?.6:.9}})),Fk=xe.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"}));De();var Dm=RN(({src:e,alt:t,isComponentSet:n,loadingDone:r})=>{let[o,i]=Ek(!1),[s,a]=Ek(!1);return DN(()=>{i(!1),a(!1)},[e]),o?Me.createElement(Ys,null,Me.createElement(Fm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(Ks,null,"Failed to load")):e?Me.createElement(Me.Fragment,null,!s&&Me.createElement(Ys,{style:{position:"absolute",inset:0}},Me.createElement(Im,null),Me.createElement(Ks,null,"Loading...")),Me.createElement(Jv,{src:e,alt:t,onLoad:()=>a(!0),onError:()=>i(!0),style:{opacity:s?1:0}})):r?Me.createElement(Ys,null,Me.createElement(Fm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(Ks,null,"No preview")):Me.createElement(Ys,null,Me.createElement(Im,null),Me.createElement(Ks,null,"Loading..."))}),Qs=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,isLoadingVariants:i=!1,isExpanded:s,isNew:a=!1,onToggleExpand:u,onSelect:c,multiSelect:l=!1,selectedFrames:d=new Set,variantFilters:f=[]})=>{let p=e.type==="COMPONENT_SET",g=p&&(e.children&&e.children.length>0||(e.childCount??0)>0),S=e.children||o||[],C=Me.useMemo(()=>S.length===0?[]:f.some(R=>R.value)?S.filter(R=>R.variantProperties?f.every(z=>z.value?R.variantProperties?.[z.property]===z.value:!0):!1):S,[S,f]),F=R=>{if(p&&g){u(e.id,R);return}c(e)},k=l?Mm:Xv;return Me.createElement(Me.Fragment,null,Me.createElement(k,{onClick:F,title:e.name,isSelected:l?d.has(e.id):void 0,style:{cursor:"pointer"}},l&&!g&&Me.createElement(Bm,{isSelected:d.has(e.id)},d.has(e.id)?"\u2713":""),p?Me.createElement(Qv,null,g&&Me.createElement(nk,{onClick:R=>u(e.id,R),title:s?"Collapse variants":"Expand variants"},s?"\u25BC":"\u25B6"),g&&Me.createElement(ok,null,C.length>0&&C.length!==S.length?`${C.length} / ${S.length}`:e.childCount??S.length," variants"),Me.createElement(Dm,{src:t,alt:e.name,isComponentSet:!0})):Me.createElement(Tm,null,Me.createElement(Dm,{src:t,alt:e.name,isComponentSet:!1})),Me.createElement(Em,null,Me.createElement(Am,null,e.name,a&&Me.createElement(Fk,null,"New")),Me.createElement(Pm,null,e.type))),g&&s&&i&&Me.createElement(Me.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((R,z)=>Me.createElement(sk,{key:`skeleton-${z}`},Me.createElement(ak,null),Me.createElement(Lm,{width:"80%"}),Me.createElement(Lm,{width:"50%"})))),g&&s&&!i&&C.map(R=>Me.createElement(Rm,{key:R.id,variant:R,thumbnail:r?.[R.id]||n[R.id],onSelect:c,multiSelect:l,isSelected:d.has(R.id),loadingDone:!!t||r!==void 0&&R.id in(r||{})})))},Rm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1})=>Me.createElement(r?Mm:rk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Me.createElement(Bm,{isSelected:o},o?"\u2713":""),Me.createElement(Tm,null,Me.createElement(Dm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i})),Me.createElement(Em,null,Me.createElement(Am,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Me.createElement(ik,null,Object.entries(e.variantProperties).map(([u,c])=>Me.createElement(lk,{key:u},Me.createElement(ck,null,u,":")," ",Me.createElement(uk,null,c)))),Me.createElement(Pm,{style:{marginTop:"6px"}},"VARIANT")));var zN=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),NN=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),ON=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),Lk=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),Mk=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),Gl=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),_N=Ye(En)({flex:1,width:"auto"}),Bk=Ye(so)({flex:1,fontSize:"13px"}),$N=Ye.div({flex:1,overflow:"auto",padding:"8px"}),UN=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}})),jN=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),HN=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),WN=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})),VN=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),GN=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"})),qN=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),YN=Ye.div({flex:1,overflow:"hidden"}),KN=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),XN=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)"}}})),QN=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),JN=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),ZN=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),eO=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Nm=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),tO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Om=20,nO=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"})),rO=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`}})),oO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),iO=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`}})),sO=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),_m=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),$m=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),aO=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),lO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Dk=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),Rk=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"}}})),zk=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"}}})),cO=()=>X.createElement(lO,null,Array.from({length:8}).map((e,t)=>X.createElement(Dk,{key:t},X.createElement(Rk,null),X.createElement(zk,{width:`${60+t%3*15}%`})))),uO=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"})),pO=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"}),dO=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)"}}})),fO=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),Nk=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=Gs({projectId:i,limit:Om,enabled:!!i}),[a,u]=Li("all"),[c,l]=Li(""),[d,f]=Li(null),[p,g]=Li(1),[S,C]=Li(null),[F,k]=Li(!1),R=zm(()=>{let h=new Set;return e.forEach(T=>{T.componentTitle&&h.add(T.componentTitle)}),Array.from(h).sort()},[e]),z=zm(()=>e.filter(h=>{if(a!=="all"&&h.componentTitle!==a)return!1;if(c){let T=c.toLowerCase();return h.name.toLowerCase().includes(T)||h.title.toLowerCase().includes(T)}return!0}),[e,a,c]),_=d?s.frames.find(h=>h.id===d):null,M=zm(()=>{if(!d)return[];let h=s.variantChildren[d]||[];return h.length===0?[]:s.variantFilters.some(T=>T.value)?h.filter(T=>T.variantProperties?s.variantFilters.every(I=>I.value?T.variantProperties?.[I.property]===I.value:!0):!1):h},[d,s.variantChildren,s.variantFilters]),B=M.slice(0,p*Om),m=M.length>p*Om;Ak(()=>{if(!d||B.length===0)return;let h=B.map(T=>T.id);s.fetchVariantThumbnails(d,h)},[d,B.length,p]),Ak(()=>{k(!1)},[]);let x=Pk(async h=>{if(n)try{let T=q(),I=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${T}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:h.id,name:h.name})})).ok)throw new Error("Failed to save mapping");o(n,h.id,h.name)}catch(T){y.error("[MapStoriesTab] Error saving mapping:",T)}},[n,i,o]),b=Pk((h,T)=>{if(T.stopPropagation(),d===h){f(null),g(1);return}f(h),g(1),!s.variantThumbnails[h]&&!s.loadingVariants.has(h)&&s.toggleExpanded(h,T)},[d,s]),E=e.find(h=>h.id===n);return t?X.createElement(aO,null,"Loading stories..."):X.createElement(zN,null,X.createElement(NN,null,X.createElement(Lk,null,X.createElement(Mk,null,"Storybook Stories"),X.createElement(Gl,null,X.createElement(_N,{value:a,onChange:h=>u(h.target.value)},X.createElement("option",{value:"all"},"All Components"),R.map(h=>X.createElement("option",{key:h,value:h},h)))),X.createElement(Gl,null,X.createElement(Bk,{type:"text",placeholder:"Search stories...",value:c,onChange:h=>l(h.target.value)}))),X.createElement($N,null,z.length===0?X.createElement($m,null,"No stories found"):z.map(h=>X.createElement(UN,{key:h.id,selected:h.id===n,mapped:!!h.figmaMapping,onClick:()=>r(h.id)},X.createElement(jN,null,X.createElement(HN,null,h.name),X.createElement(WN,{mapped:!!h.figmaMapping},h.figmaMapping?"Mapped":"Unmapped")),X.createElement(VN,null,h.title),h.figmaMapping&&X.createElement(GN,{onMouseEnter:()=>C(h.id),onMouseLeave:()=>C(null)},(()=>{let T=h.figmaMapping?.figmaNodeId,I=T?s.resolveThumbnail(T):void 0;return X.createElement(X.Fragment,null,I?X.createElement(qN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}):X.createElement("span",null,"\u{1F517}"),S===h.id&&I&&X.createElement(XN,null,X.createElement(QN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}),X.createElement(JN,null,h.figmaMapping?.figmaFrameName)))})(),X.createElement(YN,null,X.createElement(KN,null,h.figmaMapping.figmaFrameName))))))),X.createElement(ON,null,n?X.createElement(X.Fragment,null,X.createElement(uO,null,X.createElement("span",null,"Click a Figma component below to link it to"," ",X.createElement("strong",null,E?.name))),X.createElement(Lk,null,X.createElement(Mk,null,"Figma Components"),X.createElement(Gl,null,X.createElement(eO,null,X.createElement(Nm,null,X.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:h=>s.setShowComponentSets(h.target.checked)}),"Component Sets"),X.createElement(Nm,null,X.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:h=>s.setShowFrames(h.target.checked)}),"Frames"),X.createElement(Nm,null,X.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:h=>s.setShowComponents(h.target.checked)}),"Components")),s.availablePages.length>1&&X.createElement(Pi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:h=>s.setFigmaPage(h.target.value)},X.createElement("option",{value:""},"All pages"),s.availablePages.map(h=>X.createElement("option",{key:h,value:h},h)))),s.availableFilters.length>0&&X.createElement(Wl,null,X.createElement(Xs,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:h,values:T})=>{let I=s.variantFilters.find(v=>v.property===h);return X.createElement(Pi,{key:h,isActive:!!I?.value,value:I?.value||"",onChange:v=>s.handleFilterChange(h,v.target.value)},X.createElement("option",{value:""},h),T.map(v=>X.createElement("option",{key:v,value:v},h,"=",v)))}),s.availableFilters.length>5&&X.createElement(Xs,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(h=>h.value)&&X.createElement(Vl,{onClick:s.clearFilters},"Clear All")),X.createElement(Gl,null,X.createElement(Bk,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:h=>s.setSearch(h.target.value)}))),X.createElement(ZN,null,F&&X.createElement(pO,null,X.createElement(dO,null),X.createElement(fO,null,"Loading thumbnails...")),s.isLoading?X.createElement(cO,null):s.filteredFrames.length===0?X.createElement($m,null,X.createElement("span",null,"No components found")):X.createElement(tO,null,d&&_?X.createElement(X.Fragment,null,X.createElement(oO,null,X.createElement(iO,{onClick:()=>{f(null),g(1)}},"Back"),X.createElement(sO,null,_.name)),s.loadingVariants.has(d)?X.createElement(X.Fragment,null,X.createElement(_m,null,"Loading ",_.childCount??"..."," variants..."),Array.from({length:Math.min(8,_.childCount??8)}).map((h,T)=>X.createElement(Dk,{key:`variant-skeleton-${T}`},X.createElement(Rk,null),X.createElement(zk,{width:`${60+T%3*15}%`})))):X.createElement(X.Fragment,null,X.createElement(_m,null,"Showing ",B.length," of ",M.length," variants"),B.map(h=>X.createElement(Rm,{key:h.id,variant:h,thumbnail:s.variantThumbnails[d]?.[h.id]||s.thumbnails[h.id],onSelect:x,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d)})))):X.createElement(X.Fragment,null,X.createElement(_m,null,"Showing ",s.frames.length," of ",s.totalFrames," components"),s.filteredFrames.map(h=>X.createElement(Qs,{key:h.id,frame:h,thumbnail:s.thumbnails[h.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[h.id],variantChildren:s.variantChildren[h.id],isLoadingVariants:s.loadingVariants.has(h.id),isExpanded:!1,onToggleExpand:b,onSelect:x,variantFilters:s.variantFilters}))),(d?m:s.hasMore)&&X.createElement(nO,null,X.createElement(rO,{disabled:s.loadingMore,onClick:async()=>{d?g(h=>h+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):X.createElement($m,null,X.createElement("span",null,"Select a story from the left to link it to Figma"))))};je();import et,{useState as Um,useMemo as Ok,useCallback as _k}from"react";import{styled as Rt}from"storybook/theming";pt();var gO=Rt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),mO=Rt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),hO=Rt(En)({width:"auto",minWidth:"200px"}),xO=Rt(so)({fontSize:"13px",minWidth:"250px"}),yO=Rt.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}})),bO=Rt.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}})),SO=Rt.div({flex:1,overflow:"auto"}),wO=Rt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),vO=Rt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),ql=Rt.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}`})),kO=Rt.tbody({}),CO=Rt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),Yl=Rt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),TO=Rt.div({display:"flex",flexDirection:"column",gap:"2px"}),IO=Rt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),FO=Rt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),EO=Rt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),AO=Rt.div({display:"flex",alignItems:"center",gap:"8px"}),PO=Rt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),LO=Rt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),$k=Rt.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`}})),MO=Rt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),BO=Rt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),Uk=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=Um("all"),[a,u]=Um(""),[c,l]=Um(!0),d=Ok(()=>{let C=new Set;return e.forEach(F=>{F.componentTitle&&C.add(F.componentTitle)}),Array.from(C).sort()},[e]),f=Ok(()=>e.filter(C=>{if(i!=="all"&&C.componentTitle!==i||!c&&!C.figmaMapping)return!1;if(a){let F=a.toLowerCase();return C.name.toLowerCase().includes(F)||C.title.toLowerCase().includes(F)||(C.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),p=_k(async C=>{try{let F=q(),k=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${F}/api/mappings?projectId=${o}&storyId=${C}`,{method:"DELETE",headers:{Authorization:`Bearer ${k}`}})).ok)throw new Error("Failed to delete mapping");r(C)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),g=_k(()=>{let C=e.filter(z=>z.figmaMapping).map(z=>({storyId:z.id,storyName:z.name,storyTitle:z.title,figmaNodeId:z.figmaMapping.figmaNodeId,figmaFrameName:z.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(C,null,2)],{type:"application/json"}),k=URL.createObjectURL(F),R=document.createElement("a");R.href=k,R.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(k)},[e]);if(t)return et.createElement(BO,null,"Loading mappings...");let S=e.filter(C=>C.figmaMapping).length;return et.createElement(gO,null,et.createElement(mO,null,et.createElement(hO,{value:i,onChange:C=>s(C.target.value)},et.createElement("option",{value:"all"},"All Components"),d.map(C=>et.createElement("option",{key:C,value:C},C))),et.createElement(xO,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:C=>u(C.target.value)}),et.createElement(yO,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),et.createElement(bO,{onClick:g,disabled:S===0},"\u{1F4E5} Export JSON")),f.length===0?et.createElement(MO,null,et.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):et.createElement(SO,null,et.createElement(wO,null,et.createElement(vO,null,et.createElement("tr",null,et.createElement(ql,{style:{width:"35%"}},"Story"),et.createElement(ql,{style:{width:"35%"}},"Figma Component"),et.createElement(ql,{style:{width:"15%"}},"Status"),et.createElement(ql,{style:{width:"15%"}},"Actions"))),et.createElement(kO,null,f.map(C=>et.createElement(CO,{key:C.id,mapped:!!C.figmaMapping},et.createElement(Yl,null,et.createElement(TO,null,et.createElement(IO,null,C.name),et.createElement(FO,null,C.title))),et.createElement(Yl,null,et.createElement(EO,{mapped:!!C.figmaMapping},C.figmaMapping?et.createElement(et.Fragment,null,et.createElement("span",null,"\u{1F3A8}"),C.figmaMapping.figmaFrameName):"\u2014")),et.createElement(Yl,null,et.createElement(AO,null,et.createElement(PO,{mapped:!!C.figmaMapping}),et.createElement(LO,{mapped:!!C.figmaMapping},C.figmaMapping?"Mapped":"Unmapped"))),et.createElement(Yl,null,C.figmaMapping?et.createElement($k,{variant:"unlink",onClick:()=>p(C.id)},"Unlink"):et.createElement($k,{variant:"link",onClick:()=>n(C.id)},"Link"))))))))};import ke,{useState as ec,useMemo as Yk}from"react";import{styled as dt}from"storybook/theming";import jk from"react";import{styled as Hk,keyframes as DO}from"storybook/theming";var RO=DO`
|
|
41
|
+
`,mN=zn.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})),hN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),xN=zn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),yN=zn.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()}}),bN=zn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),SN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),wN=zn.span({display:"flex",alignItems:"center",gap:"4px"}),vN=zn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),kN=zn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),CN=zn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),TN=zn.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"}})),$v=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Ze(),[n,r]=vm(!1),[o,i]=vm(!1),[s,a]=vm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=q(),l=localStorage.getItem("uicopilot_session_token"),p=await ie(`${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 f=await p.json();a(f),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Ut.createElement(pN,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Ut.createElement(fN,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Ut.createElement(Ut.Fragment,null,Ut.createElement(gN,null)," Checking..."):s?Ut.createElement(Ut.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Ut.createElement(Ut.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Ut.createElement(mN,null,Ut.createElement(hN,null,Ut.createElement(xN,null,"Figma Design Quality"),Ut.createElement(yN,{score:s.score},Math.round(s.score),"%")),Ut.createElement(bN,null,Object.entries(s.categories).map(([c,l])=>Ut.createElement(SN,{key:c},Ut.createElement(wN,null,Ut.createElement(vN,{status:l.status},uN(l.status)),cN[c]||c),Ut.createElement(kN,null,l.score)))),s.summary&&Ut.createElement(CN,null,s.summary),s.recommendations?.length>0&&Ut.createElement(TN,null,s.recommendations.slice(0,2).map((c,l)=>Ut.createElement("li",{key:l},c))))):null};var FN=Go.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),EN=Go.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),AN=Go.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),PN=Go.div({display:"flex",gap:"8px",alignItems:"center"}),LN=Go.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:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight}})),MN=Go(en)({whiteSpace:"nowrap"}),BN=Go.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),jv=()=>{let{selectedProjectId:e,projects:t}=Ze(),{sessionToken:n}=Se(),{updateProject:r}=qr(),o=t.find(w=>w.id===e),[i,s]=km(""),[a,u]=km(!1),[c,l]=km(null),p=o?.figmaFileUrl||o?.figmaFileId||"";IN(()=>{s(p),l(null)},[o?.id,p]);let f=i!==p,d=Uv(async()=>{if(!(!e||!f))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let w=q();try{await ie(`${w}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}ie(`${w}/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(w){l({type:"error",message:w instanceof Error?w.message:"Failed to save"})}finally{u(!1)}},[e,i,f,r]),m=Uv(w=>{w.key==="Enter"&&f&&!a&&d()},[f,a,d]);return e?So.createElement(FN,null,So.createElement(EN,null,So.createElement(AN,null,"Figma File URL"),So.createElement($v,{figmaFileUrl:p})),So.createElement(PN,null,So.createElement(LN,{type:"text",value:i,onChange:w=>s(w.target.value),onKeyDown:m,placeholder:"https://www.figma.com/file/..."}),So.createElement(MN,{onClick:d,disabled:!f||a},a?"Saving...":"Save")),c&&So.createElement(BN,{variant:c.type},c.message)):null};import kt,{useState as nc,useEffect as X_}from"react";import{styled as Yn}from"storybook/theming";we();Ue();import Je,{useState as Bi,useEffect as w_,useCallback as Co}from"react";import{styled as Jt}from"storybook/theming";Ue();Ue();De();import K,{useState as Li,useEffect as Ak,useMemo as zm,useCallback as Pk}from"react";import{styled as Ye}from"storybook/theming";pt();import Pe,{useState as Ek,useEffect as DN,memo as RN}from"react";import{styled as he}from"storybook/theming";var Hv=he.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}),Wv=he.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}`})),Vv=he.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),Gv=he.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),qv=he(wn)({fontSize:"20px",padding:"4px 8px"}),Yv=he.div({flex:1,overflow:"auto",padding:"20px"}),Kv=he(so)({fontSize:"14px",marginBottom:"16px"}),Cm=he.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Xv=he.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:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Tm=he.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"})),Qv=he.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"})),Jv=he.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),Ks=he.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})),Im=he.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Xs=he.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Fm=he.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Em=he.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Am=he.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Pm=he.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Zv=he.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),jl=he.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),ek=he.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),tk=he.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),nk=he.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:le}})),rk=he.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,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:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),ok=he.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:le,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),ik=he.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),OZ=he.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"})),sk=he.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),ak=he.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%"}}})),Lm=he.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"}})),lk=he.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})),ck=he.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),uk=he.span(({theme:e})=>({color:e.color.defaultText})),Hl=he.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%"}}})),pk=he.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),dk=he.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),fk=he.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),gk=he(En)({flex:1,width:"auto"}),mk=he.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),hk=he.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"})),xk=he.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),yk=he.span(({theme:e})=>({color:e.color.defaultText})),bk=he.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}})),Sk=he.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}})),wk=he.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),Wl=he.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),Qs=he.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Pi=he(En)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),Vl=he.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`}})),vk=he.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),kk=he.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:le,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),Ck=he.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Mm=he.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?le: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:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Bm=he.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?le:e.appBorderColor}`,backgroundColor:t?le:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),Tk=he.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),Ik=he.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:le,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:le,opacity:t?.6:.9}})),Fk=he.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"}));De();var Dm=RN(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=Ek(!1),[a,u]=Ek(!1);return DN(()=>{s(!1),u(!1)},[e]),i?Pe.createElement(Ks,null,Pe.createElement(Fm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Pe.createElement(Xs,null,"Failed to load")):e?Pe.createElement(Pe.Fragment,null,!a&&Pe.createElement(Ks,{style:{position:"absolute",inset:0}},Pe.createElement(Im,null),Pe.createElement(Xs,null,"Loading...")),Pe.createElement(Jv,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?Pe.createElement(Ks,null,Pe.createElement(Fm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Pe.createElement(Xs,null,o?"Render failed":"No preview")):Pe.createElement(Ks,null,Pe.createElement(Im,null),Pe.createElement(Xs,null,"Loading..."))}),Js=({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:f=new Set,variantFilters:d=[]})=>{let m=e.type==="COMPONENT_SET",w=m&&(e.children&&e.children.length>0||(e.childCount??0)>0),k=e.children||o||[],F=Pe.useMemo(()=>k.length===0?[]:d.some(R=>R.value)?k.filter(R=>R.variantProperties?d.every(O=>O.value?R.variantProperties?.[O.property]===O.value:!0):!1):k,[k,d]),C=R=>{if(m&&w){c(e.id,R);return}l(e)},z=p?Mm:Xv;return Pe.createElement(Pe.Fragment,null,Pe.createElement(z,{onClick:C,title:e.name,isSelected:p?f.has(e.id):void 0,style:{cursor:"pointer"}},p&&!w&&Pe.createElement(Bm,{isSelected:f.has(e.id)},f.has(e.id)?"\u2713":""),m?Pe.createElement(Qv,null,w&&Pe.createElement(nk,{onClick:R=>c(e.id,R),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),w&&Pe.createElement(ok,null,F.length>0&&F.length!==k.length?`${F.length} / ${k.length}`:e.childCount??k.length," variants"),Pe.createElement(Dm,{src:t,alt:e.name,isComponentSet:!0})):Pe.createElement(Tm,null,Pe.createElement(Dm,{src:t,alt:e.name,isComponentSet:!1})),Pe.createElement(Em,null,Pe.createElement(Am,null,e.name,u&&Pe.createElement(Fk,null,"New")),Pe.createElement(Pm,null,e.type))),w&&a&&s&&Pe.createElement(Pe.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((R,O)=>Pe.createElement(sk,{key:`skeleton-${O}`},Pe.createElement(ak,null),Pe.createElement(Lm,{width:"80%"}),Pe.createElement(Lm,{width:"50%"})))),w&&a&&!s&&F.map(R=>Pe.createElement(Rm,{key:R.id,variant:R,thumbnail:r?.[R.id]||n[R.id],onSelect:l,multiSelect:p,isSelected:f.has(R.id),loadingDone:!!t||r!==void 0&&R.id in(r||{}),failed:i?.has(R.id)})))},Rm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>Pe.createElement(r?Mm:rk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Pe.createElement(Bm,{isSelected:o},o?"\u2713":""),Pe.createElement(Tm,null,Pe.createElement(Dm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),Pe.createElement(Em,null,Pe.createElement(Am,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Pe.createElement(ik,null,Object.entries(e.variantProperties).map(([c,l])=>Pe.createElement(lk,{key:c},Pe.createElement(ck,null,c,":")," ",Pe.createElement(uk,null,l)))),Pe.createElement(Pm,{style:{marginTop:"6px"}},"VARIANT")));var zN=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),NN=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),ON=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),Lk=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),Mk=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),Gl=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),_N=Ye(En)({flex:1,width:"auto"}),Bk=Ye(so)({flex:1,fontSize:"13px"}),$N=Ye.div({flex:1,overflow:"auto",padding:"8px"}),UN=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}})),jN=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),HN=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),WN=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})),VN=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),GN=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"})),qN=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),YN=Ye.div({flex:1,overflow:"hidden"}),KN=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),XN=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)"}}})),QN=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),JN=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),ZN=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),eO=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Nm=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),tO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Om=20,nO=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"})),rO=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`}})),oO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),iO=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`}})),sO=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),_m=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),$m=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),aO=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),lO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Dk=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),Rk=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"}}})),zk=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"}}})),cO=()=>K.createElement(lO,null,Array.from({length:8}).map((e,t)=>K.createElement(Dk,{key:t},K.createElement(Rk,null),K.createElement(zk,{width:`${60+t%3*15}%`})))),uO=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"})),pO=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"}),dO=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)"}}})),fO=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),Nk=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=qs({projectId:i,limit:Om,enabled:!!i}),[a,u]=Li("all"),[c,l]=Li(""),[p,f]=Li(null),[d,m]=Li(1),[w,k]=Li(null),[F,C]=Li(!1),z=zm(()=>{let h=new Set;return e.forEach(T=>{T.componentTitle&&h.add(T.componentTitle)}),Array.from(h).sort()},[e]),R=zm(()=>e.filter(h=>{if(a!=="all"&&h.componentTitle!==a)return!1;if(c){let T=c.toLowerCase();return h.name.toLowerCase().includes(T)||h.title.toLowerCase().includes(T)}return!0}),[e,a,c]),O=p?s.frames.find(h=>h.id===p):null,L=zm(()=>{if(!p)return[];let h=s.variantChildren[p]||[];return h.length===0?[]:s.variantFilters.some(T=>T.value)?h.filter(T=>T.variantProperties?s.variantFilters.every(I=>I.value?T.variantProperties?.[I.property]===I.value:!0):!1):h},[p,s.variantChildren,s.variantFilters]),B=L.slice(0,d*Om),g=L.length>d*Om;Ak(()=>{if(!p||B.length===0)return;let h=B.map(T=>T.id);s.fetchVariantThumbnails(p,h)},[p,B.length,d]),Ak(()=>{C(!1)},[]);let x=Pk(async h=>{if(n)try{let T=q(),I=localStorage.getItem("uicopilot_session_token");if(!(await ie(`${T}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:h.id,name:h.name})})).ok)throw new Error("Failed to save mapping");o(n,h.id,h.name)}catch(T){y.error("[MapStoriesTab] Error saving mapping:",T)}},[n,i,o]),b=Pk((h,T)=>{if(T.stopPropagation(),p===h){f(null),m(1);return}f(h),m(1),!s.variantThumbnails[h]&&!s.loadingVariants.has(h)&&s.toggleExpanded(h,T)},[p,s]),E=e.find(h=>h.id===n);return t?K.createElement(aO,null,"Loading stories..."):K.createElement(zN,null,K.createElement(NN,null,K.createElement(Lk,null,K.createElement(Mk,null,"Storybook Stories"),K.createElement(Gl,null,K.createElement(_N,{value:a,onChange:h=>u(h.target.value)},K.createElement("option",{value:"all"},"All Components"),z.map(h=>K.createElement("option",{key:h,value:h},h)))),K.createElement(Gl,null,K.createElement(Bk,{type:"text",placeholder:"Search stories...",value:c,onChange:h=>l(h.target.value)}))),K.createElement($N,null,R.length===0?K.createElement($m,null,"No stories found"):R.map(h=>K.createElement(UN,{key:h.id,selected:h.id===n,mapped:!!h.figmaMapping,onClick:()=>r(h.id)},K.createElement(jN,null,K.createElement(HN,null,h.name),K.createElement(WN,{mapped:!!h.figmaMapping},h.figmaMapping?"Mapped":"Unmapped")),K.createElement(VN,null,h.title),h.figmaMapping&&K.createElement(GN,{onMouseEnter:()=>k(h.id),onMouseLeave:()=>k(null)},(()=>{let T=h.figmaMapping?.figmaNodeId,I=T?s.resolveThumbnail(T):void 0;return K.createElement(K.Fragment,null,I?K.createElement(qN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}):K.createElement("span",null,"\u{1F517}"),w===h.id&&I&&K.createElement(XN,null,K.createElement(QN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}),K.createElement(JN,null,h.figmaMapping?.figmaFrameName)))})(),K.createElement(YN,null,K.createElement(KN,null,h.figmaMapping.figmaFrameName))))))),K.createElement(ON,null,n?K.createElement(K.Fragment,null,K.createElement(uO,null,K.createElement("span",null,"Click a Figma component below to link it to"," ",K.createElement("strong",null,E?.name))),K.createElement(Lk,null,K.createElement(Mk,null,"Figma Components"),K.createElement(Gl,null,K.createElement(eO,null,K.createElement(Nm,null,K.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:h=>s.setShowComponentSets(h.target.checked)}),"Component Sets"),K.createElement(Nm,null,K.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:h=>s.setShowFrames(h.target.checked)}),"Frames"),K.createElement(Nm,null,K.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:h=>s.setShowComponents(h.target.checked)}),"Components")),s.availablePages.length>1&&K.createElement(Pi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:h=>s.setFigmaPage(h.target.value)},K.createElement("option",{value:""},"All pages"),s.availablePages.map(h=>K.createElement("option",{key:h,value:h},h)))),s.availableFilters.length>0&&K.createElement(Wl,null,K.createElement(Qs,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:h,values:T})=>{let I=s.variantFilters.find(v=>v.property===h);return K.createElement(Pi,{key:h,isActive:!!I?.value,value:I?.value||"",onChange:v=>s.handleFilterChange(h,v.target.value)},K.createElement("option",{value:""},h),T.map(v=>K.createElement("option",{key:v,value:v},h,"=",v)))}),s.availableFilters.length>5&&K.createElement(Qs,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(h=>h.value)&&K.createElement(Vl,{onClick:s.clearFilters},"Clear All")),K.createElement(Gl,null,K.createElement(Bk,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:h=>s.setSearch(h.target.value)}))),K.createElement(ZN,null,F&&K.createElement(pO,null,K.createElement(dO,null),K.createElement(fO,null,"Loading thumbnails...")),s.isLoading?K.createElement(cO,null):s.filteredFrames.length===0?K.createElement($m,null,K.createElement("span",null,"No components found")):K.createElement(tO,null,p&&O?K.createElement(K.Fragment,null,K.createElement(oO,null,K.createElement(iO,{onClick:()=>{f(null),m(1)}},"Back"),K.createElement(sO,null,O.name)),s.loadingVariants.has(p)?K.createElement(K.Fragment,null,K.createElement(_m,null,"Loading ",O.childCount??"..."," variants..."),Array.from({length:Math.min(8,O.childCount??8)}).map((h,T)=>K.createElement(Dk,{key:`variant-skeleton-${T}`},K.createElement(Rk,null),K.createElement(zk,{width:`${60+T%3*15}%`})))):K.createElement(K.Fragment,null,K.createElement(_m,null,"Showing ",B.length," of ",L.length," variants"),B.map(h=>K.createElement(Rm,{key:h.id,variant:h,thumbnail:s.variantThumbnails[p]?.[h.id]||s.thumbnails[h.id],onSelect:x,loadingDone:s.variantThumbnails[p]!==void 0&&!s.loadingVariants.has(p),failed:s.variantFailed[p]?.has(h.id)})))):K.createElement(K.Fragment,null,K.createElement(_m,null,"Showing ",s.frames.length," of ",s.totalFrames," components"),s.filteredFrames.map(h=>K.createElement(Js,{key:h.id,frame:h,thumbnail:s.thumbnails[h.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[h.id],variantChildren:s.variantChildren[h.id],variantFailed:s.variantFailed[h.id],isLoadingVariants:s.loadingVariants.has(h.id),isExpanded:!1,onToggleExpand:b,onSelect:x,variantFilters:s.variantFilters}))),(p?g:s.hasMore)&&K.createElement(nO,null,K.createElement(rO,{disabled:s.loadingMore,onClick:async()=>{p?m(h=>h+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):K.createElement($m,null,K.createElement("span",null,"Select a story from the left to link it to Figma"))))};Ue();import et,{useState as Um,useMemo as Ok,useCallback as _k}from"react";import{styled as zt}from"storybook/theming";pt();var gO=zt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),mO=zt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),hO=zt(En)({width:"auto",minWidth:"200px"}),xO=zt(so)({fontSize:"13px",minWidth:"250px"}),yO=zt.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}})),bO=zt.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}})),SO=zt.div({flex:1,overflow:"auto"}),wO=zt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),vO=zt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),ql=zt.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}`})),kO=zt.tbody({}),CO=zt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),Yl=zt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),TO=zt.div({display:"flex",flexDirection:"column",gap:"2px"}),IO=zt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),FO=zt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),EO=zt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),AO=zt.div({display:"flex",alignItems:"center",gap:"8px"}),PO=zt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),LO=zt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),$k=zt.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`}})),MO=zt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),BO=zt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),Uk=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=Um("all"),[a,u]=Um(""),[c,l]=Um(!0),p=Ok(()=>{let k=new Set;return e.forEach(F=>{F.componentTitle&&k.add(F.componentTitle)}),Array.from(k).sort()},[e]),f=Ok(()=>e.filter(k=>{if(i!=="all"&&k.componentTitle!==i||!c&&!k.figmaMapping)return!1;if(a){let F=a.toLowerCase();return k.name.toLowerCase().includes(F)||k.title.toLowerCase().includes(F)||(k.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),d=_k(async k=>{try{let F=q(),C=localStorage.getItem("uicopilot_session_token");if(!(await ie(`${F}/api/mappings?projectId=${o}&storyId=${k}`,{method:"DELETE",headers:{Authorization:`Bearer ${C}`}})).ok)throw new Error("Failed to delete mapping");r(k)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),m=_k(()=>{let k=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(k,null,2)],{type:"application/json"}),C=URL.createObjectURL(F),z=document.createElement("a");z.href=C,z.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(C)},[e]);if(t)return et.createElement(BO,null,"Loading mappings...");let w=e.filter(k=>k.figmaMapping).length;return et.createElement(gO,null,et.createElement(mO,null,et.createElement(hO,{value:i,onChange:k=>s(k.target.value)},et.createElement("option",{value:"all"},"All Components"),p.map(k=>et.createElement("option",{key:k,value:k},k))),et.createElement(xO,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:k=>u(k.target.value)}),et.createElement(yO,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),et.createElement(bO,{onClick:m,disabled:w===0},"\u{1F4E5} Export JSON")),f.length===0?et.createElement(MO,null,et.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):et.createElement(SO,null,et.createElement(wO,null,et.createElement(vO,null,et.createElement("tr",null,et.createElement(ql,{style:{width:"35%"}},"Story"),et.createElement(ql,{style:{width:"35%"}},"Figma Component"),et.createElement(ql,{style:{width:"15%"}},"Status"),et.createElement(ql,{style:{width:"15%"}},"Actions"))),et.createElement(kO,null,f.map(k=>et.createElement(CO,{key:k.id,mapped:!!k.figmaMapping},et.createElement(Yl,null,et.createElement(TO,null,et.createElement(IO,null,k.name),et.createElement(FO,null,k.title))),et.createElement(Yl,null,et.createElement(EO,{mapped:!!k.figmaMapping},k.figmaMapping?et.createElement(et.Fragment,null,et.createElement("span",null,"\u{1F3A8}"),k.figmaMapping.figmaFrameName):"\u2014")),et.createElement(Yl,null,et.createElement(AO,null,et.createElement(PO,{mapped:!!k.figmaMapping}),et.createElement(LO,{mapped:!!k.figmaMapping},k.figmaMapping?"Mapped":"Unmapped"))),et.createElement(Yl,null,k.figmaMapping?et.createElement($k,{variant:"unlink",onClick:()=>d(k.id)},"Unlink"):et.createElement($k,{variant:"link",onClick:()=>n(k.id)},"Link"))))))))};import ve,{useState as ec,useMemo as Yk}from"react";import{styled as dt}from"storybook/theming";import jk from"react";import{styled as Hk,keyframes as DO}from"storybook/theming";var RO=DO`
|
|
42
42
|
0% { transform: rotate(0deg); }
|
|
43
43
|
100% { transform: rotate(360deg); }
|
|
44
|
-
`,zO=Hk.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${RO} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),NO=Hk.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}}})),Br=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>jk.createElement(NO,{variant:r,disabled:t||e,onClick:n},e&&jk.createElement(zO,null),e&&i?i:o);je();import on from"react";import{styled as Js}from"storybook/theming";var Wk=Js.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"})),OO=Js.div({display:"flex",alignItems:"center",gap:"12px"}),Kl=Js.span({whiteSpace:"nowrap"}),Vk=Js.div({display:"flex",alignItems:"center",gap:"8px"}),Xl=Js.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Ql=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*lw;return r?on.createElement(Wk,null,on.createElement(Kl,null,o.toLocaleString()," tokens"),on.createElement(Vk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2)))):on.createElement(Wk,null,on.createElement(OO,null,on.createElement(Kl,null,e.toLocaleString()," input"),on.createElement("span",null,"+"),on.createElement(Kl,null,t.toLocaleString()," output"),on.createElement("span",null,"="),on.createElement(Kl,null,on.createElement("strong",null,o.toLocaleString())," tokens")),on.createElement(Vk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2))))};import Nn from"react";import{styled as wo}from"storybook/theming";function jm(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var _O=wo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),Gk=wo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),$O=wo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),UO=wo.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})),jO=wo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),HO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),WO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),VO=wo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),qk=({data:e,color:t,compact:n})=>n?Nn.createElement(Gk,{color:t},e.summary):Nn.createElement(_O,null,Nn.createElement(Gk,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Nn.createElement($O,null,e.mappings.map((r,o)=>Nn.createElement(Nn.Fragment,{key:o},Nn.createElement(UO,null,r.from," ",Nn.createElement(jO,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Nn.createElement(HO,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Nn.createElement(Nn.Fragment,null,e.defaults.map((r,o)=>Nn.createElement(WO,{key:o},Nn.createElement(VO,null,r.choice),Nn.createElement("span",null,"\u2014 ",r.why)))));var GO=dt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),qO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),YO=dt.div({display:"flex",flexDirection:"column",gap:"4px"}),KO=dt.div({display:"flex",alignItems:"center",gap:"10px"}),XO=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"})),Kk=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})),QO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),JO=dt.div({display:"flex",gap:"8px"}),ZO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),e_=dt(so)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),t_=dt.div({display:"flex",gap:"4px"}),Jl=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}})),n_=dt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),r_=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}})),o_=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}`}})),i_=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"})),Zl=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}`})),s_=dt.img({width:"100%",height:"100%",objectFit:"contain"}),eC=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)"}}})),Xk=dt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),Qk=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"})),Hm=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"})),Cee=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"})),a_=dt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),l_=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})),c_=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}})),u_=dt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),p_=dt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),d_=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})),f_=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})),g_=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"}})),Tee=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})),Jk=({src:e,alt:t})=>{let[n,r]=ec(!1);return ke.createElement(ke.Fragment,null,!n&&ke.createElement(eC,null),ke.createElement(s_,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function Zk(e){return e>=90?"high":e>=70?"medium":"low"}function m_(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var tC=({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[f,p]=ec(()=>{let b=new Set;for(let E of e.mappings)E.confidence>=90&&b.add(E.storyId);return b}),[g,S]=ec(""),[C,F]=ec("all"),k=Yk(()=>{let b=new Map;for(let E of t)b.set(E.id,{name:E.name,title:E.title});return b},[t]),R=Yk(()=>{let b=e.mappings;if(C!=="all"&&(b=b.filter(E=>Zk(E.confidence)===C)),g.trim()){let E=g.toLowerCase();b=b.filter(h=>{let T=k.get(h.storyId);return T?.name.toLowerCase().includes(E)||T?.title.toLowerCase().includes(E)||h.componentSetName.toLowerCase().includes(E)||h.figmaFrameName.toLowerCase().includes(E)})}return b},[e.mappings,C,g,k]),z=b=>{p(E=>{let h=new Set(E);return h.has(b)?h.delete(b):h.add(b),h})},_=()=>{let b=e.mappings.filter(E=>f.has(E.storyId));n(b)},M=e.mappings.filter(b=>b.confidence>=90).length,B=e.mappings.filter(b=>b.confidence>=70&&b.confidence<90).length,m=e.mappings.filter(b=>b.confidence<70).length,x=e.usage;return ke.createElement(GO,null,ke.createElement(qO,null,ke.createElement(YO,null,ke.createElement(KO,null,ke.createElement(XO,null,"Auto-Map Results"),ke.createElement(Kk,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&ke.createElement(Kk,{variant:"danger"},e.unmatched.length," unmatched"),a&&ke.createElement(f_,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),ke.createElement(QO,null,"Review matches below. Uncheck any incorrect mappings before applying.")),ke.createElement(JO,null,a==="cache"&&o&&ke.createElement(g_,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),ke.createElement(Br,{onClick:r,variant:"ghost"},"Cancel"),ke.createElement(Br,{loading:i,onClick:_,loadingText:"Applying..."},"Apply ",f.size," Selected"))),ke.createElement(ZO,null,ke.createElement(e_,{type:"text",placeholder:"Filter stories...",value:g,onChange:b=>S(b.target.value)}),ke.createElement(t_,null,ke.createElement(Jl,{active:C==="all",onClick:()=>F("all")},"All ",e.mappings.length),M>0&&ke.createElement(Jl,{active:C==="high",onClick:()=>F("high")},"\u226590% (",M,")"),B>0&&ke.createElement(Jl,{active:C==="medium",onClick:()=>F("medium")},"70-89% (",B,")"),m>0&&ke.createElement(Jl,{active:C==="low",onClick:()=>F("low")},"<70% (",m,")"))),ke.createElement(n_,null,R.map(b=>{let E=k.get(b.storyId),h=Zk(b.confidence),T=f.has(b.storyId),I=h==="low";return ke.createElement(r_,{key:b.storyId,dimmed:I&&!T},ke.createElement(o_,{checked:T,onClick:()=>z(b.storyId)},T?"\u2713":""),(()=>{let v=c?.(b.storyId);return v?ke.createElement(Zl,null,ke.createElement(Jk,{src:v,alt:E?.name||b.storyId})):l?ke.createElement(Zl,null,ke.createElement(eC,null)):ke.createElement(i_,{bgColor:I?"#f1f5f9":"#eff6ff"},ke.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:I?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)))})(),ke.createElement(Xk,null,ke.createElement(Qk,null,E?.name||b.storyId),ke.createElement(Hm,null,E?.title||"")),ke.createElement(a_,null,"\u2192"),(()=>{let v=u?.(b.figmaNodeId),A=jm(b.reason),P=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return v?ke.createElement(Zl,{title:P},ke.createElement(Jk,{src:v,alt:b.figmaFrameName})):ke.createElement(Zl,{title:P},ke.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),ke.createElement(Xk,null,ke.createElement(Qk,null,b.componentSetName),ke.createElement(Hm,null,b.figmaFrameName),ke.createElement(qk,{data:jm(b.reason),color:m_(h)})),ke.createElement(l_,{level:h},b.confidence,"%"),d&&ke.createElement(c_,{onClick:()=>d(b.componentSetName)},"Browse"))}),e.unmatched.length>0&&ke.createElement(u_,null,ke.createElement(Hm,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),ke.createElement(p_,null,e.unmatched.map(b=>{let E=k.get(b);return ke.createElement(d_,{key:b},ke.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:b)})))),x&&a!=="cache"&&ke.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},ke.createElement(Ql,{inputTokens:x.inputTokens||0,outputTokens:x.outputTokens||0,costUsd:x.costUsd||0})))};je();De();import{useState as vo,useCallback as ko,useRef as h_}from"react";import{useStorybookApi as x_}from"storybook/manager-api";function nC({projectId:e}){let t=x_(),n=h_(null),[r,o]=vo(!1),[i,s]=vo(!1),[a,u]=vo(!1),[c,l]=vo(null),[d,f]=vo(null),[p,g]=vo(null),[S,C]=vo(""),[F,k]=vo(null),R=ko(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let h=await E.json(),T=h.entries||h.stories||{},I=Object.keys(T).filter(P=>T[P].type==="story");y.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let v=[];for(let P of I){let D=T[P],N=t.getData(P),w={...N?.initialArgs||{}},j=N?.argTypes||{};for(let[G,L]of Object.entries(j))if(!(G in w)){let K=L;if(K.defaultValue!==void 0)w[G]=K.defaultValue;else if(K.table?.defaultValue?.summary!==void 0){let ee=K.table.defaultValue.summary;ee==="false"?w[G]=!1:ee==="true"?w[G]=!0:w[G]=ee}}v.push({id:P,name:D.name||P.split("--").pop()||P,title:D.title||"",initialArgs:w,argTypes:j})}let A=v.filter(P=>Object.keys(P.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${v.length} stories, ${A.length} with args`),v},[t]),z=ko(async()=>{if(!e)return!1;try{let E=q(),h=localStorage.getItem("uicopilot_session_token");if(!h)return!1;let T=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${h}`}});if(!T.ok)return!1;let I=await T.json();return I.hasSuggestions&&I.mappings?.length>0?(f(I),k("cache"),C(`Loaded ${I.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${I.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),_=ko(async E=>{o(!0),C("Collecting story information...");let h;try{if(h=await R(),E?.length&&(h=h.filter(I=>!E.includes(I.id)),y.debug(`[useAutoMap] After excluding mapped: ${h.length} stories`)),h.length===0){l("No unmapped stories found"),o(!1);return}g(h)}catch(I){l(I instanceof Error?I.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),C(`Analyzing ${h.length} stories against Figma components...`);let T=new AbortController;n.current=T;try{let I=q(),v=localStorage.getItem("uicopilot_session_token");if(!v)throw new Error("Not authenticated");let A=await fetch(`${I}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:e,stories:h.map(D=>({id:D.id,name:D.name,title:D.title,initialArgs:D.initialArgs,argTypes:D.argTypes}))}),signal:T.signal});if(!A.ok){let D=await A.json();throw new Error(D.error||"Auto-map failed")}let P=await A.json();f(P),k("llm"),C(`Found ${P.stats.matched} matches (${P.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${P.stats.matched}/${P.stats.total} matched, ${P.unmatched.length} unmatched`)}catch(I){if(I instanceof DOMException&&I.name==="AbortError"){C("Cancelled");return}l(I instanceof Error?I.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,R]),M=ko(async E=>{if(!e)return;if(l(null),f(null),k(null),o(!0),C("Checking for existing suggestions..."),await z()){o(!1);return}await _(E)},[e,z,_]),B=ko(async E=>{e&&(l(null),f(null),k(null),await _(E))},[e,_]),m=ko(async E=>{if(!(!e||E.length===0)){u(!0),C(`Applying ${E.length} mappings...`);try{let h=q(),T=localStorage.getItem("uicopilot_session_token");if(!T)throw new Error("Not authenticated");let I=0;for(let v of E)try{(await fetch(`${h}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:e,storyId:v.storyId,figmaNodeId:v.figmaNodeId,name:v.figmaFrameName||v.componentSetName})})).ok?I++:y.warn(`[useAutoMap] Failed to apply mapping for ${v.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${v.storyId}:`,A)}C(`Applied ${I}/${E.length} mappings`),y.debug(`[useAutoMap] Applied ${I}/${E.length} mappings`)}catch(h){l(h instanceof Error?h.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),x=ko(()=>{n.current?.abort()},[]),b=ko(()=>{f(null),g(null),l(null),C(""),k(null)},[]);return{collectAndMap:M,rerun:B,loadExisting:z,applyMappings:m,cancel:x,reset:b,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:S,source:F}}De();import{useState as Wm,useEffect as y_,useRef as rC}from"react";var oC=2;async function b_(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 iC(e){let[t,n]=Wm({}),[r,o]=Wm(0),[i,s]=Wm(!1),a=rC(null),u=rC(""),c=e.join(",");return y_(()=>{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+=oC){let g=e.slice(p,p+oC),S=await Promise.all(g.map(F=>b_(F,l.signal).then(k=>({id:F,img:k}))));if(l.signal.aborted)break;let C={};for(let{id:F,img:k}of S)d++,k&&(C[F]=k);Object.keys(C).length>0&&n(F=>({...F,...C})),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 be,{useState as sC,useEffect as tc,useMemo as S_}from"react";De();var Mi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=Gs({projectId:r||"",enabled:e&&!!r}),d=be.useRef(!1);tc(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[f,p]=sC(new Set),[g,S]=sC(i||o[0]?.id||"");tc(()=>{i&&S(i)},[i]),tc(()=>{l.expandedSets.forEach(B=>{let m=l.variantChildren[B];if(!m||m.length===0)return;let x=m;l.variantFilters.some(E=>E.value)&&(x=m.filter(E=>E.variantProperties?l.variantFilters.every(h=>h.value?E.variantProperties?.[h.property]===h.value:!0):!1));let b=x.slice(0,20).map(E=>E.id);b.length>0&&l.fetchVariantThumbnails(B,b)})},[l.expandedSets,l.variantChildren,l.variantFilters]),tc(()=>{p(new Set)},[g]);let C=S_(()=>{let B=[];return l.filteredFrames.forEach(m=>{if(m.type==="COMPONENT_SET"&&m.children){let x=l.variantFilters.some(b=>b.value)?m.children.filter(b=>b.variantProperties?l.variantFilters.every(E=>E.value?b.variantProperties?.[E.property]===E.value:!0):!1):m.children;B.push(...x)}else B.push(m)}),B},[l.filteredFrames,l.variantFilters]),F=B=>{if(a)p(m=>{let x=new Set(m);return x.has(B.id)?x.delete(B.id):x.add(B.id),x});else{let m=l.resolveThumbnail(B.id);try{n({...B,thumbnail:m})}catch(x){y.error("[ComponentBrowserModal] onSelect threw error:",x)}t()}},k=()=>{let B=C.map(x=>x.id),m=B.every(x=>f.has(x));p(m?new Set:new Set(B))},R=()=>{if(u&&f.size>0){let B=C.filter(m=>f.has(m.id)).map(m=>({...m,thumbnail:l.resolveThumbnail(m.id)}));u(B),p(new Set)}},z=B=>{S(B),s?.(B)},_=B=>{B.target===B.currentTarget&&t()},M=o.find(B=>B.id===g);return e?be.createElement(Hv,{onClick:_},be.createElement(Wv,null,be.createElement(Vv,null,be.createElement(Gv,null,"Link Figma Frames"),be.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},be.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"),be.createElement(qv,{onClick:t},"\xD7"))),be.createElement(Yv,null,l.error&&be.createElement(tk,null,l.error),!l.error&&be.createElement(be.Fragment,null,o.length>0&&be.createElement(dk,null,be.createElement(fk,null,"Story:"),be.createElement(gk,{value:g,onChange:B=>z(B.target.value)},o.map(B=>be.createElement("option",{key:B.id,value:B.id},B.name,B.mappingsCount?` (${B.mappingsCount} linked)`:""))),M?.mappingsCount?be.createElement(mk,{hasMapping:!0},M.mappingsCount," frames linked"):null),be.createElement(Zv,null,be.createElement(jl,null,be.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:B=>l.setShowComponentSets(B.target.checked)}),"Component Sets"),be.createElement(jl,null,be.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:B=>l.setShowFrames(B.target.checked)}),"Frames"),be.createElement(jl,null,be.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:B=>l.setShowComponents(B.target.checked)}),"Components"),l.availablePages.length>1&&be.createElement(Pi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:B=>l.setFigmaPage(B.target.value),style:{marginLeft:"auto"}},be.createElement("option",{value:""},"All pages"),l.availablePages.map(B=>be.createElement("option",{key:B,value:B},B)))),l.filterSuggestion&&be.createElement(hk,null,be.createElement(xk,null,"AI suggests:"),be.createElement(yk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([B,m])=>`${B}=${m}`).join(", ")),be.createElement(bk,{onClick:l.applySuggestedFilters},"Apply"),be.createElement(Sk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&be.createElement(wk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&be.createElement(Wl,null,be.createElement(Xs,null,"Filters:"),l.availableFilters.map(({property:B,values:m})=>{let x=l.variantFilters.find(b=>b.property===B);return be.createElement(Pi,{key:B,isActive:!!x?.value,value:x?.value||"",onChange:b=>l.handleFilterChange(B,b.target.value)},be.createElement("option",{value:""},B),m.map(b=>be.createElement("option",{key:b,value:b},B,"=",b)))}),l.variantFilters.some(B=>B.value)&&be.createElement(Vl,{onClick:l.clearFilters},"Clear All")),be.createElement(Kv,{type:"text",placeholder:"Search frames...",value:l.search,onChange:B=>l.setSearch(B.target.value),autoFocus:!0}),a&&C.length>0&&be.createElement(vk,null,be.createElement(kk,{onClick:k},f.size===C.length?"Deselect All":"Select All Visible"),be.createElement(Ck,null,f.size>0?`${f.size} selected of `:"Showing ",C.length," frames")),l.isLoading&&be.createElement(Cm,null,Array.from({length:6}).map((B,m)=>be.createElement(pk,{key:m},be.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},be.createElement(Hl,{width:"100%",height:"100%"})),be.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},be.createElement(Hl,{width:"80%",height:"16px"}),be.createElement(Hl,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&be.createElement(ek,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&be.createElement(Cm,null,l.filteredFrames.map(B=>be.createElement(Qs,{key:B.id,frame:B,thumbnail:l.thumbnails[B.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[B.id],variantChildren:l.variantChildren[B.id],isLoadingVariants:l.loadingVariants.has(B.id),isExpanded:l.expandedSets.has(B.id),isNew:l.recentlyAdded.has(B.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&be.createElement(Tk,null,be.createElement(Ik,{disabled:f.size===0,onClick:R},"Link ",f.size," Selected")))):null};ve();pt();var v_=Jt.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}),k_=Jt.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"})),C_=Jt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),T_=Jt.div({display:"flex",alignItems:"center",gap:"20px"}),I_=Jt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),F_=Jt.div({display:"flex",gap:"4px"}),aC=Jt(io)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),E_=Jt(wn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),A_=Jt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),P_=Jt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),L_=Jt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),M_=Jt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),B_=Jt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),D_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),R_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),z_=Jt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),N_=Jt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),O_=Jt.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"}})),lC=Jt.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"}})),cC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Bi("map"),[i,s]=Bi([]),[a,u]=Bi(!0),[c,l]=Bi(null),[d,f]=Bi(!1),[p,g]=Bi(null),S=nC({projectId:n}),{refreshMappings:C}=rt(),{featureFlags:F}=ie(),k=Je.useMemo(()=>S.results?.mappings.map(v=>v.storyId)||[],[S.results]),R=iC(k),z=Co(async()=>{u(!0);try{let v=await fetch("/index.json");if(!v.ok)throw new Error("Failed to fetch index.json");let A=await v.json(),P=A.entries||A.stories||{},D=Object.entries(P).filter(([,w])=>w.type==="story").map(([w,j])=>({id:w,name:j.name||w.split("--").pop()||w,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let w=q(),j=localStorage.getItem("uicopilot_session_token"),G=await oe(`${w}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(G.ok){let L=await G.json(),K=new Map((L.mappings||[]).map(ee=>[ee.storyId,ee]));D.forEach(ee=>{let re=K.get(ee.id);re&&re.figmaNodeId&&(ee.figmaMapping={figmaNodeId:re.figmaNodeId,figmaFrameName:re.name||re.figmaFrameName||""})})}}catch(w){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",w)}s(D);let N=D.find(w=>!w.figmaMapping);N?l(N.id):D.length>0&&l(D[0].id)}catch(v){console.error("[StoryMappingAssistant] Error fetching stories:",v)}finally{u(!1)}},[n]);w_(()=>{e&&z()},[e,z]);let _=Co((v,A,P)=>{s(w=>w.map(j=>j.id===v?{...j,figmaMapping:{figmaNodeId:A,figmaFrameName:P}}:j));let D=i.findIndex(w=>w.id===v),N=i.find((w,j)=>j>D&&!w.figmaMapping);N&&l(N.id)},[i]),M=Co(v=>{s(A=>A.map(P=>P.id===v?{...P,figmaMapping:null}:P))},[]),B=Co(v=>{l(v),o("map")},[]),m=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);S.collectAndMap(v)},[i,S]),x=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);f(!1),S.rerun(v)},[i,S]),b=Co(async v=>{await S.applyMappings(v),f(!1),S.reset(),z(),C()},[S,z,C]),E=Co(()=>{f(!1),S.reset()},[S]);Je.useEffect(()=>{S.results&&f(!0)},[S.results]);let h=v=>{v.target===v.currentTarget&&t()};if(!e)return null;let T=i.filter(v=>v.figmaMapping).length,I=i.length;return Je.createElement(Je.Fragment,null,Je.createElement(v_,{onClick:h},Je.createElement(k_,{onClick:v=>v.stopPropagation()},Je.createElement(C_,null,Je.createElement(T_,null,Je.createElement(I_,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(F_,null,Je.createElement(aC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(aC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Je.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!d&&!S.isCollecting&&!S.isMapping&&Je.createElement(O_,{onClick:m,disabled:a||i.length===0},Je.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},Je.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),Je.createElement("path",{d:"M2 17l10 5 10-5"}),Je.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),Je.createElement(E_,{onClick:t},"\xD7"))),Je.createElement(A_,null,(S.isCollecting||S.isMapping)&&Je.createElement(M_,null,Je.createElement(B_,null,Je.createElement(z_,null,Je.createElement(N_,null)),Je.createElement(D_,null,"Auto-mapping stories to Figma"),Je.createElement(R_,null,S.progress),Je.createElement(Br,{onClick:S.cancel,variant:"ghost"},"Cancel"))),d&&S.results&&Je.createElement(tC,{results:S.results,stories:i,onApply:b,onCancel:E,onRerun:x,isApplying:S.isApplying,isRerunning:S.isCollecting||S.isMapping,source:S.source,resolveThumbnail:v=>S.results?.thumbnailUrls?.[v],resolveStoryScreenshot:v=>R.screenshots[v],isCapturingScreenshots:R.isCapturing,onBrowse:v=>g(v)}),!d&&!S.isCollecting&&!S.isMapping&&(r==="map"?Je.createElement(Nk,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:_,projectId:n}):Je.createElement(Uk,{stories:i,loading:a,onLink:B,onUnlink:M,projectId:n}))),Je.createElement(P_,null,Je.createElement(L_,null,Je.createElement("span",null,"Total: ",I," stories"),Je.createElement(lC,{type:"mapped"},Je.createElement("span",{className:"dot"}),T," mapped"),Je.createElement(lC,{type:"unmapped"},Je.createElement("span",{className:"dot"}),I-T," unmapped"))))),Je.createElement(Mi,{isOpen:!!p,onClose:()=>g(null),onSelect:()=>g(null),projectId:n,initialSearch:p||void 0}))};import Xr,{useEffect as __,useCallback as $_}from"react";import{styled as qo,keyframes as uC}from"storybook/theming";var U_=uC({from:{opacity:0},to:{opacity:1}}),j_=uC({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),H_=qo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${U_} 150ms ease-out`}),W_=qo.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:`${j_} 150ms ease-out`})),V_=qo.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),G_=qo.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})),q_=qo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),Y_=qo.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}})),K_=qo.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":{opacity:.9}})),Di=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",onConfirm:s,onCancel:a})=>{let u=$_(c=>{c.key==="Escape"&&a()},[a]);return __(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?Xr.createElement(Xr.Fragment,null,Xr.createElement(H_,{onClick:a}),Xr.createElement(W_,{role:"dialog","aria-modal":"true","aria-label":t},Xr.createElement(V_,null,t),Xr.createElement(G_,null,n),Xr.createElement(q_,null,Xr.createElement(Y_,{onClick:a},o),Xr.createElement(K_,{variant:i,onClick:s},r)))):null};pt();var pC=Yn.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_=Yn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),J_=Yn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),Z_=Yn.div({display:"flex",alignItems:"center",gap:"8px"}),e$=Yn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),t$=Yn.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"})),n$=Yn.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"})),r$=Yn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),o$=Yn(Zc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),i$=Yn(Zc)(({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)"}})),s$=Yn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),a$=Yn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),l$=Yn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),dC=()=>{let[e,t]=nc(!1),[n,r]=nc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Ze(),{sessionToken:i}=we();X_(()=>{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 M=await _.json(),B=M.entries||M.stories||{},m=Object.keys(B).filter(T=>B[T].type==="story").length,x=Object.keys(B).filter(T=>B[T].type==="story"),b=q(),E=await oe(`${b}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),h=0;if(E.ok){let T=await E.json(),I=T.mappings||T||[];if(Array.isArray(I)){let v=new Set(I.map(A=>A.storyId).filter(Boolean));h=x.filter(A=>v.has(A)).length}else{let v=await oe(`${b}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(v.ok){let A=await v.json();h=Math.min(A.mappedStoriesCount||0,m)}}}r({totalStories:m,mappedStories:h,loading:!1})}catch(_){console.error("[FigmaMappingsSection] Error fetching stats:",_),r(M=>({...M,loading:!1}))}},[a,u]=nc(!1),[c,l]=nc(!1),d=async()=>{!o||!i||l(!0)},f=async()=>{l(!1),u(!0);try{let _=q(),M=await oe(`${_}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!M.ok)throw new Error("Failed to fetch mappings");let m=(await M.json()).mappings||[];await Promise.all(m.map(x=>oe(`${_}/api/mappings?id=${encodeURIComponent(x.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(_){console.error("[FigmaMappingsSection] Unlink all failed:",_)}finally{u(!1)}},p=()=>t(!0),g=()=>{t(!1),o&&i&&s()};if(!o)return kt.createElement(pC,null,kt.createElement(s$,null,"Select a project to link Figma designs"));let{totalStories:S,loading:C}=n,F=Math.min(n.mappedStories,S),k=F===0?"none":F>=S?"complete":"partial",R=S>0?Math.min(100,Math.round(F/S*100)):0,z=k==="none"?"Link designs":"Manage";return kt.createElement(kt.Fragment,null,kt.createElement(pC,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(J_,null,kt.createElement(r$,null,"Figma Mappings"),kt.createElement(Z_,null,C?kt.createElement(kt.Fragment,null,kt.createElement(a$,null),kt.createElement(l$,null,"Loading...")):kt.createElement(kt.Fragment,null,kt.createElement(e$,null,kt.createElement(t$,{percent:R,state:k})),kt.createElement(n$,{state:k},`${F}/${S}`)))),F>0&&kt.createElement(i$,{onClick:d,disabled:C||a},a?"Unlinking...":"Unlink All"),kt.createElement(o$,{onClick:p,disabled:C},z)),e&&kt.createElement(cC,{isOpen:e,onClose:g,projectId:o}),kt.createElement(Di,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:f,onCancel:()=>l(!1)}))};import ce,{useState as Zs,useEffect as Vm,useCallback as c$}from"react";import{styled as Kn}from"storybook/theming";ve();je();pt();var Gm=Kn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),qm=Kn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Ym=Kn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Ete=Kn(Er)({padding:"5px 12px",fontSize:"12px"}),Km=Kn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),rc=Kn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),u$=Kn.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})),p$=Kn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Xm=Kn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),d$=Kn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),oc=Kn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),ic=Kn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Yo=Kn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),fC=new Set,gC=()=>{let{userRole:e,featureFlags:t}=ie(),[n,r]=Zs(null),[o,i]=Zs(!0),[s,a]=Zs(!1),[u,c]=Zs(!1),[l,d]=Zs(!1),{selectedProjectId:f,projects:p}=Ze(),{sessionToken:g}=we(),S=c$(async()=>{if(!(!f||!g))try{let M=q(),B=await oe(`${M}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${g}`}});if(B.ok){let m=await B.json();r(m)}}catch(M){console.error("[FigmaCacheSection] Error:",M)}finally{i(!1)}},[f,g]);Vm(()=>{S()},[S]),Vm(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||fC.has(f))return;let M=p.find(m=>m.id===f);(M?.figmaFileUrl||M?.figmaFileId)&&(fC.add(f),C())},[o,s,n?.structureStatus,f,p]),Vm(()=>{let M=n?.thumbnailProgress?.status,B=n?.enrichmentProgress?.status,m=n?.thumbnailProgress?.cached??0,x=n?.thumbnailProgress?.total??0,b=M==="in-progress"||M==="pending"||x>0&&m<x,E=B==="in-progress"||B==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(b||E||h)||!n||n.structureStatus==="none")return;let I=setInterval(()=>{S()},3e3);return()=>{clearInterval(I)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,S]);let C=async()=>{if(!(!f||!g)){a(!0);try{let M=q();await oe(`${M}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${g}`}},6e4),await new Promise(B=>setTimeout(B,1e3)),await S(),setTimeout(async()=>{await S()},3e3)}catch(M){console.error("[FigmaCacheSection] Reload error:",M)}finally{a(!1)}}},F=async()=>{if(!(!f||!g)){c(!0);try{let M=q(),B=await oe(`${M}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})});console.log("[FigmaCacheSection] Cache invalidate response:",B.status),await oe(`${M}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(M){console.error("[FigmaCacheSection] Clear cache error:",M)}finally{c(!1)}}},k=async()=>{if(!(!f||!g)){d(!0);try{let M=q();await oe(`${M}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})});let B=setInterval(async()=>{await S()},3e3),m=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(clearInterval(B),clearInterval(m),d(!1),S())},3e3);setTimeout(()=>{clearInterval(B),clearInterval(m),d(!1)},6e5)}catch(M){console.error("[FigmaCacheSection] Enrich error:",M),d(!1)}}};if(!f)return null;if(o)return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache")),ce.createElement(Km,null,ce.createElement(rc,null,"Loading cache status\u2026")),ce.createElement(oc,null,ce.createElement(ic,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache"),ce.createElement(Br,{loading:s,onClick:C,loadingText:"Loading..."},"\u21BB Load")),s?ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):ce.createElement(Km,null,ce.createElement(rc,null,"No cache \u2014 click Load to fetch from Figma")));let R=M=>{let B=Date.now()-new Date(M).getTime(),m=Math.floor(B/6e4);if(m<1)return"just now";if(m<60)return`${m}m ago`;let x=Math.floor(m/60);return x<24?`${x}h ago`:`${Math.floor(x/24)}d ago`},z=n.cacheDiff,_=z&&(z.added.length>0||z.removed.length>0||z.renamed.length>0);return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache"," ",ce.createElement(u$,{status:n.structureStatus},n.structureStatus)),ce.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&ce.createElement(Br,{loading:l,onClick:k,loadingText:"Enriching..."},"Enrich"),ce.createElement(Br,{loading:u,onClick:F,variant:"ghost",loadingText:"Clearing..."},"Clear"),ce.createElement(Br,{loading:s,onClick:C,loadingText:"Reloading..."},"\u21BB Reload"))),s&&ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma...")),ce.createElement(Km,null,ce.createElement(rc,null,ce.createElement("strong",null,n.componentSetCount)," component sets"),ce.createElement(rc,null,ce.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&ce.createElement(d$,null,"Updated ",R(n.structureCachedAt))),_&&ce.createElement(p$,null,"Since last reload:"," ",z.added.length>0&&ce.createElement(Xm,{type:"added"},"+",z.added.length," added"),z.added.length>0&&z.removed.length>0&&" \xB7 ",z.removed.length>0&&ce.createElement(Xm,{type:"removed"},"\u2212",z.removed.length," removed"),(z.added.length>0||z.removed.length>0)&&z.renamed.length>0&&" \xB7 ",z.renamed.length>0&&ce.createElement(Xm,{type:"renamed"},z.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Caching component set thumbnails to CDN...",n.thumbnailProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.thumbnailProgress.currentName)),ce.createElement("span",null,n.thumbnailProgress.cached," / ",n.thumbnailProgress.total))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: ",n.thumbnailProgress.cached," / ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending")&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: not pre-cached")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Enriching components with AI...",n.enrichmentProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.enrichmentProgress.currentName)),ce.createElement("span",null,n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&ce.createElement(ce.Fragment,null,ce.createElement(Yo,null,ce.createElement("span",null,"AI enrichment: ",n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&ce.createElement("div",{style:{marginTop:"6px"}},ce.createElement(Ql,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import ht,{useState as Ri}from"react";import{styled as Dr}from"storybook/theming";ve();je();pt();var Qm=Dr.div({padding:"12px 16px"}),f$=Dr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),mC=Dr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),hC=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:le,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),g$=Dr.div({display:"flex",gap:"8px",alignItems:"center"}),m$=Dr.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:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),xC=Dr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),h$=Dr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:le,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),x$=Dr.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})),y$=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),yC=({onConnected:e})=>{let{sessionToken:t}=we(),[n,r]=Ri(!1),[o,i]=Ri(""),[s,a]=Ri(!1),[u,c]=Ri(null),[l,d]=Ri(null),[f,p]=Ri(!1),g=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let S=q(),C=await oe(`${S}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),F=await C.json();if(!C.ok){c({type:"error",message:F.error||"Failed to save token"});return}d(F.figmaUser?.handle||F.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${F.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?ht.createElement(Qm,null,ht.createElement(mC,null,"Figma Personal Access Token"),ht.createElement(x$,null,ht.createElement("span",null,"\u2713 Connected as ",ht.createElement("strong",null,l)),ht.createElement(y$,{onClick:()=>{d(null),c(null)}},"Change token"))):n?ht.createElement(Qm,null,ht.createElement(f$,null,ht.createElement(mC,null,"Figma Personal Access Token"),ht.createElement(hC,{onClick:()=>p(!f)},f?"Hide instructions":"How to generate")),f&&ht.createElement(h$,null,ht.createElement("ol",null,ht.createElement("li",null,"Open ",ht.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),ht.createElement("li",null,"Click the ",ht.createElement("strong",null,"Security")," tab"),ht.createElement("li",null,"Scroll to ",ht.createElement("strong",null,"Personal access tokens")),ht.createElement("li",null,"Click ",ht.createElement("strong",null,"Generate new token")),ht.createElement("li",null,"Enable ",ht.createElement("strong",null,"File content: Read only")," under Scopes"),ht.createElement("li",null,"Copy the token and paste it below"))),ht.createElement(g$,null,ht.createElement(m$,{type:"password",value:o,onChange:S=>i(S.target.value),placeholder:"figd_...",onKeyDown:S=>{S.key==="Enter"&&o.trim()&&g()}}),ht.createElement(en,{onClick:g,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&ht.createElement(xC,{variant:u.type},u.message),ht.createElement(xC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):ht.createElement(Qm,null,ht.createElement(hC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};ve();je();pt();var S$=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"})),Zm=vr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),w$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),v$=vr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),k$=vr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),eh=vr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),C$=vr.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"})),T$=vr.div({display:"flex",alignItems:"center",gap:"8px"}),I$=vr(er)(({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"})),F$=vr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Yte=vr.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"}}),E$=vr.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}})),SC=({hideHeader:e=!1})=>{let{sessionToken:t}=we(),[n,r]=Jm(!1),[o,i]=Jm(null),[s,a]=Jm(!1);b$(()=>{if(!t)return;let d=q();oe(`${d}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(f=>f.json()).then(f=>i(!!f.connected)).catch(()=>i(!1))},[t]);let u=bC(()=>{let f=`${q()}/addon/auth`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100")},[]),c=bC(async()=>{try{r(!0);let d=q(),f=await oe(`${d}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});(f.ok||f.status===404)&&i(!1)}catch{}finally{r(!1)}},[t]),l=e?null:bt.createElement(w$,null,bt.createElement(v$,null,S$),bt.createElement(k$,null,"Figma Integration"));return o===null?bt.createElement(Zm,null,l,bt.createElement(eh,null,bt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?bt.createElement(Zm,null,l,bt.createElement(eh,null,bt.createElement(F$,null,bt.createElement(en,{onClick:u,style:{width:"100%"}},"Connect with Figma"),bt.createElement(E$,null,"or"),bt.createElement(yC,{onConnected:()=>i(!0)})))):bt.createElement(Zm,null,l,bt.createElement(C$,null,bt.createElement(T$,null,bt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),bt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),bt.createElement(I$,{onClick:()=>a(!0),disabled:n},n?"Disconnecting...":"Disconnect")),bt.createElement(Di,{isOpen:s,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:()=>{a(!1),c()},onCancel:()=>a(!1)}),bt.createElement(eh,null,bt.createElement(jv,null),bt.createElement(dC,null),bt.createElement(gC,null)))};ve();var A$=cr.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"}),P$=cr.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"})),L$=cr.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})),M$=cr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),B$=cr(wn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),D$=cr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),wC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),vC=cr.div({display:"flex",alignItems:"center",gap:"10px"}),kC=cr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),R$=cr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:le,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),z$=cr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),CC=cr.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"}})),TC=({onClose:e})=>{let{isConnected:t}=we(),{selectedProjectId:n}=Ze();return Et.createElement(A$,{onClick:e},Et.createElement(P$,{onClick:r=>r.stopPropagation()},Et.createElement(L$,null,Et.createElement(M$,null,"Settings"),Et.createElement(B$,{onClick:e,title:"Close settings"},"\xD7")),Et.createElement(D$,null,Et.createElement(wC,null,Et.createElement(vC,null,Et.createElement(R$,null,"UI"),Et.createElement(kC,null,"UI Copilot")),Et.createElement(CC,null,Et.createElement(Nv,null),t&&Et.createElement(_v,null))),t&&n&&Et.createElement(wC,null,Et.createElement(vC,null,Et.createElement(z$,null,Et.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Et.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"}),Et.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"}),Et.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Et.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"}),Et.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"}))),Et.createElement(kC,null,"Figma Integration")),Et.createElement(CC,null,Et.createElement(SC,{hideHeader:!0}))))))};import ft,{useEffect as RC,useMemo as p4,useState as d4,useRef as f4}from"react";import{styled as Cn,keyframes as g4}from"storybook/theming";ve();ve();import Kt,{useState as N$}from"react";import{styled as On}from"storybook/theming";var Qr=[{id:"claude-sonnet-4-5-20250929",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 O$=On.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),_$=On.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),$$=On.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"}}),U$=On.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}})),j$=On.div({position:"relative",display:"inline-block"}),H$=On.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}})),W$=On.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"})),th=On.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),nh=On.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),V$=On.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}})),G$=On.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),q$=On.div({flex:1,minWidth:0}),Y$=On.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),K$=On.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),X$=5,IC=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ie(),[r,o]=N$(!1),i=Qr.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=Qr.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=Qr.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=Qr.filter(p=>e.includes(p.id)),c=e.length<X$,l=(p,g)=>{g.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let g=e.includes(p);g&&e.length===1||!g&&!c||n||(t(p),o(!1))},f=p=>{let g=e.includes(p.id),S=g&&e.length===1,C=n||S||!g&&!c;return Kt.createElement(V$,{key:p.id,disabled:C,onClick:()=>d(p.id)},Kt.createElement(G$,{type:"checkbox",checked:g,disabled:C,onChange:()=>{},onClick:F=>F.stopPropagation()}),Kt.createElement(q$,null,Kt.createElement(Y$,null,p.name),p.description&&Kt.createElement(K$,null,p.description)))};return Kt.createElement(O$,null,Kt.createElement(j$,null,Kt.createElement(H$,{disabled:n,isOpen:r,onClick:()=>o(!r)},Kt.createElement("span",null,"Select model"),Kt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Kt.createElement(W$,null,Kt.createElement(th,null,Kt.createElement(nh,null,"Anthropic"),i.map(f)),Kt.createElement(th,null,Kt.createElement(nh,null,"OpenAI"),s.map(f)),Kt.createElement(th,null,Kt.createElement(nh,null,"Google"),a.map(f)))),Kt.createElement(_$,null,u.map(p=>Kt.createElement($$,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Kt.createElement(U$,{disabled:n,onClick:g=>l(p.id,g),title:"Remove model"},"\xD7")))))};import Ce,{useState as Q$,useEffect as J$}from"react";import{styled as jt,keyframes as Ni}from"storybook/theming";ve();var Z$=Ni`
|
|
44
|
+
`,zO=Hk.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${RO} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),NO=Hk.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}}})),Br=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>jk.createElement(NO,{variant:r,disabled:t||e,onClick:n},e&&jk.createElement(zO,null),e&&i?i:o);Ue();import on from"react";import{styled as Zs}from"storybook/theming";var Wk=Zs.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"})),OO=Zs.div({display:"flex",alignItems:"center",gap:"12px"}),Kl=Zs.span({whiteSpace:"nowrap"}),Vk=Zs.div({display:"flex",alignItems:"center",gap:"8px"}),Xl=Zs.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Ql=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*lw;return r?on.createElement(Wk,null,on.createElement(Kl,null,o.toLocaleString()," tokens"),on.createElement(Vk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2)))):on.createElement(Wk,null,on.createElement(OO,null,on.createElement(Kl,null,e.toLocaleString()," input"),on.createElement("span",null,"+"),on.createElement(Kl,null,t.toLocaleString()," output"),on.createElement("span",null,"="),on.createElement(Kl,null,on.createElement("strong",null,o.toLocaleString())," tokens")),on.createElement(Vk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2))))};import Nn from"react";import{styled as wo}from"storybook/theming";function jm(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var _O=wo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),Gk=wo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),$O=wo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),UO=wo.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})),jO=wo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),HO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),WO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),VO=wo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),qk=({data:e,color:t,compact:n})=>n?Nn.createElement(Gk,{color:t},e.summary):Nn.createElement(_O,null,Nn.createElement(Gk,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Nn.createElement($O,null,e.mappings.map((r,o)=>Nn.createElement(Nn.Fragment,{key:o},Nn.createElement(UO,null,r.from," ",Nn.createElement(jO,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Nn.createElement(HO,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Nn.createElement(Nn.Fragment,null,e.defaults.map((r,o)=>Nn.createElement(WO,{key:o},Nn.createElement(VO,null,r.choice),Nn.createElement("span",null,"\u2014 ",r.why)))));var GO=dt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),qO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),YO=dt.div({display:"flex",flexDirection:"column",gap:"4px"}),KO=dt.div({display:"flex",alignItems:"center",gap:"10px"}),XO=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"})),Kk=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})),QO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),JO=dt.div({display:"flex",gap:"8px"}),ZO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),e_=dt(so)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),t_=dt.div({display:"flex",gap:"4px"}),Jl=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}})),n_=dt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),r_=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}})),o_=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}`}})),i_=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"})),Zl=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}`})),s_=dt.img({width:"100%",height:"100%",objectFit:"contain"}),eC=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)"}}})),Xk=dt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),Qk=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"})),Hm=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"})),Cee=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"})),a_=dt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),l_=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})),c_=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}})),u_=dt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),p_=dt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),d_=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})),f_=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})),g_=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"}})),Tee=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})),Jk=({src:e,alt:t})=>{let[n,r]=ec(!1);return ve.createElement(ve.Fragment,null,!n&&ve.createElement(eC,null),ve.createElement(s_,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function Zk(e){return e>=90?"high":e>=70?"medium":"low"}function m_(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var tC=({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[f,d]=ec(()=>{let b=new Set;for(let E of e.mappings)E.confidence>=90&&b.add(E.storyId);return b}),[m,w]=ec(""),[k,F]=ec("all"),C=Yk(()=>{let b=new Map;for(let E of t)b.set(E.id,{name:E.name,title:E.title});return b},[t]),z=Yk(()=>{let b=e.mappings;if(k!=="all"&&(b=b.filter(E=>Zk(E.confidence)===k)),m.trim()){let E=m.toLowerCase();b=b.filter(h=>{let T=C.get(h.storyId);return T?.name.toLowerCase().includes(E)||T?.title.toLowerCase().includes(E)||h.componentSetName.toLowerCase().includes(E)||h.figmaFrameName.toLowerCase().includes(E)})}return b},[e.mappings,k,m,C]),R=b=>{d(E=>{let h=new Set(E);return h.has(b)?h.delete(b):h.add(b),h})},O=()=>{let b=e.mappings.filter(E=>f.has(E.storyId));n(b)},L=e.mappings.filter(b=>b.confidence>=90).length,B=e.mappings.filter(b=>b.confidence>=70&&b.confidence<90).length,g=e.mappings.filter(b=>b.confidence<70).length,x=e.usage;return ve.createElement(GO,null,ve.createElement(qO,null,ve.createElement(YO,null,ve.createElement(KO,null,ve.createElement(XO,null,"Auto-Map Results"),ve.createElement(Kk,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&ve.createElement(Kk,{variant:"danger"},e.unmatched.length," unmatched"),a&&ve.createElement(f_,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),ve.createElement(QO,null,"Review matches below. Uncheck any incorrect mappings before applying.")),ve.createElement(JO,null,a==="cache"&&o&&ve.createElement(g_,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),ve.createElement(Br,{onClick:r,variant:"ghost"},"Cancel"),ve.createElement(Br,{loading:i,onClick:O,loadingText:"Applying..."},"Apply ",f.size," Selected"))),ve.createElement(ZO,null,ve.createElement(e_,{type:"text",placeholder:"Filter stories...",value:m,onChange:b=>w(b.target.value)}),ve.createElement(t_,null,ve.createElement(Jl,{active:k==="all",onClick:()=>F("all")},"All ",e.mappings.length),L>0&&ve.createElement(Jl,{active:k==="high",onClick:()=>F("high")},"\u226590% (",L,")"),B>0&&ve.createElement(Jl,{active:k==="medium",onClick:()=>F("medium")},"70-89% (",B,")"),g>0&&ve.createElement(Jl,{active:k==="low",onClick:()=>F("low")},"<70% (",g,")"))),ve.createElement(n_,null,z.map(b=>{let E=C.get(b.storyId),h=Zk(b.confidence),T=f.has(b.storyId),I=h==="low";return ve.createElement(r_,{key:b.storyId,dimmed:I&&!T},ve.createElement(o_,{checked:T,onClick:()=>R(b.storyId)},T?"\u2713":""),(()=>{let v=c?.(b.storyId);return v?ve.createElement(Zl,null,ve.createElement(Jk,{src:v,alt:E?.name||b.storyId})):l?ve.createElement(Zl,null,ve.createElement(eC,null)):ve.createElement(i_,{bgColor:I?"#f1f5f9":"#eff6ff"},ve.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:I?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)))})(),ve.createElement(Xk,null,ve.createElement(Qk,null,E?.name||b.storyId),ve.createElement(Hm,null,E?.title||"")),ve.createElement(a_,null,"\u2192"),(()=>{let v=u?.(b.figmaNodeId),A=jm(b.reason),P=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return v?ve.createElement(Zl,{title:P},ve.createElement(Jk,{src:v,alt:b.figmaFrameName})):ve.createElement(Zl,{title:P},ve.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),ve.createElement(Xk,null,ve.createElement(Qk,null,b.componentSetName),ve.createElement(Hm,null,b.figmaFrameName),ve.createElement(qk,{data:jm(b.reason),color:m_(h)})),ve.createElement(l_,{level:h},b.confidence,"%"),p&&ve.createElement(c_,{onClick:()=>p(b.componentSetName)},"Browse"))}),e.unmatched.length>0&&ve.createElement(u_,null,ve.createElement(Hm,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),ve.createElement(p_,null,e.unmatched.map(b=>{let E=C.get(b);return ve.createElement(d_,{key:b},ve.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:b)})))),x&&a!=="cache"&&ve.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},ve.createElement(Ql,{inputTokens:x.inputTokens||0,outputTokens:x.outputTokens||0,costUsd:x.costUsd||0})))};Ue();De();import{useState as vo,useCallback as ko,useRef as h_}from"react";import{useStorybookApi as x_}from"storybook/manager-api";function nC({projectId:e}){let t=x_(),n=h_(null),[r,o]=vo(!1),[i,s]=vo(!1),[a,u]=vo(!1),[c,l]=vo(null),[p,f]=vo(null),[d,m]=vo(null),[w,k]=vo(""),[F,C]=vo(null),z=ko(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let h=await E.json(),T=h.entries||h.stories||{},I=Object.keys(T).filter(P=>T[P].type==="story");y.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let v=[];for(let P of I){let D=T[P],N=t.getData(P),S={...N?.initialArgs||{}},j=N?.argTypes||{};for(let[G,M]of Object.entries(j))if(!(G in S)){let J=M;if(J.defaultValue!==void 0)S[G]=J.defaultValue;else if(J.table?.defaultValue?.summary!==void 0){let Z=J.table.defaultValue.summary;Z==="false"?S[G]=!1:Z==="true"?S[G]=!0:S[G]=Z}}v.push({id:P,name:D.name||P.split("--").pop()||P,title:D.title||"",initialArgs:S,argTypes:j})}let A=v.filter(P=>Object.keys(P.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${v.length} stories, ${A.length} with args`),v},[t]),R=ko(async()=>{if(!e)return!1;try{let E=q(),h=localStorage.getItem("uicopilot_session_token");if(!h)return!1;let T=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${h}`}});if(!T.ok)return!1;let I=await T.json();return I.hasSuggestions&&I.mappings?.length>0?(f(I),C("cache"),k(`Loaded ${I.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${I.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),O=ko(async E=>{o(!0),k("Collecting story information...");let h;try{if(h=await z(),E?.length&&(h=h.filter(I=>!E.includes(I.id)),y.debug(`[useAutoMap] After excluding mapped: ${h.length} stories`)),h.length===0){l("No unmapped stories found"),o(!1);return}m(h)}catch(I){l(I instanceof Error?I.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),k(`Analyzing ${h.length} stories against Figma components...`);let T=new AbortController;n.current=T;try{let I=q(),v=localStorage.getItem("uicopilot_session_token");if(!v)throw new Error("Not authenticated");let A=await fetch(`${I}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:e,stories:h.map(D=>({id:D.id,name:D.name,title:D.title,initialArgs:D.initialArgs,argTypes:D.argTypes}))}),signal:T.signal});if(!A.ok){let D=await A.json();throw new Error(D.error||"Auto-map failed")}let P=await A.json();f(P),C("llm"),k(`Found ${P.stats.matched} matches (${P.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${P.stats.matched}/${P.stats.total} matched, ${P.unmatched.length} unmatched`)}catch(I){if(I instanceof DOMException&&I.name==="AbortError"){k("Cancelled");return}l(I instanceof Error?I.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,z]),L=ko(async E=>{if(!e)return;if(l(null),f(null),C(null),o(!0),k("Checking for existing suggestions..."),await R()){o(!1);return}await O(E)},[e,R,O]),B=ko(async E=>{e&&(l(null),f(null),C(null),await O(E))},[e,O]),g=ko(async E=>{if(!(!e||E.length===0)){u(!0),k(`Applying ${E.length} mappings...`);try{let h=q(),T=localStorage.getItem("uicopilot_session_token");if(!T)throw new Error("Not authenticated");let I=0;for(let v of E)try{(await fetch(`${h}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:e,storyId:v.storyId,figmaNodeId:v.figmaNodeId,name:v.figmaFrameName||v.componentSetName})})).ok?I++:y.warn(`[useAutoMap] Failed to apply mapping for ${v.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${v.storyId}:`,A)}k(`Applied ${I}/${E.length} mappings`),y.debug(`[useAutoMap] Applied ${I}/${E.length} mappings`)}catch(h){l(h instanceof Error?h.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),x=ko(()=>{n.current?.abort()},[]),b=ko(()=>{f(null),m(null),l(null),k(""),C(null)},[]);return{collectAndMap:L,rerun:B,loadExisting:R,applyMappings:g,cancel:x,reset:b,isCollecting:r,isMapping:i,isApplying:a,error:c,results:p,manifest:d,progress:w,source:F}}De();import{useState as Wm,useEffect as y_,useRef as rC}from"react";var oC=2;async function b_(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 iC(e){let[t,n]=Wm({}),[r,o]=Wm(0),[i,s]=Wm(!1),a=rC(null),u=rC(""),c=e.join(",");return y_(()=>{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+=oC){let m=e.slice(d,d+oC),w=await Promise.all(m.map(F=>b_(F,l.signal).then(C=>({id:F,img:C}))));if(l.signal.aborted)break;let k={};for(let{id:F,img:C}of w)p++,C&&(k[F]=C);Object.keys(k).length>0&&n(F=>({...F,...k})),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 ye,{useState as sC,useEffect as tc,useMemo as S_}from"react";De();var Mi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=qs({projectId:r||"",enabled:e&&!!r}),p=ye.useRef(!1);tc(()=>{e&&c&&!p.current&&(l.setSearch(c),p.current=!0),e||(p.current=!1)},[e,c]);let[f,d]=sC(new Set),[m,w]=sC(i||o[0]?.id||"");tc(()=>{i&&w(i)},[i]),tc(()=>{l.expandedSets.forEach(B=>{let g=l.variantChildren[B];if(!g||g.length===0)return;let x=g;l.variantFilters.some(E=>E.value)&&(x=g.filter(E=>E.variantProperties?l.variantFilters.every(h=>h.value?E.variantProperties?.[h.property]===h.value:!0):!1));let b=x.slice(0,20).map(E=>E.id);b.length>0&&l.fetchVariantThumbnails(B,b)})},[l.expandedSets,l.variantChildren,l.variantFilters]),tc(()=>{d(new Set)},[m]);let k=S_(()=>{let B=[];return l.filteredFrames.forEach(g=>{if(g.type==="COMPONENT_SET"&&g.children){let x=l.variantFilters.some(b=>b.value)?g.children.filter(b=>b.variantProperties?l.variantFilters.every(E=>E.value?b.variantProperties?.[E.property]===E.value:!0):!1):g.children;B.push(...x)}else B.push(g)}),B},[l.filteredFrames,l.variantFilters]),F=B=>{if(a)d(g=>{let x=new Set(g);return x.has(B.id)?x.delete(B.id):x.add(B.id),x});else{let g=l.resolveThumbnail(B.id);try{n({...B,thumbnail:g})}catch(x){y.error("[ComponentBrowserModal] onSelect threw error:",x)}t()}},C=()=>{let B=k.map(x=>x.id),g=B.every(x=>f.has(x));d(g?new Set:new Set(B))},z=()=>{if(u&&f.size>0){let B=k.filter(g=>f.has(g.id)).map(g=>({...g,thumbnail:l.resolveThumbnail(g.id)}));u(B),d(new Set)}},R=B=>{w(B),s?.(B)},O=B=>{B.target===B.currentTarget&&t()},L=o.find(B=>B.id===m);return e?ye.createElement(Hv,{onClick:O},ye.createElement(Wv,null,ye.createElement(Vv,null,ye.createElement(Gv,null,"Link Figma Frames"),ye.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},ye.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"),ye.createElement(qv,{onClick:t},"\xD7"))),ye.createElement(Yv,null,l.error&&ye.createElement(tk,null,l.error),!l.error&&ye.createElement(ye.Fragment,null,o.length>0&&ye.createElement(dk,null,ye.createElement(fk,null,"Story:"),ye.createElement(gk,{value:m,onChange:B=>R(B.target.value)},o.map(B=>ye.createElement("option",{key:B.id,value:B.id},B.name,B.mappingsCount?` (${B.mappingsCount} linked)`:""))),L?.mappingsCount?ye.createElement(mk,{hasMapping:!0},L.mappingsCount," frames linked"):null),ye.createElement(Zv,null,ye.createElement(jl,null,ye.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:B=>l.setShowComponentSets(B.target.checked)}),"Component Sets"),ye.createElement(jl,null,ye.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:B=>l.setShowFrames(B.target.checked)}),"Frames"),ye.createElement(jl,null,ye.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:B=>l.setShowComponents(B.target.checked)}),"Components"),l.availablePages.length>1&&ye.createElement(Pi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:B=>l.setFigmaPage(B.target.value),style:{marginLeft:"auto"}},ye.createElement("option",{value:""},"All pages"),l.availablePages.map(B=>ye.createElement("option",{key:B,value:B},B)))),l.filterSuggestion&&ye.createElement(hk,null,ye.createElement(xk,null,"AI suggests:"),ye.createElement(yk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([B,g])=>`${B}=${g}`).join(", ")),ye.createElement(bk,{onClick:l.applySuggestedFilters},"Apply"),ye.createElement(Sk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&ye.createElement(wk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&ye.createElement(Wl,null,ye.createElement(Qs,null,"Filters:"),l.availableFilters.map(({property:B,values:g})=>{let x=l.variantFilters.find(b=>b.property===B);return ye.createElement(Pi,{key:B,isActive:!!x?.value,value:x?.value||"",onChange:b=>l.handleFilterChange(B,b.target.value)},ye.createElement("option",{value:""},B),g.map(b=>ye.createElement("option",{key:b,value:b},B,"=",b)))}),l.variantFilters.some(B=>B.value)&&ye.createElement(Vl,{onClick:l.clearFilters},"Clear All")),ye.createElement(Kv,{type:"text",placeholder:"Search frames...",value:l.search,onChange:B=>l.setSearch(B.target.value),autoFocus:!0}),a&&k.length>0&&ye.createElement(vk,null,ye.createElement(kk,{onClick:C},f.size===k.length?"Deselect All":"Select All Visible"),ye.createElement(Ck,null,f.size>0?`${f.size} selected of `:"Showing ",k.length," frames")),l.isLoading&&ye.createElement(Cm,null,Array.from({length:6}).map((B,g)=>ye.createElement(pk,{key:g},ye.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},ye.createElement(Hl,{width:"100%",height:"100%"})),ye.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},ye.createElement(Hl,{width:"80%",height:"16px"}),ye.createElement(Hl,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&ye.createElement(ek,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&ye.createElement(Cm,null,l.filteredFrames.map(B=>ye.createElement(Js,{key:B.id,frame:B,thumbnail:l.thumbnails[B.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[B.id],variantChildren:l.variantChildren[B.id],variantFailed:l.variantFailed[B.id],isLoadingVariants:l.loadingVariants.has(B.id),isExpanded:l.expandedSets.has(B.id),isNew:l.recentlyAdded.has(B.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&ye.createElement(Tk,null,ye.createElement(Ik,{disabled:f.size===0,onClick:z},"Link ",f.size," Selected")))):null};we();pt();var v_=Jt.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}),k_=Jt.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"})),C_=Jt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),T_=Jt.div({display:"flex",alignItems:"center",gap:"20px"}),I_=Jt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),F_=Jt.div({display:"flex",gap:"4px"}),aC=Jt(io)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),E_=Jt(wn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),A_=Jt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),P_=Jt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),L_=Jt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),M_=Jt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),B_=Jt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),D_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),R_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),z_=Jt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),N_=Jt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),O_=Jt.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"}})),lC=Jt.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"}})),cC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Bi("map"),[i,s]=Bi([]),[a,u]=Bi(!0),[c,l]=Bi(null),[p,f]=Bi(!1),[d,m]=Bi(null),w=nC({projectId:n}),{refreshMappings:k}=rt(),{featureFlags:F}=se(),C=Je.useMemo(()=>w.results?.mappings.map(v=>v.storyId)||[],[w.results]),z=iC(C),R=Co(async()=>{u(!0);try{let v=await fetch("/index.json");if(!v.ok)throw new Error("Failed to fetch index.json");let A=await v.json(),P=A.entries||A.stories||{},D=Object.entries(P).filter(([,S])=>S.type==="story").map(([S,j])=>({id:S,name:j.name||S.split("--").pop()||S,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let S=q(),j=localStorage.getItem("uicopilot_session_token"),G=await ie(`${S}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(G.ok){let M=await G.json(),J=new Map((M.mappings||[]).map(Z=>[Z.storyId,Z]));D.forEach(Z=>{let oe=J.get(Z.id);oe&&oe.figmaNodeId&&(Z.figmaMapping={figmaNodeId:oe.figmaNodeId,figmaFrameName:oe.name||oe.figmaFrameName||""})})}}catch(S){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",S)}s(D);let N=D.find(S=>!S.figmaMapping);N?l(N.id):D.length>0&&l(D[0].id)}catch(v){console.error("[StoryMappingAssistant] Error fetching stories:",v)}finally{u(!1)}},[n]);w_(()=>{e&&R()},[e,R]);let O=Co((v,A,P)=>{s(S=>S.map(j=>j.id===v?{...j,figmaMapping:{figmaNodeId:A,figmaFrameName:P}}:j));let D=i.findIndex(S=>S.id===v),N=i.find((S,j)=>j>D&&!S.figmaMapping);N&&l(N.id)},[i]),L=Co(v=>{s(A=>A.map(P=>P.id===v?{...P,figmaMapping:null}:P))},[]),B=Co(v=>{l(v),o("map")},[]),g=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);w.collectAndMap(v)},[i,w]),x=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);f(!1),w.rerun(v)},[i,w]),b=Co(async v=>{await w.applyMappings(v),f(!1),w.reset(),R(),k()},[w,R,k]),E=Co(()=>{f(!1),w.reset()},[w]);Je.useEffect(()=>{w.results&&f(!0)},[w.results]);let h=v=>{v.target===v.currentTarget&&t()};if(!e)return null;let T=i.filter(v=>v.figmaMapping).length,I=i.length;return Je.createElement(Je.Fragment,null,Je.createElement(v_,{onClick:h},Je.createElement(k_,{onClick:v=>v.stopPropagation()},Je.createElement(C_,null,Je.createElement(T_,null,Je.createElement(I_,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(F_,null,Je.createElement(aC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(aC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Je.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!p&&!w.isCollecting&&!w.isMapping&&Je.createElement(O_,{onClick:g,disabled:a||i.length===0},Je.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},Je.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),Je.createElement("path",{d:"M2 17l10 5 10-5"}),Je.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),Je.createElement(E_,{onClick:t},"\xD7"))),Je.createElement(A_,null,(w.isCollecting||w.isMapping)&&Je.createElement(M_,null,Je.createElement(B_,null,Je.createElement(z_,null,Je.createElement(N_,null)),Je.createElement(D_,null,"Auto-mapping stories to Figma"),Je.createElement(R_,null,w.progress),Je.createElement(Br,{onClick:w.cancel,variant:"ghost"},"Cancel"))),p&&w.results&&Je.createElement(tC,{results:w.results,stories:i,onApply:b,onCancel:E,onRerun:x,isApplying:w.isApplying,isRerunning:w.isCollecting||w.isMapping,source:w.source,resolveThumbnail:v=>w.results?.thumbnailUrls?.[v],resolveStoryScreenshot:v=>z.screenshots[v],isCapturingScreenshots:z.isCapturing,onBrowse:v=>m(v)}),!p&&!w.isCollecting&&!w.isMapping&&(r==="map"?Je.createElement(Nk,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:O,projectId:n}):Je.createElement(Uk,{stories:i,loading:a,onLink:B,onUnlink:L,projectId:n}))),Je.createElement(P_,null,Je.createElement(L_,null,Je.createElement("span",null,"Total: ",I," stories"),Je.createElement(lC,{type:"mapped"},Je.createElement("span",{className:"dot"}),T," mapped"),Je.createElement(lC,{type:"unmapped"},Je.createElement("span",{className:"dot"}),I-T," unmapped"))))),Je.createElement(Mi,{isOpen:!!d,onClose:()=>m(null),onSelect:()=>m(null),projectId:n,initialSearch:d||void 0}))};import Xr,{useEffect as __,useCallback as $_}from"react";import{styled as qo,keyframes as uC}from"storybook/theming";var U_=uC({from:{opacity:0},to:{opacity:1}}),j_=uC({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),H_=qo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${U_} 150ms ease-out`}),W_=qo.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:`${j_} 150ms ease-out`})),V_=qo.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),G_=qo.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})),q_=qo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),Y_=qo.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}})),K_=qo.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":{opacity:.9}})),Di=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",onConfirm:s,onCancel:a})=>{let u=$_(c=>{c.key==="Escape"&&a()},[a]);return __(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?Xr.createElement(Xr.Fragment,null,Xr.createElement(H_,{onClick:a}),Xr.createElement(W_,{role:"dialog","aria-modal":"true","aria-label":t},Xr.createElement(V_,null,t),Xr.createElement(G_,null,n),Xr.createElement(q_,null,Xr.createElement(Y_,{onClick:a},o),Xr.createElement(K_,{variant:i,onClick:s},r)))):null};pt();var pC=Yn.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_=Yn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),J_=Yn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),Z_=Yn.div({display:"flex",alignItems:"center",gap:"8px"}),e$=Yn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),t$=Yn.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"})),n$=Yn.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"})),r$=Yn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),o$=Yn(Zc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),i$=Yn(Zc)(({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)"}})),s$=Yn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),a$=Yn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),l$=Yn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),dC=()=>{let[e,t]=nc(!1),[n,r]=nc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Ze(),{sessionToken:i}=Se();X_(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(O=>({...O,loading:!0}));try{let O=await fetch("/index.json");if(!O.ok)throw new Error("Failed to fetch Storybook index");let L=await O.json(),B=L.entries||L.stories||{},g=Object.keys(B).filter(T=>B[T].type==="story").length,x=Object.keys(B).filter(T=>B[T].type==="story"),b=q(),E=await ie(`${b}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),h=0;if(E.ok){let T=await E.json(),I=T.mappings||T||[];if(Array.isArray(I)){let v=new Set(I.map(A=>A.storyId).filter(Boolean));h=x.filter(A=>v.has(A)).length}else{let v=await ie(`${b}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(v.ok){let A=await v.json();h=Math.min(A.mappedStoriesCount||0,g)}}}r({totalStories:g,mappedStories:h,loading:!1})}catch(O){console.error("[FigmaMappingsSection] Error fetching stats:",O),r(L=>({...L,loading:!1}))}},[a,u]=nc(!1),[c,l]=nc(!1),p=async()=>{!o||!i||l(!0)},f=async()=>{l(!1),u(!0);try{let O=q(),L=await ie(`${O}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!L.ok)throw new Error("Failed to fetch mappings");let g=(await L.json()).mappings||[];await Promise.all(g.map(x=>ie(`${O}/api/mappings?id=${encodeURIComponent(x.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(O){console.error("[FigmaMappingsSection] Unlink all failed:",O)}finally{u(!1)}},d=()=>t(!0),m=()=>{t(!1),o&&i&&s()};if(!o)return kt.createElement(pC,null,kt.createElement(s$,null,"Select a project to link Figma designs"));let{totalStories:w,loading:k}=n,F=Math.min(n.mappedStories,w),C=F===0?"none":F>=w?"complete":"partial",z=w>0?Math.min(100,Math.round(F/w*100)):0,R=C==="none"?"Link designs":"Manage";return kt.createElement(kt.Fragment,null,kt.createElement(pC,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(J_,null,kt.createElement(r$,null,"Figma Mappings"),kt.createElement(Z_,null,k?kt.createElement(kt.Fragment,null,kt.createElement(a$,null),kt.createElement(l$,null,"Loading...")):kt.createElement(kt.Fragment,null,kt.createElement(e$,null,kt.createElement(t$,{percent:z,state:C})),kt.createElement(n$,{state:C},`${F}/${w}`)))),F>0&&kt.createElement(i$,{onClick:p,disabled:k||a},a?"Unlinking...":"Unlink All"),kt.createElement(o$,{onClick:d,disabled:k},R)),e&&kt.createElement(cC,{isOpen:e,onClose:m,projectId:o}),kt.createElement(Di,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:f,onCancel:()=>l(!1)}))};import ce,{useState as ea,useEffect as Vm,useCallback as c$}from"react";import{styled as Kn}from"storybook/theming";we();Ue();pt();var Gm=Kn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),qm=Kn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Ym=Kn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Ete=Kn(Er)({padding:"5px 12px",fontSize:"12px"}),Km=Kn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),rc=Kn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),u$=Kn.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})),p$=Kn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Xm=Kn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),d$=Kn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),oc=Kn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),ic=Kn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Yo=Kn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),fC=new Set,gC=()=>{let{userRole:e,featureFlags:t}=se(),[n,r]=ea(null),[o,i]=ea(!0),[s,a]=ea(!1),[u,c]=ea(!1),[l,p]=ea(!1),{selectedProjectId:f,projects:d}=Ze(),{sessionToken:m}=Se(),w=c$(async()=>{if(!(!f||!m))try{let L=q(),B=await ie(`${L}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${m}`}});if(B.ok){let g=await B.json();r(g)}}catch(L){console.error("[FigmaCacheSection] Error:",L)}finally{i(!1)}},[f,m]);Vm(()=>{w()},[w]),Vm(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||fC.has(f))return;let L=d.find(g=>g.id===f);(L?.figmaFileUrl||L?.figmaFileId)&&(fC.add(f),k())},[o,s,n?.structureStatus,f,d]),Vm(()=>{let L=n?.thumbnailProgress?.status,B=n?.enrichmentProgress?.status,g=n?.thumbnailProgress?.cached??0,x=n?.thumbnailProgress?.total??0,b=L==="in-progress"||L==="pending"||x>0&&g<x,E=B==="in-progress"||B==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(b||E||h)||!n||n.structureStatus==="none")return;let I=setInterval(()=>{w()},3e3);return()=>{clearInterval(I)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,w]);let k=async()=>{if(!(!f||!m)){a(!0);try{let L=q();await ie(`${L}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${m}`}},6e4),await new Promise(B=>setTimeout(B,1e3)),await w(),setTimeout(async()=>{await w()},3e3)}catch(L){console.error("[FigmaCacheSection] Reload error:",L)}finally{a(!1)}}},F=async()=>{if(!(!f||!m)){c(!0);try{let L=q(),B=await ie(`${L}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:f})});console.log("[FigmaCacheSection] Cache invalidate response:",B.status),await ie(`${L}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:f})}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(L){console.error("[FigmaCacheSection] Clear cache error:",L)}finally{c(!1)}}},C=async()=>{if(!(!f||!m)){p(!0);try{let L=q();await ie(`${L}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:f})});let B=setInterval(async()=>{await w()},3e3),g=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(clearInterval(B),clearInterval(g),p(!1),w())},3e3);setTimeout(()=>{clearInterval(B),clearInterval(g),p(!1)},6e5)}catch(L){console.error("[FigmaCacheSection] Enrich error:",L),p(!1)}}};if(!f)return null;if(o)return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache")),ce.createElement(Km,null,ce.createElement(rc,null,"Loading cache status\u2026")),ce.createElement(oc,null,ce.createElement(ic,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache"),ce.createElement(Br,{loading:s,onClick:k,loadingText:"Loading..."},"\u21BB Load")),s?ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):ce.createElement(Km,null,ce.createElement(rc,null,"No cache \u2014 click Load to fetch from Figma")));let z=L=>{let B=Date.now()-new Date(L).getTime(),g=Math.floor(B/6e4);if(g<1)return"just now";if(g<60)return`${g}m ago`;let x=Math.floor(g/60);return x<24?`${x}h ago`:`${Math.floor(x/24)}d ago`},R=n.cacheDiff,O=R&&(R.added.length>0||R.removed.length>0||R.renamed.length>0);return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache"," ",ce.createElement(u$,{status:n.structureStatus},n.structureStatus)),ce.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&ce.createElement(Br,{loading:l,onClick:C,loadingText:"Enriching..."},"Enrich"),ce.createElement(Br,{loading:u,onClick:F,variant:"ghost",loadingText:"Clearing..."},"Clear"),ce.createElement(Br,{loading:s,onClick:k,loadingText:"Reloading..."},"\u21BB Reload"))),s&&ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma...")),ce.createElement(Km,null,ce.createElement(rc,null,ce.createElement("strong",null,n.componentSetCount)," component sets"),ce.createElement(rc,null,ce.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&ce.createElement(d$,null,"Updated ",z(n.structureCachedAt))),O&&ce.createElement(p$,null,"Since last reload:"," ",R.added.length>0&&ce.createElement(Xm,{type:"added"},"+",R.added.length," added"),R.added.length>0&&R.removed.length>0&&" \xB7 ",R.removed.length>0&&ce.createElement(Xm,{type:"removed"},"\u2212",R.removed.length," removed"),(R.added.length>0||R.removed.length>0)&&R.renamed.length>0&&" \xB7 ",R.renamed.length>0&&ce.createElement(Xm,{type:"renamed"},R.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Caching component set thumbnails to CDN...",n.thumbnailProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.thumbnailProgress.currentName)),ce.createElement("span",null,n.thumbnailProgress.cached," / ",n.thumbnailProgress.total))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: ",n.thumbnailProgress.cached," / ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending")&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: not pre-cached")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Enriching components with AI...",n.enrichmentProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.enrichmentProgress.currentName)),ce.createElement("span",null,n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&ce.createElement(ce.Fragment,null,ce.createElement(Yo,null,ce.createElement("span",null,"AI enrichment: ",n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&ce.createElement("div",{style:{marginTop:"6px"}},ce.createElement(Ql,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import ht,{useState as Ri}from"react";import{styled as Dr}from"storybook/theming";we();Ue();pt();var Qm=Dr.div({padding:"12px 16px"}),f$=Dr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),mC=Dr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),hC=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:le,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),g$=Dr.div({display:"flex",gap:"8px",alignItems:"center"}),m$=Dr.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:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),xC=Dr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),h$=Dr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:le,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),x$=Dr.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})),y$=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),yC=({onConnected:e})=>{let{sessionToken:t}=Se(),[n,r]=Ri(!1),[o,i]=Ri(""),[s,a]=Ri(!1),[u,c]=Ri(null),[l,p]=Ri(null),[f,d]=Ri(!1),m=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let w=q(),k=await ie(`${w}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),F=await k.json();if(!k.ok){c({type:"error",message:F.error||"Failed to save token"});return}p(F.figmaUser?.handle||F.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${F.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?ht.createElement(Qm,null,ht.createElement(mC,null,"Figma Personal Access Token"),ht.createElement(x$,null,ht.createElement("span",null,"\u2713 Connected as ",ht.createElement("strong",null,l)),ht.createElement(y$,{onClick:()=>{p(null),c(null)}},"Change token"))):n?ht.createElement(Qm,null,ht.createElement(f$,null,ht.createElement(mC,null,"Figma Personal Access Token"),ht.createElement(hC,{onClick:()=>d(!f)},f?"Hide instructions":"How to generate")),f&&ht.createElement(h$,null,ht.createElement("ol",null,ht.createElement("li",null,"Open ",ht.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),ht.createElement("li",null,"Click the ",ht.createElement("strong",null,"Security")," tab"),ht.createElement("li",null,"Scroll to ",ht.createElement("strong",null,"Personal access tokens")),ht.createElement("li",null,"Click ",ht.createElement("strong",null,"Generate new token")),ht.createElement("li",null,"Enable ",ht.createElement("strong",null,"File content: Read only")," under Scopes"),ht.createElement("li",null,"Copy the token and paste it below"))),ht.createElement(g$,null,ht.createElement(m$,{type:"password",value:o,onChange:w=>i(w.target.value),placeholder:"figd_...",onKeyDown:w=>{w.key==="Enter"&&o.trim()&&m()}}),ht.createElement(en,{onClick:m,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&ht.createElement(xC,{variant:u.type},u.message),ht.createElement(xC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):ht.createElement(Qm,null,ht.createElement(hC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};we();Ue();pt();var S$=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"})),Zm=vr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),w$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),v$=vr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),k$=vr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),eh=vr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),C$=vr.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"})),T$=vr.div({display:"flex",alignItems:"center",gap:"8px"}),I$=vr(er)(({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"})),F$=vr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Yte=vr.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"}}),E$=vr.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}})),SC=({hideHeader:e=!1})=>{let{sessionToken:t}=Se(),[n,r]=Jm(!1),[o,i]=Jm(null),[s,a]=Jm(!1);b$(()=>{if(!t)return;let p=q();ie(`${p}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(f=>f.json()).then(f=>i(!!f.connected)).catch(()=>i(!1))},[t]);let u=bC(()=>{let f=`${q()}/addon/auth`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100")},[]),c=bC(async()=>{try{r(!0);let p=q(),f=await ie(`${p}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});(f.ok||f.status===404)&&i(!1)}catch{}finally{r(!1)}},[t]),l=e?null:bt.createElement(w$,null,bt.createElement(v$,null,S$),bt.createElement(k$,null,"Figma Integration"));return o===null?bt.createElement(Zm,null,l,bt.createElement(eh,null,bt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?bt.createElement(Zm,null,l,bt.createElement(eh,null,bt.createElement(F$,null,bt.createElement(en,{onClick:u,style:{width:"100%"}},"Connect with Figma"),bt.createElement(E$,null,"or"),bt.createElement(yC,{onConnected:()=>i(!0)})))):bt.createElement(Zm,null,l,bt.createElement(C$,null,bt.createElement(T$,null,bt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),bt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),bt.createElement(I$,{onClick:()=>a(!0),disabled:n},n?"Disconnecting...":"Disconnect")),bt.createElement(Di,{isOpen:s,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:()=>{a(!1),c()},onCancel:()=>a(!1)}),bt.createElement(eh,null,bt.createElement(jv,null),bt.createElement(dC,null),bt.createElement(gC,null)))};we();var A$=cr.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"}),P$=cr.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"})),L$=cr.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})),M$=cr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),B$=cr(wn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),D$=cr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),wC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),vC=cr.div({display:"flex",alignItems:"center",gap:"10px"}),kC=cr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),R$=cr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:le,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),z$=cr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),CC=cr.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"}})),TC=({onClose:e})=>{let{isConnected:t}=Se(),{selectedProjectId:n}=Ze();return At.createElement(A$,{onClick:e},At.createElement(P$,{onClick:r=>r.stopPropagation()},At.createElement(L$,null,At.createElement(M$,null,"Settings"),At.createElement(B$,{onClick:e,title:"Close settings"},"\xD7")),At.createElement(D$,null,At.createElement(wC,null,At.createElement(vC,null,At.createElement(R$,null,"UI"),At.createElement(kC,null,"UI Copilot")),At.createElement(CC,null,At.createElement(Nv,null),t&&At.createElement(_v,null))),t&&n&&At.createElement(wC,null,At.createElement(vC,null,At.createElement(z$,null,At.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},At.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"}),At.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"}),At.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),At.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"}),At.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"}))),At.createElement(kC,null,"Figma Integration")),At.createElement(CC,null,At.createElement(SC,{hideHeader:!0}))))))};import ft,{useEffect as RC,useMemo as p4,useState as d4,useRef as f4}from"react";import{styled as Cn,keyframes as g4}from"storybook/theming";we();we();import Kt,{useState as N$}from"react";import{styled as On}from"storybook/theming";var Qr=[{id:"claude-sonnet-4-5-20250929",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 O$=On.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),_$=On.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),$$=On.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"}}),U$=On.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}})),j$=On.div({position:"relative",display:"inline-block"}),H$=On.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}})),W$=On.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"})),th=On.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),nh=On.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),V$=On.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}})),G$=On.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),q$=On.div({flex:1,minWidth:0}),Y$=On.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),K$=On.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),X$=5,IC=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=se(),[r,o]=N$(!1),i=Qr.filter(d=>d.provider==="anthropic"&&!e.includes(d.id)),s=Qr.filter(d=>d.provider==="openai"&&!e.includes(d.id)),a=Qr.filter(d=>d.provider==="google"&&!e.includes(d.id)),u=Qr.filter(d=>e.includes(d.id)),c=e.length<X$,l=(d,m)=>{m.stopPropagation(),e.length>1&&!n&&t(d)},p=d=>{let m=e.includes(d);m&&e.length===1||!m&&!c||n||(t(d),o(!1))},f=d=>{let m=e.includes(d.id),w=m&&e.length===1,k=n||w||!m&&!c;return Kt.createElement(V$,{key:d.id,disabled:k,onClick:()=>p(d.id)},Kt.createElement(G$,{type:"checkbox",checked:m,disabled:k,onChange:()=>{},onClick:F=>F.stopPropagation()}),Kt.createElement(q$,null,Kt.createElement(Y$,null,d.name),d.description&&Kt.createElement(K$,null,d.description)))};return Kt.createElement(O$,null,Kt.createElement(j$,null,Kt.createElement(H$,{disabled:n,isOpen:r,onClick:()=>o(!r)},Kt.createElement("span",null,"Select model"),Kt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Kt.createElement(W$,null,Kt.createElement(th,null,Kt.createElement(nh,null,"Anthropic"),i.map(f)),Kt.createElement(th,null,Kt.createElement(nh,null,"OpenAI"),s.map(f)),Kt.createElement(th,null,Kt.createElement(nh,null,"Google"),a.map(f)))),Kt.createElement(_$,null,u.map(d=>Kt.createElement($$,{key:d.id,disabled:n,provider:d.provider},d.name,e.length>1&&Kt.createElement(U$,{disabled:n,onClick:m=>l(d.id,m),title:"Remove model"},"\xD7")))))};import ke,{useState as Q$,useEffect as J$}from"react";import{styled as jt,keyframes as Ni}from"storybook/theming";we();var Z$=Ni`
|
|
45
45
|
0%, 100% {
|
|
46
46
|
opacity: 1;
|
|
47
47
|
transform: scale(1);
|
|
@@ -78,24 +78,24 @@ ${st}`).join(`
|
|
|
78
78
|
`;var vne=jt.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),rh=jt.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),kne=jt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderRadius:"8px",backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:"12px",fontWeight:500,color:e.textMutedColor,animation:`${AC} 0.3s ease-out`})),r4=Ni`
|
|
79
79
|
from { transform: rotate(0deg); }
|
|
80
80
|
to { transform: rotate(360deg); }
|
|
81
|
-
`,Cne=jt.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${r4} 0.8s linear infinite`,flexShrink:0})),FC=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),o4=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#dcfce7",fontSize:"12px",fontWeight:700,color:"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"}),Tne=jt.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:`${n4} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var zi=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),ea=jt.span(({color:e="#6b7280"})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:e,whiteSpace:"nowrap"})),EC=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),ta=jt.span(({color:e})=>({fontWeight:700,color:e})),i4=jt.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"12px",backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:"12px",color:t.textMutedColor},"& .score-value":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:"20px",fontWeight:700,color:e,lineHeight:1},"& .score-dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:e}})),Ine=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Fne=jt.span(({color:e=le})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${Z$} 1.2s ease-in-out infinite`,marginRight:"4px"})),Ene=jt.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return le;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 le;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${t4} 1.5s ease-in-out infinite`}:{}})),Ane=jt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Pne=jt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),s4=jt.button(({theme:e,isExporting:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",fontSize:"11px",fontWeight:600,color:t?e.color.mediumdark:"#7c3aed",backgroundColor:t?e.background.hoverable:"#ede9fe",border:"none",borderRadius:"12px",cursor:t?"not-allowed":"pointer",transition:"all 0.2s",whiteSpace:"nowrap","&:hover":{backgroundColor:t?e.background.hoverable:"#ddd6fe"}})),a4=jt.span({display:"inline-block",width:"10px",height:"10px",border:"2px solid #c4b5fd",borderTopColor:"#7c3aed",borderRadius:"50%",animation:"export-spin 0.8s linear infinite","@keyframes export-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),l4=jt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${e4} 1.2s linear infinite`,flexShrink:0}),c4=({color:e=le})=>Ce.createElement(l4,null,Ce.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 Ce.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Lne=jt.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:`${AC} 0.3s ease-out`}));function u4(e){let[t,n]=Q$(0);return J$(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var PC=({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:f})=>{let p=u4(e||t),{exportPDF:g,isExporting:S}=cm(),{featureFlags:C}=ie(),F=C.showCosts,k=3.65,R=m=>m<.01?`$${m.toFixed(4)}`:m<.1?`$${m.toFixed(3)}`:`$${m.toFixed(2)}`,z=m=>{let x=m*k;return x<.01?`\u20AA${x.toFixed(4)}`:x<.1?`\u20AA${x.toFixed(3)}`:`\u20AA${x.toFixed(2)}`},_=m=>m>=1e3?`${(m/1e3).toFixed(1)}K`:m.toString(),M=m=>m>=80?"score-high":m>=50?"score-medium":"score-low",B=m=>m>=80?"high":m>=50?"medium":"low";if(e)return Ce.createElement(rh,null,Ce.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},p,"s \xB7 Esc to stop"));if(t)return Ce.createElement(rh,null,Ce.createElement(FC,null,Ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(c4,{color:"#7c3aed"}),Ce.createElement(ta,{color:"#7c3aed"},"Verifying...")),c&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement("span",{style:{color:"#6b7280"}},p,"s"))));if(r>0||o!==void 0){let m=(a||0)+(u||0),x=(d||0)>0,b=x&&a?Math.round(d/a*100):0,E=Math.max(o??0,i??0),h=I=>I>=80?"#16a34a":I>=50?"#ca8a04":"#dc2626",T=I=>I>=100?"\u25CF":I>=50?"\u25D0":"\u25CB";return Ce.createElement(rh,null,r===0?Ce.createElement(o4,null,Ce.createElement("span",null,"\u2713"),"Perfect!"):Ce.createElement(FC,null,Ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ce.createElement(i4,{tint:h(E),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},Ce.createElement("span",{className:"score-dot"}),Ce.createElement("span",{className:"score-label"},"Score"),Ce.createElement("span",{className:"score-value"},E)),F&&s!==void 0&&s>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(ta,{color:"#16a34a"},R(s)),Ce.createElement("span",{style:{color:"#6b7280"}},"/"),Ce.createElement(ta,{color:"#16a34a"},z(s)))),F&&m>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${x?` \xB7 Cached: ${d?.toLocaleString()}`:""}`},Ce.createElement(EC,{color:"#7c3aed"},"#"),Ce.createElement(ta,{color:"#7c3aed"},_(m)),Ce.createElement("span",{style:{color:"#6b7280"}},"tokens"),x&&Ce.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",b,"%"))),f!==void 0&&f>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(EC,{color:"#6b7280"},"\u23F1"),Ce.createElement(ta,{color:"#6b7280"},f,"s"))),Ce.createElement(zi,null,"|"),Ce.createElement(s4,{onClick:g,disabled:S,isExporting:S,title:"Download design review report as PDF"},S?Ce.createElement(Ce.Fragment,null,Ce.createElement(a4,null),"Exporting..."):Ce.createElement(Ce.Fragment,null,"\u2193 Report")))}return null};var m4=Cn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),$ne=Cn.div({display:"flex",gap:"8px",alignItems:"center"}),h4=g4({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),x4=Cn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${h4} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),y4=Cn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),b4=Cn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"16px",padding:"14px 18px",borderRadius:"14px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02)",flexWrap:"wrap"})),S4=Cn.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:La},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:"#ffffff",border:"none",padding:"12px 24px",fontSize:"14px",fontWeight:600,borderRadius:"10px",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)`}}}),w4=Cn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),v4=Cn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),k4=Cn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),C4=Cn(En)({width:"auto",minWidth:"200px"}),T4=Cn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),LC=Cn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),MC=Cn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?La:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),BC=Cn.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)"})),DC=Cn.input({position:"absolute",opacity:0,width:0,height:0}),I4=()=>{let[e,t]=d4(0),n=f4();RC(()=>(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)},oh=()=>{let{sessionToken:e}=Bs(),{usageData:t}=we(),{selectedProjectId:n}=qr(),{currentMapping:r,hasMapping:o}=Ho(),{loadingMapping:i,currentStoryId:s}=rt(),{startReview:a,cancelReview:u,isReviewing:c}=Jg(),{isLoadingScreenshots:l}=Uo(),{storybookImageUrl:d,figmaImageUrl:f,currentReviewId:p,reviewHistory:g,setReviewDetailTab:S,setReviewResults:C,setFigmaImageUrl:F,setStorybookImageUrl:k,setFullPrompt:R,setFullResponse:z,includeTextComparison:_,setIncludeTextComparison:M,usePromptCache:B,setUsePromptCache:m,isValidating:x,validationUsage:b,isGenerating:E,isApplying:h,streamingStatus:T,featureFlags:I,userRole:v,roleOverride:A,isReviewing:P}=ie(),D=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=g.find(he=>he.id===p),j=(N?.issues||[]).filter(he=>!he.dismissed).length,G=N?.complianceScore,L=N?.visualSimilarity,K=(N?.costUsd||0)+(b?.costUsd||0),ee=(N?.inputTokens||0)+(b?.inputTokens||0),re=(N?.outputTokens||0)+(b?.outputTokens||0),de=p4(()=>{let he=s?g.filter(ne=>ne.storyId===s):g,vt=he.filter(ne=>!ne.parentReviewId).sort((ne,W)=>new Date(W.createdAt).getTime()-new Date(ne.createdAt).getTime()),Ge=he.filter(ne=>ne.parentReviewId),lt=[];for(let ne of vt){lt.push(ne);let W=Ge.filter(Ae=>Ae.parentReviewId===ne.id).sort((Ae,ge)=>(Ae.iterationNumber||0)-(ge.iterationNumber||0));lt.push(...W)}let nt=Ge.filter(ne=>!vt.some(W=>W.id===ne.parentReviewId));return lt.push(...nt),lt},[g,s]);RC(()=>{if(!c)return;let he=vt=>{vt.key==="Escape"&&(vt.preventDefault(),u())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[c,u]);let ae=o&&r?.figmaNodeId,qe=E||h,tt=!!(e&&n&&!c&&!l&&!qe&&s&&d&&ae&&f),se=async(he=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{S("chat"),await a({isIteration:he,parentReviewId:he?p:void 0})}catch(vt){console.error("[ReviewActions] Review error:",vt)}},pe=()=>se(!1),Ie=he=>{let vt=he.target.value;if(vt){let Ge=g.find(lt=>lt.id===vt);Ge&&(C({id:Ge.id,componentId:Ge.componentId,storyId:Ge.storyId,modelId:Ge.modelId,complianceScore:Ge.complianceScore,issuesCount:Ge.issuesCount,issues:Ge.issues,createdAt:new Date(Ge.createdAt),visualSimilarity:Ge.visualSimilarity,timestamp:new Date(Ge.createdAt).toISOString()}),Ge.figmaImageData&&F(Ge.figmaImageData),Ge.storybookImageData&&k(Ge.storybookImageData),(A??v)==="admin"&&(R(Ge.aiPrompt||""),z(Ge.aiResponse||"")),S("issues"))}},ze=he=>{let vt=new Date(he),lt=new Date().getTime()-vt.getTime(),nt=Math.floor(lt/6e4),ne=Math.floor(lt/36e5),W=Math.floor(lt/864e5);return nt<1?"Just now":nt<60?`${nt}m ago`:ne<24?`${ne}h ago`:W<7?`${W}d ago`:vt.toLocaleDateString()},me=he=>he?he.includes("haiku")?"Haiku":he.includes("sonnet")?"Sonnet":he.includes("opus")?"Opus":he.includes("gpt-4o-mini")?"GPT-4o mini":he.includes("gpt-4o")?"GPT-4o":he.includes("gpt-4")?"GPT-4":he.includes("o3")?"o3":he.includes("o1")?"o1":he.split("-")[0]||"":"",Nt=he=>{let vt=he.split("--"),Ge=vt[vt.length-1]||he;return Ge.charAt(0).toUpperCase()+Ge.slice(1)};return ft.createElement("div",null,ft.createElement(m4,null,I.enableModelSelection&&ft.createElement(IC,null),ft.createElement(T4,null,ft.createElement(LC,{title:"Compare text content between Figma design and Storybook component"},ft.createElement(DC,{type:"checkbox",checked:_,onChange:he=>M(he.target.checked)}),ft.createElement(MC,{checked:_},ft.createElement(BC,{checked:_})),"Compare text"),I.showCosts&&ft.createElement(LC,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ft.createElement(DC,{type:"checkbox",checked:B,onChange:he=>m(he.target.checked)}),ft.createElement(MC,{checked:B},ft.createElement(BC,{checked:B})),"Cache prompt")),ft.createElement(b4,null,ft.createElement(S4,{variant:c?"yellow":"purple",disabled:c?!1:!tt,onClick:c?u:pe,title:c?"Click to stop review":e?n?s?ae?l?"Loading screenshots...":qe?"Wait for fixes to complete...":d?f?"Review this component implementation":"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 UI Copilot first"},c?ft.createElement(ft.Fragment,null,ft.createElement(x4,null),"Reviewing",ft.createElement(I4,null)):ft.createElement(ft.Fragment,null,ft.createElement(y4,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")),P?null:x||N?ft.createElement(PC,{isReviewing:!1,isValidating:x,streamingStatus:T,issueCount:j,score:G,visualSimilarity:L,costUsd:K||N?.costUsd,inputTokens:ee||N?.inputTokens,outputTokens:re||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,de.length>0&&ft.createElement(v4,null,ft.createElement(k4,null,"Review History"),ft.createElement(C4,{value:p||"",onChange:Ie},ft.createElement("option",{value:""},"Select a review..."),de.map(he=>{let vt=!!he.parentReviewId,Ge=vt?" \u21B3 ":"\u25CF ",lt=vt&&he.iterationNumber?`Iter ${he.iterationNumber} - `:"",nt=he.issuesCount??he.issues?.length??0,ne=he.complianceScore??"--",W=me(he.modelId);return ft.createElement("option",{key:he.id,value:he.id},Ge,lt,ze(he.createdAt)," - ",nt," issues (",ne,"%)",W?` \xB7 ${W}`:"",he.storyId?` \xB7 ${Nt(he.storyId)}`:"")}))))),!ae&&!i&&ft.createElement(w4,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import Hne,{useState as Wne}from"react";import{styled as zC}from"storybook/theming";var qne=zC.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Yne=zC(io)({padding:"8px 12px",fontSize:"12px"});import Qne,{useState as Jne}from"react";import{styled as ih}from"storybook/theming";ve();je();De();pt();var ire=ih.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),sre=ih(Er)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),are=ih.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import ure from"react";import{styled as F4}from"storybook/theming";var fre=F4.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ve();import hre from"react";import{styled as Rr}from"storybook/theming";var bre=Rr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),Sre=Rr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),wre=Rr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),vre=Rr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),kre=Rr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Cre=Rr.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"})),Tre=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Ire=Rr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),Fre=Rr.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)"}}})),Ere=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ve();import Lre,{useState as Mre}from"react";import{styled as zr}from"storybook/theming";var Rre=zr.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)`}}),zre=zr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Nre=zr.div({display:"flex",alignItems:"center",gap:"8px"}),Ore=zr.span({fontSize:"12px",opacity:.7}),_re=zr.span({fontSize:"13px",fontWeight:500}),$re=zr.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})),Ure=zr.div({marginTop:"12px",fontSize:"11px"}),jre=zr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),Hre=zr.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"})),Wre=zr.span({fontSize:"12px"});De();je();import Xt from"react";import{styled as Qi}from"storybook/theming";import Tr,{useEffect as gW}from"react";import{styled as ya}from"storybook/theming";ve();import ni,{useState as H5}from"react";import{styled as Wi}from"storybook/theming";var NC={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 OC(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var E4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P4={};function sc(e,t){return((t||P4).jsx?A4:E4).test(e)}var L4=/[ \t\n\f\r]/g;function sh(e){return typeof e=="object"?e.type==="text"?_C(e.value):!1:_C(e)}function _C(e){return e.replace(L4,"")===""}var Jr=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Jr.prototype.normal={};Jr.prototype.property={};Jr.prototype.space=void 0;function ah(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Jr(n,r,t)}function na(e){return e.toLowerCase()}var sn=class{constructor(t,n){this.attribute=n,this.property=t}};sn.prototype.attribute="";sn.prototype.booleanish=!1;sn.prototype.boolean=!1;sn.prototype.commaOrSpaceSeparated=!1;sn.prototype.commaSeparated=!1;sn.prototype.defined=!1;sn.prototype.mustUseProperty=!1;sn.prototype.number=!1;sn.prototype.overloadedBoolean=!1;sn.prototype.property="";sn.prototype.spaceSeparated=!1;sn.prototype.space=void 0;var ra={};ye(ra,{boolean:()=>We,booleanish:()=>zt,commaOrSpaceSeparated:()=>_n,commaSeparated:()=>To,number:()=>Y,overloadedBoolean:()=>ac,spaceSeparated:()=>St});var M4=0,We=Ko(),zt=Ko(),ac=Ko(),Y=Ko(),St=Ko(),To=Ko(),_n=Ko();function Ko(){return 2**++M4}var lh=Object.keys(ra),Xo=class extends sn{constructor(t,n,r,o){let i=-1;if(super(t,n),$C(this,"space",o),typeof r=="number")for(;++i<lh.length;){let s=lh[i];$C(this,lh[i],(r&ra[s])===ra[s])}}};Xo.prototype.defined=!0;function $C(e,t,n){n&&(e[t]=n)}function ur(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new Xo(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[na(r)]=r,n[na(i.attribute)]=r}return new Jr(t,n,e.space)}var ch=ur({properties:{ariaActiveDescendant:null,ariaAtomic:zt,ariaAutoComplete:null,ariaBusy:zt,ariaChecked:zt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:St,ariaCurrent:null,ariaDescribedBy:St,ariaDetails:null,ariaDisabled:zt,ariaDropEffect:St,ariaErrorMessage:null,ariaExpanded:zt,ariaFlowTo:St,ariaGrabbed:zt,ariaHasPopup:null,ariaHidden:zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:St,ariaLevel:Y,ariaLive:null,ariaModal:zt,ariaMultiLine:zt,ariaMultiSelectable:zt,ariaOrientation:null,ariaOwns:St,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:zt,ariaReadOnly:zt,ariaRelevant:null,ariaRequired:zt,ariaRoleDescription:St,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:zt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function lc(e,t){return t in e?e[t]:t}function cc(e,t){return lc(e,t.toLowerCase())}var UC=ur({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:To,acceptCharset:St,accessKey:St,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:St,autoFocus:We,autoPlay:We,blocking:St,capture:null,charSet:null,checked:We,cite:null,className:St,cols:Y,colSpan:null,content:null,contentEditable:zt,controls:We,controlsList:St,coords:Y|To,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:ac,draggable:zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:St,height:Y,hidden:ac,high:Y,href:null,hrefLang:null,htmlFor:St,httpEquiv:St,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:St,itemRef:St,itemScope:We,itemType:St,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:We,muted:We,name:null,nonce:null,noModule:We,noValidate:We,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:We,optimum:Y,pattern:null,ping:St,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:St,required:We,reversed:We,rows:Y,rowSpan:Y,sandbox:St,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:zt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:St,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:We,declare:We,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:zt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:cc});var jC=ur({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:_n,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:St,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:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,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:To,g2:To,glyphName:To,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,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:Y,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:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:St,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,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:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lc});var uh=ur({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 ph=ur({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cc});var dh=ur({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var fh={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 B4=/[A-Z]/g,HC=/-[a-z]/g,D4=/^data[-\w.:]+$/i;function gh(e,t){let n=na(t),r=t,o=sn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&D4.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(HC,z4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!HC.test(i)){let s=i.replace(B4,R4);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=Xo}return new o(r,t)}function R4(e){return"-"+e.toLowerCase()}function z4(e){return e.charAt(1).toUpperCase()}var WC=ah([ch,UC,uh,ph,dh],"html"),uc=ah([ch,jC,uh,ph,dh],"svg");function VC(e){return e.join(" ").trim()}var s1=Pa(n1(),1);var dc=r1("end"),Oi=r1("start");function r1(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 xh(e){let t=Oi(e),n=dc(e);if(t&&n)return{start:t,end:n}}function Io(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?o1(e.position):"start"in e||"end"in e?o1(e):"line"in e||"column"in e?yh(e):""}function yh(e){return i1(e&&e.line)+":"+i1(e&&e.column)}function o1(e){return yh(e&&e.start)+"-"+yh(e&&e.end)}function i1(e){return e&&typeof e=="number"?e:1}var Ht=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=Io(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}};Ht.prototype.file="";Ht.prototype.name="";Ht.prototype.reason="";Ht.prototype.message="";Ht.prototype.stack="";Ht.prototype.column=void 0;Ht.prototype.line=void 0;Ht.prototype.ancestors=void 0;Ht.prototype.cause=void 0;Ht.prototype.fatal=void 0;Ht.prototype.place=void 0;Ht.prototype.ruleId=void 0;Ht.prototype.source=void 0;var bh={}.hasOwnProperty,lU=new Map,cU=/[A-Z]/g,uU=new Set(["table","tbody","thead","tfoot","tr"]),pU=new Set(["td","th"]),a1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sh(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=bU(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=yU(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"?uc:WC,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=l1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function l1(e,t,n){if(t.type==="element")return dU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return fU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return mU(e,t,n);if(t.type==="mdxjsEsm")return gU(e,t);if(t.type==="root")return hU(e,t,n);if(t.type==="text")return xU(e,t)}function dU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=uc,e.schema=o),e.ancestors.push(t);let i=u1(e,t.tagName,!1),s=SU(e,t),a=vh(e,t);return uU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!sh(u):!0})),c1(e,s,i,t),wh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function fU(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)}ia(e,t.position)}function gU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ia(e,t.position)}function mU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=uc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:u1(e,t.name,!0),s=wU(e,t),a=vh(e,t);return c1(e,s,i,t),wh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function hU(e,t,n){let r={};return wh(r,vh(e,t)),e.create(t,e.Fragment,r,n)}function xU(e,t){return t.value}function c1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function yU(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 bU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Oi(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 SU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&bh.call(t.properties,o)){let i=vU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&pU.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 wU(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 ia(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 ia(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function vh(e,t){let n=[],r=-1,o=e.passKeys?new Map:lU;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=l1(e,i,s);a!==void 0&&n.push(a)}return n}function vU(e,t,n){let r=gh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?OC(n):VC(n)),r.property==="style"){let o=typeof n=="object"?n:kU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=CU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?fh[r.property]||r.property:r.attribute,n]}}function kU(e,t){try{return(0,s1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Ht("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=a1+"#cannot-parse-style-attribute",o}}function u1(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=sc(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=sc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return bh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ia(e)}function ia(e,t){let n=new Ht("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=a1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function CU(e){let t={},n;for(n in e)bh.call(e,n)&&(t[TU(n)]=e[n]);return t}function TU(e){let t=e.replace(cU,IU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function IU(e){return"-"+e.toLowerCase()}var sa={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 D5,jsx as R5,jsxs as z5}from"react/jsx-runtime";import{useEffect as npe,useState as rpe}from"react";var FU={};function kh(e,t){let n=t||FU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return d1(e,r,o)}function d1(e,t,n){if(EU(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 p1(e.children,t,n)}return Array.isArray(e)?p1(e,t,n):""}function p1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=d1(e[o],t,n);return r.join("")}function EU(e){return!!(e&&typeof e=="object")}var f1=document.createElement("i");function _i(e){let t="&"+e+";";f1.innerHTML=t;let n=f1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(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 Tn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}var g1={}.hasOwnProperty;function m1(e){let t={},n=-1;for(;++n<e.length;)AU(t,e[n]);return t}function AU(e,t){let n;for(n in t){let o=(g1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){g1.call(o,s)||(o[s]=[]);let a=i[s];PU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function PU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function fc(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 Zr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Xn=Fo(/[A-Za-z]/),an=Fo(/[\dA-Za-z]/),h1=Fo(/[#-'*+\--9=?A-Z^-~]/);function aa(e){return e!==null&&(e<32||e===127)}var la=Fo(/\d/),x1=Fo(/[\dA-Fa-f]/),y1=Fo(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function $e(e){return e===-2||e===-1||e===32}var b1=Fo(/\p{P}|\p{S}/u),S1=Fo(/\s/);function Fo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&an(e.charCodeAt(n+1))&&an(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 Ve(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return $e(u)?(e.enter(n),a(u)):t(u)}function a(u){return $e(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var w1={tokenize:LU};function LU(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"),Ve(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 k1={tokenize:MU},v1={tokenize:BU};function MU(e){let t=this,n=[],r=0,o,i,s;return a;function a(R){if(r<n.length){let z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,u,c)(R)}return c(R)}function u(R){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&k();let z=t.events.length,_=z,M;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){M=t.events[_][1].end;break}F(r);let B=z;for(;B<t.events.length;)t.events[B][1].end={...M},B++;return dn(t.events,_+1,0,t.events.slice(z)),t.events.length=B,c(R)}return a(R)}function c(R){if(r===n.length){if(!o)return f(R);if(o.currentConstruct&&o.currentConstruct.concrete)return g(R);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(v1,l,d)(R)}function l(R){return o&&k(),F(r),f(R)}function d(R){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,g(R)}function f(R){return t.containerState={},e.attempt(v1,p,g)(R)}function p(R){return r++,n.push([t.currentConstruct,t.containerState]),f(R)}function g(R){if(R===null){o&&k(),F(0),e.consume(R);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),S(R)}function S(R){if(R===null){C(e.exit("chunkFlow"),!0),F(0),e.consume(R);return}return ue(R)?(e.consume(R),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(R),S)}function C(R,z){let _=t.sliceStream(R);if(z&&_.push(null),R.previous=i,i&&(i.next=R),i=R,o.defineSkip(R.start),o.write(_),t.parser.lazy[R.start.line]){let M=o.events.length;for(;M--;)if(o.events[M][1].start.offset<s&&(!o.events[M][1].end||o.events[M][1].end.offset>s))return;let B=t.events.length,m=B,x,b;for(;m--;)if(t.events[m][0]==="exit"&&t.events[m][1].type==="chunkFlow"){if(x){b=t.events[m][1].end;break}x=!0}for(F(r),M=B;M<t.events.length;)t.events[M][1].end={...b},M++;dn(t.events,m+1,0,t.events.slice(B)),t.events.length=M}}function F(R){let z=n.length;for(;z-- >R;){let _=n[z];t.containerState=_[1],_[0].exit.call(t,e)}n.length=R}function k(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function BU(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ch(e){if(e===null||Wt(e)||S1(e))return 1;if(b1(e))return 2}function $i(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 ca={name:"attention",resolveAll:DU,tokenize:RU};function DU(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},f={...e[n][1].start};C1(d,-u),C1(f,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:f},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=Tn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Tn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Tn(c,$i(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Tn(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=Tn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,dn(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 RU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Ch(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=Ch(u),d=!l||l===2&&o||n.includes(u),f=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!f)),c._close=!!(i===42?f:f&&(l||!d)),t(u)}}function C1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Th={name:"autolink",tokenize:zU};function zU(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 Xn(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||an(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||an(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||aa(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):h1(p)?(e.consume(p),c):n(p)}function l(p){return an(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):f(p)}function f(p){if((p===45||an(p))&&r++<63){let g=p===45?f:d;return e.consume(p),g}return n(p)}}var Eo={partial:!0,tokenize:NU};function NU(e,t,n){return r;function r(i){return $e(i)?Ve(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var gc={continuation:{tokenize:_U},exit:$U,name:"blockQuote",tokenize:OU};function OU(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 $e(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function _U(e,t,n){let r=this;return o;function o(s){return $e(s)?Ve(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(gc,t,n)(s)}}function $U(e){e.exit("blockQuote")}var mc={name:"characterEscape",tokenize:UU};function UU(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return y1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var hc={name:"characterReference",tokenize:jU};function jU(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=an,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=x1,l):(e.enter("characterReferenceValue"),i=7,s=la,l(d))}function l(d){if(d===59&&o){let f=e.exit("characterReferenceValue");return s===an&&!_i(r.sliceSerialize(f))?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 T1={partial:!0,tokenize:WU},xc={concrete:!0,name:"codeFenced",tokenize:HU};function HU(e,t,n){let r=this,o={partial:!0,tokenize:_},i=0,s=0,a;return u;function u(M){return c(M)}function c(M){let B=r.events[r.events.length-1];return i=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,a=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(M)}function l(M){return M===a?(s++,e.consume(M),l):s<3?n(M):(e.exit("codeFencedFenceSequence"),$e(M)?Ve(e,d,"whitespace")(M):d(M))}function d(M){return M===null||ue(M)?(e.exit("codeFencedFence"),r.interrupt?t(M):e.check(T1,S,z)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(M))}function f(M){return M===null||ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(M)):$e(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(M)):M===96&&M===a?n(M):(e.consume(M),f)}function p(M){return M===null||ue(M)?d(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(M))}function g(M){return M===null||ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(M)):M===96&&M===a?n(M):(e.consume(M),g)}function S(M){return e.attempt(o,z,C)(M)}function C(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),F}function F(M){return i>0&&$e(M)?Ve(e,k,"linePrefix",i+1)(M):k(M)}function k(M){return M===null||ue(M)?e.check(T1,S,z)(M):(e.enter("codeFlowValue"),R(M))}function R(M){return M===null||ue(M)?(e.exit("codeFlowValue"),k(M)):(e.consume(M),R)}function z(M){return e.exit("codeFenced"),t(M)}function _(M,B,m){let x=0;return b;function b(v){return M.enter("lineEnding"),M.consume(v),M.exit("lineEnding"),E}function E(v){return M.enter("codeFencedFence"),$e(v)?Ve(M,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):h(v)}function h(v){return v===a?(M.enter("codeFencedFenceSequence"),T(v)):m(v)}function T(v){return v===a?(x++,M.consume(v),T):x>=s?(M.exit("codeFencedFenceSequence"),$e(v)?Ve(M,I,"whitespace")(v):I(v)):m(v)}function I(v){return v===null||ue(v)?(M.exit("codeFencedFence"),B(v)):m(v)}}}function WU(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 ua={name:"codeIndented",tokenize:GU},VU={partial:!0,tokenize:qU};function GU(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),Ve(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(VU,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 qU(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):Ve(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 Ih={name:"codeText",previous:KU,resolve:YU,tokenize:XU};function YU(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 KU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function XU(e,t,n){let r=this,o=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),o++,u):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(f))}function l(f){return f===null||f===32||f===96||ue(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",l(f))}}var yc=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&&pa(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),pa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),pa(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);pa(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);pa(this.left,n.reverse())}}};function pa(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 bc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new yc(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,QU(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 dn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function QU(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,f=-1,p=n,g=0,S=0,C=[S];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;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(S=f+1,C.push(S),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):C.pop(),f=C.length;f--;){let F=a.slice(C[f],C[f+1]),k=i.pop();u.push([k,k+F.length-1]),e.splice(k,2,F)}for(u.reverse(),f=-1;++f<u.length;)c[g+u[f][0]]=g+u[f][1],g+=u[f][1]-u[f][0]-1;return c}var Fh={resolve:ZU,tokenize:e3},JU={partial:!0,tokenize:t3};function ZU(e){return bc(e),e}function e3(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(JU,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 t3(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ve(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 Sc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return d;function d(F){return F===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(F),e.exit(i),f):F===null||F===32||F===41||aa(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),S(F))}function f(F){return F===62?(e.enter(i),e.consume(F),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(F))}function p(F){return F===62?(e.exit("chunkString"),e.exit(a),f(F)):F===null||F===60||ue(F)?n(F):(e.consume(F),F===92?g:p)}function g(F){return F===60||F===62||F===92?(e.consume(F),p):p(F)}function S(F){return!l&&(F===null||F===41||Wt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,S):F===41?(e.consume(F),l--,S):F===null||F===32||F===40||aa(F)?n(F):(e.consume(F),F===92?C:S)}function C(F){return F===40||F===41||F===92?(e.consume(F),S):S(F)}}function wc(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=!$e(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function vc(e,t,n,r,o,i){let s;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(o),e.consume(f),e.exit(o),s=f===40?41:f,u):n(f)}function u(f){return f===s?(e.enter(o),e.consume(f),e.exit(o),e.exit(r),t):(e.enter(i),c(f))}function c(f){return f===s?(e.exit(i),u(s)):f===null?n(f):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===s||f===null||ue(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:l)}function d(f){return f===s||f===92?(e.consume(f),l):l(f)}}function Jo(e,t){let n;return r;function r(o){return ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):$e(o)?Ve(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Eh={name:"definition",tokenize:r3},n3={partial:!0,tokenize:o3};function r3(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return wc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=Zr(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 Wt(p)?Jo(e,c)(p):c(p)}function c(p){return Sc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(n3,d,d)(p)}function d(p){return $e(p)?Ve(e,f,"whitespace")(p):f(p)}function f(p){return p===null||ue(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function o3(e,t,n){return r;function r(a){return Wt(a)?Jo(e,o)(a):n(a)}function o(a){return vc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return $e(a)?Ve(e,s,"whitespace")(a):s(a)}function s(a){return a===null||ue(a)?t(a):n(a)}}var Ah={name:"hardBreakEscape",tokenize:i3};function i3(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 Ph={name:"headingAtx",resolve:s3,tokenize:a3};function s3(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"},dn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function a3(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||Wt(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)):$e(l)?Ve(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||Wt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var I1=["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"],Lh=["pre","script","style","textarea"];var Mh={concrete:!0,name:"htmlFlow",resolveTo:u3,tokenize:p3},l3={partial:!0,tokenize:f3},c3={partial:!0,tokenize:d3};function u3(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 p3(e,t,n){let r=this,o,i,s,a,u;return c;function c(L){return l(L)}function l(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),i=!0,S):L===63?(e.consume(L),o=3,r.interrupt?t:w):Xn(L)?(e.consume(L),s=String.fromCharCode(L),C):n(L)}function f(L){return L===45?(e.consume(L),o=2,p):L===91?(e.consume(L),o=5,a=0,g):Xn(L)?(e.consume(L),o=4,r.interrupt?t:w):n(L)}function p(L){return L===45?(e.consume(L),r.interrupt?t:w):n(L)}function g(L){let K="CDATA[";return L===K.charCodeAt(a++)?(e.consume(L),a===K.length?r.interrupt?t:h:g):n(L)}function S(L){return Xn(L)?(e.consume(L),s=String.fromCharCode(L),C):n(L)}function C(L){if(L===null||L===47||L===62||Wt(L)){let K=L===47,ee=s.toLowerCase();return!K&&!i&&Lh.includes(ee)?(o=1,r.interrupt?t(L):h(L)):I1.includes(s.toLowerCase())?(o=6,K?(e.consume(L),F):r.interrupt?t(L):h(L)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):i?k(L):R(L))}return L===45||an(L)?(e.consume(L),s+=String.fromCharCode(L),C):n(L)}function F(L){return L===62?(e.consume(L),r.interrupt?t:h):n(L)}function k(L){return $e(L)?(e.consume(L),k):b(L)}function R(L){return L===47?(e.consume(L),b):L===58||L===95||Xn(L)?(e.consume(L),z):$e(L)?(e.consume(L),R):b(L)}function z(L){return L===45||L===46||L===58||L===95||an(L)?(e.consume(L),z):_(L)}function _(L){return L===61?(e.consume(L),M):$e(L)?(e.consume(L),_):R(L)}function M(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),u=L,B):$e(L)?(e.consume(L),M):m(L)}function B(L){return L===u?(e.consume(L),u=null,x):L===null||ue(L)?n(L):(e.consume(L),B)}function m(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Wt(L)?_(L):(e.consume(L),m)}function x(L){return L===47||L===62||$e(L)?R(L):n(L)}function b(L){return L===62?(e.consume(L),E):n(L)}function E(L){return L===null||ue(L)?h(L):$e(L)?(e.consume(L),E):n(L)}function h(L){return L===45&&o===2?(e.consume(L),A):L===60&&o===1?(e.consume(L),P):L===62&&o===4?(e.consume(L),j):L===63&&o===3?(e.consume(L),w):L===93&&o===5?(e.consume(L),N):ue(L)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(l3,G,T)(L)):L===null||ue(L)?(e.exit("htmlFlowData"),T(L)):(e.consume(L),h)}function T(L){return e.check(c3,I,G)(L)}function I(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),v}function v(L){return L===null||ue(L)?T(L):(e.enter("htmlFlowData"),h(L))}function A(L){return L===45?(e.consume(L),w):h(L)}function P(L){return L===47?(e.consume(L),s="",D):h(L)}function D(L){if(L===62){let K=s.toLowerCase();return Lh.includes(K)?(e.consume(L),j):h(L)}return Xn(L)&&s.length<8?(e.consume(L),s+=String.fromCharCode(L),D):h(L)}function N(L){return L===93?(e.consume(L),w):h(L)}function w(L){return L===62?(e.consume(L),j):L===45&&o===2?(e.consume(L),w):h(L)}function j(L){return L===null||ue(L)?(e.exit("htmlFlowData"),G(L)):(e.consume(L),j)}function G(L){return e.exit("htmlFlow"),t(L)}}function d3(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 f3(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Eo,t,n)}}var Bh={name:"htmlText",tokenize:g3};function g3(e,t,n){let r=this,o,i,s;return a;function a(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),u}function u(w){return w===33?(e.consume(w),c):w===47?(e.consume(w),_):w===63?(e.consume(w),R):Xn(w)?(e.consume(w),m):n(w)}function c(w){return w===45?(e.consume(w),l):w===91?(e.consume(w),i=0,g):Xn(w)?(e.consume(w),k):n(w)}function l(w){return w===45?(e.consume(w),p):n(w)}function d(w){return w===null?n(w):w===45?(e.consume(w),f):ue(w)?(s=d,P(w)):(e.consume(w),d)}function f(w){return w===45?(e.consume(w),p):d(w)}function p(w){return w===62?A(w):w===45?f(w):d(w)}function g(w){let j="CDATA[";return w===j.charCodeAt(i++)?(e.consume(w),i===j.length?S:g):n(w)}function S(w){return w===null?n(w):w===93?(e.consume(w),C):ue(w)?(s=S,P(w)):(e.consume(w),S)}function C(w){return w===93?(e.consume(w),F):S(w)}function F(w){return w===62?A(w):w===93?(e.consume(w),F):S(w)}function k(w){return w===null||w===62?A(w):ue(w)?(s=k,P(w)):(e.consume(w),k)}function R(w){return w===null?n(w):w===63?(e.consume(w),z):ue(w)?(s=R,P(w)):(e.consume(w),R)}function z(w){return w===62?A(w):R(w)}function _(w){return Xn(w)?(e.consume(w),M):n(w)}function M(w){return w===45||an(w)?(e.consume(w),M):B(w)}function B(w){return ue(w)?(s=B,P(w)):$e(w)?(e.consume(w),B):A(w)}function m(w){return w===45||an(w)?(e.consume(w),m):w===47||w===62||Wt(w)?x(w):n(w)}function x(w){return w===47?(e.consume(w),A):w===58||w===95||Xn(w)?(e.consume(w),b):ue(w)?(s=x,P(w)):$e(w)?(e.consume(w),x):A(w)}function b(w){return w===45||w===46||w===58||w===95||an(w)?(e.consume(w),b):E(w)}function E(w){return w===61?(e.consume(w),h):ue(w)?(s=E,P(w)):$e(w)?(e.consume(w),E):x(w)}function h(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),o=w,T):ue(w)?(s=h,P(w)):$e(w)?(e.consume(w),h):(e.consume(w),I)}function T(w){return w===o?(e.consume(w),o=void 0,v):w===null?n(w):ue(w)?(s=T,P(w)):(e.consume(w),T)}function I(w){return w===null||w===34||w===39||w===60||w===61||w===96?n(w):w===47||w===62||Wt(w)?x(w):(e.consume(w),I)}function v(w){return w===47||w===62||Wt(w)?x(w):n(w)}function A(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):n(w)}function P(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),D}function D(w){return $e(w)?Ve(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):N(w)}function N(w){return e.enter("htmlTextData"),s(w)}}var Zo={name:"labelEnd",resolveAll:y3,resolveTo:b3,tokenize:S3},m3={tokenize:w3},h3={tokenize:v3},x3={tokenize:k3};function y3(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&&dn(e,0,e.length,n),e}function b3(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=Tn(a,e.slice(i+1,i+r+3)),a=Tn(a,[["enter",l,t]]),a=Tn(a,$i(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Tn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Tn(a,e.slice(s+1)),a=Tn(a,[["exit",u,t]]),dn(e,i,e.length,a),e}function S3(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(f){return i?i._inactive?d(f):(s=r.parser.defined.includes(Zr(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),u):n(f)}function u(f){return f===40?e.attempt(m3,l,s?l:d)(f):f===91?e.attempt(h3,l,s?c:d)(f):s?l(f):d(f)}function c(f){return e.attempt(x3,l,d)(f)}function l(f){return t(f)}function d(f){return i._balanced=!0,n(f)}}function w3(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 Wt(d)?Jo(e,i)(d):i(d)}function i(d){return d===41?l(d):Sc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return Wt(d)?Jo(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?vc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return Wt(d)?Jo(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 v3(e,t,n){let r=this;return o;function o(a){return wc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Zr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function k3(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 Dh={name:"labelStartImage",resolveAll:Zo.resolveAll,tokenize:C3};function C3(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 Rh={name:"labelStartLink",resolveAll:Zo.resolveAll,tokenize:T3};function T3(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 da={name:"lineEnding",tokenize:I3};function I3(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}var ei={name:"thematicBreak",tokenize:F3};function F3(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"),$e(c)?Ve(e,a,"whitespace")(c):a(c))}}var yn={continuation:{tokenize:L3},exit:B3,name:"list",tokenize:P3},E3={partial:!0,tokenize:D3},A3={partial:!0,tokenize:M3};function P3(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 g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:la(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ei,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 la(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(Eo,r.interrupt?n:l,e.attempt(E3,f,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,f(p)}function d(p){return $e(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function L3(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Eo,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!$e(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(A3,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(yn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function M3(e,t,n){let r=this;return Ve(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 B3(e){e.exit(this.containerState.type)}function D3(e,t,n){let r=this;return Ve(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!$e(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var kc={name:"setextUnderline",resolveTo:R3,tokenize:z3};function R3(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 z3(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"),$e(c)?Ve(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var F1={tokenize:N3};function N3(e){let t=this,n=e.attempt(Eo,r,e.attempt(this.parser.constructs.flowInitial,o,Ve(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Fh,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 E1={resolveAll:M1()},A1=L1("string"),P1=L1("text");function L1(e){return{resolveAll:M1(e==="text"?O3: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],f=-1;if(d)for(;++f<d.length;){let p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function M1(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 O3(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],o=t.sliceStream(r),i=o.length,s=-1,a=0,u;for(;i--;){let c=o[i];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)u=!0,a++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){let c={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:r.start._bufferIndex+s,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}var zh={};ye(zh,{attentionMarkers:()=>G3,contentInitial:()=>$3,disable:()=>q3,document:()=>_3,flow:()=>j3,flowInitial:()=>U3,insideSpan:()=>V3,string:()=>H3,text:()=>W3});var _3={42:yn,43:yn,45:yn,48:yn,49:yn,50:yn,51:yn,52:yn,53:yn,54:yn,55:yn,56:yn,57:yn,62:gc},$3={91:Eh},U3={[-2]:ua,[-1]:ua,32:ua},j3={35:Ph,42:ei,45:[kc,ei],60:Mh,61:kc,95:ei,96:xc,126:xc},H3={38:hc,92:mc},W3={[-5]:da,[-4]:da,[-3]:da,33:Dh,38:hc,42:ca,60:[Th,Bh],91:Rh,92:[Ah,mc],93:Zo,95:ca,96:Ih},V3={null:[ca,E1]},G3={null:[42,95]},q3={null:[]};function B1(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:x(B),check:x(m),consume:z,enter:_,exit:M,interrupt:x(m,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:C,parser:e,previous:null,sliceSerialize:g,sliceStream:S,write:p},d=t.tokenize.call(l,c),f;return t.resolveAll&&i.push(t),l;function p(T){return s=Tn(s,T),k(),s[s.length-1]!==null?[]:(b(t,0),l.events=$i(i,l.events,l),l.events)}function g(T,I){return K3(S(T),I)}function S(T){return Y3(s,T)}function C(){let{_bufferIndex:T,_index:I,line:v,column:A,offset:P}=r;return{_bufferIndex:T,_index:I,line:v,column:A,offset:P}}function F(T){o[T.line]=T.column,h()}function k(){let T;for(;r._index<s.length;){let I=s[r._index];if(typeof I=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<I.length;)R(I.charCodeAt(r._bufferIndex));else R(I)}}function R(T){u=void 0,f=T,d=d(T)}function z(T){ue(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,h()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T,u=!0}function _(T,I){let v=I||{};return v.type=T,v.start=C(),l.events.push(["enter",v,l]),a.push(v),v}function M(T){let I=a.pop();return I.end=C(),l.events.push(["exit",I,l]),I}function B(T,I){b(T,I.from)}function m(T,I){I.restore()}function x(T,I){return v;function v(A,P,D){let N,w,j,G;return Array.isArray(A)?K(A):"tokenize"in A?K([A]):L(A);function L(ae){return qe;function qe(tt){let se=tt!==null&&ae[tt],pe=tt!==null&&ae.null,Ie=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return K(Ie)(tt)}}function K(ae){return N=ae,w=0,ae.length===0?D:ee(ae[w])}function ee(ae){return qe;function qe(tt){return G=E(),j=ae,ae.partial||(l.currentConstruct=ae),ae.name&&l.parser.constructs.disable.null.includes(ae.name)?de(tt):ae.tokenize.call(I?Object.assign(Object.create(l),I):l,c,re,de)(tt)}}function re(ae){return u=!0,T(j,G),P}function de(ae){return u=!0,G.restore(),++w<N.length?ee(N[w]):D}}}function b(T,I){T.resolveAll&&!i.includes(T)&&i.push(T),T.resolve&&dn(l.events,I,l.events.length-I,T.resolve(l.events.slice(I),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function E(){let T=C(),I=l.previous,v=l.currentConstruct,A=l.events.length,P=Array.from(a);return{from:A,restore:D};function D(){r=T,l.previous=I,l.currentConstruct=v,l.events.length=A,a=P,h()}}function h(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function Y3(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 K3(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
|
+
`,Cne=jt.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${r4} 0.8s linear infinite`,flexShrink:0})),FC=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),o4=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#dcfce7",fontSize:"12px",fontWeight:700,color:"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"}),Tne=jt.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:`${n4} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var zi=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),ta=jt.span(({color:e="#6b7280"})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:e,whiteSpace:"nowrap"})),EC=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),na=jt.span(({color:e})=>({fontWeight:700,color:e})),i4=jt.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"12px",backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:"12px",color:t.textMutedColor},"& .score-value":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:"20px",fontWeight:700,color:e,lineHeight:1},"& .score-dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:e}})),Ine=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Fne=jt.span(({color:e=le})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${Z$} 1.2s ease-in-out infinite`,marginRight:"4px"})),Ene=jt.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return le;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 le;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${t4} 1.5s ease-in-out infinite`}:{}})),Ane=jt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Pne=jt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),s4=jt.button(({theme:e,isExporting:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",fontSize:"11px",fontWeight:600,color:t?e.color.mediumdark:"#7c3aed",backgroundColor:t?e.background.hoverable:"#ede9fe",border:"none",borderRadius:"12px",cursor:t?"not-allowed":"pointer",transition:"all 0.2s",whiteSpace:"nowrap","&:hover":{backgroundColor:t?e.background.hoverable:"#ddd6fe"}})),a4=jt.span({display:"inline-block",width:"10px",height:"10px",border:"2px solid #c4b5fd",borderTopColor:"#7c3aed",borderRadius:"50%",animation:"export-spin 0.8s linear infinite","@keyframes export-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),l4=jt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${e4} 1.2s linear infinite`,flexShrink:0}),c4=({color:e=le})=>ke.createElement(l4,null,ke.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 ke.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Lne=jt.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:`${AC} 0.3s ease-out`}));function u4(e){let[t,n]=Q$(0);return J$(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var PC=({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:f})=>{let d=u4(e||t),{exportPDF:m,isExporting:w}=cm(),{featureFlags:k}=se(),F=k.showCosts,C=3.65,z=g=>g<.01?`$${g.toFixed(4)}`:g<.1?`$${g.toFixed(3)}`:`$${g.toFixed(2)}`,R=g=>{let x=g*C;return x<.01?`\u20AA${x.toFixed(4)}`:x<.1?`\u20AA${x.toFixed(3)}`:`\u20AA${x.toFixed(2)}`},O=g=>g>=1e3?`${(g/1e3).toFixed(1)}K`:g.toString(),L=g=>g>=80?"score-high":g>=50?"score-medium":"score-low",B=g=>g>=80?"high":g>=50?"medium":"low";if(e)return ke.createElement(rh,null,ke.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},d,"s \xB7 Esc to stop"));if(t)return ke.createElement(rh,null,ke.createElement(FC,null,ke.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ke.createElement(zi,null,"|"),ke.createElement(ta,null,ke.createElement(c4,{color:"#7c3aed"}),ke.createElement(na,{color:"#7c3aed"},"Verifying...")),c&&ke.createElement(ke.Fragment,null,ke.createElement(zi,null,"|"),ke.createElement(ta,null,ke.createElement("span",{style:{color:"#6b7280"}},d,"s"))));if(r>0||o!==void 0){let g=(a||0)+(u||0),x=(p||0)>0,b=x&&a?Math.round(p/a*100):0,E=Math.max(o??0,i??0),h=I=>I>=80?"#16a34a":I>=50?"#ca8a04":"#dc2626",T=I=>I>=100?"\u25CF":I>=50?"\u25D0":"\u25CB";return ke.createElement(rh,null,r===0?ke.createElement(o4,null,ke.createElement("span",null,"\u2713"),"Perfect!"):ke.createElement(FC,null,ke.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ke.createElement(i4,{tint:h(E),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},ke.createElement("span",{className:"score-dot"}),ke.createElement("span",{className:"score-label"},"Score"),ke.createElement("span",{className:"score-value"},E)),F&&s!==void 0&&s>0&&ke.createElement(ke.Fragment,null,ke.createElement(zi,null,"|"),ke.createElement(ta,null,ke.createElement(na,{color:"#16a34a"},z(s)),ke.createElement("span",{style:{color:"#6b7280"}},"/"),ke.createElement(na,{color:"#16a34a"},R(s)))),F&&g>0&&ke.createElement(ke.Fragment,null,ke.createElement(zi,null,"|"),ke.createElement(ta,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${x?` \xB7 Cached: ${p?.toLocaleString()}`:""}`},ke.createElement(EC,{color:"#7c3aed"},"#"),ke.createElement(na,{color:"#7c3aed"},O(g)),ke.createElement("span",{style:{color:"#6b7280"}},"tokens"),x&&ke.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",b,"%"))),f!==void 0&&f>0&&ke.createElement(ke.Fragment,null,ke.createElement(zi,null,"|"),ke.createElement(ta,null,ke.createElement(EC,{color:"#6b7280"},"\u23F1"),ke.createElement(na,{color:"#6b7280"},f,"s"))),ke.createElement(zi,null,"|"),ke.createElement(s4,{onClick:m,disabled:w,isExporting:w,title:"Download design review report as PDF"},w?ke.createElement(ke.Fragment,null,ke.createElement(a4,null),"Exporting..."):ke.createElement(ke.Fragment,null,"\u2193 Report")))}return null};var m4=Cn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),$ne=Cn.div({display:"flex",gap:"8px",alignItems:"center"}),h4=g4({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),x4=Cn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${h4} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),y4=Cn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),b4=Cn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"16px",padding:"14px 18px",borderRadius:"14px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02)",flexWrap:"wrap"})),S4=Cn.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:Ma},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:"#ffffff",border:"none",padding:"12px 24px",fontSize:"14px",fontWeight:600,borderRadius:"10px",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)`}}}),w4=Cn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),v4=Cn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),k4=Cn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),C4=Cn(En)({width:"auto",minWidth:"200px"}),T4=Cn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),LC=Cn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),MC=Cn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?Ma:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),BC=Cn.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)"})),DC=Cn.input({position:"absolute",opacity:0,width:0,height:0}),I4=()=>{let[e,t]=d4(0),n=f4();RC(()=>(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)},oh=()=>{let{sessionToken:e}=Bs(),{usageData:t}=Se(),{selectedProjectId:n}=qr(),{currentMapping:r,hasMapping:o}=Ho(),{loadingMapping:i,currentStoryId:s}=rt(),{startReview:a,cancelReview:u,isReviewing:c}=Jg(),{isLoadingScreenshots:l}=Uo(),{storybookImageUrl:p,figmaImageUrl:f,currentReviewId:d,reviewHistory:m,setReviewDetailTab:w,setReviewResults:k,setFigmaImageUrl:F,setStorybookImageUrl:C,setFullPrompt:z,setFullResponse:R,includeTextComparison:O,setIncludeTextComparison:L,usePromptCache:B,setUsePromptCache:g,isValidating:x,validationUsage:b,isGenerating:E,isApplying:h,streamingStatus:T,featureFlags:I,userRole:v,roleOverride:A,isReviewing:P}=se(),D=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=m.find(fe=>fe.id===d),j=(N?.issues||[]).filter(fe=>!fe.dismissed).length,G=N?.complianceScore,M=N?.visualSimilarity,J=(N?.costUsd||0)+(b?.costUsd||0),Z=(N?.inputTokens||0)+(b?.inputTokens||0),oe=(N?.outputTokens||0)+(b?.outputTokens||0),pe=p4(()=>{let fe=s?m.filter(re=>re.storyId===s):m,vt=fe.filter(re=>!re.parentReviewId).sort((re,W)=>new Date(W.createdAt).getTime()-new Date(re.createdAt).getTime()),Ge=fe.filter(re=>re.parentReviewId),lt=[];for(let re of vt){lt.push(re);let W=Ge.filter(Fe=>Fe.parentReviewId===re.id).sort((Fe,me)=>(Fe.iterationNumber||0)-(me.iterationNumber||0));lt.push(...W)}let nt=Ge.filter(re=>!vt.some(W=>W.id===re.parentReviewId));return lt.push(...nt),lt},[m,s]);RC(()=>{if(!c)return;let fe=vt=>{vt.key==="Escape"&&(vt.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let ae=o&&r?.figmaNodeId,qe=E||h,tt=!!(e&&n&&!c&&!l&&!qe&&s&&p&&ae&&f),Ve=async(fe=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{w("chat"),await a({isIteration:fe,parentReviewId:fe?d:void 0})}catch(vt){console.error("[ReviewActions] Review error:",vt)}},te=()=>Ve(!1),Be=fe=>{let vt=fe.target.value;if(vt){let Ge=m.find(lt=>lt.id===vt);Ge&&(k({id:Ge.id,componentId:Ge.componentId,storyId:Ge.storyId,modelId:Ge.modelId,complianceScore:Ge.complianceScore,issuesCount:Ge.issuesCount,issues:Ge.issues,createdAt:new Date(Ge.createdAt),visualSimilarity:Ge.visualSimilarity,timestamp:new Date(Ge.createdAt).toISOString()}),Ge.figmaImageData&&F(Ge.figmaImageData),Ge.storybookImageData&&C(Ge.storybookImageData),(A??v)==="admin"&&(z(Ge.aiPrompt||""),R(Ge.aiResponse||"")),w("issues"))}},Le=fe=>{let vt=new Date(fe),lt=new Date().getTime()-vt.getTime(),nt=Math.floor(lt/6e4),re=Math.floor(lt/36e5),W=Math.floor(lt/864e5);return nt<1?"Just now":nt<60?`${nt}m ago`:re<24?`${re}h ago`:W<7?`${W}d ago`:vt.toLocaleDateString()},de=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]||"":"",Et=fe=>{let vt=fe.split("--"),Ge=vt[vt.length-1]||fe;return Ge.charAt(0).toUpperCase()+Ge.slice(1)};return ft.createElement("div",null,ft.createElement(m4,null,I.enableModelSelection&&ft.createElement(IC,null),ft.createElement(T4,null,ft.createElement(LC,{title:"Compare text content between Figma design and Storybook component"},ft.createElement(DC,{type:"checkbox",checked:O,onChange:fe=>L(fe.target.checked)}),ft.createElement(MC,{checked:O},ft.createElement(BC,{checked:O})),"Compare text"),I.showCosts&&ft.createElement(LC,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ft.createElement(DC,{type:"checkbox",checked:B,onChange:fe=>g(fe.target.checked)}),ft.createElement(MC,{checked:B},ft.createElement(BC,{checked:B})),"Cache prompt")),ft.createElement(b4,null,ft.createElement(S4,{variant:c?"yellow":"purple",disabled:c?!1:!tt,onClick:c?u:te,title:c?"Click to stop review":e?n?s?ae?l?"Loading screenshots...":qe?"Wait for fixes to complete...":p?f?"Review this component implementation":"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 UI Copilot first"},c?ft.createElement(ft.Fragment,null,ft.createElement(x4,null),"Reviewing",ft.createElement(I4,null)):ft.createElement(ft.Fragment,null,ft.createElement(y4,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")),P?null:x||N?ft.createElement(PC,{isReviewing:!1,isValidating:x,streamingStatus:T,issueCount:j,score:G,visualSimilarity:M,costUsd:J||N?.costUsd,inputTokens:Z||N?.inputTokens,outputTokens:oe||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,pe.length>0&&ft.createElement(v4,null,ft.createElement(k4,null,"Review History"),ft.createElement(C4,{value:d||"",onChange:Be},ft.createElement("option",{value:""},"Select a review..."),pe.map(fe=>{let vt=!!fe.parentReviewId,Ge=vt?" \u21B3 ":"\u25CF ",lt=vt&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",nt=fe.issuesCount??fe.issues?.length??0,re=fe.complianceScore??"--",W=de(fe.modelId);return ft.createElement("option",{key:fe.id,value:fe.id},Ge,lt,Le(fe.createdAt)," - ",nt," issues (",re,"%)",W?` \xB7 ${W}`:"",fe.storyId?` \xB7 ${Et(fe.storyId)}`:"")}))))),!ae&&!i&&ft.createElement(w4,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import Hne,{useState as Wne}from"react";import{styled as zC}from"storybook/theming";var qne=zC.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Yne=zC(io)({padding:"8px 12px",fontSize:"12px"});import Qne,{useState as Jne}from"react";import{styled as ih}from"storybook/theming";we();Ue();De();pt();var ire=ih.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),sre=ih(Er)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),are=ih.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import ure from"react";import{styled as F4}from"storybook/theming";var fre=F4.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));we();import hre from"react";import{styled as Rr}from"storybook/theming";var bre=Rr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),Sre=Rr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),wre=Rr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),vre=Rr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),kre=Rr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Cre=Rr.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"})),Tre=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Ire=Rr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),Fre=Rr.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)"}}})),Ere=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));we();import Lre,{useState as Mre}from"react";import{styled as zr}from"storybook/theming";var Rre=zr.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)`}}),zre=zr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Nre=zr.div({display:"flex",alignItems:"center",gap:"8px"}),Ore=zr.span({fontSize:"12px",opacity:.7}),_re=zr.span({fontSize:"13px",fontWeight:500}),$re=zr.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})),Ure=zr.div({marginTop:"12px",fontSize:"11px"}),jre=zr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),Hre=zr.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"})),Wre=zr.span({fontSize:"12px"});De();Ue();import Xt from"react";import{styled as Qi}from"storybook/theming";import Tr,{useEffect as gW}from"react";import{styled as ba}from"storybook/theming";we();import ni,{useState as H5}from"react";import{styled as Wi}from"storybook/theming";var NC={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 OC(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var E4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P4={};function sc(e,t){return((t||P4).jsx?A4:E4).test(e)}var L4=/[ \t\n\f\r]/g;function sh(e){return typeof e=="object"?e.type==="text"?_C(e.value):!1:_C(e)}function _C(e){return e.replace(L4,"")===""}var Jr=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Jr.prototype.normal={};Jr.prototype.property={};Jr.prototype.space=void 0;function ah(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Jr(n,r,t)}function ra(e){return e.toLowerCase()}var sn=class{constructor(t,n){this.attribute=n,this.property=t}};sn.prototype.attribute="";sn.prototype.booleanish=!1;sn.prototype.boolean=!1;sn.prototype.commaOrSpaceSeparated=!1;sn.prototype.commaSeparated=!1;sn.prototype.defined=!1;sn.prototype.mustUseProperty=!1;sn.prototype.number=!1;sn.prototype.overloadedBoolean=!1;sn.prototype.property="";sn.prototype.spaceSeparated=!1;sn.prototype.space=void 0;var oa={};xe(oa,{boolean:()=>He,booleanish:()=>Nt,commaOrSpaceSeparated:()=>_n,commaSeparated:()=>To,number:()=>Y,overloadedBoolean:()=>ac,spaceSeparated:()=>St});var M4=0,He=Ko(),Nt=Ko(),ac=Ko(),Y=Ko(),St=Ko(),To=Ko(),_n=Ko();function Ko(){return 2**++M4}var lh=Object.keys(oa),Xo=class extends sn{constructor(t,n,r,o){let i=-1;if(super(t,n),$C(this,"space",o),typeof r=="number")for(;++i<lh.length;){let s=lh[i];$C(this,lh[i],(r&oa[s])===oa[s])}}};Xo.prototype.defined=!0;function $C(e,t,n){n&&(e[t]=n)}function ur(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new Xo(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ra(r)]=r,n[ra(i.attribute)]=r}return new Jr(t,n,e.space)}var ch=ur({properties:{ariaActiveDescendant:null,ariaAtomic:Nt,ariaAutoComplete:null,ariaBusy:Nt,ariaChecked:Nt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:St,ariaCurrent:null,ariaDescribedBy:St,ariaDetails:null,ariaDisabled:Nt,ariaDropEffect:St,ariaErrorMessage:null,ariaExpanded:Nt,ariaFlowTo:St,ariaGrabbed:Nt,ariaHasPopup:null,ariaHidden:Nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:St,ariaLevel:Y,ariaLive:null,ariaModal:Nt,ariaMultiLine:Nt,ariaMultiSelectable:Nt,ariaOrientation:null,ariaOwns:St,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:Nt,ariaReadOnly:Nt,ariaRelevant:null,ariaRequired:Nt,ariaRoleDescription:St,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:Nt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function lc(e,t){return t in e?e[t]:t}function cc(e,t){return lc(e,t.toLowerCase())}var UC=ur({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:To,acceptCharset:St,accessKey:St,action:null,allow:null,allowFullScreen:He,allowPaymentRequest:He,allowUserMedia:He,alt:null,as:null,async:He,autoCapitalize:null,autoComplete:St,autoFocus:He,autoPlay:He,blocking:St,capture:null,charSet:null,checked:He,cite:null,className:St,cols:Y,colSpan:null,content:null,contentEditable:Nt,controls:He,controlsList:St,coords:Y|To,crossOrigin:null,data:null,dateTime:null,decoding:null,default:He,defer:He,dir:null,dirName:null,disabled:He,download:ac,draggable:Nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:He,formTarget:null,headers:St,height:Y,hidden:ac,high:Y,href:null,hrefLang:null,htmlFor:St,httpEquiv:St,id:null,imageSizes:null,imageSrcSet:null,inert:He,inputMode:null,integrity:null,is:null,isMap:He,itemId:null,itemProp:St,itemRef:St,itemScope:He,itemType:St,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:He,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:He,muted:He,name:null,nonce:null,noModule:He,noValidate:He,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:He,optimum:Y,pattern:null,ping:St,placeholder:null,playsInline:He,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:He,referrerPolicy:null,rel:St,required:He,reversed:He,rows:Y,rowSpan:Y,sandbox:St,scope:null,scoped:He,seamless:He,selected:He,shadowRootClonable:He,shadowRootDelegatesFocus:He,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:Nt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:He,useMap:null,value:Nt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:St,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:He,declare:He,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:He,noHref:He,noShade:He,noWrap:He,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:Nt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:He,disableRemotePlayback:He,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:cc});var jC=ur({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:_n,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:St,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:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:He,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,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:To,g2:To,glyphName:To,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,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:Y,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:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:St,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,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:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lc});var uh=ur({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 ph=ur({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cc});var dh=ur({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var fh={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 B4=/[A-Z]/g,HC=/-[a-z]/g,D4=/^data[-\w.:]+$/i;function gh(e,t){let n=ra(t),r=t,o=sn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&D4.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(HC,z4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!HC.test(i)){let s=i.replace(B4,R4);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=Xo}return new o(r,t)}function R4(e){return"-"+e.toLowerCase()}function z4(e){return e.charAt(1).toUpperCase()}var WC=ah([ch,UC,uh,ph,dh],"html"),uc=ah([ch,jC,uh,ph,dh],"svg");function VC(e){return e.join(" ").trim()}var s1=La(n1(),1);var dc=r1("end"),Oi=r1("start");function r1(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 xh(e){let t=Oi(e),n=dc(e);if(t&&n)return{start:t,end:n}}function Io(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?o1(e.position):"start"in e||"end"in e?o1(e):"line"in e||"column"in e?yh(e):""}function yh(e){return i1(e&&e.line)+":"+i1(e&&e.column)}function o1(e){return yh(e&&e.start)+"-"+yh(e&&e.end)}function i1(e){return e&&typeof e=="number"?e:1}var Ht=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=Io(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}};Ht.prototype.file="";Ht.prototype.name="";Ht.prototype.reason="";Ht.prototype.message="";Ht.prototype.stack="";Ht.prototype.column=void 0;Ht.prototype.line=void 0;Ht.prototype.ancestors=void 0;Ht.prototype.cause=void 0;Ht.prototype.fatal=void 0;Ht.prototype.place=void 0;Ht.prototype.ruleId=void 0;Ht.prototype.source=void 0;var bh={}.hasOwnProperty,lU=new Map,cU=/[A-Z]/g,uU=new Set(["table","tbody","thead","tfoot","tr"]),pU=new Set(["td","th"]),a1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sh(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=bU(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=yU(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"?uc:WC,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=l1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function l1(e,t,n){if(t.type==="element")return dU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return fU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return mU(e,t,n);if(t.type==="mdxjsEsm")return gU(e,t);if(t.type==="root")return hU(e,t,n);if(t.type==="text")return xU(e,t)}function dU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=uc,e.schema=o),e.ancestors.push(t);let i=u1(e,t.tagName,!1),s=SU(e,t),a=vh(e,t);return uU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!sh(u):!0})),c1(e,s,i,t),wh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function fU(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)}sa(e,t.position)}function gU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sa(e,t.position)}function mU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=uc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:u1(e,t.name,!0),s=wU(e,t),a=vh(e,t);return c1(e,s,i,t),wh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function hU(e,t,n){let r={};return wh(r,vh(e,t)),e.create(t,e.Fragment,r,n)}function xU(e,t){return t.value}function c1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function yU(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 bU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Oi(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 SU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&bh.call(t.properties,o)){let i=vU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&pU.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 wU(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 sa(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 sa(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function vh(e,t){let n=[],r=-1,o=e.passKeys?new Map:lU;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=l1(e,i,s);a!==void 0&&n.push(a)}return n}function vU(e,t,n){let r=gh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?OC(n):VC(n)),r.property==="style"){let o=typeof n=="object"?n:kU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=CU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?fh[r.property]||r.property:r.attribute,n]}}function kU(e,t){try{return(0,s1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Ht("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=a1+"#cannot-parse-style-attribute",o}}function u1(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=sc(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=sc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return bh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);sa(e)}function sa(e,t){let n=new Ht("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=a1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function CU(e){let t={},n;for(n in e)bh.call(e,n)&&(t[TU(n)]=e[n]);return t}function TU(e){let t=e.replace(cU,IU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function IU(e){return"-"+e.toLowerCase()}var aa={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 D5,jsx as R5,jsxs as z5}from"react/jsx-runtime";import{useEffect as npe,useState as rpe}from"react";var FU={};function kh(e,t){let n=t||FU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return d1(e,r,o)}function d1(e,t,n){if(EU(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 p1(e.children,t,n)}return Array.isArray(e)?p1(e,t,n):""}function p1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=d1(e[o],t,n);return r.join("")}function EU(e){return!!(e&&typeof e=="object")}var f1=document.createElement("i");function _i(e){let t="&"+e+";";f1.innerHTML=t;let n=f1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(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 Tn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}var g1={}.hasOwnProperty;function m1(e){let t={},n=-1;for(;++n<e.length;)AU(t,e[n]);return t}function AU(e,t){let n;for(n in t){let o=(g1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){g1.call(o,s)||(o[s]=[]);let a=i[s];PU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function PU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function fc(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 Zr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Xn=Fo(/[A-Za-z]/),an=Fo(/[\dA-Za-z]/),h1=Fo(/[#-'*+\--9=?A-Z^-~]/);function la(e){return e!==null&&(e<32||e===127)}var ca=Fo(/\d/),x1=Fo(/[\dA-Fa-f]/),y1=Fo(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function _e(e){return e===-2||e===-1||e===32}var b1=Fo(/\p{P}|\p{S}/u),S1=Fo(/\s/);function Fo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&an(e.charCodeAt(n+1))&&an(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 We(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return _e(u)?(e.enter(n),a(u)):t(u)}function a(u){return _e(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var w1={tokenize:LU};function LU(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"),We(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 k1={tokenize:MU},v1={tokenize:BU};function MU(e){let t=this,n=[],r=0,o,i,s;return a;function a(z){if(r<n.length){let R=n[r];return t.containerState=R[1],e.attempt(R[0].continuation,u,c)(z)}return c(z)}function u(z){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&C();let R=t.events.length,O=R,L;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){L=t.events[O][1].end;break}F(r);let B=R;for(;B<t.events.length;)t.events[B][1].end={...L},B++;return dn(t.events,O+1,0,t.events.slice(R)),t.events.length=B,c(z)}return a(z)}function c(z){if(r===n.length){if(!o)return f(z);if(o.currentConstruct&&o.currentConstruct.concrete)return m(z);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(v1,l,p)(z)}function l(z){return o&&C(),F(r),f(z)}function p(z){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(z)}function f(z){return t.containerState={},e.attempt(v1,d,m)(z)}function d(z){return r++,n.push([t.currentConstruct,t.containerState]),f(z)}function m(z){if(z===null){o&&C(),F(0),e.consume(z);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),w(z)}function w(z){if(z===null){k(e.exit("chunkFlow"),!0),F(0),e.consume(z);return}return ue(z)?(e.consume(z),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(z),w)}function k(z,R){let O=t.sliceStream(z);if(R&&O.push(null),z.previous=i,i&&(i.next=z),i=z,o.defineSkip(z.start),o.write(O),t.parser.lazy[z.start.line]){let L=o.events.length;for(;L--;)if(o.events[L][1].start.offset<s&&(!o.events[L][1].end||o.events[L][1].end.offset>s))return;let B=t.events.length,g=B,x,b;for(;g--;)if(t.events[g][0]==="exit"&&t.events[g][1].type==="chunkFlow"){if(x){b=t.events[g][1].end;break}x=!0}for(F(r),L=B;L<t.events.length;)t.events[L][1].end={...b},L++;dn(t.events,g+1,0,t.events.slice(B)),t.events.length=L}}function F(z){let R=n.length;for(;R-- >z;){let O=n[R];t.containerState=O[1],O[0].exit.call(t,e)}n.length=z}function C(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function BU(e,t,n){return We(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ch(e){if(e===null||Wt(e)||S1(e))return 1;if(b1(e))return 2}function $i(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 ua={name:"attention",resolveAll:DU,tokenize:RU};function DU(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},f={...e[n][1].start};C1(p,-u),C1(f,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:f},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=Tn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Tn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Tn(c,$i(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Tn(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=Tn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,dn(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 RU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Ch(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=Ch(u),p=!l||l===2&&o||n.includes(u),f=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?p:p&&(o||!f)),c._close=!!(i===42?f:f&&(l||!p)),t(u)}}function C1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Th={name:"autolink",tokenize:zU};function zU(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 Xn(d)?(e.consume(d),s):d===64?n(d):c(d)}function s(d){return d===43||d===45||d===46||an(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||an(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||la(d)?n(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),l):h1(d)?(e.consume(d),c):n(d)}function l(d){return an(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):f(d)}function f(d){if((d===45||an(d))&&r++<63){let m=d===45?f:p;return e.consume(d),m}return n(d)}}var Eo={partial:!0,tokenize:NU};function NU(e,t,n){return r;function r(i){return _e(i)?We(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var gc={continuation:{tokenize:_U},exit:$U,name:"blockQuote",tokenize:OU};function OU(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 _e(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function _U(e,t,n){let r=this;return o;function o(s){return _e(s)?We(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(gc,t,n)(s)}}function $U(e){e.exit("blockQuote")}var mc={name:"characterEscape",tokenize:UU};function UU(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return y1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var hc={name:"characterReference",tokenize:jU};function jU(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=an,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=x1,l):(e.enter("characterReferenceValue"),i=7,s=ca,l(p))}function l(p){if(p===59&&o){let f=e.exit("characterReferenceValue");return s===an&&!_i(r.sliceSerialize(f))?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 T1={partial:!0,tokenize:WU},xc={concrete:!0,name:"codeFenced",tokenize:HU};function HU(e,t,n){let r=this,o={partial:!0,tokenize:O},i=0,s=0,a;return u;function u(L){return c(L)}function c(L){let B=r.events[r.events.length-1];return i=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,a=L,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(L)}function l(L){return L===a?(s++,e.consume(L),l):s<3?n(L):(e.exit("codeFencedFenceSequence"),_e(L)?We(e,p,"whitespace")(L):p(L))}function p(L){return L===null||ue(L)?(e.exit("codeFencedFence"),r.interrupt?t(L):e.check(T1,w,R)(L)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(L))}function f(L){return L===null||ue(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(L)):_e(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),We(e,d,"whitespace")(L)):L===96&&L===a?n(L):(e.consume(L),f)}function d(L){return L===null||ue(L)?p(L):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(L))}function m(L){return L===null||ue(L)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(L)):L===96&&L===a?n(L):(e.consume(L),m)}function w(L){return e.attempt(o,R,k)(L)}function k(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),F}function F(L){return i>0&&_e(L)?We(e,C,"linePrefix",i+1)(L):C(L)}function C(L){return L===null||ue(L)?e.check(T1,w,R)(L):(e.enter("codeFlowValue"),z(L))}function z(L){return L===null||ue(L)?(e.exit("codeFlowValue"),C(L)):(e.consume(L),z)}function R(L){return e.exit("codeFenced"),t(L)}function O(L,B,g){let x=0;return b;function b(v){return L.enter("lineEnding"),L.consume(v),L.exit("lineEnding"),E}function E(v){return L.enter("codeFencedFence"),_e(v)?We(L,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):h(v)}function h(v){return v===a?(L.enter("codeFencedFenceSequence"),T(v)):g(v)}function T(v){return v===a?(x++,L.consume(v),T):x>=s?(L.exit("codeFencedFenceSequence"),_e(v)?We(L,I,"whitespace")(v):I(v)):g(v)}function I(v){return v===null||ue(v)?(L.exit("codeFencedFence"),B(v)):g(v)}}}function WU(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 pa={name:"codeIndented",tokenize:GU},VU={partial:!0,tokenize:qU};function GU(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),We(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(VU,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 qU(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):We(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 Ih={name:"codeText",previous:KU,resolve:YU,tokenize:XU};function YU(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 KU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function XU(e,t,n){let r=this,o=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),o++,u):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,p(f)):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(f))}function l(f){return f===null||f===32||f===96||ue(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),l)}function p(f){return f===96?(e.consume(f),i++,p):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",l(f))}}var yc=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&&da(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),da(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),da(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);da(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);da(this.left,n.reverse())}}};function da(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 bc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new yc(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,QU(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 dn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function QU(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,f=-1,d=n,m=0,w=0,k=[w];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;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(w=f+1,k.push(w),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(s.events=[],d?(d._tokenizer=void 0,d.previous=void 0):k.pop(),f=k.length;f--;){let F=a.slice(k[f],k[f+1]),C=i.pop();u.push([C,C+F.length-1]),e.splice(C,2,F)}for(u.reverse(),f=-1;++f<u.length;)c[m+u[f][0]]=m+u[f][1],m+=u[f][1]-u[f][0]-1;return c}var Fh={resolve:ZU,tokenize:e3},JU={partial:!0,tokenize:t3};function ZU(e){return bc(e),e}function e3(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(JU,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 t3(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),We(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 Sc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return p;function p(F){return F===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(F),e.exit(i),f):F===null||F===32||F===41||la(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),w(F))}function f(F){return F===62?(e.enter(i),e.consume(F),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(F))}function d(F){return F===62?(e.exit("chunkString"),e.exit(a),f(F)):F===null||F===60||ue(F)?n(F):(e.consume(F),F===92?m:d)}function m(F){return F===60||F===62||F===92?(e.consume(F),d):d(F)}function w(F){return!l&&(F===null||F===41||Wt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,w):F===41?(e.consume(F),l--,w):F===null||F===32||F===40||la(F)?n(F):(e.consume(F),F===92?k:w)}function k(F){return F===40||F===41||F===92?(e.consume(F),w):w(F)}}function wc(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=!_e(d)),d===92?f:p)}function f(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function vc(e,t,n,r,o,i){let s;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(o),e.consume(f),e.exit(o),s=f===40?41:f,u):n(f)}function u(f){return f===s?(e.enter(o),e.consume(f),e.exit(o),e.exit(r),t):(e.enter(i),c(f))}function c(f){return f===s?(e.exit(i),u(s)):f===null?n(f):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),We(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===s||f===null||ue(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?p:l)}function p(f){return f===s||f===92?(e.consume(f),l):l(f)}}function Jo(e,t){let n;return r;function r(o){return ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):_e(o)?We(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Eh={name:"definition",tokenize:r3},n3={partial:!0,tokenize:o3};function r3(e,t,n){let r=this,o;return i;function i(d){return e.enter("definition"),s(d)}function s(d){return wc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return o=Zr(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 Wt(d)?Jo(e,c)(d):c(d)}function c(d){return Sc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function l(d){return e.attempt(n3,p,p)(d)}function p(d){return _e(d)?We(e,f,"whitespace")(d):f(d)}function f(d){return d===null||ue(d)?(e.exit("definition"),r.parser.defined.push(o),t(d)):n(d)}}function o3(e,t,n){return r;function r(a){return Wt(a)?Jo(e,o)(a):n(a)}function o(a){return vc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return _e(a)?We(e,s,"whitespace")(a):s(a)}function s(a){return a===null||ue(a)?t(a):n(a)}}var Ah={name:"hardBreakEscape",tokenize:i3};function i3(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 Ph={name:"headingAtx",resolve:s3,tokenize:a3};function s3(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"},dn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function a3(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||Wt(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)):_e(l)?We(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||Wt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var I1=["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"],Lh=["pre","script","style","textarea"];var Mh={concrete:!0,name:"htmlFlow",resolveTo:u3,tokenize:p3},l3={partial:!0,tokenize:f3},c3={partial:!0,tokenize:d3};function u3(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 p3(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),f):M===47?(e.consume(M),i=!0,w):M===63?(e.consume(M),o=3,r.interrupt?t:S):Xn(M)?(e.consume(M),s=String.fromCharCode(M),k):n(M)}function f(M){return M===45?(e.consume(M),o=2,d):M===91?(e.consume(M),o=5,a=0,m):Xn(M)?(e.consume(M),o=4,r.interrupt?t:S):n(M)}function d(M){return M===45?(e.consume(M),r.interrupt?t:S):n(M)}function m(M){let J="CDATA[";return M===J.charCodeAt(a++)?(e.consume(M),a===J.length?r.interrupt?t:h:m):n(M)}function w(M){return Xn(M)?(e.consume(M),s=String.fromCharCode(M),k):n(M)}function k(M){if(M===null||M===47||M===62||Wt(M)){let J=M===47,Z=s.toLowerCase();return!J&&!i&&Lh.includes(Z)?(o=1,r.interrupt?t(M):h(M)):I1.includes(s.toLowerCase())?(o=6,J?(e.consume(M),F):r.interrupt?t(M):h(M)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?C(M):z(M))}return M===45||an(M)?(e.consume(M),s+=String.fromCharCode(M),k):n(M)}function F(M){return M===62?(e.consume(M),r.interrupt?t:h):n(M)}function C(M){return _e(M)?(e.consume(M),C):b(M)}function z(M){return M===47?(e.consume(M),b):M===58||M===95||Xn(M)?(e.consume(M),R):_e(M)?(e.consume(M),z):b(M)}function R(M){return M===45||M===46||M===58||M===95||an(M)?(e.consume(M),R):O(M)}function O(M){return M===61?(e.consume(M),L):_e(M)?(e.consume(M),O):z(M)}function L(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),u=M,B):_e(M)?(e.consume(M),L):g(M)}function B(M){return M===u?(e.consume(M),u=null,x):M===null||ue(M)?n(M):(e.consume(M),B)}function g(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Wt(M)?O(M):(e.consume(M),g)}function x(M){return M===47||M===62||_e(M)?z(M):n(M)}function b(M){return M===62?(e.consume(M),E):n(M)}function E(M){return M===null||ue(M)?h(M):_e(M)?(e.consume(M),E):n(M)}function h(M){return M===45&&o===2?(e.consume(M),A):M===60&&o===1?(e.consume(M),P):M===62&&o===4?(e.consume(M),j):M===63&&o===3?(e.consume(M),S):M===93&&o===5?(e.consume(M),N):ue(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(l3,G,T)(M)):M===null||ue(M)?(e.exit("htmlFlowData"),T(M)):(e.consume(M),h)}function T(M){return e.check(c3,I,G)(M)}function I(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),v}function v(M){return M===null||ue(M)?T(M):(e.enter("htmlFlowData"),h(M))}function A(M){return M===45?(e.consume(M),S):h(M)}function P(M){return M===47?(e.consume(M),s="",D):h(M)}function D(M){if(M===62){let J=s.toLowerCase();return Lh.includes(J)?(e.consume(M),j):h(M)}return Xn(M)&&s.length<8?(e.consume(M),s+=String.fromCharCode(M),D):h(M)}function N(M){return M===93?(e.consume(M),S):h(M)}function S(M){return M===62?(e.consume(M),j):M===45&&o===2?(e.consume(M),S):h(M)}function j(M){return M===null||ue(M)?(e.exit("htmlFlowData"),G(M)):(e.consume(M),j)}function G(M){return e.exit("htmlFlow"),t(M)}}function d3(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 f3(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Eo,t,n)}}var Bh={name:"htmlText",tokenize:g3};function g3(e,t,n){let r=this,o,i,s;return a;function a(S){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(S),u}function u(S){return S===33?(e.consume(S),c):S===47?(e.consume(S),O):S===63?(e.consume(S),z):Xn(S)?(e.consume(S),g):n(S)}function c(S){return S===45?(e.consume(S),l):S===91?(e.consume(S),i=0,m):Xn(S)?(e.consume(S),C):n(S)}function l(S){return S===45?(e.consume(S),d):n(S)}function p(S){return S===null?n(S):S===45?(e.consume(S),f):ue(S)?(s=p,P(S)):(e.consume(S),p)}function f(S){return S===45?(e.consume(S),d):p(S)}function d(S){return S===62?A(S):S===45?f(S):p(S)}function m(S){let j="CDATA[";return S===j.charCodeAt(i++)?(e.consume(S),i===j.length?w:m):n(S)}function w(S){return S===null?n(S):S===93?(e.consume(S),k):ue(S)?(s=w,P(S)):(e.consume(S),w)}function k(S){return S===93?(e.consume(S),F):w(S)}function F(S){return S===62?A(S):S===93?(e.consume(S),F):w(S)}function C(S){return S===null||S===62?A(S):ue(S)?(s=C,P(S)):(e.consume(S),C)}function z(S){return S===null?n(S):S===63?(e.consume(S),R):ue(S)?(s=z,P(S)):(e.consume(S),z)}function R(S){return S===62?A(S):z(S)}function O(S){return Xn(S)?(e.consume(S),L):n(S)}function L(S){return S===45||an(S)?(e.consume(S),L):B(S)}function B(S){return ue(S)?(s=B,P(S)):_e(S)?(e.consume(S),B):A(S)}function g(S){return S===45||an(S)?(e.consume(S),g):S===47||S===62||Wt(S)?x(S):n(S)}function x(S){return S===47?(e.consume(S),A):S===58||S===95||Xn(S)?(e.consume(S),b):ue(S)?(s=x,P(S)):_e(S)?(e.consume(S),x):A(S)}function b(S){return S===45||S===46||S===58||S===95||an(S)?(e.consume(S),b):E(S)}function E(S){return S===61?(e.consume(S),h):ue(S)?(s=E,P(S)):_e(S)?(e.consume(S),E):x(S)}function h(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(e.consume(S),o=S,T):ue(S)?(s=h,P(S)):_e(S)?(e.consume(S),h):(e.consume(S),I)}function T(S){return S===o?(e.consume(S),o=void 0,v):S===null?n(S):ue(S)?(s=T,P(S)):(e.consume(S),T)}function I(S){return S===null||S===34||S===39||S===60||S===61||S===96?n(S):S===47||S===62||Wt(S)?x(S):(e.consume(S),I)}function v(S){return S===47||S===62||Wt(S)?x(S):n(S)}function A(S){return S===62?(e.consume(S),e.exit("htmlTextData"),e.exit("htmlText"),t):n(S)}function P(S){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),D}function D(S){return _e(S)?We(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):N(S)}function N(S){return e.enter("htmlTextData"),s(S)}}var Zo={name:"labelEnd",resolveAll:y3,resolveTo:b3,tokenize:S3},m3={tokenize:w3},h3={tokenize:v3},x3={tokenize:k3};function y3(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&&dn(e,0,e.length,n),e}function b3(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=Tn(a,e.slice(i+1,i+r+3)),a=Tn(a,[["enter",l,t]]),a=Tn(a,$i(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Tn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Tn(a,e.slice(s+1)),a=Tn(a,[["exit",u,t]]),dn(e,i,e.length,a),e}function S3(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(f){return i?i._inactive?p(f):(s=r.parser.defined.includes(Zr(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),u):n(f)}function u(f){return f===40?e.attempt(m3,l,s?l:p)(f):f===91?e.attempt(h3,l,s?c:p)(f):s?l(f):p(f)}function c(f){return e.attempt(x3,l,p)(f)}function l(f){return t(f)}function p(f){return i._balanced=!0,n(f)}}function w3(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 Wt(p)?Jo(e,i)(p):i(p)}function i(p){return p===41?l(p):Sc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function s(p){return Wt(p)?Jo(e,u)(p):l(p)}function a(p){return n(p)}function u(p){return p===34||p===39||p===40?vc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):l(p)}function c(p){return Wt(p)?Jo(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 v3(e,t,n){let r=this;return o;function o(a){return wc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Zr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function k3(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 Dh={name:"labelStartImage",resolveAll:Zo.resolveAll,tokenize:C3};function C3(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 Rh={name:"labelStartLink",resolveAll:Zo.resolveAll,tokenize:T3};function T3(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 fa={name:"lineEnding",tokenize:I3};function I3(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),We(e,t,"linePrefix")}}var ei={name:"thematicBreak",tokenize:F3};function F3(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"),_e(c)?We(e,a,"whitespace")(c):a(c))}}var yn={continuation:{tokenize:L3},exit:B3,name:"list",tokenize:P3},E3={partial:!0,tokenize:D3},A3={partial:!0,tokenize:M3};function P3(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 m=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:ca(d)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(ei,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 ca(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(Eo,r.interrupt?n:l,e.attempt(E3,f,p))}function l(d){return r.containerState.initialBlankLine=!0,i++,f(d)}function p(d){return _e(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),f):n(d)}function f(d){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function L3(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Eo,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,We(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!_e(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(A3,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,We(e,e.attempt(yn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function M3(e,t,n){let r=this;return We(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 B3(e){e.exit(this.containerState.type)}function D3(e,t,n){let r=this;return We(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!_e(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var kc={name:"setextUnderline",resolveTo:R3,tokenize:z3};function R3(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 z3(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"),_e(c)?We(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var F1={tokenize:N3};function N3(e){let t=this,n=e.attempt(Eo,r,e.attempt(this.parser.constructs.flowInitial,o,We(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Fh,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 E1={resolveAll:M1()},A1=L1("string"),P1=L1("text");function L1(e){return{resolveAll:M1(e==="text"?O3: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],f=-1;if(p)for(;++f<p.length;){let d=p[f];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function M1(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 O3(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],o=t.sliceStream(r),i=o.length,s=-1,a=0,u;for(;i--;){let c=o[i];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)u=!0,a++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){let c={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:r.start._bufferIndex+s,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}var zh={};xe(zh,{attentionMarkers:()=>G3,contentInitial:()=>$3,disable:()=>q3,document:()=>_3,flow:()=>j3,flowInitial:()=>U3,insideSpan:()=>V3,string:()=>H3,text:()=>W3});var _3={42:yn,43:yn,45:yn,48:yn,49:yn,50:yn,51:yn,52:yn,53:yn,54:yn,55:yn,56:yn,57:yn,62:gc},$3={91:Eh},U3={[-2]:pa,[-1]:pa,32:pa},j3={35:Ph,42:ei,45:[kc,ei],60:Mh,61:kc,95:ei,96:xc,126:xc},H3={38:hc,92:mc},W3={[-5]:fa,[-4]:fa,[-3]:fa,33:Dh,38:hc,42:ua,60:[Th,Bh],91:Rh,92:[Ah,mc],93:Zo,95:ua,96:Ih},V3={null:[ua,E1]},G3={null:[42,95]},q3={null:[]};function B1(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:x(B),check:x(g),consume:R,enter:O,exit:L,interrupt:x(g,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:k,parser:e,previous:null,sliceSerialize:m,sliceStream:w,write:d},p=t.tokenize.call(l,c),f;return t.resolveAll&&i.push(t),l;function d(T){return s=Tn(s,T),C(),s[s.length-1]!==null?[]:(b(t,0),l.events=$i(i,l.events,l),l.events)}function m(T,I){return K3(w(T),I)}function w(T){return Y3(s,T)}function k(){let{_bufferIndex:T,_index:I,line:v,column:A,offset:P}=r;return{_bufferIndex:T,_index:I,line:v,column:A,offset:P}}function F(T){o[T.line]=T.column,h()}function C(){let T;for(;r._index<s.length;){let I=s[r._index];if(typeof I=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<I.length;)z(I.charCodeAt(r._bufferIndex));else z(I)}}function z(T){u=void 0,f=T,p=p(T)}function R(T){ue(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,h()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T,u=!0}function O(T,I){let v=I||{};return v.type=T,v.start=k(),l.events.push(["enter",v,l]),a.push(v),v}function L(T){let I=a.pop();return I.end=k(),l.events.push(["exit",I,l]),I}function B(T,I){b(T,I.from)}function g(T,I){I.restore()}function x(T,I){return v;function v(A,P,D){let N,S,j,G;return Array.isArray(A)?J(A):"tokenize"in A?J([A]):M(A);function M(ae){return qe;function qe(tt){let Ve=tt!==null&&ae[tt],te=tt!==null&&ae.null,Be=[...Array.isArray(Ve)?Ve:Ve?[Ve]:[],...Array.isArray(te)?te:te?[te]:[]];return J(Be)(tt)}}function J(ae){return N=ae,S=0,ae.length===0?D:Z(ae[S])}function Z(ae){return qe;function qe(tt){return G=E(),j=ae,ae.partial||(l.currentConstruct=ae),ae.name&&l.parser.constructs.disable.null.includes(ae.name)?pe(tt):ae.tokenize.call(I?Object.assign(Object.create(l),I):l,c,oe,pe)(tt)}}function oe(ae){return u=!0,T(j,G),P}function pe(ae){return u=!0,G.restore(),++S<N.length?Z(N[S]):D}}}function b(T,I){T.resolveAll&&!i.includes(T)&&i.push(T),T.resolve&&dn(l.events,I,l.events.length-I,T.resolve(l.events.slice(I),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function E(){let T=k(),I=l.previous,v=l.currentConstruct,A=l.events.length,P=Array.from(a);return{from:A,restore:D};function D(){r=T,l.previous=I,l.currentConstruct=v,l.events.length=A,a=P,h()}}function h(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function Y3(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 K3(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 Nh(e){let r={constructs:m1([zh,...(e||{}).extensions||[]]),content:o(w1),defined:[],document:o(k1),flow:o(F1),lazy:{},string:o(A1),text:o(P1)};return r;function o(i){return s;function s(a){return B1(r,i,a)}}}function Oh(e){for(;!bc(e););return e}var D1=/[\0\t\n\r]/g;function _h(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,f,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(D1.lastIndex=d,c=D1.exec(i),f=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(f),!c){t=i.slice(d);break}if(p===10&&d===f&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<f&&(u.push(i.slice(d,f)),e+=f-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=f+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var X3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function R1(e){return e.replace(X3,Q3)}function Q3(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return fc(n.slice(i?2:1),i?16:10)}return _i(n)||e}var N1={}.hasOwnProperty;function $h(e,t,n){return typeof t!="string"&&(n=t,t=void 0),J3(n)(Oh(Nh(n).document().write(_h()(e,t,!0))))}function J3(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ge),autolinkProtocol:x,autolinkEmail:x,atxHeading:i(me),blockQuote:i(tt),characterEscape:x,characterReference:x,codeFenced:i(se),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(se,s),codeText:i(pe,s),codeTextData:x,data:x,codeFlowValue:x,definition:i(Ie),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(ze),hardBreakEscape:i(Nt),hardBreakTrailing:i(Nt),htmlFlow:i(he,s),htmlFlowData:x,htmlText:i(he,s),htmlTextData:x,image:i(vt),label:s,link:i(Ge),listItem:i(nt),listItemValue:f,listOrdered:i(lt,d),listUnordered:i(lt),paragraph:i(ne),reference:L,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(me),strong:i(W),thematicBreak:i(ge)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:qe,autolinkProtocol:ae,blockQuote:u(),characterEscapeValue:b,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:re,characterReference:de,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:b,codeIndented:u(F),codeText:u(v),codeTextData:b,data:b,definition:u(),definitionDestinationString:z,definitionLabelString:k,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(h),hardBreakTrailing:u(h),htmlFlow:u(T),htmlFlowData:b,htmlText:u(I),htmlTextData:b,image:u(P),label:N,labelText:D,lineEnding:E,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:K,resourceDestinationString:w,resourceTitleString:j,resource:G,setextHeading:u(m),setextHeadingLineSequence:B,setextHeadingText:M,strong:u(),thematicBreak:u()}};O1(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let U={type:"root",children:[]},H={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Pe=[],Ne=-1;for(;++Ne<O.length;)if(O[Ne][1].type==="listOrdered"||O[Ne][1].type==="listUnordered")if(O[Ne][0]==="enter")Pe.push(Ne);else{let xt=Pe.pop();Ne=o(O,xt,Ne)}for(Ne=-1;++Ne<O.length;){let xt=t[O[Ne][0]];N1.call(xt,O[Ne][1].type)&&xt[O[Ne][1].type].call(Object.assign({sliceSerialize:O[Ne][2].sliceSerialize},H),O[Ne][1])}if(H.tokenStack.length>0){let xt=H.tokenStack[H.tokenStack.length-1];(xt[1]||z1).call(H,void 0,xt[0])}for(U.position={start:Ao(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Ao(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<t.transforms.length;)U=t.transforms[Ne](U)||U;return U}function o(O,U,H){let Pe=U-1,Ne=-1,xt=!1,Un,Qn,In,oo;for(;++Pe<=H;){let bn=O[Pe];switch(bn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{bn[0]==="enter"?Ne++:Ne--,oo=void 0;break}case"lineEndingBlank":{bn[0]==="enter"&&(Un&&!oo&&!Ne&&!In&&(In=Pe),oo=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oo=void 0}if(!Ne&&bn[0]==="enter"&&bn[1].type==="listItemPrefix"||Ne===-1&&bn[0]==="exit"&&(bn[1].type==="listUnordered"||bn[1].type==="listOrdered")){if(Un){let Ir=Pe;for(Qn=void 0;Ir--;){let Zt=O[Ir];if(Zt[1].type==="lineEnding"||Zt[1].type==="lineEndingBlank"){if(Zt[0]==="exit")continue;Qn&&(O[Qn][1].type="lineEndingBlank",xt=!0),Zt[1].type="lineEnding",Qn=Ir}else if(!(Zt[1].type==="linePrefix"||Zt[1].type==="blockQuotePrefix"||Zt[1].type==="blockQuotePrefixWhitespace"||Zt[1].type==="blockQuoteMarker"||Zt[1].type==="listItemIndent"))break}In&&(!Qn||In<Qn)&&(Un._spread=!0),Un.end=Object.assign({},Qn?O[Qn][1].start:bn[1].end),O.splice(Qn||Pe,0,["exit",Un,bn[2]]),Pe++,H++}if(bn[1].type==="listItemPrefix"){let Ir={type:"listItem",_spread:!1,start:Object.assign({},bn[1].start),end:void 0};Un=Ir,O.splice(Pe,0,["enter",Ir,bn[2]]),Pe++,H++,In=void 0,oo=!0}}}return O[U][1]._spread=xt,H}function i(O,U){return H;function H(Pe){a.call(this,O(Pe),Pe),U&&U.call(this,Pe)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,U,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([U,H||void 0]),O.position={start:Ao(U.start),end:void 0}}function u(O){return U;function U(H){O&&O.call(this,H),c.call(this,H)}}function c(O,U){let H=this.stack.pop(),Pe=this.tokenStack.pop();if(Pe)Pe[0].type!==O.type&&(U?U.call(this,O,Pe[0]):(Pe[1]||z1).call(this,O,Pe[0]));else throw new Error("Cannot close `"+O.type+"` ("+Io({start:O.start,end:O.end})+"): it\u2019s not open");H.position.end=Ao(O.end)}function l(){return kh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(O){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),U=this.stack[this.stack.length-1];U.lang=O}function g(){let O=this.resume(),U=this.stack[this.stack.length-1];U.meta=O}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/(\r?\n|\r)$/g,"")}function k(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(O)).toLowerCase()}function R(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function z(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function _(O){let U=this.stack[this.stack.length-1];if(!U.depth){let H=this.sliceSerialize(O).length;U.depth=H}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function B(O){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function m(){this.data.setextHeadingSlurpLineEnding=void 0}function x(O){let H=this.stack[this.stack.length-1].children,Pe=H[H.length-1];(!Pe||Pe.type!=="text")&&(Pe=Ae(),Pe.position={start:Ao(O.start),end:void 0},H.push(Pe)),this.stack.push(Pe)}function b(O){let U=this.stack.pop();U.value+=this.sliceSerialize(O),U.position.end=Ao(O.end)}function E(O){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=U.children[U.children.length-1];H.position.end=Ao(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(x.call(this,O),b.call(this,O))}function h(){this.data.atHardBreak=!0}function T(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function I(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function v(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function A(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function P(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function D(O){let U=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=R1(U),H.identifier=Zr(U).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Pe=O.children;H.children=Pe}else H.alt=U}function w(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function j(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function G(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function K(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function ee(O){this.data.characterReferenceType=O.type}function re(O){let U=this.sliceSerialize(O),H=this.data.characterReferenceType,Pe;H?(Pe=fc(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Pe=_i(U);let Ne=this.stack[this.stack.length-1];Ne.value+=Pe}function de(O){let U=this.stack.pop();U.position.end=Ao(O.end)}function ae(O){b.call(this,O);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(O)}function qe(O){b.call(this,O);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(O)}function tt(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function pe(){return{type:"inlineCode",value:""}}function Ie(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function me(){return{type:"heading",depth:0,children:[]}}function Nt(){return{type:"break"}}function he(){return{type:"html",value:""}}function vt(){return{type:"image",title:null,url:"",alt:null}}function Ge(){return{type:"link",title:null,url:"",children:[]}}function lt(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function nt(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function ne(){return{type:"paragraph",children:[]}}function W(){return{type:"strong",children:[]}}function Ae(){return{type:"text",value:""}}function ge(){return{type:"thematicBreak"}}}function Ao(e){return{line:e.line,column:e.column,offset:e.offset}}function O1(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?O1(e,r):Z3(e,r)}}function Z3(e,t){let n;for(n in t)if(N1.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 z1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Io({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is still open")}function Cc(e){let t=this;t.parser=n;function n(r){return $h(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _1(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 $1(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 Nh(e){let r={constructs:m1([zh,...(e||{}).extensions||[]]),content:o(w1),defined:[],document:o(k1),flow:o(F1),lazy:{},string:o(A1),text:o(P1)};return r;function o(i){return s;function s(a){return B1(r,i,a)}}}function Oh(e){for(;!bc(e););return e}var D1=/[\0\t\n\r]/g;function _h(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,p,f,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(D1.lastIndex=p,c=D1.exec(i),f=c&&c.index!==void 0?c.index:i.length,d=i.charCodeAt(f),!c){t=i.slice(p);break}if(d===10&&p===f&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<f&&(u.push(i.slice(p,f)),e+=f-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=f+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var X3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function R1(e){return e.replace(X3,Q3)}function Q3(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return fc(n.slice(i?2:1),i?16:10)}return _i(n)||e}var N1={}.hasOwnProperty;function $h(e,t,n){return typeof t!="string"&&(n=t,t=void 0),J3(n)(Oh(Nh(n).document().write(_h()(e,t,!0))))}function J3(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ge),autolinkProtocol:x,autolinkEmail:x,atxHeading:i(de),blockQuote:i(tt),characterEscape:x,characterReference:x,codeFenced:i(Ve),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Ve,s),codeText:i(te,s),codeTextData:x,data:x,codeFlowValue:x,definition:i(Be),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(Le),hardBreakEscape:i(Et),hardBreakTrailing:i(Et),htmlFlow:i(fe,s),htmlFlowData:x,htmlText:i(fe,s),htmlTextData:x,image:i(vt),label:s,link:i(Ge),listItem:i(nt),listItemValue:f,listOrdered:i(lt,p),listUnordered:i(lt),paragraph:i(re),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(de),strong:i(W),thematicBreak:i(me)},exit:{atxHeading:u(),atxHeadingSequence:O,autolink:u(),autolinkEmail:qe,autolinkProtocol:ae,blockQuote:u(),characterEscapeValue:b,characterReferenceMarkerHexadecimal:Z,characterReferenceMarkerNumeric:Z,characterReferenceValue:oe,characterReference:pe,codeFenced:u(k),codeFencedFence:w,codeFencedFenceInfo:d,codeFencedFenceMeta:m,codeFlowValue:b,codeIndented:u(F),codeText:u(v),codeTextData:b,data:b,definition:u(),definitionDestinationString:R,definitionLabelString:C,definitionTitleString:z,emphasis:u(),hardBreakEscape:u(h),hardBreakTrailing:u(h),htmlFlow:u(T),htmlFlowData:b,htmlText:u(I),htmlTextData:b,image:u(P),label:N,labelText:D,lineEnding:E,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:J,resourceDestinationString:S,resourceTitleString:j,resource:G,setextHeading:u(g),setextHeadingLineSequence:B,setextHeadingText:L,strong:u(),thematicBreak:u()}};O1(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(_){let U={type:"root",children:[]},H={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Ee=[],ze=-1;for(;++ze<_.length;)if(_[ze][1].type==="listOrdered"||_[ze][1].type==="listUnordered")if(_[ze][0]==="enter")Ee.push(ze);else{let xt=Ee.pop();ze=o(_,xt,ze)}for(ze=-1;++ze<_.length;){let xt=t[_[ze][0]];N1.call(xt,_[ze][1].type)&&xt[_[ze][1].type].call(Object.assign({sliceSerialize:_[ze][2].sliceSerialize},H),_[ze][1])}if(H.tokenStack.length>0){let xt=H.tokenStack[H.tokenStack.length-1];(xt[1]||z1).call(H,void 0,xt[0])}for(U.position={start:Ao(_.length>0?_[0][1].start:{line:1,column:1,offset:0}),end:Ao(_.length>0?_[_.length-2][1].end:{line:1,column:1,offset:0})},ze=-1;++ze<t.transforms.length;)U=t.transforms[ze](U)||U;return U}function o(_,U,H){let Ee=U-1,ze=-1,xt=!1,Un,Qn,In,oo;for(;++Ee<=H;){let bn=_[Ee];switch(bn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{bn[0]==="enter"?ze++:ze--,oo=void 0;break}case"lineEndingBlank":{bn[0]==="enter"&&(Un&&!oo&&!ze&&!In&&(In=Ee),oo=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oo=void 0}if(!ze&&bn[0]==="enter"&&bn[1].type==="listItemPrefix"||ze===-1&&bn[0]==="exit"&&(bn[1].type==="listUnordered"||bn[1].type==="listOrdered")){if(Un){let Ir=Ee;for(Qn=void 0;Ir--;){let Zt=_[Ir];if(Zt[1].type==="lineEnding"||Zt[1].type==="lineEndingBlank"){if(Zt[0]==="exit")continue;Qn&&(_[Qn][1].type="lineEndingBlank",xt=!0),Zt[1].type="lineEnding",Qn=Ir}else if(!(Zt[1].type==="linePrefix"||Zt[1].type==="blockQuotePrefix"||Zt[1].type==="blockQuotePrefixWhitespace"||Zt[1].type==="blockQuoteMarker"||Zt[1].type==="listItemIndent"))break}In&&(!Qn||In<Qn)&&(Un._spread=!0),Un.end=Object.assign({},Qn?_[Qn][1].start:bn[1].end),_.splice(Qn||Ee,0,["exit",Un,bn[2]]),Ee++,H++}if(bn[1].type==="listItemPrefix"){let Ir={type:"listItem",_spread:!1,start:Object.assign({},bn[1].start),end:void 0};Un=Ir,_.splice(Ee,0,["enter",Ir,bn[2]]),Ee++,H++,In=void 0,oo=!0}}}return _[U][1]._spread=xt,H}function i(_,U){return H;function H(Ee){a.call(this,_(Ee),Ee),U&&U.call(this,Ee)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(_,U,H){this.stack[this.stack.length-1].children.push(_),this.stack.push(_),this.tokenStack.push([U,H||void 0]),_.position={start:Ao(U.start),end:void 0}}function u(_){return U;function U(H){_&&_.call(this,H),c.call(this,H)}}function c(_,U){let H=this.stack.pop(),Ee=this.tokenStack.pop();if(Ee)Ee[0].type!==_.type&&(U?U.call(this,_,Ee[0]):(Ee[1]||z1).call(this,_,Ee[0]));else throw new Error("Cannot close `"+_.type+"` ("+Io({start:_.start,end:_.end})+"): it\u2019s not open");H.position.end=Ao(_.end)}function l(){return kh(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function f(_){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(_),10),this.data.expectingFirstListItemValue=void 0}}function d(){let _=this.resume(),U=this.stack[this.stack.length-1];U.lang=_}function m(){let _=this.resume(),U=this.stack[this.stack.length-1];U.meta=_}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){let _=this.resume(),U=this.stack[this.stack.length-1];U.value=_.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let _=this.resume(),U=this.stack[this.stack.length-1];U.value=_.replace(/(\r?\n|\r)$/g,"")}function C(_){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(_)).toLowerCase()}function z(){let _=this.resume(),U=this.stack[this.stack.length-1];U.title=_}function R(){let _=this.resume(),U=this.stack[this.stack.length-1];U.url=_}function O(_){let U=this.stack[this.stack.length-1];if(!U.depth){let H=this.sliceSerialize(_).length;U.depth=H}}function L(){this.data.setextHeadingSlurpLineEnding=!0}function B(_){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(_).codePointAt(0)===61?1:2}function g(){this.data.setextHeadingSlurpLineEnding=void 0}function x(_){let H=this.stack[this.stack.length-1].children,Ee=H[H.length-1];(!Ee||Ee.type!=="text")&&(Ee=Fe(),Ee.position={start:Ao(_.start),end:void 0},H.push(Ee)),this.stack.push(Ee)}function b(_){let U=this.stack.pop();U.value+=this.sliceSerialize(_),U.position.end=Ao(_.end)}function E(_){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=U.children[U.children.length-1];H.position.end=Ao(_.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(x.call(this,_),b.call(this,_))}function h(){this.data.atHardBreak=!0}function T(){let _=this.resume(),U=this.stack[this.stack.length-1];U.value=_}function I(){let _=this.resume(),U=this.stack[this.stack.length-1];U.value=_}function v(){let _=this.resume(),U=this.stack[this.stack.length-1];U.value=_}function A(){let _=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";_.type+="Reference",_.referenceType=U,delete _.url,delete _.title}else delete _.identifier,delete _.label;this.data.referenceType=void 0}function P(){let _=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";_.type+="Reference",_.referenceType=U,delete _.url,delete _.title}else delete _.identifier,delete _.label;this.data.referenceType=void 0}function D(_){let U=this.sliceSerialize(_),H=this.stack[this.stack.length-2];H.label=R1(U),H.identifier=Zr(U).toLowerCase()}function N(){let _=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Ee=_.children;H.children=Ee}else H.alt=U}function S(){let _=this.resume(),U=this.stack[this.stack.length-1];U.url=_}function j(){let _=this.resume(),U=this.stack[this.stack.length-1];U.title=_}function G(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function J(_){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(_)).toLowerCase(),this.data.referenceType="full"}function Z(_){this.data.characterReferenceType=_.type}function oe(_){let U=this.sliceSerialize(_),H=this.data.characterReferenceType,Ee;H?(Ee=fc(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ee=_i(U);let ze=this.stack[this.stack.length-1];ze.value+=Ee}function pe(_){let U=this.stack.pop();U.position.end=Ao(_.end)}function ae(_){b.call(this,_);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(_)}function qe(_){b.call(this,_);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(_)}function tt(){return{type:"blockquote",children:[]}}function Ve(){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 Le(){return{type:"emphasis",children:[]}}function de(){return{type:"heading",depth:0,children:[]}}function Et(){return{type:"break"}}function fe(){return{type:"html",value:""}}function vt(){return{type:"image",title:null,url:"",alt:null}}function Ge(){return{type:"link",title:null,url:"",children:[]}}function lt(_){return{type:"list",ordered:_.type==="listOrdered",start:null,spread:_._spread,children:[]}}function nt(_){return{type:"listItem",spread:_._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function W(){return{type:"strong",children:[]}}function Fe(){return{type:"text",value:""}}function me(){return{type:"thematicBreak"}}}function Ao(e){return{line:e.line,column:e.column,offset:e.offset}}function O1(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?O1(e,r):Z3(e,r)}}function Z3(e,t){let n;for(n in t)if(N1.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 z1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Io({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is still open")}function Cc(e){let t=this;t.parser=n;function n(r){return $h(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _1(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 $1(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 U1(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 j1(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function H1(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function W1(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=pr(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 V1(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 G1(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Tc(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 q1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Tc(e,t);let o={src:pr(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 Y1(e,t){let n={src:pr(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 K1(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 X1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Tc(e,t);let o={href:pr(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 Q1(e,t){let n={href:pr(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 J1(e,t,n){let r=e.all(t),o=n?e5(n):Z1(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],
|
|
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 j1(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function H1(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function W1(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=pr(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 V1(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 G1(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Tc(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 q1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Tc(e,t);let o={src:pr(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 Y1(e,t){let n={src:pr(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 K1(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 X1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Tc(e,t);let o={href:pr(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 Q1(e,t){let n={href:pr(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 J1(e,t,n){let r=e.all(t),o=n?e5(n):Z1(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 e5(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Z1(n[r])}return t}function Z1(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 tT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function rT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oT(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=Oi(t.children[1]),u=dc(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 iT(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
|
|
87
|
+
`});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function e5(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Z1(n[r])}return t}function Z1(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 tT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function rT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oT(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=Oi(t.children[1]),u=dc(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 iT(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],f={},d=s?s[u]:void 0;d&&(f.align=d);let m={type:"element",tagName:i,properties:f,children:[]};p&&(m.children=e.all(p),e.patch(p,m),m=e.applyData(p,m)),c.push(m)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function sT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(aT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(aT(t.slice(o),o>0,!1)),i.join("")}function aT(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 cT(e,t){let n={type:"text",value:lT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function uT(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var pT={blockquote:_1,break:$1,code:U1,delete:j1,emphasis:H1,footnoteReference:W1,heading:V1,html:G1,imageReference:q1,image:Y1,inlineCode:K1,linkReference:X1,link:Q1,listItem:J1,list:eT,paragraph:tT,root:nT,strong:rT,table:oT,tableCell:sT,tableRow:iT,text:cT,thematicBreak:uT,toml:Ic,yaml:Ic,definition:Ic,footnoteDefinition:Ic};function Ic(){}var dT=typeof self=="object"?self:globalThis,o5=(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 dT[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 dT[i](s),o)};return r},Hh=e=>o5(new Map,e)(0);var Ui="",{toString:i5}={},{keys:s5}=Object,ga=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=i5.call(e).slice(8,-1);switch(n){case"Array":return[1,Ui];case"Object":return[2,Ui];case"Date":return[3,Ui];case"RegExp":return[4,Ui];case"Map":return[5,Ui];case"Set":return[6,Ui];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Ec=([e,t])=>e===0&&(t==="function"||t==="symbol"),a5=(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]=ga(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 f=s;return u==="DataView"?f=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(f=new Uint8Array(s)),o([u,[...f]],s)}let l=[],p=o([a,l],s);for(let f of s)l.push(i(f));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 f of s5(s))(e||!Ec(ga(s[f])))&&l.push([i(f),i(s[f])]);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[f,d]of s)(e||!(Ec(ga(f))||Ec(ga(d))))&&l.push([i(f),i(d)]);return p}case 6:{let l=[],p=o([a,l],s);for(let f of s)(e||!Ec(ga(f)))&&l.push(i(f));return p}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},Wh=(e,{json:t,lossy:n}={})=>{let r=[];return a5(!(t||n),!!t,new Map,r)(e),r};var ji=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Hh(Wh(e,t)):structuredClone(e):(e,t)=>Hh(Wh(e,t));function l5(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 c5(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function xT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||l5,r=e.options.footnoteBackLabel||c5,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(),f=pr(p.toLowerCase()),d=0,m=[],w=e.footnoteCounts.get(p);for(;w!==void 0&&++d<=w;){m.length>0&&m.push({type:"text",value:" "});let C=typeof n=="string"?n:n(u,d);typeof C=="string"&&(C={type:"text",value:C}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,d),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}let k=l[l.length-1];if(k&&k.type==="element"&&k.tagName==="p"){let C=k.children[k.children.length-1];C&&C.type==="text"?C.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...m)}else l.push(...m);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(l,!0)};e.patch(c,F),a.push(F)}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 Ac=(function(e){if(e==null)return f5;if(typeof e=="function")return Pc(e);if(typeof e=="object")return Array.isArray(e)?u5(e):p5(e);if(typeof e=="string")return d5(e);throw new Error("Expected function, string, or object as test")});function u5(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ac(e[n]);return Pc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function p5(e){let t=e;return Pc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function d5(e){return Pc(t);function t(n){return n&&n.type===e}}function Pc(e){return t;function t(n,r,o){return!!(g5(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function f5(){return!0}function g5(e){return e!==null&&typeof e=="object"&&"type"in e}var yT=[],Vh=!0,Lc=!1,Gh="skip";function qh(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Ac(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let
|
|
89
|
+
`}]}}var Ac=(function(e){if(e==null)return f5;if(typeof e=="function")return Pc(e);if(typeof e=="object")return Array.isArray(e)?u5(e):p5(e);if(typeof e=="string")return d5(e);throw new Error("Expected function, string, or object as test")});function u5(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ac(e[n]);return Pc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function p5(e){let t=e;return Pc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function d5(e){return Pc(t);function t(n){return n&&n.type===e}}function Pc(e){return t;function t(n,r,o){return!!(g5(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function f5(){return!0}function g5(e){return e!==null&&typeof e=="object"&&"type"in e}var yT=[],Vh=!0,Lc=!1,Gh="skip";function qh(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Ac(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(f,"name",{value:"node ("+(u.type+(d?"<"+d+">":""))+")"})}return f;function f(){let d=yT,m,w,k;if((!t||i(u,c,l[l.length-1]||void 0))&&(d=m5(n(u,l)),d[0]===Lc))return d;if("children"in u&&u.children){let F=u;if(F.children&&d[0]!==Gh)for(w=(r?F.children.length:-1)+s,k=l.concat(F);w>-1&&w<F.children.length;){let C=F.children[w];if(m=a(C,w,k)(),m[0]===Lc)return m;w=typeof m[1]=="number"?m[1]:w+s}}return d}}}function m5(e){return Array.isArray(e)?e:typeof e=="number"?[Vh,e]:e==null?yT:[e]}function ma(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),qh(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 Yh={}.hasOwnProperty,h5={};function ST(e,t){let n=t||h5,r=new Map,o=new Map,i=new Map,s={...pT,...n.handlers},a={all:c,applyData:y5,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:x5,wrap:S5};return ma(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let p=l.type==="definition"?r:o,f=String(l.identifier).toUpperCase();p.has(f)||p.set(f,l)}}),a;function u(l,p){let f=l.type,d=a.handlers[f];if(Yh.call(a.handlers,f)&&d)return d(a,l,p);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in l){let{children:w,...k}=l,F=ji(k);return F.children=a.all(l),F}return ji(l)}return(a.options.unknownHandler||b5)(a,l,p)}function c(l){let p=[];if("children"in l){let f=l.children,d=-1;for(;++d<f.length;){let m=a.one(f[d],l);if(m){if(d&&f[d-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=bT(m.value)),!Array.isArray(m)&&m.type==="element")){let w=m.children[0];w&&w.type==="text"&&(w.value=bT(w.value))}Array.isArray(m)?p.push(...m):p.push(m)}}}return p}}function x5(e,t){e.position&&(t.position=xh(e))}function y5(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 b5(e,t){let n=t.data||{},r="value"in t&&!(Yh.call(n,"hProperties")||Yh.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 S5(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 bT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Mc(e,t){let n=ST(e,t),r=n.one(e,void 0),o=xT(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 Bc(e,t){return e&&"run"in e?async function(n,r){let o=Mc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Mc(n,{file:r,...e||t})}}function Kh(e){if(e)throw e}var zc=Pa(AT(),1);function ma(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 Xh(){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?PT(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 PT(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 kr={basename:w5,dirname:v5,extname:k5,join:C5,sep:"/"};function w5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ha(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 v5(e){if(ha(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 k5(e){ha(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 C5(...e){let t=-1,n;for(;++t<e.length;)ha(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":T5(n)}function T5(e){ha(e);let t=e.codePointAt(0)===47,n=I5(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function I5(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 ha(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var LT={cwd:F5};function F5(){return"/"}function Hi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function MT(e){if(typeof e=="string")e=new URL(e);else if(!Hi(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 E5(e)}function E5(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 Qh=["history","path","basename","stem","extname","dirname"],ti=class{constructor(t){let n;t?Hi(t)?n={path:t}:typeof t=="string"||A5(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":LT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Qh.length;){let i=Qh[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)Qh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?kr.basename(this.path):void 0}set basename(t){Zh(t,"basename"),Jh(t,"basename"),this.path=kr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?kr.dirname(this.path):void 0}set dirname(t){BT(this.basename,"dirname"),this.path=kr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?kr.extname(this.path):void 0}set extname(t){if(Jh(t,"extname"),BT(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=kr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Hi(t)&&(t=MT(t)),Zh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?kr.basename(this.path,this.extname):void 0}set stem(t){Zh(t,"stem"),Jh(t,"stem"),this.path=kr.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 Ht(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 Jh(e,t){if(e&&e.includes(kr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+kr.sep+"`")}function Zh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function BT(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function A5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var DT=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var P5={}.hasOwnProperty,rx=class e extends DT{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=Xh()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,zc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(nx("data",this.frozen),this.namespace[t]=n,this):P5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(nx("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=Rc(t),r=this.parser||this.Parser;return ex("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),ex("process",this.parser||this.Parser),tx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Rc(t),u=r.parse(a);r.run(u,a,function(l,d,f){if(l||!d||!f)return c(l);let p=d,g=r.stringify(p,f);M5(g)?f.value=g:f.result=g,c(l,f)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),ex("processSync",this.parser||this.Parser),tx("processSync",this.compiler||this.Compiler),this.process(t,o),zT("processSync","process",n),r;function o(i,s){n=!0,Kh(i),r=s}}run(t,n,r){RT(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=Rc(n);o.run(t,u,c);function c(l,d,f){let p=d||t;l?a(l):s?s(p):r(void 0,p,f)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),zT("runSync","run",r),o;function i(s,a){Kh(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Rc(n),o=this.compiler||this.Compiler;return tx("stringify",o),RT(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(nx("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,zc.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,f=-1;for(;++d<r.length;)if(r[d][0]===c){f=d;break}if(f===-1)r.push([c,...l]);else if(l.length>0){let[p,...g]=l,S=r[f][1];ma(S)&&ma(p)&&(p=(0,zc.default)(!0,S,p)),r[f]=[c,p,...g]}}}},ox=new rx().freeze();function ex(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function tx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nx(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 RT(e){if(!ma(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zT(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Rc(e){return L5(e)?e:new ti(e)}function L5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function M5(e){return typeof e=="string"||B5(e)}function B5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var N5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",NT=[],OT={allowDangerousHtml:!0},O5=/^(https?|ircs?|mailto|xmpp)$/i,_5=[{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 ix(e){let t=$5(e),n=U5(e);return j5(t.runSync(t.parse(n),n),e)}function $5(e){let t=e.rehypePlugins||NT,n=e.remarkPlugins||NT,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...OT}:OT;return ox().use(Cc).use(n).use(Bc,r).use(t)}function U5(e){let t=e.children||"",n=new ti;return typeof t=="string"?n.value=t:(""+t,void 0),n}function j5(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||_T;for(let l of _5)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+N5+l.id,void 0);return n&&i&&void 0,ga(e,c),Sh(e,{Fragment:D5,components:o,ignoreInvalidStyle:!0,jsx:R5,jsxs:z5,passKeys:!0,passNode:!0});function c(l,d,f){if(l.type==="raw"&&f&&typeof d=="number")return s?f.children.splice(d,1):f.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in sa)if(Object.hasOwn(sa,p)&&Object.hasOwn(l.properties,p)){let g=l.properties[p],S=sa[p];(S===null||S.includes(l.tagName))&&(l.properties[p]=u(String(g||""),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,f)),p&&f&&typeof d=="number")return a&&l.children?f.children.splice(d,1,...l.children):f.children.splice(d,1),d}}}function _T(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||O5.test(e.slice(0,t))?e:""}ve();var W5=Wi.div({display:"flex",flexDirection:"column",gap:"12px"}),V5=Wi.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),G5=Wi.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),q5=Wi(er)({padding:"6px 12px",fontSize:"12px"}),Y5=Wi.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:NC.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}})),K5=Wi.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),sx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ie(),[r,o]=H5(!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?ni.createElement(W5,null,ni.createElement(V5,null,ni.createElement(G5,null,"Full Prompt"),ni.createElement(q5,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),ni.createElement(Y5,null,ni.createElement(ix,null,e))):ni.createElement(K5,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import eo,{useRef as X5}from"react";import{styled as Cr}from"storybook/theming";ve();var Q5=Cr.div({display:"flex",flexDirection:"column",gap:"8px"}),Tpe=Cr.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"}}),J5=Cr.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})),Z5=Cr.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})),Ipe=Cr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),$T=Cr.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||le,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||le,backgroundColor:e.background.warning||"#ffedd5"}})),e6=Cr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),t6=Cr.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"})),n6=Cr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),r6=Cr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Fpe=Cr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function o6(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 ax=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ie(),s=X5(null);if((i??o)!=="admin")return null;let u=r?n.find(g=>g.id===r):null,c=u?u.issues.length>0&&u.issues.every(g=>g.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(g=>g.role==="assistant"||g.role==="system"&&g.content.includes("auto-dismissed")),f=d.length===0&&!!t;if(d.length===0&&!f)return eo.createElement(e6,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 eo.createElement(Q5,null,l&&eo.createElement(t6,null,eo.createElement(n6,null,"Component Matches Design"),eo.createElement(r6,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.")),eo.createElement(J5,{ref:s},p.map((g,S)=>eo.createElement(Z5,{key:S,role:g.role},g.role==="system"?eo.createElement($T,null,g.content):eo.createElement($T,{dangerouslySetInnerHTML:{__html:o6(g.content)}})))))};import dr from"react";import{styled as Po}from"storybook/theming";ve();De();var i6=Po.div({display:"flex",flexDirection:"column",gap:"12px"}),s6=Po.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),a6=Po.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}}}),UT=Po.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"}}),l6=Po.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),jT=Po.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||le,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||le,backgroundColor:e.background.warning||"#ffedd5"}})),HT=Po.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),c6=Po.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 WT(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 u6(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 VT=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ie();if((i??o)!=="admin")return null;dr.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?dr.createElement(HT,null,"No models selected. Select multiple models to compare results."):dr.createElement(i6,null,dr.createElement(s6,null,a.map(l=>{let d=Qr.find(F=>F.id===l),f=c[l],g=u6(t&&f?.streamingMessages&&f.streamingMessages.length>0?f.streamingMessages[0].content||"":f?.fullResponse?f.fullResponse:""),S=l===u;if(!d)return null;let C=t&&!f?.completed;return dr.createElement(a6,{key:l,isActive:S,provider:d.provider,onClick:()=>n(l)},d.name,f&&g.issueCount>0&&dr.createElement(UT,{variant:"issues",value:g.issueCount},g.issueCount," issues"),f&&g.score!==null&&dr.createElement(UT,{variant:"score",value:g.score},"Score: ",g.score),C&&dr.createElement(c6,null))})),dr.createElement(l6,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>dr.createElement(jT,{key:d,dangerouslySetInnerHTML:{__html:WT(l.content)}})):c[u]?.fullResponse?dr.createElement(jT,{dangerouslySetInnerHTML:{__html:WT(c[u].fullResponse)}}):dr.createElement(HT,null,t?`Waiting for ${Qr.find(l=>l.id===u)?.name}...`:`No response yet for ${Qr.find(l=>l.id===u)?.name}`)))};import Ue from"react";import{styled as Ct}from"storybook/theming";ve();Ls();ve();import{useCallback as lx}from"react";De();function GT(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ie(),{sessionToken:r}=we(),o=lx(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=lx((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}Nl(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=lx(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}Nl(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 V,{useMemo as SH,useState as wH,useEffect as vH}from"react";import{styled as it,keyframes as kH}from"storybook/theming";import Z,{useState as fx,useRef as pj,useCallback as aI,memo as dj}from"react";import{styled as Ee}from"storybook/theming";import to,{useState as p6}from"react";import{styled as no}from"storybook/theming";var d6=no.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}),f6=no.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"8px",padding:"24px",maxWidth:"500px",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}`})),g6=no.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),m6=no.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),h6=no.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),x6=no.textarea(({theme:e})=>({width:"100%",minHeight:"80px",padding:"10px",fontSize:"13px",borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",marginBottom:"20px","&:focus":{outline:"none",borderColor:le,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),y6=no.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),b6=no(en)({}),S6=no(Er)({}),qT=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=p6("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return to.createElement(d6,{onClick:c=>{c.target===c.currentTarget&&a()}},to.createElement(f6,null,to.createElement(g6,null,"Dismiss as False Positive"),to.createElement(m6,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),to.createElement(h6,{htmlFor:"dismiss-reason"},"Reason (optional)"),to.createElement(x6,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),to.createElement(y6,null,to.createElement(S6,{onClick:a},"Cancel"),to.createElement(b6,{onClick:s},"Dismiss Issue"))))};ve();import Fe from"react";import{styled as ot}from"storybook/theming";var Be={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"},w6=ot.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),v6=ot.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),k6=ot.div({position:"relative",backgroundColor:Be.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Ype=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Be.dash,padding:"0 8px",height:18,fontSize:11}),Kpe=ot.div({position:"absolute",color:Be.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Xpe=ot.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%)"}})),Qpe=ot.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}})),C6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Be.errBg:Be.borderBoxBg,border:`1px solid ${e.isErr?Be.err:Be.borderBoxStroke}`,borderRadius:6,padding:0})),T6=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Be.text}),I6=ot.span({fontWeight:500,fontSize:11}),Jpe=ot.span({color:Be.dash}),F6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Be.errBg:Be.paddingBg,border:`1px solid ${e.isErr?Be.err:Be.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),E6=ot.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Be.text,fontStyle:"italic"}),Nc=ot.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Be.err:Be.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%)"}})),A6=ot.div(e=>({backgroundColor:e.isErr?Be.errBg:"#fff",border:`1.5px dashed ${e.isErr?Be.err:Be.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Be.err:Be.text,fontWeight:e.isErr?600:400})),P6=ot.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Be.dim,fontFamily:"monospace"}),L6=ot.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Be.ok,padding:"4px 8px 6px"}),Zpe=ot.div({fontSize:11,fontWeight:600,color:Be.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),ede=ot.span({fontSize:12,color:Be.dim}),M6=ot.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),B6=ot.div({fontSize:9,color:Be.dim,marginTop:2}),D6=({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}=ie(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?j6(n):null,g=d.padding||p||{top:0,right:0,bottom:0,left:0},S=d.strokeWeight??(a?Vi(n)??0:0),C=d.width??(u?H6(n)??"\u2014":"\u2014"),F=d.height??(u?W6(n)??"\u2014":"\u2014");return Fe.createElement(Fe.Fragment,null,Fe.createElement(k6,null,Fe.createElement(C6,{isErr:a},Fe.createElement(T6,null,Fe.createElement(I6,null,"Border"),Fe.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Be.err:Be.dim}},S)),Fe.createElement(F6,{isErr:s},Fe.createElement(E6,null,"Padding"),Fe.createElement(Nc,{side:"top",isErr:s},g.top),Fe.createElement(Nc,{side:"right",isErr:s},g.right),Fe.createElement(Nc,{side:"bottom",isErr:s},g.bottom),Fe.createElement(Nc,{side:"left",isErr:s},g.left),Fe.createElement(A6,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Fe.createElement(M6,{src:l,alt:"Figma element"}),Fe.createElement(B6,null,C," \xD7 ",F)))),Fe.createElement(P6,null,"border-box")),Fe.createElement(L6,null,"\u2192 ",n))},YT=ot.div({backgroundColor:Be.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),R6=ot.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),cx=ot.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Be.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),z6=ot.div({position:"absolute",border:`1.5px dashed ${Be.err}`,pointerEvents:"none",zIndex:0}),N6=ot.div({position:"absolute",border:`1.5px dashed ${Be.blue}`,pointerEvents:"none",zIndex:0}),KT=ot.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%)"}})),tde=ot.div({fontSize:12,color:Be.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),O6=ot.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),XT=ot.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Be.err:Be.ok})),_6=ot.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),QT=ot.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),JT=ot.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Be.err:Be.ok})),ZT=ot.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Be.err:Be.ok,textDecoration:e.variant==="err"?"line-through":"none"})),$6=ot.span({fontSize:16,color:Be.dim,paddingBottom:20}),eI=ot.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function tI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var U6=({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,f=o.fontSize??(s?Vi(n):14),p=o.fontWeight??(a?Vi(n):600),S=(o.lineHeight??(u?Vi(n):null))||Math.round((f||14)*1.43),C=`${Math.min(Math.max(f||14,24),48)}px`;if(d)return Fe.createElement(Fe.Fragment,null,Fe.createElement(YT,null,Fe.createElement(R6,null,Fe.createElement(N6,{style:{top:-6,left:0,right:0,bottom:-6}}),Fe.createElement(z6,{style:{top:2,left:8,right:8,bottom:2}}),Fe.createElement(KT,{color:s?Be.err:"#7b3030",side:"left"},s?t:`${f}px`),Fe.createElement(KT,{color:u?Be.err:"#7b3030",side:"right"},u?t:`${S}px`),Fe.createElement(cx,{fSize:C,fWeight:String(p||600)},"Ag")),Fe.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Fe.createElement(eI,{color:Be.err},"\u2508\u2508 font-size",s?" \u2717":""),Fe.createElement(eI,{color:Be.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Fe.createElement(O6,null,Fe.createElement(XT,{variant:"err"},t),Fe.createElement("span",{style:{color:Be.dim}},"\u2192"),Fe.createElement(XT,{variant:"ok"},n))));let F=a?t:String(p||600),k=a?n:F,R=Vi(t),z=Vi(n);return Fe.createElement(Fe.Fragment,null,Fe.createElement(YT,null,Fe.createElement(_6,null,Fe.createElement(QT,null,Fe.createElement(JT,{variant:"err"},"Current"),Fe.createElement(cx,{fSize:C,fWeight:a?F:String(p||600),style:{color:Be.err}},c?t:"Ag"),Fe.createElement(ZT,{variant:"err"},a&&R?`${t} (${tI(R)})`:t)),Fe.createElement($6,null,"\u2192"),Fe.createElement(QT,null,Fe.createElement(JT,{variant:"ok"},"Figma"),Fe.createElement(cx,{fSize:C,fWeight:a?k:String(p||600),style:{color:Be.ok}},c?n:"Ag"),Fe.createElement(ZT,{variant:"ok"},a&&z?`${n} (${tI(z)})`:n)))))};function j6(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 Vi(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function H6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function W6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var nI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function V6(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 rI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=V6(e.property);return Fe.createElement(w6,null,Fe.createElement(v6,null,"\u25BE Layer properties",t?"":" (from review)"),n?Fe.createElement(U6,{...e}):Fe.createElement(D6,{...e}))};import Nr from"react";import{styled as Or}from"storybook/theming";var G6={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)"}},q6=Or.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),Y6=Or.div(({theme:e,category:t})=>{let n=G6[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}`}}),K6=Or.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}}}),X6=Or.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"}}),Q6=Or.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),J6=Or.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"}}),Z6=Or.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"}}),ej=Or.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"}}),tj=Or.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}`})),nj=Or.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),rj=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},oI=({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=rj(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),f=e.generatedFix?.filePath||e.file;return Nr.createElement(q6,null,Nr.createElement(Y6,{category:e.type},e.type),e.status!=="pending"&&Nr.createElement(K6,{status:e.status},e.status),n&&t&&Nr.createElement(X6,null,t),d&&Nr.createElement(Q6,null,c.ai&&!l&&Nr.createElement(J6,null,c.ai),c.programmatic&&Nr.createElement(Z6,null,"Pre-filter: ",c.programmatic)),a&&Nr.createElement(ej,{title:u},"Unreliable"),e.dismissed&&Nr.createElement(tj,null,"Dismissed"),i&&s&&f&&Nr.createElement(nj,null,f))};import $n from"react";import{styled as Lo}from"storybook/theming";var oj=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},ij=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",sj=Lo.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"})),ux=Lo.div({display:"flex",gap:"8px",alignItems:"baseline"}),px=Lo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),dx=Lo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),aj=Lo(dx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),lj=Lo(dx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),cj=Lo.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
|
|
93
|
+
`},o)),i}function Bc(e,t){return e&&"run"in e?async function(n,r){let o=Mc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Mc(n,{file:r,...e||t})}}function Kh(e){if(e)throw e}var zc=La(AT(),1);function ha(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 Xh(){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?PT(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 PT(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 kr={basename:w5,dirname:v5,extname:k5,join:C5,sep:"/"};function w5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');xa(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 v5(e){if(xa(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 k5(e){xa(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 C5(...e){let t=-1,n;for(;++t<e.length;)xa(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":T5(n)}function T5(e){xa(e);let t=e.codePointAt(0)===47,n=I5(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function I5(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 xa(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var LT={cwd:F5};function F5(){return"/"}function Hi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function MT(e){if(typeof e=="string")e=new URL(e);else if(!Hi(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 E5(e)}function E5(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 Qh=["history","path","basename","stem","extname","dirname"],ti=class{constructor(t){let n;t?Hi(t)?n={path:t}:typeof t=="string"||A5(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":LT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Qh.length;){let i=Qh[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)Qh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?kr.basename(this.path):void 0}set basename(t){Zh(t,"basename"),Jh(t,"basename"),this.path=kr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?kr.dirname(this.path):void 0}set dirname(t){BT(this.basename,"dirname"),this.path=kr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?kr.extname(this.path):void 0}set extname(t){if(Jh(t,"extname"),BT(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=kr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Hi(t)&&(t=MT(t)),Zh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?kr.basename(this.path,this.extname):void 0}set stem(t){Zh(t,"stem"),Jh(t,"stem"),this.path=kr.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 Ht(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 Jh(e,t){if(e&&e.includes(kr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+kr.sep+"`")}function Zh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function BT(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function A5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var DT=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var P5={}.hasOwnProperty,rx=class e extends DT{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=Xh()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,zc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(nx("data",this.frozen),this.namespace[t]=n,this):P5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(nx("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=Rc(t),r=this.parser||this.Parser;return ex("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),ex("process",this.parser||this.Parser),tx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Rc(t),u=r.parse(a);r.run(u,a,function(l,p,f){if(l||!p||!f)return c(l);let d=p,m=r.stringify(d,f);M5(m)?f.value=m:f.result=m,c(l,f)});function c(l,p){l||!p?s(l):i?i(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),ex("processSync",this.parser||this.Parser),tx("processSync",this.compiler||this.Compiler),this.process(t,o),zT("processSync","process",n),r;function o(i,s){n=!0,Kh(i),r=s}}run(t,n,r){RT(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=Rc(n);o.run(t,u,c);function c(l,p,f){let d=p||t;l?a(l):s?s(d):r(void 0,d,f)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),zT("runSync","run",r),o;function i(s,a){Kh(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Rc(n),o=this.compiler||this.Compiler;return tx("stringify",o),RT(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(nx("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,zc.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,f=-1;for(;++p<r.length;)if(r[p][0]===c){f=p;break}if(f===-1)r.push([c,...l]);else if(l.length>0){let[d,...m]=l,w=r[f][1];ha(w)&&ha(d)&&(d=(0,zc.default)(!0,w,d)),r[f]=[c,d,...m]}}}},ox=new rx().freeze();function ex(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function tx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nx(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 RT(e){if(!ha(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zT(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Rc(e){return L5(e)?e:new ti(e)}function L5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function M5(e){return typeof e=="string"||B5(e)}function B5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var N5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",NT=[],OT={allowDangerousHtml:!0},O5=/^(https?|ircs?|mailto|xmpp)$/i,_5=[{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 ix(e){let t=$5(e),n=U5(e);return j5(t.runSync(t.parse(n),n),e)}function $5(e){let t=e.rehypePlugins||NT,n=e.remarkPlugins||NT,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...OT}:OT;return ox().use(Cc).use(n).use(Bc,r).use(t)}function U5(e){let t=e.children||"",n=new ti;return typeof t=="string"?n.value=t:(""+t,void 0),n}function j5(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||_T;for(let l of _5)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+N5+l.id,void 0);return n&&i&&void 0,ma(e,c),Sh(e,{Fragment:D5,components:o,ignoreInvalidStyle:!0,jsx:R5,jsxs:z5,passKeys:!0,passNode:!0});function c(l,p,f){if(l.type==="raw"&&f&&typeof p=="number")return s?f.children.splice(p,1):f.children[p]={type:"text",value:l.value},p;if(l.type==="element"){let d;for(d in aa)if(Object.hasOwn(aa,d)&&Object.hasOwn(l.properties,d)){let m=l.properties[d],w=aa[d];(w===null||w.includes(l.tagName))&&(l.properties[d]=u(String(m||""),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,f)),d&&f&&typeof p=="number")return a&&l.children?f.children.splice(p,1,...l.children):f.children.splice(p,1),p}}}function _T(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||O5.test(e.slice(0,t))?e:""}we();var W5=Wi.div({display:"flex",flexDirection:"column",gap:"12px"}),V5=Wi.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),G5=Wi.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),q5=Wi(er)({padding:"6px 12px",fontSize:"12px"}),Y5=Wi.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:NC.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}})),K5=Wi.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),sx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=se(),[r,o]=H5(!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?ni.createElement(W5,null,ni.createElement(V5,null,ni.createElement(G5,null,"Full Prompt"),ni.createElement(q5,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),ni.createElement(Y5,null,ni.createElement(ix,null,e))):ni.createElement(K5,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import eo,{useRef as X5}from"react";import{styled as Cr}from"storybook/theming";we();var Q5=Cr.div({display:"flex",flexDirection:"column",gap:"8px"}),Tpe=Cr.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"}}),J5=Cr.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})),Z5=Cr.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})),Ipe=Cr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),$T=Cr.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||le,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||le,backgroundColor:e.background.warning||"#ffedd5"}})),e6=Cr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),t6=Cr.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"})),n6=Cr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),r6=Cr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Fpe=Cr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function o6(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 ax=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=se(),s=X5(null);if((i??o)!=="admin")return null;let u=r?n.find(m=>m.id===r):null,c=u?u.issues.length>0&&u.issues.every(m=>m.dismissed):!1,l=u&&(u.complianceScore===100||c),p=e.filter(m=>m.role==="assistant"||m.role==="system"&&m.content.includes("auto-dismissed")),f=p.length===0&&!!t;if(p.length===0&&!f)return eo.createElement(e6,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 eo.createElement(Q5,null,l&&eo.createElement(t6,null,eo.createElement(n6,null,"Component Matches Design"),eo.createElement(r6,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.")),eo.createElement(J5,{ref:s},d.map((m,w)=>eo.createElement(Z5,{key:w,role:m.role},m.role==="system"?eo.createElement($T,null,m.content):eo.createElement($T,{dangerouslySetInnerHTML:{__html:o6(m.content)}})))))};import dr from"react";import{styled as Po}from"storybook/theming";we();De();var i6=Po.div({display:"flex",flexDirection:"column",gap:"12px"}),s6=Po.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),a6=Po.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}}}),UT=Po.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"}}),l6=Po.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),jT=Po.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||le,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||le,backgroundColor:e.background.warning||"#ffedd5"}})),HT=Po.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),c6=Po.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 WT(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 u6(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 VT=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=se();if((i??o)!=="admin")return null;dr.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?dr.createElement(HT,null,"No models selected. Select multiple models to compare results."):dr.createElement(i6,null,dr.createElement(s6,null,a.map(l=>{let p=Qr.find(F=>F.id===l),f=c[l],m=u6(t&&f?.streamingMessages&&f.streamingMessages.length>0?f.streamingMessages[0].content||"":f?.fullResponse?f.fullResponse:""),w=l===u;if(!p)return null;let k=t&&!f?.completed;return dr.createElement(a6,{key:l,isActive:w,provider:p.provider,onClick:()=>n(l)},p.name,f&&m.issueCount>0&&dr.createElement(UT,{variant:"issues",value:m.issueCount},m.issueCount," issues"),f&&m.score!==null&&dr.createElement(UT,{variant:"score",value:m.score},"Score: ",m.score),k&&dr.createElement(c6,null))})),dr.createElement(l6,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,p)=>dr.createElement(jT,{key:p,dangerouslySetInnerHTML:{__html:WT(l.content)}})):c[u]?.fullResponse?dr.createElement(jT,{dangerouslySetInnerHTML:{__html:WT(c[u].fullResponse)}}):dr.createElement(HT,null,t?`Waiting for ${Qr.find(l=>l.id===u)?.name}...`:`No response yet for ${Qr.find(l=>l.id===u)?.name}`)))};import $e from"react";import{styled as Ct}from"storybook/theming";we();Ls();we();import{useCallback as lx}from"react";De();function GT(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=se(),{sessionToken:r}=Se(),o=lx(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=lx((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}Ol(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=lx(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}Ol(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 V,{useMemo as SH,useState as wH,useEffect as vH}from"react";import{styled as it,keyframes as kH}from"storybook/theming";import ee,{useState as fx,useRef as pj,useCallback as aI,memo as dj}from"react";import{styled as Ie}from"storybook/theming";import to,{useState as p6}from"react";import{styled as no}from"storybook/theming";var d6=no.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}),f6=no.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"8px",padding:"24px",maxWidth:"500px",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}`})),g6=no.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),m6=no.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),h6=no.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),x6=no.textarea(({theme:e})=>({width:"100%",minHeight:"80px",padding:"10px",fontSize:"13px",borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",marginBottom:"20px","&:focus":{outline:"none",borderColor:le,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),y6=no.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),b6=no(en)({}),S6=no(Er)({}),qT=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=p6("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return to.createElement(d6,{onClick:c=>{c.target===c.currentTarget&&a()}},to.createElement(f6,null,to.createElement(g6,null,"Dismiss as False Positive"),to.createElement(m6,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),to.createElement(h6,{htmlFor:"dismiss-reason"},"Reason (optional)"),to.createElement(x6,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),to.createElement(y6,null,to.createElement(S6,{onClick:a},"Cancel"),to.createElement(b6,{onClick:s},"Dismiss Issue"))))};we();import Te from"react";import{styled as ot}from"storybook/theming";var Me={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"},w6=ot.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),v6=ot.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),k6=ot.div({position:"relative",backgroundColor:Me.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Ype=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Me.dash,padding:"0 8px",height:18,fontSize:11}),Kpe=ot.div({position:"absolute",color:Me.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Xpe=ot.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%)"}})),Qpe=ot.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}})),C6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Me.errBg:Me.borderBoxBg,border:`1px solid ${e.isErr?Me.err:Me.borderBoxStroke}`,borderRadius:6,padding:0})),T6=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Me.text}),I6=ot.span({fontWeight:500,fontSize:11}),Jpe=ot.span({color:Me.dash}),F6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Me.errBg:Me.paddingBg,border:`1px solid ${e.isErr?Me.err:Me.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),E6=ot.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Me.text,fontStyle:"italic"}),Nc=ot.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Me.err:Me.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%)"}})),A6=ot.div(e=>({backgroundColor:e.isErr?Me.errBg:"#fff",border:`1.5px dashed ${e.isErr?Me.err:Me.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Me.err:Me.text,fontWeight:e.isErr?600:400})),P6=ot.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Me.dim,fontFamily:"monospace"}),L6=ot.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Me.ok,padding:"4px 8px 6px"}),Zpe=ot.div({fontSize:11,fontWeight:600,color:Me.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),ede=ot.span({fontSize:12,color:Me.dim}),M6=ot.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),B6=ot.div({fontSize:9,color:Me.dim,marginTop:2}),D6=({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}=se(),p=r||{},d=!(!!r&&Object.keys(r).length>0)&&s?j6(n):null,m=p.padding||d||{top:0,right:0,bottom:0,left:0},w=p.strokeWeight??(a?Vi(n)??0:0),k=p.width??(u?H6(n)??"\u2014":"\u2014"),F=p.height??(u?W6(n)??"\u2014":"\u2014");return Te.createElement(Te.Fragment,null,Te.createElement(k6,null,Te.createElement(C6,{isErr:a},Te.createElement(T6,null,Te.createElement(I6,null,"Border"),Te.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Me.err:Me.dim}},w)),Te.createElement(F6,{isErr:s},Te.createElement(E6,null,"Padding"),Te.createElement(Nc,{side:"top",isErr:s},m.top),Te.createElement(Nc,{side:"right",isErr:s},m.right),Te.createElement(Nc,{side:"bottom",isErr:s},m.bottom),Te.createElement(Nc,{side:"left",isErr:s},m.left),Te.createElement(A6,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Te.createElement(M6,{src:l,alt:"Figma element"}),Te.createElement(B6,null,k," \xD7 ",F)))),Te.createElement(P6,null,"border-box")),Te.createElement(L6,null,"\u2192 ",n))},YT=ot.div({backgroundColor:Me.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),R6=ot.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),cx=ot.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Me.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),z6=ot.div({position:"absolute",border:`1.5px dashed ${Me.err}`,pointerEvents:"none",zIndex:0}),N6=ot.div({position:"absolute",border:`1.5px dashed ${Me.blue}`,pointerEvents:"none",zIndex:0}),KT=ot.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%)"}})),tde=ot.div({fontSize:12,color:Me.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),O6=ot.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),XT=ot.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Me.err:Me.ok})),_6=ot.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),QT=ot.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),JT=ot.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Me.err:Me.ok})),ZT=ot.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Me.err:Me.ok,textDecoration:e.variant==="err"?"line-through":"none"})),$6=ot.span({fontSize:16,color:Me.dim,paddingBottom:20}),eI=ot.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function tI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var U6=({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,f=o.fontSize??(s?Vi(n):14),d=o.fontWeight??(a?Vi(n):600),w=(o.lineHeight??(u?Vi(n):null))||Math.round((f||14)*1.43),k=`${Math.min(Math.max(f||14,24),48)}px`;if(p)return Te.createElement(Te.Fragment,null,Te.createElement(YT,null,Te.createElement(R6,null,Te.createElement(N6,{style:{top:-6,left:0,right:0,bottom:-6}}),Te.createElement(z6,{style:{top:2,left:8,right:8,bottom:2}}),Te.createElement(KT,{color:s?Me.err:"#7b3030",side:"left"},s?t:`${f}px`),Te.createElement(KT,{color:u?Me.err:"#7b3030",side:"right"},u?t:`${w}px`),Te.createElement(cx,{fSize:k,fWeight:String(d||600)},"Ag")),Te.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Te.createElement(eI,{color:Me.err},"\u2508\u2508 font-size",s?" \u2717":""),Te.createElement(eI,{color:Me.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Te.createElement(O6,null,Te.createElement(XT,{variant:"err"},t),Te.createElement("span",{style:{color:Me.dim}},"\u2192"),Te.createElement(XT,{variant:"ok"},n))));let F=a?t:String(d||600),C=a?n:F,z=Vi(t),R=Vi(n);return Te.createElement(Te.Fragment,null,Te.createElement(YT,null,Te.createElement(_6,null,Te.createElement(QT,null,Te.createElement(JT,{variant:"err"},"Current"),Te.createElement(cx,{fSize:k,fWeight:a?F:String(d||600),style:{color:Me.err}},c?t:"Ag"),Te.createElement(ZT,{variant:"err"},a&&z?`${t} (${tI(z)})`:t)),Te.createElement($6,null,"\u2192"),Te.createElement(QT,null,Te.createElement(JT,{variant:"ok"},"Figma"),Te.createElement(cx,{fSize:k,fWeight:a?C:String(d||600),style:{color:Me.ok}},c?n:"Ag"),Te.createElement(ZT,{variant:"ok"},a&&R?`${n} (${tI(R)})`:n)))))};function j6(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 Vi(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function H6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function W6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var nI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function V6(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 rI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=V6(e.property);return Te.createElement(w6,null,Te.createElement(v6,null,"\u25BE Layer properties",t?"":" (from review)"),n?Te.createElement(U6,{...e}):Te.createElement(D6,{...e}))};import Nr from"react";import{styled as Or}from"storybook/theming";var G6={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)"}},q6=Or.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),Y6=Or.div(({theme:e,category:t})=>{let n=G6[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}`}}),K6=Or.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}}}),X6=Or.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"}}),Q6=Or.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),J6=Or.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"}}),Z6=Or.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"}}),ej=Or.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"}}),tj=Or.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}`})),nj=Or.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),rj=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},oI=({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=rj(e.detectedBy),l=o&&c.ai===o,p=r&&!l&&(c.ai||c.programmatic),f=e.generatedFix?.filePath||e.file;return Nr.createElement(q6,null,Nr.createElement(Y6,{category:e.type},e.type),e.status!=="pending"&&Nr.createElement(K6,{status:e.status},e.status),n&&t&&Nr.createElement(X6,null,t),p&&Nr.createElement(Q6,null,c.ai&&!l&&Nr.createElement(J6,null,c.ai),c.programmatic&&Nr.createElement(Z6,null,"Pre-filter: ",c.programmatic)),a&&Nr.createElement(ej,{title:u},"Unreliable"),e.dismissed&&Nr.createElement(tj,null,"Dismissed"),i&&s&&f&&Nr.createElement(nj,null,f))};import $n from"react";import{styled as Lo}from"storybook/theming";var oj=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},ij=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",sj=Lo.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"})),ux=Lo.div({display:"flex",gap:"8px",alignItems:"baseline"}),px=Lo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),dx=Lo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),aj=Lo(dx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),lj=Lo(dx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),cj=Lo.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)"})),uj=Lo.span({display:"flex",alignItems:"center"}),iI=({value:e,isStrikethrough:t=!1})=>{let n=oj(e),r=ij(e),o=t?aj:lj;return n?$n.createElement(uj,null,$n.createElement(cj,{color:n,title:`Color: ${n}`}),$n.createElement(o,null,r)):$n.createElement(o,null,r)},sI=({property:e,currentValue:t,suggestedValue:n})=>$n.createElement(sj,null,$n.createElement(ux,null,$n.createElement(px,null,"Property"),$n.createElement(dx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&$n.createElement(ux,null,$n.createElement(px,null,"Current"),$n.createElement(iI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&$n.createElement(ux,null,$n.createElement(px,null,"Expected"),$n.createElement(iI,{value:n,isStrikethrough:!1})));
|
|
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},Uj=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},jj=e=>({"claude-sonnet-4-5-20250929":"Sonnet 4.5","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,SI=dj(({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:
|
|
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)"})),uj=Lo.span({display:"flex",alignItems:"center"}),iI=({value:e,isStrikethrough:t=!1})=>{let n=oj(e),r=ij(e),o=t?aj:lj;return n?$n.createElement(uj,null,$n.createElement(cj,{color:n,title:`Color: ${n}`}),$n.createElement(o,null,r)):$n.createElement(o,null,r)},sI=({property:e,currentValue:t,suggestedValue:n})=>$n.createElement(sj,null,$n.createElement(ux,null,$n.createElement(px,null,"Property"),$n.createElement(dx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&$n.createElement(ux,null,$n.createElement(px,null,"Current"),$n.createElement(iI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&$n.createElement(ux,null,$n.createElement(px,null,"Expected"),$n.createElement(iI,{value:n,isStrikethrough:!1})));we();var lI=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 fj(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 gj=Ie.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"}})),xde=Ie.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),mj=Ie.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),hj=Ie.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),xj=Ie.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:le},"&:checked":{backgroundColor:le,borderColor:le},"&: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"}})),yj=Ie.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:"#94a3b8","& svg":{width:"16px",height:"16px"}})),yde=Ie.div({flex:1,minWidth:0}),bde=Ie.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),bj=Ie.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),gx=Ie.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"}})),Sj=Ie(gx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),Sde=Ie.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),wde=Ie.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),wj=Ie.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),vde=Ie.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"})),kde=Ie.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),vj=Ie.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"}})),kj=Ie.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${le}`})),Cj=Ie.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:le,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),Tj=Ie.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"}})),Ij=Ie.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),cI=Ie.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"})),Cde=Ie.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),Fj=Ie(wn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),Tde=Ie(Fj)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),Ej=Ie.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontStyle:"italic",marginTop:"8px",padding:"8px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${e.color.negative}`})),uI=Ie.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"})),Aj=Ie.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),Pj=Ie.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),Lj=Ie.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),Mj=Ie.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})),pI=Ie.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),dI=Ie.details({marginBottom:"8px"}),fI=Ie.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),Bj=Ie.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"})),Dj=Ie.div({display:"flex",gap:"8px",marginTop:"8px"}),Rj=Ie(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),zj=Ie(Er)({padding:"6px 12px",fontSize:"12px"}),Ide=Ie(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),Fde=Ie.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),Nj=Ie.div({display:"flex",alignItems:"center",gap:"12px"}),Oj=Ie.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),_j=Ie.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Ede=Ie.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}}})),$j=Ie.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",fontSize:"11px",fontFamily:"monospace",lineHeight:"1.5",marginTop:"8px"})),gI=Ie.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"})),mI=Ie.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}`})),hI=Ie.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),xI=Ie.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=Ie.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),bI=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},Uj=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},jj=e=>({"claude-sonnet-4-5-20250929":"Sonnet 4.5","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,SI=dj(({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}=se(),[f,d]=fx(!1),[m,w]=fx(!1),[k,F]=fx(!1),C=pj(null),z=aI(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{p(e.id),F(!0)},100)},[e.id,p]),R=aI(()=>{C.current&&clearTimeout(C.current),C.current=null,p(null),F(!1)},[p]),O=()=>{e.dismissed?s(e.id):d(!0)},L=x=>{i(e.id,x),d(!1)},B=async()=>{let x=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&x.push(`Property: ${e.property}`),e.currentValue&&x.push(`Current: ${e.currentValue}`),e.suggestedValue&&x.push(`Expected: ${e.suggestedValue}`),e.file&&x.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&x.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&x.push(`
|
|
99
99
|
Suggested code:
|
|
100
100
|
\`\`\`
|
|
101
101
|
${e.suggestedCode}
|
|
@@ -109,25 +109,25 @@ Diff:
|
|
|
109
109
|
\`\`\`diff
|
|
110
110
|
${E.diffPreview}
|
|
111
111
|
\`\`\``),E.error&&x.push(`Error: ${E.error}`)}let b=x.filter(Boolean).join(`
|
|
112
|
-
`);try{await navigator.clipboard.writeText(b),
|
|
112
|
+
`);try{await navigator.clipboard.writeText(b),w(!0),setTimeout(()=>w(!1),2e3)}catch(E){console.error("Failed to copy:",E)}},g=e.generatedFix?.status==="applied";return ee.createElement(ee.Fragment,null,ee.createElement(gj,{dismissed:!!e.dismissed,fixApplied:g,onMouseEnter:z,onMouseLeave:R},ee.createElement(mj,null,ee.createElement(xj,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),ee.createElement(yj,{severity:e.severity},e.severity==="critical"?ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("circle",{cx:"12",cy:"12",r:"10"}),ee.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),ee.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.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"}),ee.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),ee.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("circle",{cx:"12",cy:"12",r:"10"}),ee.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),ee.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),ee.createElement(hj,null,e.title),ee.createElement(bj,null,ee.createElement(gx,{onClick:B,title:"Copy issue details"},m?ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("polyline",{points:"20 6 9 17 4 12"})):ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),ee.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?ee.createElement(gx,{onClick:O,title:"Restore issue"},ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("polyline",{points:"1 4 1 10 7 10"}),ee.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):ee.createElement(Sj,{onClick:O,title:"Dismiss issue"},ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ee.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),ee.createElement(oI,{issue:e,modelDisplayName:jj(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&&ee.createElement(wj,null,e.description),e.property&&ee.createElement(sI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&k&&e.property&&e.currentValue&&e.suggestedValue&&fj(e.property)&&ee.createElement(rI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&ee.createElement(vj,null,ee.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&ee.createElement(kj,null,ee.createElement(Cj,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((x,b)=>ee.createElement(Tj,{key:`${x.property}-${b}`},ee.createElement(Ij,null,x.property),ee.createElement(cI,{type:"current"},x.currentValue),ee.createElement(cI,{type:"suggested"},x.suggestedValue)))),e.dismissed&&ee.createElement(Ej,null,ee.createElement("strong",null,"Filtered by:")," ",Uj(e.dismissedBy),e.dismissReason&&ee.createElement(ee.Fragment,null,ee.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&ee.createElement(uI,null,ee.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&ee.createElement(Aj,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?ee.createElement(Nj,{style:{margin:0}},ee.createElement(Oj,null),ee.createElement(_j,{style:{margin:0}},"Generating fix...")):ee.createElement(ee.Fragment,null,ee.createElement(Pj,null,ee.createElement(Lj,null,"AI-Generated Fix"),ee.createElement(Mj,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&ee.createElement(pI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&ee.createElement(pI,{style:{color:"#6b7280",fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?ee.createElement(dI,null,ee.createElement(fI,null,"View Diff"),ee.createElement($j,null,ee.createElement(gI,{side:"old"},ee.createElement(mI,{side:"old"},"Old"),ee.createElement(hI,null,bI(e.generatedFix.diffPreview).map((x,b)=>ee.createElement(xI,{key:`old-${b}`,type:x.oldLine.type},x.oldLine.content||"\xA0")))),ee.createElement(gI,{side:"new"},ee.createElement(mI,{side:"new"},"New"),ee.createElement(hI,null,bI(e.generatedFix.diffPreview).map((x,b)=>ee.createElement(xI,{key:`new-${b}`,type:x.newLine.type},x.newLine.content||"\xA0")))))):e.generatedFix.code&&ee.createElement(dI,null,ee.createElement(fI,null,"View Generated Code"),ee.createElement(Bj,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&ee.createElement(uI,null,ee.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&ee.createElement(Dj,null,ee.createElement(Rj,{onClick:()=>a(e.id)},"Apply Fix"),u&&ee.createElement(zj,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&ee.createElement(yI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&ee.createElement(yI,{status:"applied"},"\u2713 Fix applied successfully")))),ee.createElement(qT,{isOpen:f,issueTitle:e.title,onConfirm:L,onCancel:()=>d(!1)}))});import mx from"react";import{styled as hx,keyframes as Hj}from"storybook/theming";var Wj=Hj`
|
|
113
113
|
0% { transform: rotate(0deg); }
|
|
114
114
|
100% { transform: rotate(360deg); }
|
|
115
|
-
`,Vj=hx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),Gj=hx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${Wj} 0.8s linear infinite`})),qj=hx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Oc=({label:e="Loading..."})=>mx.createElement(Vj,null,mx.createElement(Gj,null),mx.createElement(qj,null,e));
|
|
115
|
+
`,Vj=hx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),Gj=hx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${Wj} 0.8s linear infinite`})),qj=hx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Oc=({label:e="Loading..."})=>mx.createElement(Vj,null,mx.createElement(Gj,null),mx.createElement(qj,null,e));we();import gt,{useState as Yj,useEffect as Kj,useRef as Xj}from"react";import{styled as fn,keyframes as ya}from"storybook/theming";var Gi="#8b6cc1",Qj="rgba(139, 108, 193, 0.2)",kI="rgba(139, 108, 193, 0.15)",Jj="rgba(139, 108, 193, 0.1)",Zj="rgba(139, 108, 193, 0.5)",CI=ya`
|
|
116
116
|
from { transform: rotate(0deg); }
|
|
117
117
|
to { transform: rotate(360deg); }
|
|
118
|
-
`,eH=
|
|
118
|
+
`,eH=ya`
|
|
119
119
|
from { transform: rotate(0deg); }
|
|
120
120
|
to { transform: rotate(-360deg); }
|
|
121
|
-
`,tH=
|
|
121
|
+
`,tH=ya`
|
|
122
122
|
0%, 100% { opacity: 1; transform: scale(1); }
|
|
123
123
|
50% { opacity: 0.6; transform: scale(1.05); }
|
|
124
|
-
`,nH=
|
|
124
|
+
`,nH=ya`
|
|
125
125
|
from { opacity: 0; transform: translateY(8px); }
|
|
126
126
|
to { opacity: 1; transform: translateY(0); }
|
|
127
|
-
`,rH=
|
|
127
|
+
`,rH=ya`
|
|
128
128
|
0%, 100% { opacity: 1; }
|
|
129
129
|
50% { opacity: 0.4; }
|
|
130
|
-
`,oH=fn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${nH} 0.4s ease-out`}),iH=fn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),sH=fn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${kI} 0%, transparent 70%)`,animation:`${tH} 2s ease-in-out infinite`}),aH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${Qj}`}),lH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:Gi,borderRightColor:Gi,animation:`${CI} 1.2s linear infinite`}),cH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${kI}`}),uH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:Zj,animation:`${eH} 1.8s linear infinite`}),pH=fn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),dH=fn.div({position:"absolute",inset:0,animation:`${CI} 3s linear infinite`}),fH=fn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:Gi}),gH=()=>gt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:Gi,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.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"}),gt.createElement("path",{d:"M5 3v4"}),gt.createElement("path",{d:"M3 5h4"}),gt.createElement("path",{d:"M19 17v4"}),gt.createElement("path",{d:"M17 19h4"})),mH=fn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),hH=fn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),xH=fn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),xx=fn.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:Jj,color:Gi},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),wI=fn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),vI=fn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:Gi,animation:`${rH} 1.5s ease-in-out infinite`}),yH=fn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),bH=()=>gt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("polyline",{points:"20 6 9 17 4 12"})),TI=()=>{let{streamingProgress:e}=
|
|
130
|
+
`,oH=fn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${nH} 0.4s ease-out`}),iH=fn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),sH=fn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${kI} 0%, transparent 70%)`,animation:`${tH} 2s ease-in-out infinite`}),aH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${Qj}`}),lH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:Gi,borderRightColor:Gi,animation:`${CI} 1.2s linear infinite`}),cH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${kI}`}),uH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:Zj,animation:`${eH} 1.8s linear infinite`}),pH=fn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),dH=fn.div({position:"absolute",inset:0,animation:`${CI} 3s linear infinite`}),fH=fn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:Gi}),gH=()=>gt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:Gi,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.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"}),gt.createElement("path",{d:"M5 3v4"}),gt.createElement("path",{d:"M3 5h4"}),gt.createElement("path",{d:"M19 17v4"}),gt.createElement("path",{d:"M17 19h4"})),mH=fn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),hH=fn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),xH=fn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),xx=fn.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:Jj,color:Gi},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),wI=fn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),vI=fn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:Gi,animation:`${rH} 1.5s ease-in-out infinite`}),yH=fn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),bH=()=>gt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("polyline",{points:"20 6 9 17 4 12"})),TI=()=>{let{streamingProgress:e}=se(),t=(e||0)>25,[n,r]=Yj(0),o=Xj();return Kj(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),gt.createElement(oH,null,gt.createElement(iH,null,gt.createElement(sH,null),gt.createElement(aH,null),gt.createElement(lH,null),gt.createElement(cH,null),gt.createElement(uH,null),gt.createElement(pH,null,gt.createElement(gH,null)),gt.createElement(dH,null,gt.createElement(fH,null))),gt.createElement(mH,null,"Analyzing designs"),gt.createElement(hH,null,"AI is comparing screenshots and detecting issues"),gt.createElement(xH,null,gt.createElement(xx,{variant:t?"done":"active"},t?gt.createElement(bH,null):gt.createElement(vI,null),"Screenshots"),gt.createElement(wI,null),gt.createElement(xx,{variant:t?"active":"pending"},t?gt.createElement(vI,null):null,"Analysis"),gt.createElement(wI,null),gt.createElement(xx,{variant:"pending"},"Report")),gt.createElement(yH,null,n,"s \xB7 Esc to stop"))};we();var Gde=it.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}})),qde=it.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:le})),CH=it.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),TH=it.div({display:"flex",gap:"8px"}),II=it(En)({flex:1}),IH=it.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}})),FH=it.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),EH=it.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"}})),AH=it.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),PH=it.div({display:"flex",alignItems:"center",gap:"2px"}),_c=it(wn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),yx=it.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),LH=it.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Yde=it.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Mo=it.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:le};case"selected":return{bg:e.color.tertiary,text:le};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:le};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"}}),MH=it.div({display:"flex",flexDirection:"column"}),BH=it.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),FI=it.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),EI=it.div({fontSize:"36px",marginBottom:"12px"}),AI=it.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),PI=it.div({fontSize:"12px"}),DH=kH`
|
|
131
131
|
0% {
|
|
132
132
|
transform: translateY(0) rotate(0deg) scale(1);
|
|
133
133
|
opacity: 1;
|
|
@@ -139,31 +139,31 @@ ${E.diffPreview}
|
|
|
139
139
|
transform: translateY(120px) rotate(720deg) scale(0.3);
|
|
140
140
|
opacity: 0;
|
|
141
141
|
}
|
|
142
|
-
`;var Kde=it.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Xde=it.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:`${DH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var RH=it.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}}})),zH=it(wn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),LI=it.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),MI=it(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),BI=it(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),DI=it(en)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),NH=it.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}}),OH=it.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),_H=it.span(({confidence:e})=>{let t=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:t,fontSize:"11px",fontWeight:700}}),$H=it.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),UH=it.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),$c=it.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),Uc=it.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),jH=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},RI=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:
|
|
143
|
-
${
|
|
144
|
-
${
|
|
142
|
+
`;var Kde=it.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Xde=it.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:`${DH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var RH=it.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}}})),zH=it(wn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),LI=it.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),MI=it(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),BI=it(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),DI=it(en)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),NH=it.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}}),OH=it.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),_H=it.span(({confidence:e})=>{let t=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:t,fontSize:"11px",fontWeight:700}}),$H=it.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),UH=it.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),$c=it.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),Uc=it.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),jH=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},RI=({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:f,onSelectAllFixes:d,onApplyFixes:m,onApplyFix:w,onCopyAllFixes:k,onGenerateFixes:F,onDismiss:C,onUndismiss:z,isGenerating:R=!1,isApplying:O=!1,isCopying:L=!1,applyFixesResult:B,onDismissResult:g,generationTiming:x,generationUsage:b,generationProgress:E,autoApplySupported:h=!0,hasReviewBeenRun:T=!1,isLoadingReview:I=!1,isReviewing:v=!1,selfReview:A})=>{let[P,D]=V.useState("all"),[N,S]=V.useState("all"),[j,G]=V.useState(!1),[M,J]=V.useState(!0),{includeComponentIssues:Z,setIncludeComponentIssues:oe,featureFlags:pe}=se(),ae=V.useRef(null),[qe,tt]=wH(0);vH(()=>{if(!R){tt(0);return}let re=setInterval(()=>tt(W=>W+1),1e3);return()=>clearInterval(re)},[R]);let Ve=async()=>{let re=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 ze=H.generatedFix;if(Ee.push(""),Ee.push("--- AI-Generated Fix ---"),Ee.push(`Fix Status: ${ze.status}`),ze.confidence!==void 0){let xt=ze.confidence>1?ze.confidence:Math.round(ze.confidence*100);Ee.push(`Confidence: ${xt}%`)}ze.strategy&&Ee.push(`Strategy: ${ze.strategy}`),ze.filePath&&Ee.push(`Target file: ${ze.filePath}`),ze.code&&Ee.push(`Generated code:
|
|
143
|
+
${ze.code}`),ze.diffPreview&&Ee.push(`Diff:
|
|
144
|
+
${ze.diffPreview}`),ze.error&&Ee.push(`Error: ${ze.error}`)}return Ee.push(""),Ee.filter(Boolean).join(`
|
|
145
145
|
`)}).join(`
|
|
146
146
|
---
|
|
147
147
|
|
|
148
|
-
`),W=
|
|
148
|
+
`),W=te.filter(H=>H.generatedFix?.status==="applied").length,Fe=te.filter(H=>H.generatedFix?.status==="ready").length,me=W>0||Fe>0?` | Fixes: ${W} applied, ${Fe} ready`:"",_=r!==void 0?` | Similarity: ${r}%`:"",U=`Score: ${n}/100${_} | ${te.length} issues${me}
|
|
149
149
|
|
|
150
|
-
`;try{await navigator.clipboard.writeText(U+ne),G(!0),setTimeout(()=>G(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};V.useEffect(()=>{B&&ae.current&&ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[B]);let pe=SH(()=>e.filter(ne=>{let W=P==="all"||ne.severity===P,Ae=N==="all"||ne.status===N,ge=ee||!jH(ne);return W&&Ae&&ge}),[e,P,N,ee]),Ie=()=>{pe.forEach(ne=>{ne.selectedForFix||l(ne.id)})},ze=()=>{pe.forEach(ne=>{ne.selectedForFix&&l(ne.id)})},me=()=>{pe.forEach(ne=>{ne.generatedFix&&ne.generatedFix.status==="ready"&&!ne.selectedForFix&&l(ne.id)})},Nt=pe.filter(ne=>ne.selectedForFix).length,he=pe.filter(ne=>ne.severity==="critical").length,vt=pe.filter(ne=>ne.severity==="major").length,Ge=pe.filter(ne=>ne.severity==="minor").length,lt=pe.filter(ne=>ne.generatedFix&&ne.generatedFix.status==="ready").length,nt=pe.filter(ne=>ne.selectedForFix&&ne.generatedFix&&ne.generatedFix.status==="ready").length;return e.length===0?I?V.createElement(Oc,{label:"Loading review..."}):v?V.createElement(TI,null):V.createElement(FI,null,V.createElement(EI,null,T?"\u2728":"\u{1F441}\uFE0F"),V.createElement(AI,null,T?"No issues found":"No review yet"),V.createElement(PI,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):V.createElement(CH,{"data-testid":"issues-panel"},V.createElement(TH,null,V.createElement(II,{value:P,onChange:ne=>D(ne.target.value)},V.createElement("option",{value:"all"},"All Severities"),V.createElement("option",{value:"critical"},"Critical Only"),V.createElement("option",{value:"major"},"Major Only"),V.createElement("option",{value:"minor"},"Minor Only")),V.createElement(II,{value:N,onChange:ne=>w(ne.target.value)},V.createElement("option",{value:"all"},"All Statuses"),V.createElement("option",{value:"pending"},"Pending"),V.createElement("option",{value:"applied"},"Applied"),V.createElement("option",{value:"verified"},"Verified"),V.createElement("option",{value:"failed"},"Failed"))),V.createElement("div",null,V.createElement(IH,{isOpen:L,onClick:()=>K(!L)},V.createElement(FH,null,V.createElement(EH,{isOpen:L},V.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},V.createElement("polyline",{points:"6 9 12 15 18 9"}))),V.createElement(LH,null,pe.length," issues"),(()=>{if(pe.length===0)return null;let ne=pe.map(ge=>ge.generatedFix?.filePath||ge.file).filter(Boolean);if(ne.length===0)return null;let W=ne[0];return ne.every(ge=>ge===W)?V.createElement(BH,null,"in ",W):null})(),V.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},he>0&&V.createElement(yx,{variant:"critical"},he," critical"),vt>0&&V.createElement(yx,{variant:"major"},vt," major"),Ge>0&&V.createElement(yx,{variant:"minor"},Ge," minor"))),V.createElement(PH,{onClick:ne=>ne.stopPropagation()},V.createElement(_c,{onClick:Ie},"All"),V.createElement(_c,{onClick:ze},"None"),V.createElement(_c,{onClick:se},j?"\u2713":"\u2398"," Copy"),lt>0&&V.createElement(_c,{onClick:me},"Fixes (",lt,")"))),B&&V.createElement(RH,{ref:ae,variant:B.error||B.failed>0?"warning":"success"},B.error?V.createElement(V.Fragment,null,B.error):B.failed>0?V.createElement(V.Fragment,null,"Applied ",B.succeeded,"/",B.total," fixes. ",B.failed," failed. Run a new review to verify."):V.createElement(V.Fragment,null,"Applied ",B.total," fix",B.total!==1?"es":"","! Run a new review to verify changes."),m&&V.createElement(zH,{onClick:m},"\u2715")),Nt>0&&V.createElement(LI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),de.enableFixGeneration&&F&&V.createElement(DI,{disabled:z||_||M,onClick:F},V.createElement("span",null,"\u{1F916}"),z&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:z?`Generating... (${qe}s)`:`Generate Fixes for ${Nt} Issue${Nt>1?"s":""}`),de.enableFixApply&&h&&g&&V.createElement(MI,{disabled:z||_||nt===0,onClick:g},_?"Applying...":z?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),de.enableFixApply&&!h&&C&&V.createElement(BI,{disabled:z||M||nt===0,copied:M,onClick:C},M?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")),A&&!z&&V.createElement(NH,{confidence:A.overallConfidence},V.createElement(OH,null,V.createElement($H,null,"AI Self-Review"),V.createElement(_H,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),V.createElement(UH,null,A.variantSafety&&V.createElement($c,null,V.createElement(Uc,null,"Variant safety: "),A.variantSafety),A.gaps.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Gaps: "),V.createElement("ul",null,A.gaps.map((ne,W)=>V.createElement("li",{key:W},ne)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Why not 100%: "),V.createElement("ul",null,A.reasonsNotPerfect.map((ne,W)=>V.createElement("li",{key:W},ne)))),A.suggestions&&A.suggestions.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Suggestions: "),V.createElement("ul",null,A.suggestions.map((ne,W)=>V.createElement("li",{key:W},ne)))))),L&&V.createElement(AH,null,pe.length===0?V.createElement(FI,null,V.createElement(EI,null,"\u{1F50D}"),V.createElement(AI,null,"No issues match current filters"),V.createElement(PI,null,"Try adjusting your severity or status filters")):V.createElement(MH,null,(()=>{let ne={};pe.forEach(U=>{let H=U.detectedBy;H&&(ne[H]=(ne[H]||0)+1)});let W=Object.entries(ne).sort((U,H)=>H[1]-U[1])[0],Ae=W&&W[1]>pe.length/2?W[0]:void 0,ge=pe.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),O=ge.length>0&&ge.every(U=>U===ge[0]);return pe.map(U=>V.createElement(SI,{key:U.id,issue:U,modelId:t,dominantDetector:Ae,showFilePath:!O,onToggleSelection:l,onDismiss:k,onUndismiss:R,onApplyFix:S}))})()))),Nt>0&&V.createElement(LI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),de.enableFixGeneration&&F&&V.createElement(DI,{disabled:z||_||M,onClick:F},V.createElement("span",null,"\u{1F916}"),z&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:z?`Generating... (${qe}s)`:`Generate Fixes for ${Nt} Issue${Nt>1?"s":""}`),de.enableFixApply&&h&&g&&V.createElement(MI,{disabled:z||_||nt===0,onClick:g},_?"Applying...":z?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),de.enableFixApply&&!h&&C&&V.createElement(BI,{disabled:z||M||nt===0,copied:M,onClick:C},M?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")))};De();var HH=Ct.div({display:"flex",flexDirection:"column"}),WH=Ct.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),VH=Ct.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),bx=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:le}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),GH=Ct.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),afe=Ct.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),lfe=Ct.div({fontSize:"48px",marginBottom:"16px"}),cfe=Ct.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),ufe=Ct.div({fontSize:"14px",opacity:.8}),qH=Ct.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),YH=Ct.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),KH=Ct(wn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),XH=Ct(Er)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),QH=Ct.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),JH=Ct.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),ZH=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"})),sW=e=>{if(!e)return"Other";let t=e.toLowerCase();return t.includes("hug")||t.includes("fill")||t.includes("content-driven")?"HUG/FILL Sizing":t.includes("sub-pixel")||t.includes("negligible")?"Sub-pixel Differences":t.includes("values match")||t.includes("values already match")||t.includes("identical")?"Values Match":t.includes("no fix needed")||t.includes("no changes needed")?"No Fix Needed":"Other"},zI=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:"#7c3aed",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n.user;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"}})),wx=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||wx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},NI=(e,t)=>{switch(e||wx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";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"})),fW=Ct(qx)({marginTop:"12px"}),Sx=class extends Ue.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?Ue.createElement(uW,null,Ue.createElement(pW,null,"\u26A0\uFE0F Issues Panel Error"),Ue.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),Ue.createElement(dW,null,this.state.error?.message||"Unknown error",`
|
|
150
|
+
`;try{await navigator.clipboard.writeText(U+re),G(!0),setTimeout(()=>G(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};V.useEffect(()=>{B&&ae.current&&ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[B]);let te=SH(()=>e.filter(re=>{let W=P==="all"||re.severity===P,Fe=N==="all"||re.status===N,me=Z||!jH(re);return W&&Fe&&me}),[e,P,N,Z]),Be=()=>{te.forEach(re=>{re.selectedForFix||l(re.id)})},Le=()=>{te.forEach(re=>{re.selectedForFix&&l(re.id)})},de=()=>{te.forEach(re=>{re.generatedFix&&re.generatedFix.status==="ready"&&!re.selectedForFix&&l(re.id)})},Et=te.filter(re=>re.selectedForFix).length,fe=te.filter(re=>re.severity==="critical").length,vt=te.filter(re=>re.severity==="major").length,Ge=te.filter(re=>re.severity==="minor").length,lt=te.filter(re=>re.generatedFix&&re.generatedFix.status==="ready").length,nt=te.filter(re=>re.selectedForFix&&re.generatedFix&&re.generatedFix.status==="ready").length;return e.length===0?I?V.createElement(Oc,{label:"Loading review..."}):v?V.createElement(TI,null):V.createElement(FI,null,V.createElement(EI,null,T?"\u2728":"\u{1F441}\uFE0F"),V.createElement(AI,null,T?"No issues found":"No review yet"),V.createElement(PI,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):V.createElement(CH,{"data-testid":"issues-panel"},V.createElement(TH,null,V.createElement(II,{value:P,onChange:re=>D(re.target.value)},V.createElement("option",{value:"all"},"All Severities"),V.createElement("option",{value:"critical"},"Critical Only"),V.createElement("option",{value:"major"},"Major Only"),V.createElement("option",{value:"minor"},"Minor Only")),V.createElement(II,{value:N,onChange:re=>S(re.target.value)},V.createElement("option",{value:"all"},"All Statuses"),V.createElement("option",{value:"pending"},"Pending"),V.createElement("option",{value:"applied"},"Applied"),V.createElement("option",{value:"verified"},"Verified"),V.createElement("option",{value:"failed"},"Failed"))),V.createElement("div",null,V.createElement(IH,{isOpen:M,onClick:()=>J(!M)},V.createElement(FH,null,V.createElement(EH,{isOpen:M},V.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},V.createElement("polyline",{points:"6 9 12 15 18 9"}))),V.createElement(LH,null,te.length," issues"),(()=>{if(te.length===0)return null;let re=te.map(me=>me.generatedFix?.filePath||me.file).filter(Boolean);if(re.length===0)return null;let W=re[0];return re.every(me=>me===W)?V.createElement(BH,null,"in ",W):null})(),V.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},fe>0&&V.createElement(yx,{variant:"critical"},fe," critical"),vt>0&&V.createElement(yx,{variant:"major"},vt," major"),Ge>0&&V.createElement(yx,{variant:"minor"},Ge," minor"))),V.createElement(PH,{onClick:re=>re.stopPropagation()},V.createElement(_c,{onClick:Be},"All"),V.createElement(_c,{onClick:Le},"None"),V.createElement(_c,{onClick:Ve},j?"\u2713":"\u2398"," Copy"),lt>0&&V.createElement(_c,{onClick:de},"Fixes (",lt,")"))),B&&V.createElement(RH,{ref:ae,variant:B.error||B.failed>0?"warning":"success"},B.error?V.createElement(V.Fragment,null,B.error):B.failed>0?V.createElement(V.Fragment,null,"Applied ",B.succeeded,"/",B.total," fixes. ",B.failed," failed. Run a new review to verify."):V.createElement(V.Fragment,null,"Applied ",B.total," fix",B.total!==1?"es":"","! Run a new review to verify changes."),g&&V.createElement(zH,{onClick:g},"\u2715")),Et>0&&V.createElement(LI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),pe.enableFixGeneration&&F&&V.createElement(DI,{disabled:R||O||L,onClick:F},V.createElement("span",null,"\u{1F916}"),R&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:R?`Generating... (${qe}s)`:`Generate Fixes for ${Et} Issue${Et>1?"s":""}`),pe.enableFixApply&&h&&m&&V.createElement(MI,{disabled:R||O||nt===0,onClick:m},O?"Applying...":R?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),pe.enableFixApply&&!h&&k&&V.createElement(BI,{disabled:R||L||nt===0,copied:L,onClick:k},L?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")),A&&!R&&V.createElement(NH,{confidence:A.overallConfidence},V.createElement(OH,null,V.createElement($H,null,"AI Self-Review"),V.createElement(_H,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),V.createElement(UH,null,A.variantSafety&&V.createElement($c,null,V.createElement(Uc,null,"Variant safety: "),A.variantSafety),A.gaps.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Gaps: "),V.createElement("ul",null,A.gaps.map((re,W)=>V.createElement("li",{key:W},re)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Why not 100%: "),V.createElement("ul",null,A.reasonsNotPerfect.map((re,W)=>V.createElement("li",{key:W},re)))),A.suggestions&&A.suggestions.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Suggestions: "),V.createElement("ul",null,A.suggestions.map((re,W)=>V.createElement("li",{key:W},re)))))),M&&V.createElement(AH,null,te.length===0?V.createElement(FI,null,V.createElement(EI,null,"\u{1F50D}"),V.createElement(AI,null,"No issues match current filters"),V.createElement(PI,null,"Try adjusting your severity or status filters")):V.createElement(MH,null,(()=>{let re={};te.forEach(U=>{let H=U.detectedBy;H&&(re[H]=(re[H]||0)+1)});let W=Object.entries(re).sort((U,H)=>H[1]-U[1])[0],Fe=W&&W[1]>te.length/2?W[0]:void 0,me=te.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),_=me.length>0&&me.every(U=>U===me[0]);return te.map(U=>V.createElement(SI,{key:U.id,issue:U,modelId:t,dominantDetector:Fe,showFilePath:!_,onToggleSelection:l,onDismiss:C,onUndismiss:z,onApplyFix:w}))})()))),Et>0&&V.createElement(LI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),pe.enableFixGeneration&&F&&V.createElement(DI,{disabled:R||O||L,onClick:F},V.createElement("span",null,"\u{1F916}"),R&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:R?`Generating... (${qe}s)`:`Generate Fixes for ${Et} Issue${Et>1?"s":""}`),pe.enableFixApply&&h&&m&&V.createElement(MI,{disabled:R||O||nt===0,onClick:m},O?"Applying...":R?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),pe.enableFixApply&&!h&&k&&V.createElement(BI,{disabled:R||L||nt===0,copied:L,onClick:k},L?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")))};De();var HH=Ct.div({display:"flex",flexDirection:"column"}),WH=Ct.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),VH=Ct.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),bx=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:le}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),GH=Ct.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),afe=Ct.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),lfe=Ct.div({fontSize:"48px",marginBottom:"16px"}),cfe=Ct.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),ufe=Ct.div({fontSize:"14px",opacity:.8}),qH=Ct.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),YH=Ct.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),KH=Ct(wn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),XH=Ct(Er)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),QH=Ct.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),JH=Ct.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),ZH=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"})),sW=e=>{if(!e)return"Other";let t=e.toLowerCase();return t.includes("hug")||t.includes("fill")||t.includes("content-driven")?"HUG/FILL Sizing":t.includes("sub-pixel")||t.includes("negligible")?"Sub-pixel Differences":t.includes("values match")||t.includes("values already match")||t.includes("identical")?"Values Match":t.includes("no fix needed")||t.includes("no changes needed")?"No Fix Needed":"Other"},zI=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:"#7c3aed",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n.user;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"}})),wx=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||wx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},NI=(e,t)=>{switch(e||wx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";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"})),fW=Ct(qx)({marginTop:"12px"}),Sx=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",`
|
|
151
151
|
|
|
152
|
-
`,this.state.error?.stack)
|
|
153
|
-
`).forEach(H=>{U.push(`// ${H}`)})),U.push("//"),U.push("// Full Fixed Code:"),U.push(
|
|
152
|
+
`,this.state.error?.stack),$e.createElement(fW,{onClick:this.handleReset},"Try Again")):this.props.children}},OI=()=>{let{currentStoryId:e}=rt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=se(),{dismissAndSync:a,undismissAndSync:u}=GT(),{loadingMapping:c}=rt(),l=!!e&&!t&&!n&&c,[p,f]=$e.useState(!1),[d,m]=$e.useState(!1),[w,k]=$e.useState(!1),{isSupported:F,isDetecting:C}=sm(),{refreshStorybookOnly:z}=Uo(),{generateBatchFixes:R,isGenerating:O,error:L,timing:B,progress:g,usage:x,selfReview:b,lastStorybookRoot:E}=nm(),{applyFixes:h,isApplying:T}=tm({onComplete:z,storybookRoot:E}),I=r.find(W=>W.id===t),v=I?.issues||[],A=$e.useMemo(()=>v.filter(W=>!W.dismissed),[v]),P=$e.useMemo(()=>v.filter(W=>W.dismissed),[v]),D=$e.useMemo(()=>{let W={postAiValidation:0,aiValidation:0,user:0};for(let Fe of P)switch(Fe.dismissedBy){case"post-ai-validation":W.postAiValidation++;break;case"ai-validation":W.aiValidation++;break;default:W.user++;break}return W},[P]),N=A,S=I?.modelId||"unknown",j=A.filter(W=>W.severity==="critical").length,G=A.filter(W=>W.severity==="major").length,M=A.filter(W=>W.severity==="minor").length,J=I?Si(j,G,M):void 0,Z=I?.visualSimilarity,oe=I?.costUsd,pe=I?.reviewDurationMs,ae=I?.inputTokens,qe=I?.outputTokens,tt=I?.cacheCreationTokens,Ve=I?.cacheReadTokens,te=I?.parentReviewId?r.find(W=>W.id===I.parentReviewId):null,Be=$e.useMemo(()=>{if(!te||!I)return null;let W=new Set(te.issues.map(H=>`${H.type}:${H.property||""}:${H.description}`)),Fe=new Set(N.map(H=>`${H.type}:${H.property||""}:${H.description}`)),me=te.issues.filter(H=>!Fe.has(`${H.type}:${H.property||""}:${H.description}`)).length,_=N.filter(H=>W.has(`${H.type}:${H.property||""}:${H.description}`)).length,U=N.filter(H=>!W.has(`${H.type}:${H.property||""}:${H.description}`)).length;return{resolved:me,remaining:_,newIssues:U}},[te,I,N]),Le=()=>{N.forEach(W=>{W.selectedForFix||o(W.id)})},de=()=>{N.forEach(W=>{W.selectedForFix&&o(W.id)})},Et=()=>{N.forEach(W=>{W.generatedFix&&W.generatedFix.status==="ready"&&!W.selectedForFix&&o(W.id)})},{featureFlags:fe}=se(),vt=()=>{if(!fe.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let W=N.filter(Fe=>Fe.selectedForFix);if(W.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${W.length} issue(s)`,W),R(W)},Ge=()=>{if(!fe.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let W=N.filter(me=>me.selectedForFix&&me.generatedFix&&me.generatedFix.status==="ready"&&me.generatedFix.code&&me.generatedFix.filePath);if(W.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Fe=W.map(me=>({id:me.id,reviewId:me.reviewId,type:me.type,severity:me.severity,title:me.title,description:me.description,generatedFix:me.generatedFix,storyId:I?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${Fe.length} issue(s)`,Fe),h(Fe)},lt=W=>{let Fe=N.find(_=>_.id===W);if(!Fe){y.warn("[IssuesPanel] Issue not found:",W);return}if(!Fe.generatedFix||Fe.generatedFix.status!=="ready"||!Fe.generatedFix.code||!Fe.generatedFix.filePath){y.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",W);return}let me={id:Fe.id,reviewId:Fe.reviewId,type:Fe.type,severity:Fe.severity,title:Fe.title,description:Fe.description,generatedFix:Fe.generatedFix,storyId:I?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",me),h([me])},nt=async()=>{let W=N.filter(me=>me.selectedForFix&&me.generatedFix&&me.generatedFix.status==="ready"&&me.generatedFix.code&&me.generatedFix.filePath);if(W.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Fe=W.map(me=>{let _=me.generatedFix,U=[];return U.push(`// File: ${_.filePath}`),U.push(`// Issue: ${me.title||me.description}`),me.currentValue&&U.push(`// Actual: ${me.currentValue}`),me.suggestedValue&&U.push(`// Expected (Figma): ${me.suggestedValue}`),_.diffPreview&&(U.push("//"),U.push("// Diff:"),_.diffPreview.split(`
|
|
153
|
+
`).forEach(H=>{U.push(`// ${H}`)})),U.push("//"),U.push("// Full Fixed Code:"),U.push(_.code),U.join(`
|
|
154
154
|
`)}).join(`
|
|
155
155
|
|
|
156
156
|
`+"=".repeat(60)+`
|
|
157
157
|
|
|
158
|
-
`);
|
|
158
|
+
`);m(!0);try{await am(Fe)?y.debug(`[IssuesPanel] Copied ${W.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>m(!1),1500)}catch(me){y.error("[IssuesPanel] Error copying fixes:",me),m(!1)}},re=async W=>{W.stopPropagation();let Fe=P.map(_=>[`[${_.severity.toUpperCase()}] ${_.title||_.description}`,`Phase: ${NI(_.dismissedBy,_.dismissReason)}`,_.dismissReason?`Reason: ${zI(_.dismissReason)}`:"",_.property?`Property: ${_.property}`:"",_.currentValue?`Current: ${_.currentValue}`:"",_.suggestedValue?`Expected: ${_.suggestedValue}`:""].filter(Boolean).join(`
|
|
159
159
|
`)).join(`
|
|
160
160
|
|
|
161
161
|
---
|
|
162
162
|
|
|
163
|
-
`),
|
|
163
|
+
`),me=`Filtered Issues (${P.length})
|
|
164
164
|
${"=".repeat(40)}
|
|
165
165
|
|
|
166
|
-
`;try{await navigator.clipboard.writeText(ge+Ae),C(!0),setTimeout(()=>C(!1),2e3)}catch(O){y.error("Failed to copy dismissed issues:",O)}};return Ue.createElement(HH,null,Ie&&Ue.createElement(WH,null,Ue.createElement(VH,null,"\u{1F4CA} Progress:"),Ue.createElement(bx,{variant:"resolved"},"\u2705 ",Ie.resolved," resolved"),Ue.createElement(bx,{variant:"remaining"},"\u23F3 ",Ie.remaining," remaining"),Ie.newIssues>0&&Ue.createElement(bx,{variant:"new"},"\u{1F195} ",Ie.newIssues," new"),Ue.createElement(GH,null,"Iteration ",I?.iterationNumber||1)),Ue.createElement(Sx,null,Ue.createElement(RI,{issues:N,modelId:w,complianceScore:K,visualSimilarity:ee,costUsd:re,reviewDurationMs:de,inputTokens:ae,outputTokens:qe,cacheCreationTokens:tt,cacheReadTokens:se,onToggleSelection:o,onSelectAll:ze,onSelectNone:me,onSelectAllFixes:Nt,onGenerateFixes:vt,onApplyFixes:Ge,onApplyFix:lt,onCopyAllFixes:nt,onDismiss:a,onUndismiss:u,isGenerating:_,isApplying:T,isCopying:p,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:B,generationUsage:x,hasReviewBeenRun:!!I,isLoadingReview:l,isReviewing:n,generationProgress:m,autoApplySupported:F,selfReview:b})),P.length>0&&Ue.createElement(qH,null,Ue.createElement(YH,null,Ue.createElement(KH,{onClick:()=>f(!d)},Ue.createElement("span",null,d?"\u25BC":"\u25B6"),Ue.createElement("span",null,"Filtered out"),Ue.createElement(QH,null,P.length),Ue.createElement(lW,null,D.postAiValidation>0&&Ue.createElement("span",null,"\u2699\uFE0F ",D.postAiValidation),D.aiValidation>0&&Ue.createElement("span",null,"\u2726 ",D.aiValidation),D.user>0&&Ue.createElement("span",null,"\u{1F464} ",D.user))),Ue.createElement(XH,{onClick:ne},S?"\u2713 Copied!":"Copy")),d&&Ue.createElement(JH,null,(()=>{let W=P.reduce((O,U)=>{let H=sW(U.dismissReason);return O[H]||(O[H]=[]),O[H].push(U),O},{}),Ae=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(W).sort((O,U)=>Ae.indexOf(O)-Ae.indexOf(U)).map(O=>Ue.createElement(Ue.Fragment,{key:O},Ue.createElement(oW,null,O,Ue.createElement(iW,null,W[O].length)),W[O].map(U=>Ue.createElement(ZH,{key:U.id},Ue.createElement(eW,null,Ue.createElement(aW,{phase:U.dismissedBy||wx(U.dismissReason)||"post-ai-validation"},cW(U.dismissedBy,U.dismissReason)," ",NI(U.dismissedBy,U.dismissReason)),Ue.createElement(tW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),Ue.createElement(nW,null,"[",U.severity.toUpperCase(),"] ",U.title||U.description),U.dismissReason&&Ue.createElement(rW,null,zI(U.dismissReason))))))})())))};var mW=ya.div({marginTop:"20px"}),hW=ya.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),xW=ya.div({display:"flex",alignItems:"center"}),vx=ya(io)({padding:"10px 16px"}),yW=ya.div({minHeight:"200px"}),kx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ie(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return gW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Tr.createElement(mW,null,Tr.createElement(hW,null,Tr.createElement(xW,null,a&&Tr.createElement(vx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Tr.createElement(vx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Tr.createElement(vx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Tr.createElement(yW,null,a&&e==="chat"&&(u?Tr.createElement(VT,null):Tr.createElement(ax,null)),e==="issues"&&Tr.createElement(OI,null),a&&e==="prompt"&&Tr.createElement(sx,null)))};ve();import J,{useState as ri,useRef as Fx,useEffect as vW,useMemo as kW}from"react";import{styled as wt,useTheme as CW}from"storybook/theming";je();De();var jc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},ba="uicopilot_feature_flags";function Cx(){try{let e=localStorage.getItem(ba);if(e){let t=JSON.parse(e);return{...jc,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return jc}function bW(e,t){try{let r={...Cx(),[e]:t},o={};for(let i in r){let s=i;r[s]!==jc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(ba,JSON.stringify(o)):localStorage.removeItem(ba),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function SW(){try{localStorage.removeItem(ba),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function Tx(e){return Cx()[e]}function wW(){let e=Object.keys(jc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(ba,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:Cx,set:bW,reset:SW,enableAll:wW,isEnabled:Tx}});De();pt();import gn from"react";var _I=()=>gn.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"},gn.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),gn.createElement("circle",{cx:"12",cy:"12",r:"3"}));var Ix={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"},Hc=()=>gn.createElement("svg",{...Ix},gn.createElement("circle",{cx:"11",cy:"11",r:"8"}),gn.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),$I=()=>gn.createElement("svg",{...Ix},gn.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),gn.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),gn.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),gn.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),gn.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),gn.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),UI=()=>gn.createElement("svg",{...Ix},gn.createElement("polyline",{points:"23 4 23 10 17 10"}),gn.createElement("polyline",{points:"1 20 1 14 7 14"}),gn.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"}));var Sa=wt.div({marginTop:"20px"}),Ex=wt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Ax=wt.div({display:"flex",alignItems:"center",gap:"12px"}),wa=wt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Rfe=wt.div({display:"flex",gap:"8px"}),zfe=wt.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}})),jI=wt.div(({layout:e})=>({display:e==="side-by-side"?"grid":"flex",gridTemplateColumns:e==="side-by-side"?"1fr 1fr":void 0,gap:e==="side-by-side"?"12px":0,position:"relative",width:"100%",justifyContent:e==="overlay"?"center":void 0})),Wc=wt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:e.background.app,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center"})),Vc=wt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.7)",color:e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),Px=wt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),va=wt.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=wt.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),IW=wt.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),FW=wt.div({position:"relative",display:"inline-block"}),Nfe=wt.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=wt.div({position:"relative",display:"inline-block"}),Ofe=wt.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=wt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),PW=wt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),LW=wt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),MW=wt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),BW=wt.input({flex:1}),Lx=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),_fe=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),HI=wt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),qi=wt.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%"}}})),Yi=wt.div({textAlign:"center",zIndex:1}),Ki=wt.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"12px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Xi=wt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Mx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=CW(),{currentMapping:o,loadingMapping:i}=rt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:f}=ie(),{selectedProjectId:p}=Ze(),{sessionToken:g}=we(),{openComponentBrowser:S}=Rs(),{hasMapping:C,deleteMapping:F,setCurrentMapping:k}=Ho(),R=Tx("enableHoverHighlight"),[z,_]=ri("side-by-side"),[M,B]=ri(.5),[m,x]=ri(!1),[b,E]=ri(!1),[h,T]=ri(!1),I=async()=>{T(!1);try{let re=o?.id;re&&await F(re),k(null)}catch(re){y.error("[ScreenshotComparison] Failed to unlink:",re)}};vW(()=>{E(!1)},[s]);let[v,A]=ri(null),[P,D]=ri(null),N=Fx(null),w=Fx(null),j=Fx(null),G=kW(()=>{if(!R||!l||!f)return null;let re=d.find(de=>de.id===f);return re?.issues&&re.issues.find(de=>de.id===l)||null},[l,f,d]),L=re=>{let de=re.currentTarget;E(!0),!mt.getState().figmaDimensions&&de.naturalWidth&&de.naturalHeight&&mt.getState().setFigmaDimensions({width:de.naturalWidth,height:de.naturalHeight}),requestAnimationFrame(()=>{if(w.current){let{clientWidth:qe,clientHeight:tt}=w.current;qe&&tt&&D({width:qe,height:tt})}})},K=()=>{requestAnimationFrame(()=>{if(N.current){let{clientWidth:re,clientHeight:de}=N.current;re&&de&&A({width:re,height:de})}})},ee=async()=>{if(!(!p||!g)){x(!0);try{let re=q();await oe(`${re}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(re){y.error("Failed to refresh Figma:",re)}finally{x(!1)}}};return e?J.createElement(Sa,null,J.createElement(Ex,null,J.createElement(Ax,null,J.createElement(wa,null,"Screenshot Comparison"))),J.createElement(HI,null,J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading Figma..."))),J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?J.createElement(Sa,null,J.createElement(Ex,null,J.createElement(Ax,null,J.createElement(wa,null,"Screenshot Comparison"))),J.createElement(HI,null,J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading..."))))):J.createElement(Sa,null,J.createElement(wa,null,"Screenshot Comparison"),J.createElement(Wc,null,J.createElement(Vc,null,"Figma Design"),J.createElement(Px,null,J.createElement(va,{accent:r.color.secondary,onClick:S,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},J.createElement(Hc,null))),J.createElement(Lx,{style:{border:"none",padding:"16px"}},"No Figma mapping."))):!s&&!a?J.createElement(Sa,null,J.createElement(wa,null,"Screenshot Comparison"),J.createElement(Lx,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):J.createElement(Sa,{ref:j},J.createElement(Ex,null,J.createElement(Ax,null,J.createElement(wa,null,"Screenshot Comparison"))),z==="side-by-side"?J.createElement(jI,{layout:"side-by-side"},s&&!t?J.createElement(Wc,null,J.createElement(Vc,null,"Figma Design"),J.createElement(Px,null,C&&J.createElement(va,{accent:r.color.secondary,onClick:S,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},J.createElement(Hc,null)),J.createElement(va,{accent:r.color.positive,onClick:ee,disabled:m,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},J.createElement(UI,null)),C&&J.createElement(va,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},J.createElement($I,null))),J.createElement(FW,null,J.createElement(IW,{ref:w,src:s,alt:"Figma design",onLoad:L,style:{...v?{width:v.width,height:v.height}:{maxWidth:"100%",maxHeight:"120px"},opacity:b?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?J.createElement(Wc,null,J.createElement(Vc,null,"Figma Design"),J.createElement(Px,null,J.createElement(va,{accent:r.color.secondary,onClick:S,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},J.createElement(Hc,null))),J.createElement(Lx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?J.createElement(Wc,null,J.createElement(Vc,null,"Storybook Component"),J.createElement(TW,{ref:N,src:a,alt:"Storybook component",onLoad:K})):J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):J.createElement(J.Fragment,null,J.createElement(jI,{layout:"overlay"},J.createElement(EW,null,s&&a?J.createElement(J.Fragment,null,J.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},J.createElement(AW,{ref:N,src:a,alt:"Storybook component",onLoad:K,style:{maxHeight:"200px"}}),v&&J.createElement(PW,{src:s,alt:"Figma design overlay",style:{opacity:M,width:v.width,height:v.height,objectFit:"fill"}})),J.createElement("div",{style:{fontSize:"10px",color:"#888",marginTop:"8px",textAlign:"center"}},J.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",J.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),v&&` \u2022 ${v.width}\xD7${v.height}px`)):J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading Images..."))))),a&&s&&J.createElement(LW,null,J.createElement(MW,null,"Figma Opacity:"),J.createElement(BW,{type:"range",min:"0",max:"1",step:"0.01",value:M,onChange:re=>B(parseFloat(re.target.value))}),J.createElement("span",null,Math.round(M*100),"%"))),J.createElement(Di,{isOpen:h,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:I,onCancel:()=>T(!1)}))};ve();pt();var DW=Qi.div({height:"100%"}),Bx=Qi.div({marginBottom:"20px"}),WI=Qi.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"})),VI=Qi.span({fontSize:"16px",flexShrink:0}),RW=Qi.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})),GI=Qi.div({flex:1}),Dx=()=>{let{reviewError:e,getCurrentReview:t}=ie(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Rs(),{selectedProjectId:s}=qr(),{setCurrentMapping:a}=Ho(),{currentStoryId:u,currentStoryName:c}=rt(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:f,screenshotError:p,setFigmaImageDirect:g}=Uo(),S=async C=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",C),y.debug("[ReviewPanel] frame.id:",C?.id);let F=mt.getState(),k=F.selectedProjectId,R=F.currentStoryId,z=F.currentStoryName,_=F.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",k),y.debug("[ReviewPanel] currentStoryId (from store):",R),y.debug("[ReviewPanel] currentStoryName (from store):",z),C.thumbnail&&R&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),g(R,C.id,C.thumbnail));try{let M=q(),B=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!B),y.debug("[ReviewPanel] dashboardUrl:",M),!B||!k||!R){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!B,selectedProjectId:k,currentStoryId:R});return}let m=_?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:k,storyId:R,name:z,figmaNodeId:C.id,figmaFileKey:m});let x=await oe(`${M}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`},body:JSON.stringify({projectId:k,storyId:R,name:z,figmaNodeId:C.id,figmaFileKey:m})});if(x.ok){let b=await x.json();b.mapping&&(a(b.mapping),C.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),mt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",b.mapping))}else{let b=await x.text();y.error("[ReviewPanel] Failed to save mapping:",b)}}catch(M){y.error("[ReviewPanel] Error saving mapping:",M)}};return Xt.createElement(DW,null,Xt.createElement(Bx,null,Xt.createElement(oh,null)),e&&Xt.createElement(WI,null,Xt.createElement(VI,null,"\u26A0\uFE0F"),Xt.createElement(GI,null,e)),p&&Xt.createElement(WI,null,Xt.createElement(VI,null,"\u26A0\uFE0F"),Xt.createElement(GI,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(Bx,null,Xt.createElement(Mx,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:f})),Xt.createElement(Bx,null,Xt.createElement(kx,null)),Xt.createElement(Mi,{isOpen:r,onClose:o,onSelect:S,figmaFileUrl:i||"",projectId:s||void 0}))};ve();De();je();pt();import{useEffect as qI,useState as zW,useRef as Rx,useCallback as NW}from"react";var OW=q(),_W=2e3;function YI(){let{sessionToken:e,usageData:t,setUsageData:n}=we(),[r,o]=zW(null),i=Rx(null),s=Rx(!1),a=Rx(0);qI(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=NW(()=>{o(null)},[]);return qI(()=>{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 f=await oe(`${OW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(f.ok){let p=await f.json(),g=p.creditBalance,S=i.current;if(S!==null&&g>S){let C=g-S;o({message:`Credits added! +${Math.floor(C)} credit(s)`,previousBalance:S,newBalance:g}),y.debug("[useBalanceRefresh] Credits added:",C)}i.current=g,n(p),y.debug("[useBalanceRefresh] Balance updated:",g)}}catch(f){y.error("[useBalanceRefresh] Failed to refresh:",f)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}ve();ve();je();De();pt();xg();import{useEffect as $W,useRef as UW}from"react";var jW=300*1e3,KI="uicopilot_feature_flags_fetched_at";function HW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(KI);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<jW}catch{return!1}}var zx=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 XI(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ie(),{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(zx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;zx=oe(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"&&nw());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(KI,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{zx=null})},[r,e,t])}ve();je();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=fr.div`
|
|
166
|
+
`;try{await navigator.clipboard.writeText(me+Fe),k(!0),setTimeout(()=>k(!1),2e3)}catch(_){y.error("Failed to copy dismissed issues:",_)}};return $e.createElement(HH,null,Be&&$e.createElement(WH,null,$e.createElement(VH,null,"\u{1F4CA} Progress:"),$e.createElement(bx,{variant:"resolved"},"\u2705 ",Be.resolved," resolved"),$e.createElement(bx,{variant:"remaining"},"\u23F3 ",Be.remaining," remaining"),Be.newIssues>0&&$e.createElement(bx,{variant:"new"},"\u{1F195} ",Be.newIssues," new"),$e.createElement(GH,null,"Iteration ",I?.iterationNumber||1)),$e.createElement(Sx,null,$e.createElement(RI,{issues:N,modelId:S,complianceScore:J,visualSimilarity:Z,costUsd:oe,reviewDurationMs:pe,inputTokens:ae,outputTokens:qe,cacheCreationTokens:tt,cacheReadTokens:Ve,onToggleSelection:o,onSelectAll:Le,onSelectNone:de,onSelectAllFixes:Et,onGenerateFixes:vt,onApplyFixes:Ge,onApplyFix:lt,onCopyAllFixes:nt,onDismiss:a,onUndismiss:u,isGenerating:O,isApplying:T,isCopying:d,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:B,generationUsage:x,hasReviewBeenRun:!!I,isLoadingReview:l,isReviewing:n,generationProgress:g,autoApplySupported:F,selfReview:b})),P.length>0&&$e.createElement(qH,null,$e.createElement(YH,null,$e.createElement(KH,{onClick:()=>f(!p)},$e.createElement("span",null,p?"\u25BC":"\u25B6"),$e.createElement("span",null,"Filtered out"),$e.createElement(QH,null,P.length),$e.createElement(lW,null,D.postAiValidation>0&&$e.createElement("span",null,"\u2699\uFE0F ",D.postAiValidation),D.aiValidation>0&&$e.createElement("span",null,"\u2726 ",D.aiValidation),D.user>0&&$e.createElement("span",null,"\u{1F464} ",D.user))),$e.createElement(XH,{onClick:re},w?"\u2713 Copied!":"Copy")),p&&$e.createElement(JH,null,(()=>{let W=P.reduce((_,U)=>{let H=sW(U.dismissReason);return _[H]||(_[H]=[]),_[H].push(U),_},{}),Fe=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(W).sort((_,U)=>Fe.indexOf(_)-Fe.indexOf(U)).map(_=>$e.createElement($e.Fragment,{key:_},$e.createElement(oW,null,_,$e.createElement(iW,null,W[_].length)),W[_].map(U=>$e.createElement(ZH,{key:U.id},$e.createElement(eW,null,$e.createElement(aW,{phase:U.dismissedBy||wx(U.dismissReason)||"post-ai-validation"},cW(U.dismissedBy,U.dismissReason)," ",NI(U.dismissedBy,U.dismissReason)),$e.createElement(tW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),$e.createElement(nW,null,"[",U.severity.toUpperCase(),"] ",U.title||U.description),U.dismissReason&&$e.createElement(rW,null,zI(U.dismissReason))))))})())))};var mW=ba.div({marginTop:"20px"}),hW=ba.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),xW=ba.div({display:"flex",alignItems:"center"}),vx=ba(io)({padding:"10px 16px"}),yW=ba.div({minHeight:"200px"}),kx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=se(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return gW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Tr.createElement(mW,null,Tr.createElement(hW,null,Tr.createElement(xW,null,a&&Tr.createElement(vx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Tr.createElement(vx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Tr.createElement(vx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Tr.createElement(yW,null,a&&e==="chat"&&(u?Tr.createElement(VT,null):Tr.createElement(ax,null)),e==="issues"&&Tr.createElement(OI,null),a&&e==="prompt"&&Tr.createElement(sx,null)))};we();import Q,{useState as ri,useRef as Fx,useEffect as vW,useMemo as kW}from"react";import{styled as wt,useTheme as CW}from"storybook/theming";Ue();De();var jc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Sa="uicopilot_feature_flags";function Cx(){try{let e=localStorage.getItem(Sa);if(e){let t=JSON.parse(e);return{...jc,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return jc}function bW(e,t){try{let r={...Cx(),[e]:t},o={};for(let i in r){let s=i;r[s]!==jc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Sa,JSON.stringify(o)):localStorage.removeItem(Sa),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function SW(){try{localStorage.removeItem(Sa),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function Tx(e){return Cx()[e]}function wW(){let e=Object.keys(jc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Sa,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:Cx,set:bW,reset:SW,enableAll:wW,isEnabled:Tx}});De();pt();import gn from"react";var _I=()=>gn.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"},gn.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),gn.createElement("circle",{cx:"12",cy:"12",r:"3"}));var Ix={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"},Hc=()=>gn.createElement("svg",{...Ix},gn.createElement("circle",{cx:"11",cy:"11",r:"8"}),gn.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),$I=()=>gn.createElement("svg",{...Ix},gn.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),gn.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),gn.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),gn.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),gn.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),gn.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),UI=()=>gn.createElement("svg",{...Ix},gn.createElement("polyline",{points:"23 4 23 10 17 10"}),gn.createElement("polyline",{points:"1 20 1 14 7 14"}),gn.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"}));var wa=wt.div({marginTop:"20px"}),Ex=wt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Ax=wt.div({display:"flex",alignItems:"center",gap:"12px"}),va=wt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Rfe=wt.div({display:"flex",gap:"8px"}),zfe=wt.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}})),jI=wt.div(({layout:e})=>({display:e==="side-by-side"?"grid":"flex",gridTemplateColumns:e==="side-by-side"?"1fr 1fr":void 0,gap:e==="side-by-side"?"12px":0,position:"relative",width:"100%",justifyContent:e==="overlay"?"center":void 0})),Wc=wt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:e.background.app,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center"})),Vc=wt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.7)",color:e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),Px=wt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),ka=wt.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=wt.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),IW=wt.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),FW=wt.div({position:"relative",display:"inline-block"}),Nfe=wt.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=wt.div({position:"relative",display:"inline-block"}),Ofe=wt.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=wt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),PW=wt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),LW=wt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),MW=wt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),BW=wt.input({flex:1}),Lx=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),_fe=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),HI=wt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),qi=wt.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%"}}})),Yi=wt.div({textAlign:"center",zIndex:1}),Ki=wt.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"12px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Xi=wt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Mx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=CW(),{currentMapping:o,loadingMapping:i}=rt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:p,currentReviewId:f}=se(),{selectedProjectId:d}=Ze(),{sessionToken:m}=Se(),{openComponentBrowser:w}=Rs(),{hasMapping:k,deleteMapping:F,setCurrentMapping:C}=Ho(),z=Tx("enableHoverHighlight"),[R,O]=ri("side-by-side"),[L,B]=ri(.5),[g,x]=ri(!1),[b,E]=ri(!1),[h,T]=ri(!1),I=async()=>{T(!1);try{let oe=o?.id;oe&&await F(oe),C(null)}catch(oe){y.error("[ScreenshotComparison] Failed to unlink:",oe)}};vW(()=>{E(!1)},[s]);let[v,A]=ri(null),[P,D]=ri(null),N=Fx(null),S=Fx(null),j=Fx(null),G=kW(()=>{if(!z||!l||!f)return null;let oe=p.find(pe=>pe.id===f);return oe?.issues&&oe.issues.find(pe=>pe.id===l)||null},[l,f,p]),M=oe=>{let pe=oe.currentTarget;E(!0),!mt.getState().figmaDimensions&&pe.naturalWidth&&pe.naturalHeight&&mt.getState().setFigmaDimensions({width:pe.naturalWidth,height:pe.naturalHeight}),requestAnimationFrame(()=>{if(S.current){let{clientWidth:qe,clientHeight:tt}=S.current;qe&&tt&&D({width:qe,height:tt})}})},J=()=>{requestAnimationFrame(()=>{if(N.current){let{clientWidth:oe,clientHeight:pe}=N.current;oe&&pe&&A({width:oe,height:pe})}})},Z=async()=>{if(!(!d||!m)){x(!0);try{let oe=q();await ie(`${oe}/api/figma/frames/invalidate?projectId=${d}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(oe){y.error("Failed to refresh Figma:",oe)}finally{x(!1)}}};return e?Q.createElement(wa,null,Q.createElement(Ex,null,Q.createElement(Ax,null,Q.createElement(va,null,"Screenshot Comparison"))),Q.createElement(HI,null,Q.createElement(qi,null,Q.createElement(Yi,null,Q.createElement(Ki,null),Q.createElement(Xi,null,"Loading Figma..."))),Q.createElement(qi,null,Q.createElement(Yi,null,Q.createElement(Ki,null),Q.createElement(Xi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?Q.createElement(wa,null,Q.createElement(Ex,null,Q.createElement(Ax,null,Q.createElement(va,null,"Screenshot Comparison"))),Q.createElement(HI,null,Q.createElement(qi,null,Q.createElement(Yi,null,Q.createElement(Ki,null),Q.createElement(Xi,null,"Loading..."))))):Q.createElement(wa,null,Q.createElement(va,null,"Screenshot Comparison"),Q.createElement(Wc,null,Q.createElement(Vc,null,"Figma Design"),Q.createElement(Px,null,Q.createElement(ka,{accent:r.color.secondary,onClick:w,disabled:!d,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},Q.createElement(Hc,null))),Q.createElement(Lx,{style:{border:"none",padding:"16px"}},"No Figma mapping."))):!s&&!a?Q.createElement(wa,null,Q.createElement(va,null,"Screenshot Comparison"),Q.createElement(Lx,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):Q.createElement(wa,{ref:j},Q.createElement(Ex,null,Q.createElement(Ax,null,Q.createElement(va,null,"Screenshot Comparison"))),R==="side-by-side"?Q.createElement(jI,{layout:"side-by-side"},s&&!t?Q.createElement(Wc,null,Q.createElement(Vc,null,"Figma Design"),Q.createElement(Px,null,k&&Q.createElement(ka,{accent:r.color.secondary,onClick:w,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},Q.createElement(Hc,null)),Q.createElement(ka,{accent:r.color.positive,onClick:Z,disabled:g,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},Q.createElement(UI,null)),k&&Q.createElement(ka,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},Q.createElement($I,null))),Q.createElement(FW,null,Q.createElement(IW,{ref:S,src:s,alt:"Figma design",onLoad:M,style:{...v?{width:v.width,height:v.height}:{maxWidth:"100%",maxHeight:"120px"},opacity:b?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?Q.createElement(Wc,null,Q.createElement(Vc,null,"Figma Design"),Q.createElement(Px,null,Q.createElement(ka,{accent:r.color.secondary,onClick:w,disabled:!d,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},Q.createElement(Hc,null))),Q.createElement(Lx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):Q.createElement(qi,null,Q.createElement(Yi,null,Q.createElement(Ki,null),Q.createElement(Xi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?Q.createElement(Wc,null,Q.createElement(Vc,null,"Storybook Component"),Q.createElement(TW,{ref:N,src:a,alt:"Storybook component",onLoad:J})):Q.createElement(qi,null,Q.createElement(Yi,null,Q.createElement(Ki,null),Q.createElement(Xi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):Q.createElement(Q.Fragment,null,Q.createElement(jI,{layout:"overlay"},Q.createElement(EW,null,s&&a?Q.createElement(Q.Fragment,null,Q.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},Q.createElement(AW,{ref:N,src:a,alt:"Storybook component",onLoad:J,style:{maxHeight:"200px"}}),v&&Q.createElement(PW,{src:s,alt:"Figma design overlay",style:{opacity:L,width:v.width,height:v.height,objectFit:"fill"}})),Q.createElement("div",{style:{fontSize:"10px",color:"#888",marginTop:"8px",textAlign:"center"}},Q.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",Q.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),v&&` \u2022 ${v.width}\xD7${v.height}px`)):Q.createElement(qi,null,Q.createElement(Yi,null,Q.createElement(Ki,null),Q.createElement(Xi,null,"Loading Images..."))))),a&&s&&Q.createElement(LW,null,Q.createElement(MW,null,"Figma Opacity:"),Q.createElement(BW,{type:"range",min:"0",max:"1",step:"0.01",value:L,onChange:oe=>B(parseFloat(oe.target.value))}),Q.createElement("span",null,Math.round(L*100),"%"))),Q.createElement(Di,{isOpen:h,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:I,onCancel:()=>T(!1)}))};we();pt();var DW=Qi.div({height:"100%"}),Bx=Qi.div({marginBottom:"20px"}),WI=Qi.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"})),VI=Qi.span({fontSize:"16px",flexShrink:0}),RW=Qi.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})),GI=Qi.div({flex:1}),Dx=()=>{let{reviewError:e,getCurrentReview:t}=se(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Rs(),{selectedProjectId:s}=qr(),{setCurrentMapping:a}=Ho(),{currentStoryId:u,currentStoryName:c}=rt(),{isLoadingScreenshots:l,isLoadingFigma:p,isLoadingStorybook:f,screenshotError:d,setFigmaImageDirect:m}=Uo(),w=async k=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",k),y.debug("[ReviewPanel] frame.id:",k?.id);let F=mt.getState(),C=F.selectedProjectId,z=F.currentStoryId,R=F.currentStoryName,O=F.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",C),y.debug("[ReviewPanel] currentStoryId (from store):",z),y.debug("[ReviewPanel] currentStoryName (from store):",R),k.thumbnail&&z&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),m(z,k.id,k.thumbnail));try{let L=q(),B=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!B),y.debug("[ReviewPanel] dashboardUrl:",L),!B||!C||!z){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!B,selectedProjectId:C,currentStoryId:z});return}let g=O?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:C,storyId:z,name:R,figmaNodeId:k.id,figmaFileKey:g});let x=await ie(`${L}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`},body:JSON.stringify({projectId:C,storyId:z,name:R,figmaNodeId:k.id,figmaFileKey:g})});if(x.ok){let b=await x.json();b.mapping&&(a(b.mapping),k.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),mt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",b.mapping))}else{let b=await x.text();y.error("[ReviewPanel] Failed to save mapping:",b)}}catch(L){y.error("[ReviewPanel] Error saving mapping:",L)}};return Xt.createElement(DW,null,Xt.createElement(Bx,null,Xt.createElement(oh,null)),e&&Xt.createElement(WI,null,Xt.createElement(VI,null,"\u26A0\uFE0F"),Xt.createElement(GI,null,e)),d&&Xt.createElement(WI,null,Xt.createElement(VI,null,"\u26A0\uFE0F"),Xt.createElement(GI,null,"Screenshot loading error: ",d)),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(Bx,null,Xt.createElement(Mx,{isLoading:l,isLoadingFigma:p,isLoadingStorybook:f})),Xt.createElement(Bx,null,Xt.createElement(kx,null)),Xt.createElement(Mi,{isOpen:r,onClose:o,onSelect:w,figmaFileUrl:i||"",projectId:s||void 0}))};we();De();Ue();pt();import{useEffect as qI,useState as zW,useRef as Rx,useCallback as NW}from"react";var OW=q(),_W=2e3;function YI(){let{sessionToken:e,usageData:t,setUsageData:n}=Se(),[r,o]=zW(null),i=Rx(null),s=Rx(!1),a=Rx(0);qI(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=NW(()=>{o(null)},[]);return qI(()=>{if(!e)return;let c=async()=>{let p=Date.now();if(s.current||p-a.current<_W){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=p;try{y.debug("[useBalanceRefresh] Refreshing balance...");let f=await ie(`${OW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(f.ok){let d=await f.json(),m=d.creditBalance,w=i.current;if(w!==null&&m>w){let k=m-w;o({message:`Credits added! +${Math.floor(k)} credit(s)`,previousBalance:w,newBalance:m}),y.debug("[useBalanceRefresh] Credits added:",k)}i.current=m,n(d),y.debug("[useBalanceRefresh] Balance updated:",m)}}catch(f){y.error("[useBalanceRefresh] Failed to refresh:",f)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}we();we();Ue();De();pt();xg();import{useEffect as $W,useRef as UW}from"react";var jW=300*1e3,KI="uicopilot_feature_flags_fetched_at";function HW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(KI);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<jW}catch{return!1}}var zx=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 XI(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=se(),{sessionToken:r,resetAuth:o}=Se(),i=UW(null);$W(()=>{if(!r||r===i.current)return;if(i.current=r,HW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(zx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;zx=ie(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"&&nw());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(KI,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{zx=null})},[r,e,t])}we();Ue();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=fr.div`
|
|
167
167
|
position: fixed;
|
|
168
168
|
top: 16px;
|
|
169
169
|
right: 16px;
|
|
@@ -195,8 +195,8 @@ ${"=".repeat(40)}
|
|
|
195
195
|
color: ${({theme:e})=>e.color.mediumdark};
|
|
196
196
|
text-align: center;
|
|
197
197
|
opacity: 0.7;
|
|
198
|
-
`,ZW=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),e8=fr.div({fontSize:"32px"}),t8=fr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),n8=fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),QI=fr.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})),JI=fr.span({flex:1}),ZI=fr.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`}})),eF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ze(),{isConnected:r,sessionToken:o,authError:i}=
|
|
199
|
-
`);r=p.pop()||"";for(let g of p)if(g.startsWith("data: "))try{let S=JSON.parse(g.slice(6));if(S.type==="complete"){o=S.complianceScore??S.validation?.complianceScore??null;let F=(S.issues||[]).filter(k=>!k.dismissed);i=F.filter(k=>k.severity==="critical").length,s=F.filter(k=>k.severity==="major").length,a=F.filter(k=>k.severity==="minor").length,u=S.costUsd||0,c=S.inputTokens||0,l=S.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function Gc(e,t,n,r,o){e&&e.set([{value:n,typeId:c8,storyId:t,title:r,description:o}])}async function d8(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 oF(e,t,n,r,o,i){Gc(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await d8(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await u8(`${l8}/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 p8(u,i),{score:l,criticalCount:d,majorCount:f,minorCount:p,costUsd:g,inputTokens:S,outputTokens:C}=c;if(l!==null){let F=d>0||l<70?"status-value:error":f>0||l<90?"status-value:warning":"status-value:success",k=[`Score: ${l}`];d>0&&k.push(`${d} critical`),f>0&&k.push(`${f} major`),p>0&&k.push(`${p} minor`);let R=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return Gc(o,e.storyId,F,R,k.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:g,inputTokens:S,outputTokens:C}}return Gc(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 Gc(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var g8=q(),ka="uireview/badge";function iF(){let e=!1,t=!1;try{let n=f8.getChannel();n.on(Ox,async()=>{if(!t){t=!0,e=!1;try{await x8(n,()=>e)}finally{t=!1}}}),n.on(_x,()=>{e=!0})}catch{}}async function Nx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${g8}/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 m8(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function m8(e){try{if(typeof qc!="function")return;let t=qc(ka);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[ka]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[ka];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:ka,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 h8(){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 x8(e,t){let n=await Nx();if(n.length===0){e.emit(Ta,{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-5-20250929";try{let S=localStorage.getItem("uicopilot_selected_models");if(S){let C=JSON.parse(S);Array.isArray(C)&&C.length>0&&(i=C[0])}}catch{}let s=null;try{typeof qc=="function"&&(s=qc(ka))}catch{}let a=h8(),u=0,c=0,l=0,d=0,f=0,p=0;e.emit(Ca,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let g=n.map(S=>()=>oF(S,r,o,i,s,t));await rF(g,a,(S,C)=>{if(C&&typeof C=="object"&&"score"in C){let F=C;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,d+=F.costUsd||0,f+=F.inputTokens||0,p+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${S+1}/${n.length} done:`,n[S].storyName,C),e.emit(Ca,{total:n.length,completed:u+c+l,currentStoryName:n[S].storyName})},t),e.emit(Ta,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:f,outputTokens:p})}var b8=ro.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),S8=ro.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),w8=ro.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),aF=ro.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),lF=ro.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}})),v8=ro.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),k8=ro.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),cF=ro.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Ji=ro.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Ox="uireview/review-all-start",_x="uireview/review-all-cancel",Ca="uireview/review-all-progress",Ta="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 pF=()=>{let[e,t]=Ia(!1),[n,r]=Ia(null),[o,i]=Ia(null),[s,a]=Ia(null),[u,c]=Ia(uF);$x(()=>{let g=()=>c(uF()),S=setInterval(g,2e3);return window.addEventListener("storage",g),()=>{clearInterval(S),window.removeEventListener("storage",g)}},[]),$x(()=>{let g=()=>{Nx().then(k=>{a(k.length)}).catch(()=>{})},S=setTimeout(g,3e3),C=null;try{C=Yc.getChannel(),C.on("storyChanged",g),C.on("uireview/mappings-changed",g)}catch{}let F=setInterval(g,6e4);return()=>{clearTimeout(S),clearInterval(F),C&&(C.off("storyChanged",g),C.off("uireview/mappings-changed",g))}},[]),$x(()=>{let g;try{g=Yc.getChannel()}catch{return}let S=F=>{r(F),t(!0)},C=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return g.on(Ca,S),g.on(Ta,C),()=>{g.off(Ca,S),g.off(Ta,C)}},[]);let l=sF(()=>{try{Yc.getChannel().emit(Ox),t(!0),i(null)}catch{}},[]),d=sF(()=>{try{Yc.getChannel().emit(_x)}catch{}t(!1),r(null)},[]),f=n?Math.round(n.completed/n.total*100):0,p=y8();return u?Vt.createElement(b8,null,Vt.createElement(S8,null,Vt.createElement(w8,null,"UI Review"),e?Vt.createElement(lF,{running:!0,onClick:d},"Cancel"):Vt.createElement(lF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Vt.createElement(Vt.Fragment,null,Vt.createElement(cF,null,Vt.createElement(Ji,{dotColor:p.color.positive},"Pass (",o.passed,")"),Vt.createElement(Ji,{dotColor:p.color.warning},"Warn (",o.warned,")"),Vt.createElement(Ji,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Vt.createElement(aF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Vt.createElement(cF,null,Vt.createElement(Ji,{dotColor:p.color.positive},"Pass"),Vt.createElement(Ji,{dotColor:p.color.warning},"Warn"),Vt.createElement(Ji,{dotColor:p.color.negative},"Fail")),e&&n&&Vt.createElement(Vt.Fragment,null,Vt.createElement(v8,null,Vt.createElement(k8,{percent:f})),Vt.createElement(aF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as fF from"@sentry/react";var C8="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",dF=!1;function T8(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function gF(){if(!dF){dF=!0;try{fF.init({dsn:C8,environment:T8(),release:`uicopilot-addon@${process.env.npm_package_version||"unknown"}`,tracesSampleRate:0,enabled:!0,beforeSend(e){return e.tags={...e.tags,component:"storybook-addon"},e}})}catch{}}}gF();var Xc="uireview",F8=`${Xc}/panel`,E8=`${Xc}/tool`,hF=`${Xc}/test-provider`;Kc.register(Xc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof mF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=mF("uireview/badge");pv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");Kc.add(E8,{type:Ux.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Fa.createElement(nF,null)}),iF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&Kc.add(hF,{type:Ux.experimental_TEST_PROVIDER,id:hF,render:()=>Fa.createElement(pF,null)}),Kc.add(F8,{type:Ux.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Fa.createElement(I8,{active:t||!1},Fa.createElement(vg,null,Fa.createElement(eF,null)))})});
|
|
198
|
+
`,ZW=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),e8=fr.div({fontSize:"32px"}),t8=fr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),n8=fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),QI=fr.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})),JI=fr.span({flex:1}),ZI=fr.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`}})),eF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ze(),{isConnected:r,sessionToken:o,authError:i}=Se(),{currentStoryId:s}=rt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:p}=se(),[f,d]=VW(!1),m=()=>{l(null),o&&fetch(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(L=>L.json()).then(L=>{p({enableFixGeneration:!!L.enableFixGeneration,enableFixApply:!!L.enableFixApply,enableAutoMap:!!L.enableAutoMap,enableReviewBadges:!!L.enableReviewBadges,showCosts:!!L.showCosts,enableParallelReview:!!L.enableParallelReview,enableModelSelection:!!L.enableModelSelection})}).catch(()=>{})};Zg(),xm(),XI(),lm(),im();let{notification:w,dismissNotification:k}=YI();GW(()=>{if(w){let L=setTimeout(k,5e3);return()=>clearTimeout(L)}},[w,k]);let F=t.find(L=>L.id===e),C=r&&!!e&&!!F,z=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=rt(),O=C&&!!s&&!a&&R;return Bt.createElement(tu,{header:Bt.createElement(nu,{toolbar:Bt.createElement(kg,{onOpenSettings:()=>d(!0)})}),footer:Bt.createElement(JW,null,"UI Copilot v","0.5.6")},w&&Bt.createElement(YW,{variant:w.variant||"success"},Bt.createElement(KW,null,w.variant==="error"?"!":w.variant==="warning"?"\u26A0":"+"),Bt.createElement(XW,null,w.message),Bt.createElement(QW,{onClick:k},"x")),i&&Bt.createElement(QI,null,Bt.createElement("span",null,"\u26A0"),Bt.createElement(JI,null,i),Bt.createElement(ZI,{onClick:()=>d(!0)},"Reconnect")),u==="admin"&&c&&Bt.createElement(QI,null,Bt.createElement("span",null,"\u{1F441}"),Bt.createElement(JI,null,"Previewing as ",c),Bt.createElement(ZI,{onClick:m},"Exit preview")),z||O?Bt.createElement(Oc,{label:z?"Loading...":"Loading review..."}):C?Bt.createElement(Dx,null):Bt.createElement(ZW,null,Bt.createElement(e8,null,"\u2699"),Bt.createElement(t8,null,i?"Connection issue":"Set up UI Copilot"),Bt.createElement(n8,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Bt.createElement(en,{onClick:()=>d(!0)},i?"Reconnect":"Open Settings")),f&&Bt.createElement(TC,{onClose:()=>d(!1)}))};import tF,{useCallback as r8}from"react";import{useStorybookApi as o8}from"storybook/manager-api";import{IconButton as i8}from"storybook/internal/components";var s8="uireview",a8=`${s8}/panel`,nF=()=>{let e=o8(),t=r8(()=>{e.togglePanel(!0),e.setSelectedPanel(a8)},[e]);return tF.createElement(i8,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},tF.createElement(_I,null))};we();import Vt,{useState as Fa,useCallback as sF,useEffect as $x}from"react";import{styled as ro,useTheme as y8}from"storybook/theming";import{addons as Yc}from"storybook/manager-api";Ue();De();import{addons as f8,experimental_getStatusStore as qc}from"storybook/manager-api";async function rF(e,t,n,r){let o=new Array(e.length),i=0;async function s(){for(;i<e.length&&!r();){let a=i++;try{let u=await e[a]();o[a]=u,r()||n(a,u)}catch(u){o[a]=u,r()||n(a,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),o}Ue();De();var l8=q(),c8="uireview/badge";async function u8(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 p8(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:f}=await e.read();if(p)break;if(t()){e.cancel();break}r+=n.decode(f,{stream:!0});let d=r.split(`
|
|
199
|
+
`);r=d.pop()||"";for(let m of d)if(m.startsWith("data: "))try{let w=JSON.parse(m.slice(6));if(w.type==="complete"){o=w.complianceScore??w.validation?.complianceScore??null;let F=(w.issues||[]).filter(C=>!C.dismissed);i=F.filter(C=>C.severity==="critical").length,s=F.filter(C=>C.severity==="major").length,a=F.filter(C=>C.severity==="minor").length,u=w.costUsd||0,c=w.inputTokens||0,l=w.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function Gc(e,t,n,r,o){e&&e.set([{value:n,typeId:c8,storyId:t,title:r,description:o}])}async function d8(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 oF(e,t,n,r,o,i){Gc(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await d8(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await u8(`${l8}/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 p8(u,i),{score:l,criticalCount:p,majorCount:f,minorCount:d,costUsd:m,inputTokens:w,outputTokens:k}=c;if(l!==null){let F=p>0||l<70?"status-value:error":f>0||l<90?"status-value:warning":"status-value:success",C=[`Score: ${l}`];p>0&&C.push(`${p} critical`),f>0&&C.push(`${f} major`),d>0&&C.push(`${d} minor`);let z=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return Gc(o,e.storyId,F,z,C.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:m,inputTokens:w,outputTokens:k}}return Gc(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 Gc(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var g8=q(),Ca="uireview/badge";function iF(){let e=!1,t=!1;try{let n=f8.getChannel();n.on(Ox,async()=>{if(!t){t=!0,e=!1;try{await x8(n,()=>e)}finally{t=!1}}}),n.on(_x,()=>{e=!0})}catch{}}async function Nx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${g8}/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 m8(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function m8(e){try{if(typeof qc!="function")return;let t=qc(Ca);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Ca]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Ca];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Ca,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 h8(){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 x8(e,t){let n=await Nx();if(n.length===0){e.emit(Ia,{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-5-20250929";try{let w=localStorage.getItem("uicopilot_selected_models");if(w){let k=JSON.parse(w);Array.isArray(k)&&k.length>0&&(i=k[0])}}catch{}let s=null;try{typeof qc=="function"&&(s=qc(Ca))}catch{}let a=h8(),u=0,c=0,l=0,p=0,f=0,d=0;e.emit(Ta,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let m=n.map(w=>()=>oF(w,r,o,i,s,t));await rF(m,a,(w,k)=>{if(k&&typeof k=="object"&&"score"in k){let F=k;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,p+=F.costUsd||0,f+=F.inputTokens||0,d+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${w+1}/${n.length} done:`,n[w].storyName,k),e.emit(Ta,{total:n.length,completed:u+c+l,currentStoryName:n[w].storyName})},t),e.emit(Ia,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:p,inputTokens:f,outputTokens:d})}var b8=ro.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),S8=ro.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),w8=ro.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),aF=ro.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),lF=ro.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}})),v8=ro.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),k8=ro.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),cF=ro.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Ji=ro.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Ox="uireview/review-all-start",_x="uireview/review-all-cancel",Ta="uireview/review-all-progress",Ia="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 pF=()=>{let[e,t]=Fa(!1),[n,r]=Fa(null),[o,i]=Fa(null),[s,a]=Fa(null),[u,c]=Fa(uF);$x(()=>{let m=()=>c(uF()),w=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(w),window.removeEventListener("storage",m)}},[]),$x(()=>{let m=()=>{Nx().then(C=>{a(C.length)}).catch(()=>{})},w=setTimeout(m,3e3),k=null;try{k=Yc.getChannel(),k.on("storyChanged",m),k.on("uireview/mappings-changed",m)}catch{}let F=setInterval(m,6e4);return()=>{clearTimeout(w),clearInterval(F),k&&(k.off("storyChanged",m),k.off("uireview/mappings-changed",m))}},[]),$x(()=>{let m;try{m=Yc.getChannel()}catch{return}let w=F=>{r(F),t(!0)},k=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return m.on(Ta,w),m.on(Ia,k),()=>{m.off(Ta,w),m.off(Ia,k)}},[]);let l=sF(()=>{try{Yc.getChannel().emit(Ox),t(!0),i(null)}catch{}},[]),p=sF(()=>{try{Yc.getChannel().emit(_x)}catch{}t(!1),r(null)},[]),f=n?Math.round(n.completed/n.total*100):0,d=y8();return u?Vt.createElement(b8,null,Vt.createElement(S8,null,Vt.createElement(w8,null,"UI Review"),e?Vt.createElement(lF,{running:!0,onClick:p},"Cancel"):Vt.createElement(lF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Vt.createElement(Vt.Fragment,null,Vt.createElement(cF,null,Vt.createElement(Ji,{dotColor:d.color.positive},"Pass (",o.passed,")"),Vt.createElement(Ji,{dotColor:d.color.warning},"Warn (",o.warned,")"),Vt.createElement(Ji,{dotColor:d.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Vt.createElement(aF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Vt.createElement(cF,null,Vt.createElement(Ji,{dotColor:d.color.positive},"Pass"),Vt.createElement(Ji,{dotColor:d.color.warning},"Warn"),Vt.createElement(Ji,{dotColor:d.color.negative},"Fail")),e&&n&&Vt.createElement(Vt.Fragment,null,Vt.createElement(v8,null,Vt.createElement(k8,{percent:f})),Vt.createElement(aF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as fF from"@sentry/react";var C8="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",dF=!1;function T8(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function gF(){if(!dF){dF=!0;try{fF.init({dsn:C8,environment:T8(),release:`uicopilot-addon@${process.env.npm_package_version||"unknown"}`,tracesSampleRate:0,enabled:!0,beforeSend(e){return e.tags={...e.tags,component:"storybook-addon"},e}})}catch{}}}gF();var Xc="uireview",F8=`${Xc}/panel`,E8=`${Xc}/tool`,hF=`${Xc}/test-provider`;Kc.register(Xc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof mF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=mF("uireview/badge");pv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");Kc.add(E8,{type:Ux.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Ea.createElement(nF,null)}),iF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&Kc.add(hF,{type:Ux.experimental_TEST_PROVIDER,id:hF,render:()=>Ea.createElement(pF,null)}),Kc.add(F8,{type:Ux.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Ea.createElement(I8,{active:t||!1},Ea.createElement(vg,null,Ea.createElement(eF,null)))})});
|
|
200
200
|
/*! Bundled license information:
|
|
201
201
|
|
|
202
202
|
@noble/hashes/utils.js:
|